Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Ctrl+h and Ctrl+m keybindings #135

Merged
merged 1 commit into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -51,13 +51,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>-[
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) && 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