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

View File

@ -81,9 +81,11 @@ class TerminatorKeybindings:
raise KeymapError("Unhandled modifier '<%s>'" % modifier)
def lookup(self, event):
if not event:
raise KeymapError("lookup called with no event")
keyval, egroup, level, consumed = self.keymap.translate_keyboard_state(event.hardware_keycode, event.state, event.group)
try:
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
return self._lookup.get(mask, self.empty).get(event.keyval, None)