From 1eb6137572ab6c257ab6ab851d5d742167c18120 Mon Sep 17 00:00:00 2001 From: Dmitry Meyer Date: Sat, 11 Nov 2023 11:13:22 +0000 Subject: [PATCH] Add Ctrl+h and Ctrl+m keybindings --- doc/tofi.1.md | 6 +++++- doc/tofi.1.scd | 5 ++++- src/input.c | 9 +++++++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/doc/tofi.1.md b/doc/tofi.1.md index eef1942..a3e8ab3 100644 --- a/doc/tofi.1.md +++ b/doc/tofi.1.md @@ -58,6 +58,10 @@ the form **--key=value**. > Move the selection forward one page. +\ \| \-h + +> Delete character. + \-u > Delete line. @@ -66,7 +70,7 @@ the form **--key=value**. > Delete word. -\ +\ \| \-m > Confirm the current selection and quit. diff --git a/doc/tofi.1.scd b/doc/tofi.1.scd index 88ef396..8dd259f 100644 --- a/doc/tofi.1.scd +++ b/doc/tofi.1.scd @@ -52,13 +52,16 @@ All config file options described in *tofi*(5) are also accepted, in the form Move the selection forward one page. + | -h + Delete character. + -u Delete line. -w | - Delete word. - + | -m Confirm the current selection and quit. | -c | -g | -[ diff --git a/src/input.c b/src/input.c index 17b2015..8b8f0a7 100644 --- a/src/input.c +++ b/src/input.c @@ -62,7 +62,8 @@ void input_handle_keypress(struct tofi *tofi, xkb_keycode_t keycode) add_character(tofi, keycode); } else if ((key == KEY_BACKSPACE || key == KEY_W) && ctrl) { delete_word(tofi); - } else if (key == KEY_BACKSPACE) { + } else if (key == KEY_BACKSPACE + || (key == KEY_H && ctrl)) { delete_character(tofi); } else if (key == KEY_U && ctrl) { clear_input(tofi); @@ -94,7 +95,9 @@ void input_handle_keypress(struct tofi *tofi, xkb_keycode_t keycode) || ((key == KEY_C || key == KEY_LEFTBRACE || key == KEY_G) && ctrl)) { tofi->closed = true; return; - } else if (key == KEY_ENTER || key == KEY_KPENTER) { + } else if (key == KEY_ENTER + || key == KEY_KPENTER + || (key == KEY_M && ctrl)) { tofi->submit = true; return; } @@ -157,6 +160,8 @@ static uint32_t keysym_to_key(xkb_keysym_t sym) return KEY_ENTER; case XKB_KEY_KP_Enter: return KEY_KPENTER; + case XKB_KEY_m: + return KEY_M; } return (uint32_t)-1; }