Amend 2b24c03e: Do not override (Back)Tab in Adv F&R when it is useful

While testing we want to override 'Tab' in Adv F&R.
Unbinding 'Tab' seems to help, thanks to JMarc for the suggestion.
This commit is contained in:
Kornel Benko 2022-07-18 22:55:03 +02:00
parent efef533d91
commit f771f77c67
8 changed files with 49 additions and 3 deletions

View File

@ -1,6 +1,10 @@
# After replacing with something that matches the search pattern, the next
# match should not consider the just replaced text (#4388)
#
UnuseShortcut "Tab" "command-alternatives completion-accept;cell-forward;tab-insert;outline-in;depth-increment"
PrepareShortcuts
Lang it_IT.utf8
CO: findadv-01.ctrl
KD: 100

View File

@ -1,5 +1,9 @@
# Basic test on refactoring of mathematics notation
#
UnuseShortcut "Tab" "command-alternatives completion-accept;cell-forward;tab-insert;outline-in;depth-increment"
PrepareShortcuts
Lang it_IT.utf8
CO: findadv-02.ctrl
TestBegin test.lyx -dbg key,find > findadv-02.loga.txt 2>&1

View File

@ -1,5 +1,9 @@
# Regression test for #7245
#
UnuseShortcut "Tab" "command-alternatives completion-accept;cell-forward;tab-insert;outline-in;depth-increment"
PrepareShortcuts
Lang it_IT.utf8
CO: findadv-04.ctrl
TestBegin test.lyx -dbg key,find > findadv-04.loga.txt 2>&1

View File

@ -2,6 +2,10 @@
# again the search pattern, should not result in a double replacement
# (#7442)
#
UnuseShortcut "Tab" "command-alternatives completion-accept;cell-forward;tab-insert;outline-in;depth-increment"
PrepareShortcuts
Lang sk_SK.utf8
CO: findadv-12.ctrl
TestBegin test.lyx -dbg key,find > findadv-12.loga.txt 2>&1

View File

@ -1,6 +1,9 @@
# Avoiding recursive replacements when replaced text matches search pattern
# Addresses #7675.
#
UnuseShortcut "Tab" "command-alternatives completion-accept;cell-forward;tab-insert;outline-in;depth-increment"
PrepareShortcuts
Lang it_IT.utf8

View File

@ -1,6 +1,10 @@
# Test for searching the special LyX and LaTeX words
# when ignoring format
UnuseShortcut "Tab" "command-alternatives completion-accept;cell-forward;tab-insert;outline-in;depth-increment"
PrepareShortcuts
Lang sk_SK.utf8
TestBegin test.lyx -dbg key,find > findadv-logo.loga.txt 2>&1
KK: This should be a LaTeX logo:

View File

@ -1,5 +1,7 @@
# Finding styles with regexp
UseShortcut "C-F20" "regexp-mode"
UnuseShortcut "Tab" "command-alternatives completion-accept;cell-forward;tab-insert;outline-in;depth-increment"
PrepareShortcuts
Lang sk_SK.utf8

View File

@ -481,7 +481,8 @@ class Shortcuts:
def __init__(self):
self.shortcut_entry = re.compile(r'^\s*"([^"]+)"\s*\"([^"]+)\"')
self.bindings = {}
self.bind = re.compile(r'^\s*\\bind\s+"([^"]+)"')
self.unbindings = {}
self.bind = re.compile(r'^\s*\\(un)?bind\s+"([^"]+)"')
if lyx_userdir_ver is None:
self.dir = lyx_userdir
else:
@ -496,6 +497,15 @@ class Shortcuts:
else:
die(1, "cad shortcut spec(" + c + ")")
def __UnuseShortcut(self, c):
m = self.shortcut_entry.match(c)
if m:
sh = m.group(1)
fkt = m.group(2)
self.unbindings[sh] = fkt
else:
die(1, "cad shortcut spec(" + c + ")")
def __PrepareShortcuts(self):
if not self.dir is None:
tmp = tempfile.NamedTemporaryFile(suffix='.bind', delete=False)
@ -511,11 +521,15 @@ class Shortcuts:
m = self.bind.match(line)
if m:
bindfound = True
val = m.group(1)
val = m.group(2)
if val in self.bindings:
if self.bindings[val] != "":
tmp.write("\\bind \"" + val + "\" \"" + self.bindings[val] + "\"\n")
self.bindings[val] = ""
elif val in self.unbindings:
if self.unbindings[val] != "":
tmp.write("\\unbind \"" + val + "\" \"" + self.unbindings[val] + "\"\n")
self.unbindings[val] = ""
else:
tmp.write(line + '\n')
elif not bindfound:
@ -530,6 +544,11 @@ class Shortcuts:
if self.bindings[val] != "":
tmp.write("\\bind \"" + val + "\" \"" + self.bindings[val] + "\"\n")
self.bindings[val] = ""
for val in self.unbindings:
if not self.unbindings[val] is None:
if self.unbindings[val] != "":
tmp.write("\\unbind \"" + val + "\" \"" + self.unbindings[val] + "\"\n")
self.unbindings[val] = ""
tmp.close()
shutil.move(tmp.name, self.dir + '/bind/user.bind')
else:
@ -538,6 +557,8 @@ class Shortcuts:
def dispatch(self, c):
if c[0:12] == 'UseShortcut ':
self.__UseShortcut(c[12:])
elif c[0:14] == 'UnuseShortcut ':
self.__UnuseShortcut(c[14:])
elif c == 'PrepareShortcuts':
print('Preparing usefull sortcuts for tests')
self.__PrepareShortcuts()