handle commands like ':lua <something>'

develop
myk002 2022-11-12 09:57:32 -08:00
parent 2093287bf0
commit 6635b6489b
No known key found for this signature in database
GPG Key ID: 8A39CA0FA0C16E78
2 changed files with 4 additions and 1 deletions

@ -99,7 +99,9 @@ static void find_active_keybindings(df::viewscreen *screen, bool filtermenu) {
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) { string::size_type colon_pos = invoke_cmd->find(":");
// colons at location 0 are for commands like ":lua"
if (colon_pos == string::npos || colon_pos == 0) {
add_binding_if_valid(sym, *invoke_cmd, screen, filtermenu); add_binding_if_valid(sym, *invoke_cmd, screen, filtermenu);
} }
else { else {

@ -182,6 +182,7 @@ end
function MenuScreen:onSelect(_, choice) function MenuScreen:onSelect(_, choice)
if not choice or #self.subviews == 0 then return end if not choice or #self.subviews == 0 then return end
local first_word = choice.command:trim():split(' +')[1] local first_word = choice.command:trim():split(' +')[1]
if first_word:startswith(':') then first_word = first_word:sub(2) end
self.subviews.help.text_to_wrap = helpdb.is_entry(first_word) and self.subviews.help.text_to_wrap = helpdb.is_entry(first_word) and
helpdb.get_entry_short_help(first_word) or 'Command not found' helpdb.get_entry_short_help(first_word) or 'Command not found'
self.subviews.help_panel:updateLayout() self.subviews.help_panel:updateLayout()