]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/LaTeXHighlighter.cpp
Merge branch 'master' into biblatex2
[lyx.git] / src / frontends / qt4 / LaTeXHighlighter.cpp
index fa949a6e625540bb053d6c31da47f6090f3d1392..7c0e886198ccf3a36ea26967d1db6287da5a0808 100644 (file)
@@ -20,8 +20,8 @@ namespace lyx {
 namespace frontend {
 
 
-LaTeXHighlighter::LaTeXHighlighter(QTextDocument * parent)
-       : QSyntaxHighlighter(parent)
+LaTeXHighlighter::LaTeXHighlighter(QTextDocument * parent, bool at_letter)
+       : QSyntaxHighlighter(parent), at_letter_(at_letter)
 {
        auto blend = [](QColor color1, QColor color2) {
                int r = 0.5 * (color1.red() + color2.red());
@@ -91,7 +91,11 @@ void LaTeXHighlighter::highlightBlock(QString const & text)
                startIndex = exprStartDispMath.indexIn(text, startIndex + length);
        }
        // \whatever
-       static const QRegExp exprKeyword("\\\\[A-Za-z]+");
+       static const QRegExp exprKeywordAtOther("\\\\[A-Za-z]+");
+       // \wh@tever
+       static const QRegExp exprKeywordAtLetter("\\\\[A-Za-z@]+");
+       QRegExp const & exprKeyword = at_letter_ ? exprKeywordAtLetter
+                                                : exprKeywordAtOther;
        index = exprKeyword.indexIn(text);
        while (index >= 0) {
                int length = exprKeyword.matchedLength();