aboutsummaryrefslogtreecommitdiffstats
path: root/src
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
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')
-rw-r--r--src/modules/editor/scripteditor.cpp77
-rw-r--r--src/modules/eventeditor/eventeditor.cpp1
-rw-r--r--src/modules/torrent/tc_ktorrentdcopinterface.h5
3 files changed, 53 insertions, 30 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());
diff --git a/src/modules/eventeditor/eventeditor.cpp b/src/modules/eventeditor/eventeditor.cpp
index 081a3b4f3..b3c0b9d94 100644
--- a/src/modules/eventeditor/eventeditor.cpp
+++ b/src/modules/eventeditor/eventeditor.cpp
@@ -394,7 +394,6 @@ void KviEventEditor::currentItemChanged(QTreeWidgetItem * it,QTreeWidgetItem *pr
KviQString::sprintf(tmp,__tr2qs("\n\n Event:\n %s\n\n Parameters:\n%s"),
((KviEventTreeWidgetItem *)it)->m_szName.toUtf8().data(),parms.toUtf8().data());
m_pEditor->setText(tmp);
-
}
}
diff --git a/src/modules/torrent/tc_ktorrentdcopinterface.h b/src/modules/torrent/tc_ktorrentdcopinterface.h
index 9bc39e1b3..cbcda0b62 100644
--- a/src/modules/torrent/tc_ktorrentdcopinterface.h
+++ b/src/modules/torrent/tc_ktorrentdcopinterface.h
@@ -30,7 +30,8 @@
#include "tc_interface.h"
-#ifdef COMPILE_KDE_SUPPORT
+#ifdef COMPILE_KDE3_SUPPORT
+
#include <kvi_dcophelper.h>
// DCOP interface to KTorrent. this has 'DCOP' in its name
@@ -113,6 +114,6 @@
TORR_DECLARE_DESCRIPTOR(KviKTorrentDCOPInterface)
-#endif // COMPILE_KDE_SUPPORT
+#endif // COMPILE_KDE3_SUPPORT
#endif // _TC_KTORRENTDCOPINTERFACE_H_