diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2019-08-05 17:02:27 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2019-08-05 17:02:27 +0000 |
| commit | c62ce72778e2be00bea2c461f6bf8447d28708c7 (patch) | |
| tree | bfedf8770ead1aec2ca17b8b4429f4a0e43b2f69 /selection.c | |
| parent | term: re-order switch-cases to be in X button order (diff) | |
selection: mark-word using spaces only as word separator
When the user double-clicks with ctrl pressed, we now select the word
under the cursor using spaces only as word separator.
Diffstat (limited to 'selection.c')
| -rw-r--r-- | selection.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/selection.c b/selection.c index 7a0d6960..92beafe5 100644 --- a/selection.c +++ b/selection.c @@ -225,8 +225,11 @@ selection_cancel(struct terminal *term) } static bool -isword(wint_t c) +isword(wint_t c, bool spaces_only) { + if (spaces_only) + return !iswspace(c); + switch (c) { default: return !iswspace(c); @@ -243,7 +246,8 @@ isword(wint_t c) } void -selection_mark_word(struct terminal *term, int col, int row, uint32_t serial) +selection_mark_word(struct terminal *term, int col, int row, bool spaces_only, + uint32_t serial) { if (!selection_enabled(term)) return; @@ -256,7 +260,7 @@ selection_mark_word(struct terminal *term, int col, int row, uint32_t serial) const struct row *r = grid_row_in_view(term->grid, start.row); wchar_t c = r->cells[start.col].wc; - if (!(c == 0 || !isword(c))) { + if (!(c == 0 || !isword(c, spaces_only))) { while (true) { int next_col = start.col - 1; int next_row = start.row; @@ -271,7 +275,7 @@ selection_mark_word(struct terminal *term, int col, int row, uint32_t serial) const struct row *row = grid_row_in_view(term->grid, next_row); c = row->cells[next_col].wc; - if (c == 0 || !isword(c)) + if (c == 0 || !isword(c, spaces_only)) break; start.col = next_col; @@ -282,7 +286,7 @@ selection_mark_word(struct terminal *term, int col, int row, uint32_t serial) r = grid_row_in_view(term->grid, end.row); c = r->cells[end.col].wc; - if (!(c == 0 || !isword(c))) { + if (!(c == 0 || !isword(c, spaces_only))) { while (true) { int next_col = end.col + 1; int next_row = end.row; @@ -297,7 +301,7 @@ selection_mark_word(struct terminal *term, int col, int row, uint32_t serial) const struct row *row = grid_row_in_view(term->grid, next_row); c = row->cells[next_col].wc; - if (c == '\0' || !isword(c)) + if (c == '\0' || !isword(c, spaces_only)) break; end.col = next_col; |
