Try to have strings in KeyConfig
This commit is contained in:
parent
737ff2cc69
commit
28b6b97f39
@ -141,8 +141,11 @@ class KeyConfig:
|
||||
|
||||
def get_bindings_for(self, mode):
|
||||
"""Get the combined bindings for the given mode."""
|
||||
bindings = dict(val.bindings.default[mode])
|
||||
for key, binding in val.bindings.commands[mode].items():
|
||||
bindings = self._config.get_obj(
|
||||
'bindings.default', mutable=False)[mode]
|
||||
bindings_commands = self._config.get_obj(
|
||||
'bindings.commands', mutable=False).get(mode, {})
|
||||
for key, binding in bindings_commands.items():
|
||||
if binding is None:
|
||||
bindings.pop(key, None)
|
||||
else:
|
||||
@ -169,7 +172,8 @@ class KeyConfig:
|
||||
"""Get the command for a given key (or None)."""
|
||||
key = self._prepare(key, mode)
|
||||
if default:
|
||||
bindings = dict(val.bindings.default[mode])
|
||||
bindings = self._config.get_obj(
|
||||
'bindings.default', mutable=False)[mode]
|
||||
else:
|
||||
bindings = self.get_bindings_for(mode)
|
||||
return bindings.get(key, None)
|
||||
@ -208,11 +212,12 @@ class KeyConfig:
|
||||
key = self._prepare(key, mode)
|
||||
|
||||
bindings_commands = self._config.get_obj('bindings.commands')
|
||||
bindings_default = self._config.get_obj('bindings.default')
|
||||
|
||||
if val.bindings.commands[mode].get(key, None) is not None:
|
||||
if key in bindings_commands[mode]:
|
||||
# In custom bindings -> remove it
|
||||
del bindings_commands[mode][key]
|
||||
elif key in val.bindings.default[mode]:
|
||||
elif key in bindings_default[mode]:
|
||||
# In default bindings -> shadow it with None
|
||||
if mode not in bindings_commands:
|
||||
bindings_commands[mode] = {}
|
||||
|
Loading…
Reference in New Issue
Block a user