commit a298fc55d9f2b2cdbd6f4f025e1e0dc259a48846
Author: Kornel Benko <[email protected]>
Date:   Wed Feb 20 14:14:50 2019 +0100

    FindAdv: Added handling for latex environments
    
    1.) Make sure the environment is mentioned in the string for search
      (Added the keyword \latexenvironment{...})
    2.) Handle it similar to \textcolor{}
    
    That way we can also search for 'conclusion*' or 'summary' etc
    in Additional.lyx.
---
 src/lyxfind.cpp      |    7 ++++---
 src/output_latex.cpp |    5 +++++
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/lyxfind.cpp b/src/lyxfind.cpp
index 9c98540..20bef8d 100644
--- a/src/lyxfind.cpp
+++ b/src/lyxfind.cpp
@@ -951,7 +951,7 @@ static size_t identifyLeading(string const & s)
        // @TODO Support \item[text]
        // Kornel: Added textsl, textsf, textit, texttt and noun
        // + allow to search for colored text too
-       while (regex_replace(t, t, REGEX_BOS 
"\\\\(((footnotesize|tiny|scriptsize|small|large|Large|LARGE|huge|Huge|emph|noun|minisec|text(bf|md|sl|sf|it|tt))|((textcolor|foreignlanguage)\\{[a-z]+\\})|(u|uu)line|(s|x)out|uwave)|((sub)?(((sub)?section)|paragraph)|part|chapter)\\*?)\\{",
 "")
+       while (regex_replace(t, t, REGEX_BOS 
"\\\\(((footnotesize|tiny|scriptsize|small|large|Large|LARGE|huge|Huge|emph|noun|minisec|text(bf|md|sl|sf|it|tt))|((textcolor|foreignlanguage|latexenvironment)\\{[a-z]+\\*?\\})|(u|uu)line|(s|x)out|uwave)|((sub)?(((sub)?section)|paragraph)|part|chapter)\\*?)\\{",
 "")
               || regex_replace(t, t, REGEX_BOS "\\$", "")
               || regex_replace(t, t, REGEX_BOS "\\\\\\[ ", "")
               || regex_replace(t, t, REGEX_BOS " ?\\\\item\\{[a-z]+\\}", "")
@@ -972,12 +972,12 @@ typedef map<string, bool> Features;
 
 static Features identifyFeatures(string const & s)
 {
-       static regex const feature("\\\\(([a-zA-Z]+(\\{([a-z]+)\\}|\\*)?))\\{");
+       static regex const 
feature("\\\\(([a-zA-Z]+(\\{([a-z]+\\*?)\\}|\\*)?))\\{");
        static regex const valid("^("
                "("
                        
"(footnotesize|tiny|scriptsize|small|large|Large|LARGE|huge|Huge|"
                                "emph|noun|text(bf|md|sl|sf|it|tt)|"
-                               
"(textcolor|foreignlanguage|item|listitem)\\{[a-z]+\\})|"
+                               
"(textcolor|foreignlanguage|item|listitem|latexenvironment)\\{[a-z]+\\*?\\})|"
                        "(u|uu)line|(s|x)out|uwave|"
                        
"(sub|extra)?title|author|subject|publishers|dedication|(upper|lower)titleback|lyx(right)?address)|"
                
"((sub)?(((sub)?section)|paragraph)|part|chapter|lyxslide)\\*?)$");
@@ -1796,6 +1796,7 @@ void LatexInfo::buildKeys(bool isPatternString)
 
   // Split is done, if not at start of region
   makeKey("textcolor", KeyInfo(KeyInfo::isStandard, 2, 
ignoreFormats.getColor()), isPatternString);
+  makeKey("latexenvironment", KeyInfo(KeyInfo::isStandard, 2, false), 
isPatternString);
 
   // Split is done always.
   makeKey("foreignlanguage", KeyInfo(KeyInfo::isMain, 2, 
ignoreFormats.getLanguage()), isPatternString);
diff --git a/src/output_latex.cpp b/src/output_latex.cpp
index 4e637ee..8beb096 100644
--- a/src/output_latex.cpp
+++ b/src/output_latex.cpp
@@ -697,6 +697,11 @@ void parStartCommand(Paragraph const & par, otexstream & 
os,
                        os << " ";
                }
                break;
+       case LATEX_ENVIRONMENT:
+               if (runparams.for_search) {
+                       os << "\\latexenvironment{" << style.latexname() << 
"}{";
+               }
+               break;
        case LATEX_BIB_ENVIRONMENT:
                // ignore this, the inset will write itself
                break;

Reply via email to