Skip to content

Commit 1eb6137

Browse files
un-defphilj56
authored andcommitted
Add Ctrl+h and Ctrl+m keybindings
1 parent 717f3a8 commit 1eb6137

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

doc/tofi.1.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ the form **--key=value**.
5858

5959
> Move the selection forward one page.
6060
61+
\<Backspace\> \| \<Ctrl\>-h
62+
63+
> Delete character.
64+
6165
\<Ctrl\>-u
6266

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

6771
> Delete word.
6872
69-
\<Enter\>
73+
\<Enter\> \| \<Ctrl\>-m
7074

7175
> Confirm the current selection and quit.
7276

doc/tofi.1.scd

+4-1
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,16 @@ All config file options described in *tofi*(5) are also accepted, in the form
5252
<Page Down>
5353
Move the selection forward one page.
5454

55+
<Backspace> | <Ctrl>-h
56+
Delete character.
57+
5558
<Ctrl>-u
5659
Delete line.
5760

5861
<Ctrl>-w | <Ctrl>-<Backspace>
5962
Delete word.
6063

61-
<Enter>
64+
<Enter> | <Ctrl>-m
6265
Confirm the current selection and quit.
6366

6467
<Escape> | <Ctrl>-c | <Ctrl>-g | <Ctrl>-[

src/input.c

+7-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ void input_handle_keypress(struct tofi *tofi, xkb_keycode_t keycode)
6262
add_character(tofi, keycode);
6363
} else if ((key == KEY_BACKSPACE || key == KEY_W) && ctrl) {
6464
delete_word(tofi);
65-
} else if (key == KEY_BACKSPACE) {
65+
} else if (key == KEY_BACKSPACE
66+
|| (key == KEY_H && ctrl)) {
6667
delete_character(tofi);
6768
} else if (key == KEY_U && ctrl) {
6869
clear_input(tofi);
@@ -94,7 +95,9 @@ void input_handle_keypress(struct tofi *tofi, xkb_keycode_t keycode)
9495
|| ((key == KEY_C || key == KEY_LEFTBRACE || key == KEY_G) && ctrl)) {
9596
tofi->closed = true;
9697
return;
97-
} else if (key == KEY_ENTER || key == KEY_KPENTER) {
98+
} else if (key == KEY_ENTER
99+
|| key == KEY_KPENTER
100+
|| (key == KEY_M && ctrl)) {
98101
tofi->submit = true;
99102
return;
100103
}
@@ -157,6 +160,8 @@ static uint32_t keysym_to_key(xkb_keysym_t sym)
157160
return KEY_ENTER;
158161
case XKB_KEY_KP_Enter:
159162
return KEY_KPENTER;
163+
case XKB_KEY_m:
164+
return KEY_M;
160165
}
161166
return (uint32_t)-1;
162167
}

0 commit comments

Comments
 (0)