aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-12-03 18:43:45 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-12-03 18:43:45 +0000
commit0982210af21ae53135e2bb139e4a69d25d316285 (patch)
tree833cbbb0d919ae021dabc5a4c15d5a10f2738ff1
parentsearch: search_match_to_end_of_word: rename start_{row,col} -> end_{row,col} (diff)
search: map ctrl+shift+w to match to end of word, spaces only
This works just like ctrl+w, except that the only space separating characters are whitespaces.
-rw-r--r--README.md5
-rw-r--r--search.c11
2 files changed, 12 insertions, 4 deletions
diff --git a/README.md b/README.md
index 9385cd9a..caeb8e12 100644
--- a/README.md
+++ b/README.md
@@ -124,6 +124,11 @@ available:
of the word, or the next word if currently at a word separating
character.
+* <kbd>ctrl</kbd>+<kbd>shift</kbd><kbd>w</kbd>
+
+ Same as <kbd>ctrl</kbd>+<kbd>w</kbd>, except that the only word
+ separating characters are whitespace characters.
+
* <kbd>escape</kbd>, <kbd>ctrl</kbd>+<kbd>g</kbd>
Cancel the search
diff --git a/search.c b/search.c
index 03eae348..47793823 100644
--- a/search.c
+++ b/search.c
@@ -265,7 +265,7 @@ search_find_next(struct terminal *term)
}
static void
-search_match_to_end_of_word(struct terminal *term)
+search_match_to_end_of_word(struct terminal *term, bool spaces_only)
{
if (term->search.match_len == 0)
return;
@@ -299,7 +299,7 @@ search_match_to_end_of_word(struct terminal *term)
bool done = false;
for (; end_col < term->cols; end_col++) {
wchar_t wc = row->cells[end_col].wc;
- if (wc == 0 || (!first && !isword(wc, false))) {
+ if (wc == 0 || (!first && !isword(wc, spaces_only))) {
done = true;
break;
}
@@ -396,7 +396,7 @@ search_input(struct terminal *term, uint32_t key, xkb_keysym_t sym, xkb_mod_mask
const xkb_mod_mask_t ctrl = 1 << term->wl->kbd.mod_ctrl;
const xkb_mod_mask_t alt = 1 << term->wl->kbd.mod_alt;
- //const xkb_mod_mask_t shift = 1 << term->wl->kbd.mod_shift;
+ const xkb_mod_mask_t shift = 1 << term->wl->kbd.mod_shift;
//const xkb_mod_mask_t meta = 1 << term->wl->kbd.mod_meta;
enum xkb_compose_status compose_status = xkb_compose_state_get_status(
@@ -544,7 +544,10 @@ search_input(struct terminal *term, uint32_t key, xkb_keysym_t sym, xkb_mod_mask
}
else if (mods == ctrl && sym == XKB_KEY_w)
- search_match_to_end_of_word(term);
+ search_match_to_end_of_word(term, false);
+
+ else if (mods == (ctrl | shift) && sym == XKB_KEY_W)
+ search_match_to_end_of_word(term, true);
else {
uint8_t buf[64] = {0};