console: add console.key.execute.focus, bind to x

This commit is contained in:
Aldo Cortesi 2017-06-14 09:21:37 +12:00
parent 254fe34d4c
commit e5f79abb4f
2 changed files with 16 additions and 2 deletions

View File

@ -86,7 +86,7 @@ class ConsoleAddon:
""" """
self.master.window.switch() self.master.window.switch()
@command.command("console.options.reset.current") @command.command("console.options.reset.focus")
def options_reset_current(self) -> None: def options_reset_current(self) -> None:
""" """
Reset the current option in the options editor. Reset the current option in the options editor.
@ -469,6 +469,14 @@ class ConsoleAddon:
except ValueError as v: except ValueError as v:
raise exceptions.CommandError(v) raise exceptions.CommandError(v)
@command.command("console.key.execute.focus")
def key_execute_focus(self) -> None:
"""
Execute the currently focused key binding.
"""
b = self._keyfocus()
self.console_command(b.command)
def running(self): def running(self):
self.started = True self.started = True

View File

@ -128,7 +128,7 @@ def map(km):
km.add("L", "console.command options.load ", ["options"], "Load from file") km.add("L", "console.command options.load ", ["options"], "Load from file")
km.add("S", "console.command options.save ", ["options"], "Save to file") km.add("S", "console.command options.save ", ["options"], "Save to file")
km.add("D", "options.reset", ["options"], "Reset all options") km.add("D", "options.reset", ["options"], "Reset all options")
km.add("d", "console.options.reset.current", ["options"], "Reset this option") km.add("d", "console.options.reset.focus", ["options"], "Reset this option")
km.add("a", "console.grideditor.add", ["grideditor"], "Add a row after cursor") km.add("a", "console.grideditor.add", ["grideditor"], "Add a row after cursor")
km.add("A", "console.grideditor.insert", ["grideditor"], "Insert a row before cursor") km.add("A", "console.grideditor.insert", ["grideditor"], "Insert a row before cursor")
@ -164,3 +164,9 @@ def map(km):
["keybindings"], ["keybindings"],
"Unbind the currently focused key binding" "Unbind the currently focused key binding"
) )
km.add(
"x",
"console.key.execute.focus",
["keybindings"],
"Execute the currently focused key binding"
)