rework keyboard event lookup failure handling with suggestions from Thomas. Relates to LP #280959

This commit is contained in:
Chris Jones 2008-10-13 09:37:26 +01:00
parent 46774d8f9e
commit 19619bff98
1 changed files with 5 additions and 3 deletions

View File

@ -81,9 +81,11 @@ class TerminatorKeybindings:
raise KeymapError("Unhandled modifier '<%s>'" % modifier) raise KeymapError("Unhandled modifier '<%s>'" % modifier)
def lookup(self, event): def lookup(self, event):
if not event: try:
raise KeymapError("lookup called with no event")
keyval, egroup, level, consumed = self.keymap.translate_keyboard_state(event.hardware_keycode, event.state, event.group) keyval, egroup, level, consumed = self.keymap.translate_keyboard_state(event.hardware_keycode, event.state, event.group)
except TypeError:
err ("keybindings.lookup failed to translate keyboard event: %s"%dir(event))
return None
mask = (event.state & ~consumed) & self._masks mask = (event.state & ~consumed) & self._masks
return self._lookup.get(mask, self.empty).get(event.keyval, None) return self._lookup.get(mask, self.empty).get(event.keyval, None)