config: add search-bindings.delete-to-{start,end} key bindings

Defaults to ctrl+u and ctrl+k respectively.

Closes #1972
This commit is contained in:
Adrian fxj9a 2025-03-03 14:27:30 +01:00 committed by Daniel Eklöf
parent 9e6d334bd8
commit 6d39f66eb7
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
7 changed files with 47 additions and 0 deletions

View file

@ -69,10 +69,14 @@
[#1872][1872]) [#1872][1872])
* Support for kitty's text-sizing protocol (`w`, width, only), OSC-66. * Support for kitty's text-sizing protocol (`w`, width, only), OSC-66.
* `cursor.style` can now be set to `hollow` ([#1965][1965]). * `cursor.style` can now be set to `hollow` ([#1965][1965]).
* `search-bindings.delete-to-start` and
`search-bindings.delete-to-end` key bindings, defaulting to
`Control+u` and `Control+k` respectively ([#1972][1972]).
[1386]: https://codeberg.org/dnkl/foot/issues/1386 [1386]: https://codeberg.org/dnkl/foot/issues/1386
[1872]: https://codeberg.org/dnkl/foot/issues/1872 [1872]: https://codeberg.org/dnkl/foot/issues/1872
[1965]: https://codeberg.org/dnkl/foot/issues/1965 [1965]: https://codeberg.org/dnkl/foot/issues/1965
[1972]: https://codeberg.org/dnkl/foot/issues/1972
### Changed ### Changed

View file

@ -180,6 +180,8 @@ static const char *const search_binding_action_map[] = {
[BIND_ACTION_SEARCH_DELETE_PREV_WORD] = "delete-prev-word", [BIND_ACTION_SEARCH_DELETE_PREV_WORD] = "delete-prev-word",
[BIND_ACTION_SEARCH_DELETE_NEXT] = "delete-next", [BIND_ACTION_SEARCH_DELETE_NEXT] = "delete-next",
[BIND_ACTION_SEARCH_DELETE_NEXT_WORD] = "delete-next-word", [BIND_ACTION_SEARCH_DELETE_NEXT_WORD] = "delete-next-word",
[BIND_ACTION_SEARCH_DELETE_TO_START] = "delete-to-start",
[BIND_ACTION_SEARCH_DELETE_TO_END] = "delete-to-end",
[BIND_ACTION_SEARCH_EXTEND_CHAR] = "extend-char", [BIND_ACTION_SEARCH_EXTEND_CHAR] = "extend-char",
[BIND_ACTION_SEARCH_EXTEND_WORD] = "extend-to-word-boundary", [BIND_ACTION_SEARCH_EXTEND_WORD] = "extend-to-word-boundary",
[BIND_ACTION_SEARCH_EXTEND_WORD_WS] = "extend-to-next-whitespace", [BIND_ACTION_SEARCH_EXTEND_WORD_WS] = "extend-to-next-whitespace",
@ -3183,6 +3185,8 @@ add_default_search_bindings(struct config *conf)
{BIND_ACTION_SEARCH_DELETE_NEXT, m("none"), {{XKB_KEY_Delete}}}, {BIND_ACTION_SEARCH_DELETE_NEXT, m("none"), {{XKB_KEY_Delete}}},
{BIND_ACTION_SEARCH_DELETE_NEXT_WORD, m(XKB_MOD_NAME_CTRL), {{XKB_KEY_Delete}}}, {BIND_ACTION_SEARCH_DELETE_NEXT_WORD, m(XKB_MOD_NAME_CTRL), {{XKB_KEY_Delete}}},
{BIND_ACTION_SEARCH_DELETE_NEXT_WORD, m(XKB_MOD_NAME_ALT), {{XKB_KEY_d}}}, {BIND_ACTION_SEARCH_DELETE_NEXT_WORD, m(XKB_MOD_NAME_ALT), {{XKB_KEY_d}}},
{BIND_ACTION_SEARCH_DELETE_TO_START, m(XKB_MOD_NAME_CTRL), {{XKB_KEY_u}}},
{BIND_ACTION_SEARCH_DELETE_TO_END, m(XKB_MOD_NAME_CTRL), {{XKB_KEY_k}}},
{BIND_ACTION_SEARCH_EXTEND_CHAR, m(XKB_MOD_NAME_SHIFT), {{XKB_KEY_Right}}}, {BIND_ACTION_SEARCH_EXTEND_CHAR, m(XKB_MOD_NAME_SHIFT), {{XKB_KEY_Right}}},
{BIND_ACTION_SEARCH_EXTEND_WORD, m(XKB_MOD_NAME_CTRL "+" XKB_MOD_NAME_SHIFT), {{XKB_KEY_Right}}}, {BIND_ACTION_SEARCH_EXTEND_WORD, m(XKB_MOD_NAME_CTRL "+" XKB_MOD_NAME_SHIFT), {{XKB_KEY_Right}}},
{BIND_ACTION_SEARCH_EXTEND_WORD, m(XKB_MOD_NAME_CTRL), {{XKB_KEY_w}}}, {BIND_ACTION_SEARCH_EXTEND_WORD, m(XKB_MOD_NAME_CTRL), {{XKB_KEY_w}}},

View file

@ -301,6 +301,12 @@ These shortcuts affect the search box in scrollback-search mode:
*alt*+*delete*, *ctrl*+*delete* *alt*+*delete*, *ctrl*+*delete*
Deletes the **word after** the cursor. Deletes the **word after** the cursor.
*ctrl*+*u*
Deletes from the cursor to the start of the input
*ctrl*+*k*
Deletes from the cursor to the end of the input
These shortcuts affect scrolling in scrollback-search mode: These shortcuts affect scrolling in scrollback-search mode:
*shift*+*page-up* *shift*+*page-up*

View file

@ -1401,6 +1401,12 @@ scrollback search mode. The syntax is exactly the same as the regular
Deletes the **word after** the cursor. Default: _Mod1+d Deletes the **word after** the cursor. Default: _Mod1+d
Control+Delete_. Control+Delete_.
*delete-to-start*
Deletes search input before the cursor. Default: _Ctrl+u_.
*delete-to-end*
Deletes search input after the cursor. Default: _Ctrl+k_.
*extend-char* *extend-char*
Extend current selection to the right, by one character. Default: Extend current selection to the right, by one character. Default:
_Shift+Right_. _Shift+Right_.

View file

@ -225,6 +225,8 @@
# delete-prev-word=Mod1+BackSpace Control+BackSpace # delete-prev-word=Mod1+BackSpace Control+BackSpace
# delete-next=Delete # delete-next=Delete
# delete-next-word=Mod1+d Control+Delete # delete-next-word=Mod1+d Control+Delete
# delete-to-start=Control+u
# delete-to-end=Control+k
# extend-char=Shift+Right # extend-char=Shift+Right
# extend-to-word-boundary=Control+w Control+Shift+Right # extend-to-word-boundary=Control+w Control+Shift+Right
# extend-to-next-whitespace=Control+Shift+w # extend-to-next-whitespace=Control+Shift+w

View file

@ -84,6 +84,8 @@ enum bind_action_search {
BIND_ACTION_SEARCH_DELETE_PREV_WORD, BIND_ACTION_SEARCH_DELETE_PREV_WORD,
BIND_ACTION_SEARCH_DELETE_NEXT, BIND_ACTION_SEARCH_DELETE_NEXT,
BIND_ACTION_SEARCH_DELETE_NEXT_WORD, BIND_ACTION_SEARCH_DELETE_NEXT_WORD,
BIND_ACTION_SEARCH_DELETE_TO_START,
BIND_ACTION_SEARCH_DELETE_TO_END,
BIND_ACTION_SEARCH_EXTEND_CHAR, BIND_ACTION_SEARCH_EXTEND_CHAR,
BIND_ACTION_SEARCH_EXTEND_WORD, BIND_ACTION_SEARCH_EXTEND_WORD,
BIND_ACTION_SEARCH_EXTEND_WORD_WS, BIND_ACTION_SEARCH_EXTEND_WORD_WS,

View file

@ -1265,6 +1265,29 @@ execute_binding(struct seat *seat, struct terminal *term,
return true; return true;
} }
case BIND_ACTION_SEARCH_DELETE_TO_START: {
if (term->search.cursor > 0) {
memmove(&term->search.buf[0],
&term->search.buf[term->search.cursor],
(term->search.len - term->search.cursor)
* sizeof(char32_t));
term->search.len -= term->search.cursor;
term->search.cursor = 0;
*update_search_result = *redraw = true;
}
return true;
}
case BIND_ACTION_SEARCH_DELETE_TO_END: {
if (term->search.cursor < term->search.len) {
term->search.buf[term->search.cursor] = '\0';
term->search.len = term->search.cursor;
*update_search_result = *redraw = true;
}
return true;
}
case BIND_ACTION_SEARCH_EXTEND_CHAR: { case BIND_ACTION_SEARCH_EXTEND_CHAR: {
struct coord target; struct coord target;
if (search_extend_find_char_right(term, &target)) { if (search_extend_find_char_right(term, &target)) {