Correctly highlight comments in latexHighlighter

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17574 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Bo Peng 2007-03-26 15:51:34 +00:00
parent ae6c7d2c51
commit 7c0bb562cb

View File

@ -32,17 +32,9 @@ latexHighlighter::latexHighlighter(QTextDocument * parent) :
void latexHighlighter::highlightBlock(QString const & text)
{
// comment
QRegExp exprComment("^%.*$");
int index = text.indexOf(exprComment);
while (index >= 0) {
int length = exprComment.matchedLength();
setFormat(index, length, commentFormat);
index = text.indexOf(exprComment, index + length);
}
// $ $
QRegExp exprMath("\\$[^\\$]*\\$");
index = text.indexOf(exprMath);
int index = text.indexOf(exprMath);
while (index >= 0) {
int length = exprMath.matchedLength();
setFormat(index, length, mathFormat);
@ -95,6 +87,14 @@ void latexHighlighter::highlightBlock(QString const & text)
setFormat(index, length, keywordFormat);
index = text.indexOf(exprKeyword, index + length);
}
// comment
QRegExp exprComment("(^|[^\\\\])%.*$");
index = text.indexOf(exprComment);
while (index >= 0) {
int length = exprComment.matchedLength();
setFormat(index, length, commentFormat);
index = text.indexOf(exprComment, index + length);
}
}