mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-25 19:07:45 +00:00
Changes to match math equations
Now tests findadv-01 ... findadv-20 pass too. keytest.py: Expanded time for controll keys (like \[Return]) findadv*: expanded time for normal keys lyxfind.cpp: Handle math equations
This commit is contained in:
parent
645d42f451
commit
2d477c5e0a
@ -3,11 +3,17 @@
|
|||||||
#
|
#
|
||||||
Lang it_IT.utf8
|
Lang it_IT.utf8
|
||||||
CO: findadv-01.ctrl
|
CO: findadv-01.ctrl
|
||||||
|
KD: 100
|
||||||
TestBegin test.lyx -dbg key,find > findadv-01.loga.txt 2>&1
|
TestBegin test.lyx -dbg key,find > findadv-01.loga.txt 2>&1
|
||||||
KK: aaa\[Home]
|
KK: aaa\[Home]
|
||||||
KK: \CF
|
KK: \CF
|
||||||
|
Sleep 1
|
||||||
KK: a\[Tab]
|
KK: a\[Tab]
|
||||||
KK: aba\[Return]\[Return]\[Return]
|
Sleep 1
|
||||||
|
KK: aba
|
||||||
|
KK: \[Return]
|
||||||
|
Sleep 1
|
||||||
|
KK: \[Return]\[Return]
|
||||||
KK: \Cs
|
KK: \Cs
|
||||||
KK: \Axbuffer-export latex\[Return]
|
KK: \Axbuffer-export latex\[Return]
|
||||||
CR: ^abaabaa$
|
CR: ^abaabaa$
|
||||||
|
@ -3,13 +3,20 @@
|
|||||||
Lang it_IT.utf8
|
Lang it_IT.utf8
|
||||||
CO: findadv-02.ctrl
|
CO: findadv-02.ctrl
|
||||||
TestBegin test.lyx -dbg key,find > findadv-02.loga.txt 2>&1
|
TestBegin test.lyx -dbg key,find > findadv-02.loga.txt 2>&1
|
||||||
|
KD: 50
|
||||||
KK: \Cm
|
KK: \Cm
|
||||||
KK: x^(a) +\\frac 1+x^(a) \[Down]1-x^(a) \C\[Home]
|
KK: x^(a) +\\frac 1+x^(a) \[Down]1-x^(a) \C\[Home]
|
||||||
KK: \CF
|
KK: \CF
|
||||||
KK: \Cmx^(a) \[Tab]
|
KK: \Cmx^(a) \[Tab]
|
||||||
|
Sleep 1
|
||||||
KK: \Cmx_a
|
KK: \Cmx_a
|
||||||
KK: \[Return]\[Return]\[Return]
|
KK: \[Return]
|
||||||
|
Sleep 1
|
||||||
|
KK: \[Return]
|
||||||
|
Sleep 1
|
||||||
|
KK: \[Return]
|
||||||
KK: \Cs
|
KK: \Cs
|
||||||
|
KD: 10
|
||||||
KK: \Axbuffer-export latex\[Return]
|
KK: \Axbuffer-export latex\[Return]
|
||||||
CR: ^\$x_\{a\}\+\\frac\{1\+x_\{a\}\}\{1-x\^\{\(a\)\}\}\$$
|
CR: ^\$x_\{a\}\+\\frac\{1\+x_\{a\}\}\{1-x\^\{\(a\)\}\}\$$
|
||||||
CC:
|
CC:
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
Lang sk_SK.utf8
|
Lang sk_SK.utf8
|
||||||
CO: findadv-05.ctrl
|
CO: findadv-05.ctrl
|
||||||
TestBegin test.lyx -dbg key,find > findadv-05.loga.txt 2>&1
|
TestBegin test.lyx -dbg key,find > findadv-05.loga.txt 2>&1
|
||||||
|
KD: 50
|
||||||
CN: Part 1
|
CN: Part 1
|
||||||
KK: foo \Cefoo foo\Ce foo\C\[Home]
|
KK: foo \Cefoo foo\Ce foo\C\[Home]
|
||||||
KK: \Cs
|
KK: \Cs
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
Lang sk_SK.utf8
|
Lang sk_SK.utf8
|
||||||
CO: findadv-06.ctrl
|
CO: findadv-06.ctrl
|
||||||
TestBegin test.lyx -dbg key,find > findadv-06.loga.txt 2>&1
|
TestBegin test.lyx -dbg key,find > findadv-06.loga.txt 2>&1
|
||||||
|
KD: 50
|
||||||
CN: Part 1
|
CN: Part 1
|
||||||
KK: foo\[Return]
|
KK: foo\[Return]
|
||||||
KK: \Ao2
|
KK: \Ao2
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
Lang sk_SK.utf8
|
Lang sk_SK.utf8
|
||||||
CO: findadv-07.ctrl
|
CO: findadv-07.ctrl
|
||||||
TestBegin test.lyx -dbg key,find > findadv-07.loga.txt 2>&1
|
TestBegin test.lyx -dbg key,find > findadv-07.loga.txt 2>&1
|
||||||
|
KD: 100
|
||||||
CN: Part 1
|
CN: Part 1
|
||||||
KK: foo bar\[Return]
|
KK: foo bar\[Return]
|
||||||
#select itemized
|
#select itemized
|
||||||
@ -15,6 +16,7 @@ KK: \Axdialog-show findreplaceadv\[Return]
|
|||||||
# Uncheck ignore format
|
# Uncheck ignore format
|
||||||
KK: \At\Ai\Ah
|
KK: \At\Ai\Ah
|
||||||
KK: \Aob
|
KK: \Aob
|
||||||
|
Sleep 1
|
||||||
KK: foo\[Return]
|
KK: foo\[Return]
|
||||||
CP: Putting selection at .*idx: 0 par: 1 pos: 0\n with len: 3
|
CP: Putting selection at .*idx: 0 par: 1 pos: 0\n with len: 3
|
||||||
#
|
#
|
||||||
@ -26,6 +28,7 @@ KK: \[Delete]
|
|||||||
# Uncheck ignore format
|
# Uncheck ignore format
|
||||||
#KK: \At\Ai\Ah
|
#KK: \At\Ai\Ah
|
||||||
KK: \Aob
|
KK: \Aob
|
||||||
|
Sleep 1
|
||||||
KK: bar\[Return]
|
KK: bar\[Return]
|
||||||
CP: Putting selection at .*idx: 0 par: 1 pos: 4\n with len: 3
|
CP: Putting selection at .*idx: 0 par: 1 pos: 4\n with len: 3
|
||||||
TestEnd
|
TestEnd
|
||||||
|
@ -6,6 +6,7 @@ PrepareShortcuts
|
|||||||
Lang sk_SK.utf8
|
Lang sk_SK.utf8
|
||||||
CO: findadv-08.ctrl
|
CO: findadv-08.ctrl
|
||||||
TestBegin test.lyx -dbg key,find > findadv-08.loga.txt 2>&1
|
TestBegin test.lyx -dbg key,find > findadv-08.loga.txt 2>&1
|
||||||
|
KD: 100
|
||||||
CN: Part 1
|
CN: Part 1
|
||||||
Cr: ^.*Putting
|
Cr: ^.*Putting
|
||||||
CP: Key (queried) [action=buffer-begin][Ctrl+Home]
|
CP: Key (queried) [action=buffer-begin][Ctrl+Home]
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
Lang it_IT.utf8
|
Lang it_IT.utf8
|
||||||
CO: findadv-11.ctrl
|
CO: findadv-11.ctrl
|
||||||
TestBegin test.lyx -dbg key,find > findadv-11.loga.txt 2>&1
|
TestBegin test.lyx -dbg key,find > findadv-11.loga.txt 2>&1
|
||||||
|
KD: 200
|
||||||
CN: Part 1
|
CN: Part 1
|
||||||
KK: \Cm
|
KK: \Cm
|
||||||
KK: x_v \C\[Home]
|
KK: x_v \C\[Home]
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
Lang sk_SK.utf8
|
Lang sk_SK.utf8
|
||||||
CO: findadv-14.ctrl
|
CO: findadv-14.ctrl
|
||||||
TestBegin test.lyx -dbg key,find > findadv-14.loga.txt 2>&1
|
TestBegin test.lyx -dbg key,find > findadv-14.loga.txt 2>&1
|
||||||
|
KD: 100
|
||||||
CN: Part 1
|
CN: Part 1
|
||||||
KK: \Amd
|
KK: \Amd
|
||||||
KK: x^2 +x^2\C\[Home]
|
KK: x^2 +x^2\C\[Home]
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
Lang it_IT.utf8
|
Lang it_IT.utf8
|
||||||
CO: findadv-19.ctrl
|
CO: findadv-19.ctrl
|
||||||
TestBegin test.lyx -dbg key,find > findadv-19.loga.txt 2>&1
|
TestBegin test.lyx -dbg key,find > findadv-19.loga.txt 2>&1
|
||||||
|
KD: 50
|
||||||
KK: Hello world world!\C\[Home]
|
KK: Hello world world!\C\[Home]
|
||||||
KK: \Cs
|
KK: \Cs
|
||||||
KK: \CF
|
KK: \CF
|
||||||
|
@ -593,7 +593,7 @@ if qt_frontend is None:
|
|||||||
qt_frontend = 'QT4'
|
qt_frontend = 'QT4'
|
||||||
if qt_frontend == 'QT5':
|
if qt_frontend == 'QT5':
|
||||||
# Some tests sometimes failed with value 0.01 on Qt5.8
|
# Some tests sometimes failed with value 0.01 on Qt5.8
|
||||||
controlkey_delay = 0.02
|
controlkey_delay = 0.4
|
||||||
else:
|
else:
|
||||||
controlkey_delay = 0.4
|
controlkey_delay = 0.4
|
||||||
|
|
||||||
|
@ -1279,8 +1279,9 @@ int Intervall::findclosing(int start, int end)
|
|||||||
|
|
||||||
void LatexInfo::buildEntries(bool isPatternString)
|
void LatexInfo::buildEntries(bool isPatternString)
|
||||||
{
|
{
|
||||||
static regex const rmath("\\\\(begin|end)\\{((eqnarray|equation|flalign|gather|multiline|align)\\*?)\\}");
|
static regex const rmath("\\$|\\\\\\[|\\\\\\]|\\\\(begin|end)\\{((eqnarray|equation|flalign|gather|multiline|align)\\*?)\\}");
|
||||||
static regex const rkeys("\\\\((([a-zA-Z]+\\*?)(\\{([a-z]+\\*?)\\}|=[0-9]+[a-z]+)?))");
|
static regex const rkeys("\\$|\\\\\\[|\\\\\\]|\\\\((([a-zA-Z]+\\*?)(\\{([a-z]+\\*?)\\}|=[0-9]+[a-z]+)?))");
|
||||||
|
static bool disableLanguageOverride = false;
|
||||||
smatch sub, submath;
|
smatch sub, submath;
|
||||||
bool evaluatingRegexp = false;
|
bool evaluatingRegexp = false;
|
||||||
KeyInfo found;
|
KeyInfo found;
|
||||||
@ -1293,9 +1294,22 @@ void LatexInfo::buildEntries(bool isPatternString)
|
|||||||
for (sregex_iterator itmath(interval.par.begin(), interval.par.end(), rmath), end; itmath != end; ++itmath) {
|
for (sregex_iterator itmath(interval.par.begin(), interval.par.end(), rmath), end; itmath != end; ++itmath) {
|
||||||
submath = *itmath;
|
submath = *itmath;
|
||||||
if (math_end_waiting) {
|
if (math_end_waiting) {
|
||||||
if ((submath.str(1).compare("end") == 0) &&
|
size_t pos = submath.position(size_t(0));
|
||||||
|
if (math_end == "$") {
|
||||||
|
if ((submath.str(0) == "$") && (interval.par[pos-1] != '\\')) {
|
||||||
|
math_size = pos + 1 - math_pos;
|
||||||
|
math_end_waiting = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (math_end == "\\]") {
|
||||||
|
if (submath.str(0) == "\\]") {
|
||||||
|
math_size = pos + 2 - math_pos;
|
||||||
|
math_end_waiting = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ((submath.str(1).compare("end") == 0) &&
|
||||||
(submath.str(2).compare(math_end) == 0)) {
|
(submath.str(2).compare(math_end) == 0)) {
|
||||||
math_size = submath.position(size_t(0)) + submath.str(0).length() - math_pos;
|
math_size = pos + submath.str(0).length() - math_pos;
|
||||||
math_end_waiting = false;
|
math_end_waiting = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1305,10 +1319,44 @@ void LatexInfo::buildEntries(bool isPatternString)
|
|||||||
math_end = submath.str(2);
|
math_end = submath.str(2);
|
||||||
math_pos = submath.position(size_t(0));
|
math_pos = submath.position(size_t(0));
|
||||||
}
|
}
|
||||||
|
else if (submath.str(0).compare("\\[") == 0) {
|
||||||
|
math_end_waiting = true;
|
||||||
|
math_end = "\\]";
|
||||||
|
math_pos = submath.position(size_t(0));
|
||||||
|
}
|
||||||
|
else if (submath.str(0) == "$") {
|
||||||
|
size_t pos = submath.position(size_t(0));
|
||||||
|
if ((pos == 0) || (interval.par[pos-1] != '\\')) {
|
||||||
|
math_end_waiting = true;
|
||||||
|
math_end = "$";
|
||||||
|
math_pos = pos;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isPatternString) {
|
||||||
|
if (math_pos < interval.par.length()) {
|
||||||
|
// Disable language
|
||||||
|
keys["foreignlanguage"].disabled = true;
|
||||||
|
disableLanguageOverride = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
disableLanguageOverride = false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (disableLanguageOverride) {
|
||||||
|
keys["foreignlanguage"].disabled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (sregex_iterator it(interval.par.begin(), interval.par.end(), rkeys), end; it != end; ++it) {
|
for (sregex_iterator it(interval.par.begin(), interval.par.end(), rkeys), end; it != end; ++it) {
|
||||||
sub = *it;
|
sub = *it;
|
||||||
|
string key = sub.str(3);
|
||||||
|
if (key == "") {
|
||||||
|
if (sub.str(0)[0] == '\\')
|
||||||
|
key = sub.str(0)[1];
|
||||||
|
else
|
||||||
|
key = sub.str(0);
|
||||||
|
};
|
||||||
if (evaluatingRegexp) {
|
if (evaluatingRegexp) {
|
||||||
if (sub.str(1).compare("endregexp") == 0) {
|
if (sub.str(1).compare("endregexp") == 0) {
|
||||||
evaluatingRegexp = false;
|
evaluatingRegexp = false;
|
||||||
@ -1320,12 +1368,12 @@ void LatexInfo::buildEntries(bool isPatternString)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (keys.find(sub.str(3)) == keys.end()) {
|
if (keys.find(key) == keys.end()) {
|
||||||
LYXERR(Debug::FIND, "Found unknown key " << sub.str(0));
|
LYXERR(Debug::FIND, "Found unknown key " << sub.str(0));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
found = keys[sub.str(3)];
|
found = keys[key];
|
||||||
if (sub.str(3).compare("regexp") == 0) {
|
if (key.compare("regexp") == 0) {
|
||||||
evaluatingRegexp = true;
|
evaluatingRegexp = true;
|
||||||
found._tokenstart = sub.position(size_t(0));
|
found._tokenstart = sub.position(size_t(0));
|
||||||
found._tokensize = 0;
|
found._tokensize = 0;
|
||||||
@ -1337,7 +1385,7 @@ void LatexInfo::buildEntries(bool isPatternString)
|
|||||||
continue;
|
continue;
|
||||||
else if (found.keytype == KeyInfo::isMath) {
|
else if (found.keytype == KeyInfo::isMath) {
|
||||||
if (size_t(sub.position(size_t(0))) == math_pos) {
|
if (size_t(sub.position(size_t(0))) == math_pos) {
|
||||||
found = keys[sub.str(3)];
|
found = keys[key];
|
||||||
found._tokenstart = sub.position(size_t(0));
|
found._tokenstart = sub.position(size_t(0));
|
||||||
found._tokensize = math_size;
|
found._tokensize = math_size;
|
||||||
found._dataEnd = found._tokenstart + found._tokensize;
|
found._dataEnd = found._tokenstart + found._tokensize;
|
||||||
@ -1364,14 +1412,14 @@ void LatexInfo::buildEntries(bool isPatternString)
|
|||||||
found.head = sub.str(0);
|
found.head = sub.str(0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
found.head = "\\" + sub.str(3);
|
found.head = "\\" + key;
|
||||||
found._tokensize = found.head.length();
|
found._tokensize = found.head.length();
|
||||||
found._dataEnd = found._tokenstart + found._tokensize;
|
found._dataEnd = found._tokenstart + found._tokensize;
|
||||||
found._dataStart = found._dataEnd;
|
found._dataStart = found._dataEnd;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (found.parenthesiscount == 1) {
|
if (found.parenthesiscount == 1) {
|
||||||
found.head = "\\" + sub.str(3) + "{";
|
found.head = "\\" + key + "{";
|
||||||
}
|
}
|
||||||
else if (found.parenthesiscount == 2) {
|
else if (found.parenthesiscount == 2) {
|
||||||
found.head = sub.str(0) + "{";
|
found.head = sub.str(0) + "{";
|
||||||
@ -1381,7 +1429,7 @@ void LatexInfo::buildEntries(bool isPatternString)
|
|||||||
found._dataStart = found._tokenstart + found.head.length();
|
found._dataStart = found._tokenstart + found.head.length();
|
||||||
found._dataEnd = interval.findclosing(found._dataStart, interval.par.length());
|
found._dataEnd = interval.findclosing(found._dataStart, interval.par.length());
|
||||||
if (isPatternString) {
|
if (isPatternString) {
|
||||||
keys[sub.str(3)].used = true;
|
keys[key].used = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1455,9 +1503,11 @@ void LatexInfo::buildKeys(bool isPatternString)
|
|||||||
|
|
||||||
// Survives, like known character
|
// Survives, like known character
|
||||||
makeKey("lyx", KeyInfo(KeyInfo::isIgnored, 0, false), isPatternString);
|
makeKey("lyx", KeyInfo(KeyInfo::isIgnored, 0, false), isPatternString);
|
||||||
|
makeKey("item", KeyInfo(KeyInfo::isChar, 0, false), isPatternString);
|
||||||
|
|
||||||
makeKey("begin", KeyInfo(KeyInfo::isMath, 1, false), isPatternString);
|
makeKey("begin|end", KeyInfo(KeyInfo::isMath, 1, false), isPatternString);
|
||||||
makeKey("end", KeyInfo(KeyInfo::isMath, 1, false), isPatternString);
|
makeKey("[|]", KeyInfo(KeyInfo::isMath, 1, false), isPatternString);
|
||||||
|
makeKey("$", KeyInfo(KeyInfo::isMath, 1, false), isPatternString);
|
||||||
|
|
||||||
makeKey("par|uldepth|ULdepth", KeyInfo(KeyInfo::doRemove, 0, true), isPatternString);
|
makeKey("par|uldepth|ULdepth", KeyInfo(KeyInfo::doRemove, 0, true), isPatternString);
|
||||||
|
|
||||||
@ -1672,6 +1722,11 @@ int LatexInfo::dispatch(ostringstream &os, int previousStart, KeyInfo &actual)
|
|||||||
case KeyInfo::isMain: {
|
case KeyInfo::isMain: {
|
||||||
if (actual.disabled) {
|
if (actual.disabled) {
|
||||||
removeHead(actual);
|
removeHead(actual);
|
||||||
|
if ((interval.par.substr(actual._dataStart, 3) == " \\[") ||
|
||||||
|
(interval.par.substr(actual._dataStart, 8) == " \\begin{")) {
|
||||||
|
// Discard also the space before math-equation
|
||||||
|
interval.addIntervall(actual._dataStart, actual._dataStart+1);
|
||||||
|
}
|
||||||
interval.resetOpenedP(actual._dataStart-1);
|
interval.resetOpenedP(actual._dataStart-1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -1802,7 +1857,7 @@ string splitOnKnownMacros(string par, bool isPatternString) {
|
|||||||
s = os.str();
|
s = os.str();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
s = ""; /* found end */
|
s = par; /* no known macros found */
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,6 +138,10 @@ docstring stringifyFromForSearch(
|
|||||||
DocIterator const & cur,
|
DocIterator const & cur,
|
||||||
int len = -1);
|
int len = -1);
|
||||||
|
|
||||||
|
/** Set format type to be ignore by search
|
||||||
|
**/
|
||||||
|
void setIgnoreFormat(std::string type, bool value);
|
||||||
|
|
||||||
} // namespace lyx
|
} // namespace lyx
|
||||||
|
|
||||||
#endif // LYXFIND_H
|
#endif // LYXFIND_H
|
||||||
|
Loading…
Reference in New Issue
Block a user