show menu hotkey for list but not on the menu

develop
myk002 2022-11-09 17:49:55 -08:00
parent a2efc41fef
commit 47d7c477b3
No known key found for this signature in database
GPG Key ID: 8A39CA0FA0C16E78
1 changed files with 7 additions and 7 deletions

@ -52,11 +52,11 @@ static int cleanupHotkeys(lua_State *) {
return 0; 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)) if (!can_invoke(cmdline, screen))
return; return;
if (cmdline == INVOKE_MENU_COMMAND) { if (filtermenu && cmdline == INVOKE_MENU_COMMAND) {
DEBUG(log).print("filtering out hotkey menu keybinding\n"); DEBUG(log).print("filtering out hotkey menu keybinding\n");
return; return;
} }
@ -69,7 +69,7 @@ static void add_binding_if_valid(const string &sym, const string &cmdline, df::v
Core::getInstance().AddKeyBinding(keyspec, binding); 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"); DEBUG(log).print("scanning for active keybindings\n");
if (valid) if (valid)
cleanupHotkeys(NULL); cleanupHotkeys(NULL);
@ -100,7 +100,7 @@ static void find_active_keybindings(df::viewscreen *screen) {
auto list = Core::getInstance().ListKeyBindings(sym); auto list = Core::getInstance().ListKeyBindings(sym);
for (auto invoke_cmd = list.begin(); invoke_cmd != list.end(); invoke_cmd++) { for (auto invoke_cmd = list.begin(); invoke_cmd != list.end(); invoke_cmd++) {
if (invoke_cmd->find(":") == string::npos) { if (invoke_cmd->find(":") == string::npos) {
add_binding_if_valid(sym, *invoke_cmd, screen); add_binding_if_valid(sym, *invoke_cmd, screen, filtermenu);
} }
else { else {
vector<string> tokens; vector<string> tokens;
@ -108,7 +108,7 @@ static void find_active_keybindings(df::viewscreen *screen) {
string focus = tokens[0].substr(1); string focus = tokens[0].substr(1);
if (prefix_matches(focus, current_focus)) { if (prefix_matches(focus, current_focus)) {
auto cmdline = trim(tokens[1]); 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) { 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::PushVector(L, sorted_keys);
Lua::Push(L, current_bindings); Lua::Push(L, current_bindings);
return 2; return 2;
@ -137,7 +137,7 @@ static void list(color_ostream &out) {
DEBUG(log).print("listing active hotkeys\n"); DEBUG(log).print("listing active hotkeys\n");
bool was_valid = valid; bool was_valid = valid;
if (!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", out.print("Valid keybindings for the current screen (%s)\n",
current_focus.c_str()); current_focus.c_str());