aboutsummaryrefslogtreecommitdiff
path: root/selection.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2020-07-31 15:02:53 +0000
committerDaniel Eklöf <daniel@ekloef.se>2020-07-31 15:04:30 +0000
commit639a61abd86c7db3e47f2cd70fc16b7d6c6afaf4 (patch)
tree8693442620f98a0ba8e67dac03868cae62e86435 /selection.c
parentinstall: tllist is a *build* dependency, not a *runtime* dependency (diff)
config: add 'pipe-selected' key binding
This works just like pipe-visible and pipe-scrollback, but pipes the user-selected text, if any, to the external tool. Closes #51
Diffstat (limited to 'selection.c')
-rw-r--r--selection.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/selection.c b/selection.c
index ffe06c27..8dd93028 100644
--- a/selection.c
+++ b/selection.c
@@ -204,9 +204,12 @@ extract_one_const_wrapper(struct terminal *term,
return extract_one(term, row, cell, col, data);
}
-static char *
-extract_selection(const struct terminal *term)
+char *
+selection_to_text(const struct terminal *term)
{
+ if (term->selection.end.row == -1)
+ return NULL;
+
struct extraction_context *ctx = extract_begin(term->selection.kind);
if (ctx == NULL)
return NULL;
@@ -873,7 +876,7 @@ selection_to_clipboard(struct seat *seat, struct terminal *term, uint32_t serial
return;
/* Get selection as a string */
- char *text = extract_selection(term);
+ char *text = selection_to_text(term);
if (!text_to_clipboard(seat, term, text, serial))
free(text);
}
@@ -1074,7 +1077,7 @@ selection_to_primary(struct seat *seat, struct terminal *term, uint32_t serial)
return;
/* Get selection as a string */
- char *text = extract_selection(term);
+ char *text = selection_to_text(term);
if (!text_to_primary(seat, term, text, serial))
free(text);
}