From 47d7c477b39edb30a414841d110391618bc811d4 Mon Sep 17 00:00:00 2001 From: myk002 Date: Wed, 9 Nov 2022 17:49:55 -0800 Subject: [PATCH] show menu hotkey for list but not on the menu --- plugins/hotkeys.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/hotkeys.cpp b/plugins/hotkeys.cpp index 72f2e0111..77db827bd 100644 --- a/plugins/hotkeys.cpp +++ b/plugins/hotkeys.cpp @@ -52,11 +52,11 @@ static int cleanupHotkeys(lua_State *) { return 0; } -static void add_binding_if_valid(const string &sym, const string &cmdline, df::viewscreen *screen) { +static void add_binding_if_valid(const string &sym, const string &cmdline, df::viewscreen *screen, bool filtermenu) { if (!can_invoke(cmdline, screen)) return; - if (cmdline == INVOKE_MENU_COMMAND) { + if (filtermenu && cmdline == INVOKE_MENU_COMMAND) { DEBUG(log).print("filtering out hotkey menu keybinding\n"); return; } @@ -69,7 +69,7 @@ static void add_binding_if_valid(const string &sym, const string &cmdline, df::v Core::getInstance().AddKeyBinding(keyspec, binding); } -static void find_active_keybindings(df::viewscreen *screen) { +static void find_active_keybindings(df::viewscreen *screen, bool filtermenu) { DEBUG(log).print("scanning for active keybindings\n"); if (valid) cleanupHotkeys(NULL); @@ -100,7 +100,7 @@ static void find_active_keybindings(df::viewscreen *screen) { auto list = Core::getInstance().ListKeyBindings(sym); for (auto invoke_cmd = list.begin(); invoke_cmd != list.end(); invoke_cmd++) { if (invoke_cmd->find(":") == string::npos) { - add_binding_if_valid(sym, *invoke_cmd, screen); + add_binding_if_valid(sym, *invoke_cmd, screen, filtermenu); } else { vector tokens; @@ -108,7 +108,7 @@ static void find_active_keybindings(df::viewscreen *screen) { string focus = tokens[0].substr(1); if (prefix_matches(focus, current_focus)) { auto cmdline = trim(tokens[1]); - add_binding_if_valid(sym, cmdline, screen); + add_binding_if_valid(sym, cmdline, screen, filtermenu); } } } @@ -121,7 +121,7 @@ static void find_active_keybindings(df::viewscreen *screen) { } static int getHotkeys(lua_State *L) { - find_active_keybindings(Gui::getCurViewscreen(true)); + find_active_keybindings(Gui::getCurViewscreen(true), true); Lua::PushVector(L, sorted_keys); Lua::Push(L, current_bindings); return 2; @@ -137,7 +137,7 @@ static void list(color_ostream &out) { DEBUG(log).print("listing active hotkeys\n"); bool was_valid = valid; if (!valid) - find_active_keybindings(Gui::getCurViewscreen(true)); + find_active_keybindings(Gui::getCurViewscreen(true), false); out.print("Valid keybindings for the current screen (%s)\n", current_focus.c_str());