Make <Ctrl>plus/minus/etc work
This commit is contained in:
parent
ca66d55bea
commit
fbd862c1aa
|
@ -22,6 +22,7 @@ class TerminatorKeybindings:
|
||||||
empty = {}
|
empty = {}
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
self.keymap = gtk.gdk.keymap_get_default()
|
||||||
self.configure({})
|
self.configure({})
|
||||||
|
|
||||||
def configure(self, bindings):
|
def configure(self, bindings):
|
||||||
|
@ -33,18 +34,18 @@ class TerminatorKeybindings:
|
||||||
self._masks = 0
|
self._masks = 0
|
||||||
for action, binding in self.keys.items():
|
for action, binding in self.keys.items():
|
||||||
try:
|
try:
|
||||||
mask, key = self._parsebinding(binding)
|
keyval, mask = self._parsebinding(binding)
|
||||||
keyval = gtk.gdk.keyval_from_name(key)
|
#keyval, mask = gtk.accelerator_parse(binding)
|
||||||
if keyval == 0:
|
#mask = int(mask)
|
||||||
raise KeymapError("Key '%s' is unrecognised" % key)
|
|
||||||
except KeymapError, e:
|
except KeymapError, e:
|
||||||
e.action = action
|
e.action = action
|
||||||
raise e
|
raise e
|
||||||
else:
|
else:
|
||||||
|
if keyval == gtk.keysyms.Tab and mask & gtk.gdk.SHIFT_MASK:
|
||||||
|
keyval = gtk.keysyms.ISO_Left_Tab
|
||||||
|
mask &= ~gtk.gdk.SHIFT_MASK
|
||||||
self._lookup.setdefault(mask, {})
|
self._lookup.setdefault(mask, {})
|
||||||
self._lookup[mask][keyval] = action
|
self._lookup[mask][keyval] = action
|
||||||
if key == 'Tab':
|
|
||||||
self._lookup[mask][gtk.keysyms.ISO_Left_Tab] = action
|
|
||||||
self._masks |= mask
|
self._masks |= mask
|
||||||
|
|
||||||
def _parsebinding(self, binding):
|
def _parsebinding(self, binding):
|
||||||
|
@ -56,7 +57,10 @@ class TerminatorKeybindings:
|
||||||
key = re.sub(Modifier, '', binding)
|
key = re.sub(Modifier, '', binding)
|
||||||
if key == '':
|
if key == '':
|
||||||
raise KeymapError('No key found')
|
raise KeymapError('No key found')
|
||||||
return (mask, re.sub(Modifier, '', binding))
|
keyval = gtk.gdk.keyval_from_name(key)
|
||||||
|
if keyval == 0:
|
||||||
|
raise KeymapError("Key '%s' is unrecognised" % key)
|
||||||
|
return (keyval, mask)
|
||||||
|
|
||||||
def _lookup_modifier(self, modifier):
|
def _lookup_modifier(self, modifier):
|
||||||
try:
|
try:
|
||||||
|
@ -65,6 +69,7 @@ class TerminatorKeybindings:
|
||||||
raise KeymapError("Unhandled modifier '<%s>'" % modifier)
|
raise KeymapError("Unhandled modifier '<%s>'" % modifier)
|
||||||
|
|
||||||
def lookup(self, event):
|
def lookup(self, event):
|
||||||
mask = event.state & self._masks
|
keyval, egroup, level, consumed = self.keymap.translate_keyboard_state(event.hardware_keycode, event.state, event.group)
|
||||||
|
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)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue