{
// This is not a memory leak. The object will be destroyed
// with this.
- (void) new LaTeXHighlighter(preambleTE->document());
+ // @ is letter in the LyX user preamble
+ (void) new LaTeXHighlighter(preambleTE->document(), true);
preambleTE->setFont(guiApp->typewriterSystemFont());
preambleTE->setWordWrapMode(QTextOption::NoWrap);
setFocusProxy(preambleTE);
namespace frontend {
-LaTeXHighlighter::LaTeXHighlighter(QTextDocument * parent)
- : QSyntaxHighlighter(parent)
+LaTeXHighlighter::LaTeXHighlighter(QTextDocument * parent,
+ bool const at_letter)
+ : QSyntaxHighlighter(parent), at_letter_(at_letter)
{
auto blend = [](QColor color1, QColor color2) {
int r = 0.5 * (color1.red() + color2.red());
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();
class LaTeXHighlighter : public QSyntaxHighlighter
{
public:
- LaTeXHighlighter(QTextDocument * parent);
+ explicit LaTeXHighlighter(QTextDocument * parent,
+ bool const at_letter = false);
protected:
void highlightBlock(QString const & text);
QTextCharFormat keywordFormat;
QTextCharFormat mathFormat;
QTextCharFormat warningFormat;
+ // is at a letter (as in the preamble)
+ bool const at_letter_;
};
} // namespace frontend