aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmin Bandali <bandali@kelar.org>2024-02-25 14:49:53 -0500
committeradnano <me@adnano.co>2024-02-26 06:31:38 -0500
commitcb884725f61b31e861f667d7517978ea55d1279f (patch)
tree14a00e44bab621c7b7779823b277c0532d42c1a9
parent5ef1e637bfe3b9e2f58cc15d8a0dd0256e1b93d0 (diff)
downloadwmenu-cb884725f61b31e861f667d7517978ea55d1279f.tar.gz
Update keybindings to more closely follow dmenu
There's no need to distinguish between vertical and horizontal mode for the directional keys. By not doing so we match dmenu's behaviour and also reduce code duplication.
-rw-r--r--docs/wmenu.1.scd3
-rw-r--r--main.c48
2 files changed, 8 insertions, 43 deletions
diff --git a/docs/wmenu.1.scd b/docs/wmenu.1.scd
index f532b21..5fbf50e 100644
--- a/docs/wmenu.1.scd
+++ b/docs/wmenu.1.scd
@@ -112,6 +112,9 @@ arrow keys, page up, page down, home, and end.
|[ *C-g*
:[ Escape
+|[ *C-[*
+:[ Escape
+
|[ *C-h*
:[ Backspace
diff --git a/main.c b/main.c
index b30edbf..3bc0f0a 100644
--- a/main.c
+++ b/main.c
@@ -525,6 +525,9 @@ void keypress(struct menu_state *state, enum wl_keyboard_key_state key_state,
case XKB_KEY_g:
sym = XKB_KEY_Escape;
break;
+ case XKB_KEY_bracketleft:
+ sym = XKB_KEY_Escape;
+ break;
case XKB_KEY_h:
sym = XKB_KEY_BackSpace;
break;
@@ -641,48 +644,8 @@ void keypress(struct menu_state *state, enum wl_keyboard_key_state key_state,
break;
case XKB_KEY_Left:
case XKB_KEY_KP_Left:
- if (state->vertical) {
- break;
- }
- if (state->cursor && (!state->selection || !state->selection->left)) {
- state->cursor = nextrune(state, -1);
- render_frame(state);
- }
- if (state->selection && state->selection->left) {
- if (state->selection == state->leftmost) {
- state->rightmost = state->selection->left;
- state->leftmost = NULL;
- }
- state->selection = state->selection->left;
- scroll_matches(state);
- render_frame(state);
- }
- break;
- case XKB_KEY_Right:
- case XKB_KEY_KP_Right:
- if (state->vertical) {
- break;
- }
- if (state->cursor < len) {
- state->cursor = nextrune(state, +1);
- render_frame(state);
- } else if (state->cursor == len) {
- if (state->selection && state->selection->right) {
- if (state->selection == state->rightmost) {
- state->leftmost = state->selection->right;
- state->rightmost = NULL;
- }
- state->selection = state->selection->right;
- scroll_matches(state);
- render_frame(state);
- }
- }
- break;
case XKB_KEY_Up:
case XKB_KEY_KP_Up:
- if (!state->vertical) {
- break;
- }
if (state->cursor && (!state->selection || !state->selection->left)) {
state->cursor = nextrune(state, -1);
render_frame(state);
@@ -697,11 +660,10 @@ void keypress(struct menu_state *state, enum wl_keyboard_key_state key_state,
render_frame(state);
}
break;
+ case XKB_KEY_Right:
+ case XKB_KEY_KP_Right:
case XKB_KEY_Down:
case XKB_KEY_KP_Down:
- if (!state->vertical) {
- break;
- }
if (state->cursor < len) {
state->cursor = nextrune(state, +1);
render_frame(state);