aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian fxj9a <af24@tuta.io>2025-03-03 13:27:30 +0000
committerDaniel Eklöf <daniel@ekloef.se>2025-03-05 07:48:23 +0000
commit6d39f66eb7c0cafb9e12be7da6831598c6dd4afb (patch)
tree3ca3de19f31f8c2c205216ab2e275c41f2d2aff2
parentterm: reset the grapheme clustering state on cursor movements (diff)
config: add search-bindings.delete-to-{start,end} key bindings
Defaults to ctrl+u and ctrl+k respectively. Closes #1972
-rw-r--r--CHANGELOG.md4
-rw-r--r--config.c4
-rw-r--r--doc/foot.1.scd6
-rw-r--r--doc/foot.ini.5.scd6
-rw-r--r--foot.ini2
-rw-r--r--key-binding.h2
-rw-r--r--search.c23
7 files changed, 47 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 30adad73..59d69f3e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -69,10 +69,14 @@
[#1872][1872])
* Support for kitty's text-sizing protocol (`w`, width, only), OSC-66.
* `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
[1872]: https://codeberg.org/dnkl/foot/issues/1872
[1965]: https://codeberg.org/dnkl/foot/issues/1965
+[1972]: https://codeberg.org/dnkl/foot/issues/1972
### Changed
diff --git a/config.c b/config.c
index de2dc07f..df7f0031 100644
--- a/config.c
+++ b/config.c
@@ -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_NEXT] = "delete-next",
[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_WORD] = "extend-to-word-boundary",
[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_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_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_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}}},
diff --git a/doc/foot.1.scd b/doc/foot.1.scd
index fad44f19..f868c12c 100644
--- a/doc/foot.1.scd
+++ b/doc/foot.1.scd
@@ -301,6 +301,12 @@ These shortcuts affect the search box in scrollback-search mode:
*alt*+*delete*, *ctrl*+*delete*
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:
*shift*+*page-up*
diff --git a/doc/foot.ini.5.scd b/doc/foot.ini.5.scd
index 56004654..c55419d1 100644
--- a/doc/foot.ini.5.scd
+++ b/doc/foot.ini.5.scd
@@ -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
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 current selection to the right, by one character. Default:
_Shift+Right_.
diff --git a/foot.ini b/foot.ini
index a1aa118c..b852da07 100644
--- a/foot.ini
+++ b/foot.ini
@@ -225,6 +225,8 @@
# delete-prev-word=Mod1+BackSpace Control+BackSpace
# delete-next=Delete
# delete-next-word=Mod1+d Control+Delete
+# delete-to-start=Control+u
+# delete-to-end=Control+k
# extend-char=Shift+Right
# extend-to-word-boundary=Control+w Control+Shift+Right
# extend-to-next-whitespace=Control+Shift+w
diff --git a/key-binding.h b/key-binding.h
index 5f5bb9d7..89398859 100644
--- a/key-binding.h
+++ b/key-binding.h
@@ -84,6 +84,8 @@ enum bind_action_search {
BIND_ACTION_SEARCH_DELETE_PREV_WORD,
BIND_ACTION_SEARCH_DELETE_NEXT,
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_WORD,
BIND_ACTION_SEARCH_EXTEND_WORD_WS,
diff --git a/search.c b/search.c
index 20990c87..dda84e6d 100644
--- a/search.c
+++ b/search.c
@@ -1265,6 +1265,29 @@ execute_binding(struct seat *seat, struct terminal *term,
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: {
struct coord target;
if (search_extend_find_char_right(term, &target)) {