summaryrefslogtreecommitdiff
path: root/src/selection.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/selection.c')
-rw-r--r--src/selection.c29
1 files changed, 7 insertions, 22 deletions
diff --git a/src/selection.c b/src/selection.c
index 2727e8a..3ac2ee3 100644
--- a/src/selection.c
+++ b/src/selection.c
@@ -5,14 +5,6 @@
#include <stdlib.h>
#include <string.h>
-/* Copies a heap string into buf and frees it. Returns the length without the NUL. */
-static size_t text_out(char *text, char *buf, size_t cap)
-{
- size_t n = term_copy_out(text, buf, cap);
- free(text);
- return n;
-}
-
static char *link_at_text(const struct term *t, struct term_vector2i cell)
{
int col = cell.x, row = cell.y;
@@ -62,14 +54,13 @@ static char *link_at_text(const struct term *t, struct term_vector2i cell)
return out;
}
-size_t term_link_at(const struct term *t, struct term_vector2i cell, char *buf, size_t cap)
+char *term_link_at(const struct term *t, struct term_vector2i cell)
{
- if (!t)
- return 0;
+ if (!t) return NULL;
term_write_begin((struct term *)t);
char *text = link_at_text(t, cell);
term_write_end((struct term *)t);
- return text_out(text, buf, cap);
+ return text;
}
void term_select_clear(struct term *t)
@@ -775,7 +766,7 @@ static char *range_text_inner(const struct term *t,
return text;
}
-static char *history_text(struct term *t, int max_rows)
+char *term_history_text(struct term *t, int max_rows)
{
if (!t)
return NULL;
@@ -822,17 +813,11 @@ static char *history_text(struct term *t, int max_rows)
return text;
}
-size_t term_history_text(struct term *t, int max_rows, char *buf, size_t cap)
+char *term_selection_text(const struct term *t)
{
- return text_out(history_text(t, max_rows), buf, cap);
-}
-
-size_t term_selection_text(const struct term *t, char *buf, size_t cap)
-{
- if (!t)
- return 0;
+ if (!t) return NULL;
term_write_begin((struct term *)t);
char *text = range_text_inner(t, NULL);
term_write_end((struct term *)t);
- return text_out(text, buf, cap);
+ return text;
}