implement ctrl-u (erase before cursor) keybinding
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Zi How Poh · committed by Daniel Eklöf · parent c1fdcb7 · Browse files · 8 files·+40 added−8 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
8 files+40 added−8 removed
- other:+40 added−8 removed
Provenance
- Commit
3965791- Tree
e5ff6db- Author
Zi How Poh <z@pzpz.dev>- Committer
Daniel Eklöf <daniel@ekloef.se>- Parent
c1fdcb7
8 files changed+40 added−8 removed
modified:doc/fuzzel.ini.5.scd+6 added-3 removed
299 unmodified lines300 *xkbcli interactive-wayland* can be useful for finding keysym names.301 302 A key combination can only be mapped to *one* action. Lets say you303 want to bind *Control+k* to *next*. Since this is the default shortcut304-for *delete-line*, you must unmap the default binding. This can be305-done by setting _action=none_; e.g. *delete-line=none*.304+for *delete-line-forward*, you must unmap the default binding. This can be305+done by setting _action=none_; e.g. *delete-line-forward=none*.306 307 *cancel*308 Quite fuzzel without executing anythingDefault: _Control+g309 Control+c Escape_.43 unmodified lines353 *delete-prev-word*354 Deletes the **word before** the cursor. Default: _Mod1+BackSpace355 Control+BackSpace_.356 357+*delete-line-backward*358+ Deletes everything before the cursor. Default: _Control+u_.359+360 *delete-next*361 Deletes the **character after** the cursor. Default: _Delete_.362 363 *delete-next-word*364 Deletes the **word after** the cursor. Default: _Mod1+d365 Control+Delete_.366 364-*delete-line*367+*delete-line-forward*368 Deletes everything after the cursor. Default: _Control+k_.369 370 *insert-selected*371 Copies the selected entry to the prompt, replacing the current63 unmodified linesmodified:CHANGELOG.md+5 added
38 unmodified lines39 matches the given string ([#237][237]).40 * `include=<path>` option to `fuzzel.ini` ([#205][205]).41 * New option `--list-executables-in-path` add executables presents in42 the $PATH variable to the list ([#284][284]).43+* New key binding: `delete-line-backward` which corresponds to C-u in bash.44+ Also renames `delete-line` to `delete-line-forward` ([#307][307]).45 46 [130]: https://codeberg.org/dnkl/fuzzel/issues/13047 [264]: https://codeberg.org/dnkl/fuzzel/issues/26448 [252]: https://codeberg.org/dnkl/fuzzel/issues/25249 [237]: https://codeberg.org/dnkl/fuzzel/issues/23750 [205]: https://codeberg.org/dnkl/fuzzel/issues/20551 [284]: https://codeberg.org/dnkl/fuzzel/pulls/28452+[307]: https://codeberg.org/dnkl/fuzzel/pulls/30753 54 55 ### Changed56 1 unmodified line58 * Selection color is now painted over background color ([#255][255]).59 * Exact matches (of the application title) are now sorted first60 ([#259][259]).61 * Set default log level to warning ([#266][266]).62+* Rename `delete-line` binding to `delete-line-forward` ([#307][307]).63 64 [255]: https://codeberg.org/dnkl/fuzzel/issues/25565 [259]: https://codeberg.org/dnkl/fuzzel/issues/25966 [266]: https://codeberg.org/dnkl/fuzzel/pulls/26667+[307]: https://codeberg.org/dnkl/fuzzel/pulls/30768 69 70 ### Deprecated71 ### Removed555 unmodified linesmodified:config.c+4 added-2 removed
44 unmodified lines45 [BIND_ACTION_CURSOR_RIGHT] = "cursor-right",46 [BIND_ACTION_CURSOR_RIGHT_WORD] = "cursor-right-word",47 [BIND_ACTION_DELETE_PREV] = "delete-prev",48 [BIND_ACTION_DELETE_PREV_WORD] = "delete-prev-word",49+ [BIND_ACTION_DELETE_LINE_BACKWARD] = "delete-line-backward",50 [BIND_ACTION_DELETE_NEXT] = "delete-next",51 [BIND_ACTION_DELETE_NEXT_WORD] = "delete-next-word",51- [BIND_ACTION_DELETE_LINE] = "delete-line",52+ [BIND_ACTION_DELETE_LINE_FORWARD] = "delete-line-forward",53 [BIND_ACTION_INSERT_SELECTED] = "insert-selected",54 [BIND_ACTION_MATCHES_EXECUTE] = "execute",55 [BIND_ACTION_MATCHES_EXECUTE_OR_NEXT] = "execute-or-next",56 [BIND_ACTION_MATCHES_EXECUTE_INPUT] = "execute-input",1388 unmodified lines1445 {BIND_ACTION_DELETE_NEXT_WORD, m_alt, {{XKB_KEY_d}}},1446 {BIND_ACTION_DELETE_NEXT_WORD, m_ctrl, {{XKB_KEY_Delete}}},1447 {BIND_ACTION_DELETE_NEXT_WORD, m_ctrl, {{XKB_KEY_KP_Delete}}},1448 1448- {BIND_ACTION_DELETE_LINE, m_ctrl, {{XKB_KEY_k}}},1449+ {BIND_ACTION_DELETE_LINE_BACKWARD, m_ctrl, {{XKB_KEY_u}}},1450+ {BIND_ACTION_DELETE_LINE_FORWARD, m_ctrl, {{XKB_KEY_k}}},1451 1452 {BIND_ACTION_INSERT_SELECTED, m_ctrl, {{XKB_KEY_Tab}}},1453 1454 {BIND_ACTION_MATCHES_EXECUTE, m_none, {{XKB_KEY_Return}}},190 unmodified linesmodified:fuzzel.ini+2 added-1 removed
57 unmodified lines58 # cursor-home=Home Control+a59 # cursor-end=End Control+e60 # delete-prev=BackSpace61 # delete-prev-word=Mod1+BackSpace Control+BackSpace62+# delete-line-backward=Control+u63 # delete-next=Delete KP_Delete Control+d64 # delete-next-word=Mod1+d Control+Delete Control+KP_Delete64-# delete-line=Control+k65+# delete-line-forward=Control+k66 # prev=Up Control+p67 # prev-with-wrap=ISO_Left_Tab68 # prev-page=Page_Up KP_Page_Up69 # next=Down Control+n26 unmodified linesmodified:key-binding.h+2 added-1 removed
14 unmodified lines15 BIND_ACTION_CURSOR_RIGHT,16 BIND_ACTION_CURSOR_RIGHT_WORD,17 BIND_ACTION_DELETE_PREV,18 BIND_ACTION_DELETE_PREV_WORD,19+ BIND_ACTION_DELETE_LINE_BACKWARD,20 BIND_ACTION_DELETE_NEXT,21 BIND_ACTION_DELETE_NEXT_WORD,21- BIND_ACTION_DELETE_LINE,22+ BIND_ACTION_DELETE_LINE_FORWARD,23 BIND_ACTION_INSERT_SELECTED,24 25 BIND_ACTION_MATCHES_EXECUTE,26 BIND_ACTION_MATCHES_EXECUTE_OR_NEXT,75 unmodified linesmodified:prompt.c+13 added
261 unmodified lines262 {263 prompt->text[prompt->cursor] = U'\0';264 return true;265 }266+267+bool268+prompt_erase_before_cursor(struct prompt *prompt)269+{270+ if (prompt->cursor == 0) {271+ return false;272+ }273+ memmove(&prompt->text[0],274+ &prompt->text[prompt->cursor],275+ (c32len(prompt->text) - prompt->cursor + 1) * sizeof(char32_t));276+ prompt->cursor = 0;277+ return true;278+}modified:prompt.h+1 added
25 unmodified lines26 bool prompt_erase_prev_char(struct prompt *prompt);27 bool prompt_erase_next_word(struct prompt *prompt);28 bool prompt_erase_prev_word(struct prompt *prompt);29 bool prompt_erase_after_cursor(struct prompt *prompt);30+bool prompt_erase_before_cursor(struct prompt *prompt);modified:wayland.c+7 added-1 removed
594 unmodified lines595 if (*refresh)596 matches_update(wayl->matches, wayl->prompt);597 return true;598 599+ case BIND_ACTION_DELETE_LINE_BACKWARD:600+ *refresh = prompt_erase_before_cursor(wayl->prompt);601+ if (*refresh)602+ matches_update(wayl->matches, wayl->prompt);603+ return true;604+605 case BIND_ACTION_DELETE_NEXT:606 *refresh = prompt_erase_next_char(wayl->prompt);607 if (*refresh)608 matches_update(wayl->matches, wayl->prompt);4 unmodified lines613 if (*refresh)614 matches_update(wayl->matches, wayl->prompt);615 return true;616 611- case BIND_ACTION_DELETE_LINE:617+ case BIND_ACTION_DELETE_LINE_FORWARD:618 *refresh = prompt_erase_after_cursor(wayl->prompt);619 if (*refresh)620 matches_update(wayl->matches, wayl->prompt);621 return true;1595 unmodified lines