Support !-keysections, don't bind leave-mode in normal mode.
This commit is contained in:
parent
e516589fe3
commit
a796482c83
@ -797,6 +797,10 @@ KEY_FIRST_COMMENT = """
|
|||||||
# All blank lines and lines starting with '#' are ignored.
|
# All blank lines and lines starting with '#' are ignored.
|
||||||
# Inline-comments are not permitted.
|
# Inline-comments are not permitted.
|
||||||
#
|
#
|
||||||
|
# keymode is a comma separated list of modes in which the keybinding should be
|
||||||
|
# active. If keymode starts with !, the keybinding is active in all modes
|
||||||
|
# except the listed modes.
|
||||||
|
#
|
||||||
# For special keys (can't be part of a keychain), enclose them in `<`...`>`.
|
# For special keys (can't be part of a keychain), enclose them in `<`...`>`.
|
||||||
# For modifiers, you can use either `-` or `+` as delimiters, and these names:
|
# For modifiers, you can use either `-` or `+` as delimiters, and these names:
|
||||||
#
|
#
|
||||||
@ -854,7 +858,7 @@ KEY_SECTION_DESC = {
|
|||||||
|
|
||||||
|
|
||||||
KEY_DATA = collections.OrderedDict([
|
KEY_DATA = collections.OrderedDict([
|
||||||
('all', collections.OrderedDict([
|
('!normal', collections.OrderedDict([
|
||||||
('leave-mode', ['<Escape>', '<Ctrl-[>']),
|
('leave-mode', ['<Escape>', '<Ctrl-[>']),
|
||||||
])),
|
])),
|
||||||
|
|
||||||
|
@ -175,7 +175,15 @@ class KeyConfigParser(QObject):
|
|||||||
|
|
||||||
def _normalize_sectname(self, s):
|
def _normalize_sectname(self, s):
|
||||||
"""Normalize a section string like 'foo, bar,baz' to 'bar,baz,foo'."""
|
"""Normalize a section string like 'foo, bar,baz' to 'bar,baz,foo'."""
|
||||||
return ','.join(sorted(s.split(',')))
|
if s.startswith('!'):
|
||||||
|
inverted = True
|
||||||
|
s = s[1:]
|
||||||
|
else:
|
||||||
|
inverted = False
|
||||||
|
sections = ','.join(sorted(s.split(',')))
|
||||||
|
if inverted:
|
||||||
|
sections = '!' + sections
|
||||||
|
return sections
|
||||||
|
|
||||||
def _load_default(self):
|
def _load_default(self):
|
||||||
"""Load the built-in default keybindings."""
|
"""Load the built-in default keybindings."""
|
||||||
@ -246,8 +254,14 @@ class KeyConfigParser(QObject):
|
|||||||
"""Get a dict with all merged keybindings for a section."""
|
"""Get a dict with all merged keybindings for a section."""
|
||||||
bindings = {}
|
bindings = {}
|
||||||
for sectstring, d in self.keybindings.items():
|
for sectstring, d in self.keybindings.items():
|
||||||
|
if sectstring.startswith('!'):
|
||||||
|
inverted = True
|
||||||
|
sectstring = sectstring[1:]
|
||||||
|
else:
|
||||||
|
inverted = False
|
||||||
sects = [s.strip() for s in sectstring.split(',')]
|
sects = [s.strip() for s in sectstring.split(',')]
|
||||||
if any(s == section for s in sects):
|
matches = any(s == section for s in sects)
|
||||||
|
if (not inverted and matches) or (inverted and not matches):
|
||||||
bindings.update(d)
|
bindings.update(d)
|
||||||
try:
|
try:
|
||||||
bindings.update(self.keybindings['all'])
|
bindings.update(self.keybindings['all'])
|
||||||
|
Loading…
Reference in New Issue
Block a user