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
This commit is contained in:
Daniel Eklöf 2020-07-31 17:02:53 +02:00
parent 33e25e7f93
commit 639a61abd8
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
8 changed files with 43 additions and 13 deletions

View file

@ -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);
}