Update keybindings to more closely follow dmenu - wmenu - 🔧 fork of wmenu
(HTM) git clone git@git.drkhsh.at/wmenu.git
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit cb884725f61b31e861f667d7517978ea55d1279f
(DIR) parent 5ef1e637bfe3b9e2f58cc15d8a0dd0256e1b93d0
(HTM) Author: Amin Bandali <bandali@kelar.org>
Date: Sun, 25 Feb 2024 14:49:53 -0500
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.
Diffstat:
M docs/wmenu.1.scd | 3 +++
M main.c | 48 ++++---------------------------
2 files changed, 8 insertions(+), 43 deletions(-)
---
(DIR) diff --git 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
(DIR) diff --git 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);