Skip to content

Commit

Permalink
Add Ctrl+h and Ctrl+m keybindings
Browse files Browse the repository at this point in the history
  • Loading branch information
un-def authored and philj56 committed Dec 30, 2024
1 parent 717f3a8 commit 1eb6137
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
6 changes: 5 additions & 1 deletion doc/tofi.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ the form **--key=value**.

> Move the selection forward one page.
\<Backspace\> \| \<Ctrl\>-h

> Delete character.
\<Ctrl\>-u

> Delete line.
Expand All @@ -66,7 +70,7 @@ the form **--key=value**.

> Delete word.
\<Enter\>
\<Enter\> \| \<Ctrl\>-m

> Confirm the current selection and quit.
Expand Down
5 changes: 4 additions & 1 deletion doc/tofi.1.scd
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,16 @@ All config file options described in *tofi*(5) are also accepted, in the form
<Page Down>
Move the selection forward one page.

<Backspace> | <Ctrl>-h
Delete character.

<Ctrl>-u
Delete line.

<Ctrl>-w | <Ctrl>-<Backspace>
Delete word.

<Enter>
<Enter> | <Ctrl>-m
Confirm the current selection and quit.

<Escape> | <Ctrl>-c | <Ctrl>-g | <Ctrl>-[
Expand Down
9 changes: 7 additions & 2 deletions src/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 1eb6137

Please sign in to comment.