History

ScriptEditor: single quotes support and spelling fix

Thijs Wenker committed 11 years ago

Commit 660bf6b1 parent c9312802 files · +11 −11Browse files

Showing the changes to interface/src/ScriptHighlighting.cpp (1 of 2 files). Show all

Unified · Split

interface/src/ScriptHighlighting.cpp+9−9
@@ -16,7 +16,7 @@ ScriptHighlighting::ScriptHighlighting(QTextDocument* parent) : · 15 unmodified lines
1616 QSyntaxHighlighter(parent)
1717 {
1818 _keywordRegex = QRegExp("\\b(break|case|catch|continue|debugger|default|delete|do|else|finally|for|function|if|in|instanceof|new|return|switch|this|throw|try|typeof|var|void|while|with)\\b");
19− _qoutedTextRegex = QRegExp("\"[^\"]*(\"){0,1}");
19+ _quotedTextRegex = QRegExp("(\"[^\"]*(\"){0,1}|\'[^\']*(\'){0,1})");
2020 _multiLineCommentBegin = QRegExp("/\\*");
2121 _multiLineCommentEnd = QRegExp("\\*/");
2222 _numberRegex = QRegExp("[0-9]+(\\.[0-9]+){0,1}");
@@ -29,7 +29,7 @@ void ScriptHighlighting::highlightBlock(const QString& text) { · 6 unmodified lines
2929 this->highlightKeywords(text);
3030 this->formatNumbers(text);
3131 this->formatTrueFalse(text);
32− this->formatQoutedText(text);
32+ this->formatQuotedText(text);
3333 this->formatComments(text);
3434 }
3535
@@ -61,14 +61,14 @@ void ScriptHighlighting::formatComments(const QString& text) { · 25 unmodified lines
6161 int index = _singleLineComment.indexIn(text);
6262 while (index >= 0) {
6363 int length = _singleLineComment.matchedLength();
64− int quoted_index = _qoutedTextRegex.indexIn(text);
64+ int quoted_index = _quotedTextRegex.indexIn(text);
6565 bool valid = true;
6666 while (quoted_index >= 0 && valid) {
67− int quoted_length = _qoutedTextRegex.matchedLength();
67+ int quoted_length = _quotedTextRegex.matchedLength();
6868 if (quoted_index <= index && index <= (quoted_index + quoted_length)) {
6969 valid = false;
7070 }
71− quoted_index = _qoutedTextRegex.indexIn(text, quoted_index + quoted_length);
71+ quoted_index = _quotedTextRegex.indexIn(text, quoted_index + quoted_length);
7272 }
7373
7474 if (valid) {
@@ -78,12 +78,12 @@ void ScriptHighlighting::formatComments(const QString& text) { · 3 unmodified lines
7878 }
7979 }
8080
81−void ScriptHighlighting::formatQoutedText(const QString& text){
82− int index = _qoutedTextRegex.indexIn(text);
81+void ScriptHighlighting::formatQuotedText(const QString& text){
82+ int index = _quotedTextRegex.indexIn(text);
8383 while (index >= 0) {
84− int length = _qoutedTextRegex.matchedLength();
84+ int length = _quotedTextRegex.matchedLength();
8585 setFormat(index, length, Qt::red);
86− index = _qoutedTextRegex.indexIn(text, index + length);
86+ index = _quotedTextRegex.indexIn(text, index + length);
8787 }
8888 }
8989