Change CHANGED_KEY_COMMANDS to be regexes.
Break after first regex
This commit is contained in:
parent
a504bd1436
commit
630a827afc
@ -1181,13 +1181,12 @@ KEY_DATA = collections.OrderedDict([
|
||||
])
|
||||
|
||||
|
||||
# A dict of {old_cmd: new_cmd} strings.
|
||||
# A list of (regex, replacement) tuples of changed key commands.
|
||||
|
||||
CHANGED_KEY_COMMNADS = {
|
||||
'open -t about:blank': 'open -t',
|
||||
'open -b about:blank': 'open -b',
|
||||
'open -w about:blank': 'open -w',
|
||||
'download-page': 'download',
|
||||
'cancel-download': 'download-cancel',
|
||||
'search ""': 'search',
|
||||
}
|
||||
CHANGED_KEY_COMMANDS = [
|
||||
(re.compile(r'^open -([twb]) about:blank$'), r'open -\1'),
|
||||
(re.compile(r'^download-page$'), r'download'),
|
||||
(re.compile(r'^cancel-download$'), r'download-cancel'),
|
||||
(re.compile(r'^search ""$'), r'search'),
|
||||
(re.compile(r"^search ''$"), r'search'),
|
||||
]
|
||||
|
@ -255,7 +255,11 @@ class KeyConfigParser(QObject):
|
||||
command = line.split(maxsplit=1)[0]
|
||||
if command not in cmdutils.cmd_dict:
|
||||
raise KeyConfigError("Invalid command '{}'!".format(command))
|
||||
self._cur_command = configdata.CHANGED_KEY_COMMNADS.get(line, line)
|
||||
for rgx, repl in configdata.CHANGED_KEY_COMMANDS:
|
||||
if rgx.match(line):
|
||||
line = rgx.sub(repl, line)
|
||||
break
|
||||
self._cur_command = line
|
||||
|
||||
def _read_keybinding(self, line):
|
||||
"""Read a key binding from a line."""
|
||||
|
Loading…
Reference in New Issue
Block a user