aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules/editor
diff options
context:
space:
mode:
authorGravatar Fabio Bas2008-10-05 12:12:48 +0000
committerGravatar Fabio Bas2008-10-05 12:12:48 +0000
commit74241e164e30bb0eb3b0fc3dcfe837dd2587a6f5 (patch)
tree650617ac634ea655956a12f44fcb9e0f2b83c194 /src/modules/editor
parentupported documentation fix (diff)
downloadKVIrc-74241e164e30bb0eb3b0fc3dcfe837dd2587a6f5.tar.gz
KVIrc-74241e164e30bb0eb3b0fc3dcfe837dd2587a6f5.tar.bz2
KVIrc-74241e164e30bb0eb3b0fc3dcfe837dd2587a6f5.zip
fixed crash in scripteditor, thank you le_mischa
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@2655 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src/modules/editor')
-rw-r--r--src/modules/editor/scripteditor.cpp77
1 files changed, 50 insertions, 27 deletions
diff --git a/src/modules/editor/scripteditor.cpp b/src/modules/editor/scripteditor.cpp
index 86d2bdd9d..18bddd656 100644
--- a/src/modules/editor/scripteditor.cpp
+++ b/src/modules/editor/scripteditor.cpp
@@ -611,16 +611,39 @@ void KviScriptEditorSyntaxHighlighter::updateSyntaxtTextFormat()
void KviScriptEditorSyntaxHighlighter::highlightBlock(const QString & szText)
{
if(szText.isEmpty()) return;
- int start=0;
+ int start=0, lastsimplechar=-1;
// skip tabulations
- while(szText.at(start).unicode()=='\t') start++;
-
+ while(start < szText.size())
+ {
+ if(szText.at(start).unicode()=='\t')
+ {
+ start++;
+ } else {
+ break;
+ }
+ }
+
// check 'commands'
- if (szText.at(start).unicode()!='$' && szText.at(start).unicode()!='{' && szText.at(start).unicode()!='}')
+
+ while(start < szText.size())
{
- while(szText.at(start).unicode() && (szText.at(start).isLetterOrNumber() || (szText.at(start).unicode() == '.') || (szText.at(start).unicode() == '_') || (szText.at(start).unicode()== ':')))start++;
- setFormat(0,start,keywordFormat);
+ if( szText.at(start).unicode()=='$' ||
+ szText.at(start).unicode()=='{' ||
+ szText.at(start).unicode()=='}' )
+ {
+ if(lastsimplechar > -1)
+ setFormat(0,lastsimplechar,keywordFormat);
+ break;
+ } else if( szText.at(start).unicode() &&
+ ( szText.at(start).isLetterOrNumber() ||
+ szText.at(start).unicode() == '.' ||
+ szText.at(start).unicode() == '_' ||
+ szText.at(start).unicode()== ':' ) )
+ {
+ lastsimplechar = start;
+ }
+ start++;
}
// code from QT4 example
@@ -629,35 +652,35 @@ void KviScriptEditorSyntaxHighlighter::highlightBlock(const QString & szText)
{
QRegExp expression(rule.pattern);
QString sz=expression.pattern();
- index = szText.indexOf(expression,start);
- while (index >= 0)
+
+ index = szText.indexOf(expression,start);
+ while (index >= 0)
{
int length = expression.matchedLength();
- setFormat(index, length, rule.format);
- index = szText.indexOf(expression, index + length);
- }
- }
- setCurrentBlockState(0);
+ setFormat(index, length, rule.format);
+ index = szText.indexOf(expression, index + length);
+ }
+ }
- int startIndex = 0;
- if (previousBlockState() != 1) startIndex = szText.indexOf(commentStartExpression);
+ setCurrentBlockState(0);
- while (startIndex >= 0)
+ int startIndex = 0;
+ if (previousBlockState() != 1) startIndex = szText.indexOf(commentStartExpression);
+
+ while (startIndex >= 0)
{
int endIndex = szText.indexOf(commentEndExpression, startIndex);
- int commentLength;
- if (endIndex == -1)
+ int commentLength;
+ if (endIndex == -1)
{
setCurrentBlockState(1);
- commentLength = szText.length() - startIndex;
- }
- else
- {
- commentLength = endIndex - startIndex + commentEndExpression.matchedLength();
- }
- setFormat(startIndex, commentLength, commentFormat);
- startIndex = szText.indexOf(commentStartExpression, startIndex + commentLength);
- }
+ commentLength = szText.length() - startIndex;
+ } else {
+ commentLength = endIndex - startIndex + commentEndExpression.matchedLength();
+ }
+ setFormat(startIndex, commentLength, commentFormat);
+ startIndex = szText.indexOf(commentStartExpression, startIndex + commentLength);
+ }
// 'found matches' highlighting
KviScriptEditorWidget * pEditor = ((KviScriptEditorWidget *)textEdit());