Parse actions on demand

This removes the startup cost of parsing hundreds of default actions
when action_alias or kitten_alias are used. Although the cost is on the
order of 1ms, this design feels cleaner and gives nicer debug config
output.
This commit is contained in:
Kovid Goyal
2021-11-29 21:51:42 +05:30
parent 0e5f51f195
commit 0c274a9a0b
13 changed files with 288 additions and 269 deletions

View File

@@ -69,11 +69,11 @@ class Callbacks:
def on_mouse_event(self, event):
ev = MouseEvent(**event)
actions = self.opts.mousemap.get(ev)
if not actions:
action_def = self.opts.mousemap.get(ev)
if not action_def:
return False
self.current_mouse_button = ev.button
for action in actions:
for action in self.opts.alias_map.resolve_aliases(action_def, 'mouse_map'):
getattr(self, action.func)(*action.args)
self.current_mouse_button = 0
return True