diff --git a/src/curses/ui_manager.c b/src/curses/ui_manager.c index 01af60f..db242ea 100644 --- a/src/curses/ui_manager.c +++ b/src/curses/ui_manager.c @@ -605,7 +605,7 @@ int dialog_confirm(const char *title, const char *text, const char *options) { WINDOW *dialog_win; - int c, i, curs, newl, height, width; + int key, action, i, curs, newl, height, width; char *str, *tofree, *option, *word; int selected = 0; int optioncnt = 1; @@ -710,22 +710,32 @@ dialog_confirm(const char *title, const char *text, const char *options) wattroff(dialog_win, A_REVERSE); } - c = wgetch(dialog_win); - switch (c) { - case KEY_RIGHT: - selected++; - break; - case KEY_TAB: - case KEY_LEFT: - selected--; - break; - case KEY_SPACE: - case KEY_ENTER: - case KEY_INTRO: - goto done; - case KEY_ESC: - selected = -1; - goto done; + // Get pressed key + key = wgetch(dialog_win); + + // Check actions for this key + while ((action = key_find_action(key, action)) != ERR) { + // Check if we handle this action + switch (action) { + case ACTION_RIGHT: + selected++; + break; + case ACTION_LEFT: + case ACTION_NEXT_FIELD: + selected--; + break; + case ACTION_SELECT: + case ACTION_CONFIRM: + goto done; + case ACTION_PREV_SCREEN: + selected = -1; + goto done; + default: + // Parse next action + continue; + } + // key handled successfully + break; } // Cycle through ooptions diff --git a/src/keybinding.c b/src/keybinding.c index feff37b..9a9fb1d 100644 --- a/src/keybinding.c +++ b/src/keybinding.c @@ -38,8 +38,8 @@ //! sngrep keybindings key_binding_t bindings[ACTION_SENTINEL] = { { ACTION_PRINTABLE, "", { }, 0 }, - { ACTION_UP, "up", { KEY_UP, 'j' }, 2 }, - { ACTION_DOWN, "down", { KEY_DOWN, 'k' }, 2 }, + { ACTION_UP, "up", { KEY_UP, 'k' }, 2 }, + { ACTION_DOWN, "down", { KEY_DOWN, 'j' }, 2 }, { ACTION_LEFT, "left", { KEY_LEFT, 'h' }, 2 }, { ACTION_RIGHT, "right", { KEY_RIGHT, 'l'}, 2 }, { ACTION_DELETE, "delete", { KEY_DC }, 1 },