aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Szymon Tomasz Stefanek2010-06-26 13:48:18 +0000
committerGravatar Szymon Tomasz Stefanek2010-06-26 13:48:18 +0000
commit09f7a9741bca166fd31d4ab2f36ee8723969415d (patch)
treebc30ad253411f464140ad0d84dc2912ab6d76d86
parentQuick fix (diff)
downloadKVIrc-09f7a9741bca166fd31d4ab2f36ee8723969415d.tar.gz
KVIrc-09f7a9741bca166fd31d4ab2f36ee8723969415d.tar.bz2
KVIrc-09f7a9741bca166fd31d4ab2f36ee8723969415d.zip
Fix syntax highlighting
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@4530 17fca916-40b9-46aa-a4ea-0a15b648b75c
-rw-r--r--src/modules/editor/scripteditor.cpp29
1 files changed, 26 insertions, 3 deletions
diff --git a/src/modules/editor/scripteditor.cpp b/src/modules/editor/scripteditor.cpp
index d9d9ccda6..c950b6dfd 100644
--- a/src/modules/editor/scripteditor.cpp
+++ b/src/modules/editor/scripteditor.cpp
@@ -614,9 +614,28 @@ void KviScriptEditorSyntaxHighlighter::updateSyntaxtTextFormat()
void KviScriptEditorSyntaxHighlighter::highlightBlock(const QString & szText)
{
- if(szText.isEmpty()) return;
+ if(szText.isEmpty())
+ return;
+
int iIndexStart=0;
+ if(previousBlockState() == 1)
+ {
+ // in comment
+ int iCommentEnd = szText.indexOf(commentEndExpression);
+ if(iCommentEnd < 0)
+ {
+ // not found: comment until the end of the block
+ setCurrentBlockState(1);
+ setFormat(iIndexStart,szText.length(),commentFormat);
+ return;
+ }
+ // end of comment found
+ setFormat(iIndexStart,iCommentEnd - iIndexStart,commentFormat);
+ setCurrentBlockState(0);
+ iIndexStart = iCommentEnd;
+ }
+
// skip tabulations and spaces
while(iIndexStart < szText.size())
{
@@ -627,7 +646,10 @@ void KviScriptEditorSyntaxHighlighter::highlightBlock(const QString & szText)
break;
}
}
- if (iIndexStart == szText.size()) return;
+
+ if (iIndexStart == szText.size())
+ return;
+
// check 'commands'
int iCommandStart=iIndexStart;
if (szText.at(iIndexStart).unicode()!='$' && szText.at(iIndexStart).unicode()!='{' && szText.at(iIndexStart).unicode()!='}' && szText.at(iIndexStart).unicode()!='%')
@@ -659,7 +681,8 @@ void KviScriptEditorSyntaxHighlighter::highlightBlock(const QString & szText)
setCurrentBlockState(0);
int startIndex = 0;
- if (previousBlockState() != 1) startIndex = szText.indexOf(commentStartExpression);
+ if (previousBlockState() != 1)
+ startIndex = szText.indexOf(commentStartExpression);
while (startIndex >= 0)
{