From 78665a7e809afd470e1236867761d51de9737eaa Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Tue, 26 Sep 2023 17:54:03 +0200 Subject: search: add more key bindings to extend the current match This patch adds the following new search key bindings: * extend-char (shift+right) * extend-line-down (shift+down) * extend-backward-char (shift+left) * extend-backward-to-word-boundary (ctrl+shift+left) * extend-backward-to-next-whitespace (ctrl+shift+alt+left) * extend-line-up (shift+up) They can be used to extend the search match (i.e. the selection). This patch also adds an initial set of key bindings to scroll in the scrollback history: * scrollback-up-page * scrollback-down-page These work just like the key bindings for the normal mode. Also note that it was already possible to scroll using the mouse. This patch also fixes a couple of search mode bugs: * crashing when a search match ends in the last column * grapheme clusters not being matched correctly * Search match not being "extendable" after a pointer leave event * A few others, related to either large matches, or extending matches after moving the viewport. There are still a couple of (known) issues: * A search match isn't correctly highlighted if its *starting* point is outside the viewport. * Extending the match to end of the scrollback (i.e. the most recent output) is simply buggy. Related to #419 --- key-binding.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'key-binding.h') diff --git a/key-binding.h b/key-binding.h index ea2f3d6d..b85fc072 100644 --- a/key-binding.h +++ b/key-binding.h @@ -58,6 +58,9 @@ enum bind_action_normal { enum bind_action_search { BIND_ACTION_SEARCH_NONE, + BIND_ACTION_SEARCH_SCROLLBACK_UP_PAGE, + BIND_ACTION_SEARCH_SCROLLBACK_DOWN_PAGE, + // TODO: copy the remaining scrollback key-bindings from normal mode BIND_ACTION_SEARCH_CANCEL, BIND_ACTION_SEARCH_COMMIT, BIND_ACTION_SEARCH_FIND_PREV, @@ -72,8 +75,14 @@ enum bind_action_search { BIND_ACTION_SEARCH_DELETE_PREV_WORD, BIND_ACTION_SEARCH_DELETE_NEXT, BIND_ACTION_SEARCH_DELETE_NEXT_WORD, + BIND_ACTION_SEARCH_EXTEND_CHAR, BIND_ACTION_SEARCH_EXTEND_WORD, BIND_ACTION_SEARCH_EXTEND_WORD_WS, + BIND_ACTION_SEARCH_EXTEND_LINE_DOWN, + BIND_ACTION_SEARCH_EXTEND_BACKWARD_CHAR, + BIND_ACTION_SEARCH_EXTEND_BACKWARD_WORD, + BIND_ACTION_SEARCH_EXTEND_BACKWARD_WORD_WS, + BIND_ACTION_SEARCH_EXTEND_LINE_UP, BIND_ACTION_SEARCH_CLIPBOARD_PASTE, BIND_ACTION_SEARCH_PRIMARY_PASTE, BIND_ACTION_SEARCH_UNICODE_INPUT, -- cgit v1.3 From 3e67415e3e7b09c3e10c4ace3008bbaaae54110a Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Sun, 8 Oct 2023 10:37:16 +0200 Subject: config: add remaining search.scrollback key bindings All scrollback up/down key bindings are now available in search mode. --- config.c | 10 ++++++++-- doc/foot.ini.5.scd | 25 +++++++++++++++++++++++++ foot.ini | 10 ++++++++++ key-binding.h | 7 ++++++- search.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 91 insertions(+), 3 deletions(-) (limited to 'key-binding.h') diff --git a/config.c b/config.c index 8bbe27cb..e5ebb558 100644 --- a/config.c +++ b/config.c @@ -134,6 +134,14 @@ static const char *const binding_action_map[] = { static const char *const search_binding_action_map[] = { [BIND_ACTION_SEARCH_NONE] = NULL, + [BIND_ACTION_SEARCH_SCROLLBACK_UP_PAGE] = "scrollback-up-page", + [BIND_ACTION_SEARCH_SCROLLBACK_UP_HALF_PAGE] = "scrollback-up-half-page", + [BIND_ACTION_SEARCH_SCROLLBACK_UP_LINE] = "scrollback-up-line", + [BIND_ACTION_SEARCH_SCROLLBACK_DOWN_PAGE] = "scrollback-down-page", + [BIND_ACTION_SEARCH_SCROLLBACK_DOWN_HALF_PAGE] = "scrollback-down-half-page", + [BIND_ACTION_SEARCH_SCROLLBACK_DOWN_LINE] = "scrollback-down-line", + [BIND_ACTION_SEARCH_SCROLLBACK_HOME] = "scrollback-home", + [BIND_ACTION_SEARCH_SCROLLBACK_END] = "scrollback-end", [BIND_ACTION_SEARCH_CANCEL] = "cancel", [BIND_ACTION_SEARCH_COMMIT] = "commit", [BIND_ACTION_SEARCH_FIND_PREV] = "find-prev", @@ -159,8 +167,6 @@ static const char *const search_binding_action_map[] = { [BIND_ACTION_SEARCH_CLIPBOARD_PASTE] = "clipboard-paste", [BIND_ACTION_SEARCH_PRIMARY_PASTE] = "primary-paste", [BIND_ACTION_SEARCH_UNICODE_INPUT] = "unicode-input", - [BIND_ACTION_SEARCH_SCROLLBACK_UP_PAGE] = "scrollback-up-page", - [BIND_ACTION_SEARCH_SCROLLBACK_DOWN_PAGE] = "scrollback-down-page", }; static const char *const url_binding_action_map[] = { diff --git a/doc/foot.ini.5.scd b/doc/foot.ini.5.scd index 2e0127b1..5ef4dcb4 100644 --- a/doc/foot.ini.5.scd +++ b/doc/foot.ini.5.scd @@ -987,6 +987,31 @@ scrollback search mode. The syntax is exactly the same as the regular Unicode input mode. See _key-bindings.unicode-input_ for details. Default: _none_. +*scrollback-up-page* + Scrolls up/back one page in history. Default: _Shift+Page\_Up_. + +*scrollback-up-half-page* + Scrolls up/back half of a page in history. Default: _none_. + +*scrollback-up-line* + Scrolls up/back a single line in history. Default: _none_. + +*scrollback-down-page* + Scroll down/forward one page in history. Default: + _Shift+Page\_Down_. + +*scrollback-down-half-page* + Scroll down/forward half of a page in history. Default: _none_. + +*scrollback-down-line* + Scroll down/forward a single line in history. Default: _none_. + +*scrollback-home* + Scroll to the beginning of the scrollback. Default: _none_. + +*scrollback-end* + Scroll to the end (bottom) of the scrollback. Default: _none_. + # SECTION: url-bindings This section lets you override the default key bindings used in URL diff --git a/foot.ini b/foot.ini index dbd2baab..cdbd8259 100644 --- a/foot.ini +++ b/foot.ini @@ -139,6 +139,8 @@ # scrollback-down-page=Shift+Page_Down # scrollback-down-half-page=none # scrollback-down-line=none +# scrollback-home=none +# scrollback-end=none # clipboard-copy=Control+Shift+c XF86Copy # clipboard-paste=Control+Shift+v XF86Paste # primary-paste=Shift+Insert @@ -187,6 +189,14 @@ # clipboard-paste=Control+v Control+Shift+v Control+y XF86Paste # primary-paste=Shift+Insert # unicode-input=none +# scrollback-up-page=Shift+Page_Up +# scrollback-up-half-page=none +# scrollback-up-line=none +# scrollback-down-page=Shift+Page_Down +# scrollback-down-half-page=none +# scrollback-down-line=none +# scrollback-home=none +# scrollback-end=none [url-bindings] # cancel=Control+g Control+c Control+d Escape diff --git a/key-binding.h b/key-binding.h index b85fc072..050c80a6 100644 --- a/key-binding.h +++ b/key-binding.h @@ -59,8 +59,13 @@ enum bind_action_normal { enum bind_action_search { BIND_ACTION_SEARCH_NONE, BIND_ACTION_SEARCH_SCROLLBACK_UP_PAGE, + BIND_ACTION_SEARCH_SCROLLBACK_UP_HALF_PAGE, + BIND_ACTION_SEARCH_SCROLLBACK_UP_LINE, BIND_ACTION_SEARCH_SCROLLBACK_DOWN_PAGE, - // TODO: copy the remaining scrollback key-bindings from normal mode + BIND_ACTION_SEARCH_SCROLLBACK_DOWN_HALF_PAGE, + BIND_ACTION_SEARCH_SCROLLBACK_DOWN_LINE, + BIND_ACTION_SEARCH_SCROLLBACK_HOME, + BIND_ACTION_SEARCH_SCROLLBACK_END, BIND_ACTION_SEARCH_CANCEL, BIND_ACTION_SEARCH_COMMIT, BIND_ACTION_SEARCH_FIND_PREV, diff --git a/search.c b/search.c index 90dd337c..55388577 100644 --- a/search.c +++ b/search.c @@ -1071,6 +1071,20 @@ execute_binding(struct seat *seat, struct terminal *term, } return false; + case BIND_ACTION_SEARCH_SCROLLBACK_UP_HALF_PAGE: + if (term->grid == &term->normal) { + cmd_scrollback_up(term, max(term->rows / 2, 1)); + return true; + } + break; + + case BIND_ACTION_SEARCH_SCROLLBACK_UP_LINE: + if (term->grid == &term->normal) { + cmd_scrollback_up(term, 1); + return true; + } + break; + case BIND_ACTION_SEARCH_SCROLLBACK_DOWN_PAGE: if (term->grid == &term->normal) { cmd_scrollback_down(term, term->rows); @@ -1078,6 +1092,34 @@ execute_binding(struct seat *seat, struct terminal *term, } return false; + case BIND_ACTION_SEARCH_SCROLLBACK_DOWN_HALF_PAGE: + if (term->grid == &term->normal) { + cmd_scrollback_down(term, max(term->rows / 2, 1)); + return true; + } + break; + + case BIND_ACTION_SEARCH_SCROLLBACK_DOWN_LINE: + if (term->grid == &term->normal) { + cmd_scrollback_down(term, 1); + return true; + } + break; + + case BIND_ACTION_SEARCH_SCROLLBACK_HOME: + if (term->grid == &term->normal) { + cmd_scrollback_up(term, term->grid->num_rows); + return true; + } + break; + + case BIND_ACTION_SEARCH_SCROLLBACK_END: + if (term->grid == &term->normal) { + cmd_scrollback_down(term, term->grid->num_rows); + return true; + } + break; + case BIND_ACTION_SEARCH_CANCEL: if (term->search.view_followed_offset) grid->view = grid->offset; -- cgit v1.3