]> git.lyx.org Git - features.git/commitdiff
Advaced search: Added handling to search for colored text
authorKornel Benko <kornel@lyx.org>
Tue, 2 Oct 2018 09:53:01 +0000 (11:53 +0200)
committerKornel Benko <kornel@lyx.org>
Tue, 2 Oct 2018 09:53:01 +0000 (11:53 +0200)
if used with format enabled

src/lyxfind.cpp

index 08faf0af950291d556ba09d5cc24cf9c2e51b255..936ea2410e762ec9d8ad46f2f015044511c474ac 100644 (file)
@@ -841,8 +841,9 @@ static size_t identifyLeading(string const & s)
 {
        string t = s;
        // @TODO Support \item[text]
-       // Kornel: Added textsf, textit and noun
-       while (regex_replace(t, t, REGEX_BOS "\\\\(emph|noun|text(bf|sl|sf|it|tt)|(u|uu)line|(s|x)out|uwave|subsubsection|subsection|section|subparagraph|paragraph|part)\\*?\\{", "")
+       // Kornel: Added textsl, textsf, textit, texttt and noun
+       // + allow to seach for colored text too
+       while (regex_replace(t, t, REGEX_BOS "\\\\(emph|noun|text(bf|sl|sf|it|tt|color\\{[a-z]+\\})|(u|uu)line|(s|x)out|uwave|subsubsection|subsection|section|subparagraph|paragraph|part)\\*?\\{", "")
               || regex_replace(t, t, REGEX_BOS "\\$", "")
               || regex_replace(t, t, REGEX_BOS "\\\\\\[ ", "")
               || regex_replace(t, t, REGEX_BOS "\\\\item ", "")
@@ -1104,9 +1105,10 @@ string MatchStringAdv::normalize(docstring const & s, bool hack_braces) const
        while ((pos = t.find("\n")) != string::npos)
                t.replace(pos, 1, " ");
        // Remove stale empty \emph{}, \textbf{} and similar blocks from latexify
-       // Kornel: Added textsf, textit and noun
+       // Kornel: Added textsl, textsf, textit, texttt and noun
+       // + allow to seach for colored text too
        LYXERR(Debug::FIND, "Removing stale empty \\emph{}, \\textbf{}, \\*section{} macros from: " << t);
-       while (regex_replace(t, t, "\\\\(emph|noun|text(bf|sl|sf|it|tt)|(u|uu)line|(s|x)out|uwave|subsubsection|subsection|section|subparagraph|paragraph|part)(\\{\\})+", ""))
+       while (regex_replace(t, t, "\\\\(emph|noun|text(bf|sl|sf|it|tt|color\\{[a-z]+\\})|(u|uu)line|(s|x)out|uwave|subsubsection|subsection|section|subparagraph|paragraph|part)(\\{\\})+", ""))
                LYXERR(Debug::FIND, "  further removing stale empty \\emph{}, \\textbf{} macros from: " << t);
 
        // FIXME - check what preceeds the brace