Showing the changes to interface/src/ScriptHighlighting.cpp (1 of 2 files). Show all
Unified · Split
| @@ -16,7 +16,7 @@ ScriptHighlighting::ScriptHighlighting(QTextDocument* parent) : · 15 unmodified lines | |||
| 16 | QSyntaxHighlighter(parent) | 16 | QSyntaxHighlighter(parent) |
| 17 | { | 17 | { |
| 18 | _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"); | 18 | _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})"); |
| 20 | _multiLineCommentBegin = QRegExp("/\\*"); | 20 | _multiLineCommentBegin = QRegExp("/\\*"); |
| 21 | _multiLineCommentEnd = QRegExp("\\*/"); | 21 | _multiLineCommentEnd = QRegExp("\\*/"); |
| 22 | _numberRegex = QRegExp("[0-9]+(\\.[0-9]+){0,1}"); | 22 | _numberRegex = QRegExp("[0-9]+(\\.[0-9]+){0,1}"); |
| @@ -29,7 +29,7 @@ void ScriptHighlighting::highlightBlock(const QString& text) { · 6 unmodified lines | |||
| 29 | this->highlightKeywords(text); | 29 | this->highlightKeywords(text); |
| 30 | this->formatNumbers(text); | 30 | this->formatNumbers(text); |
| 31 | this->formatTrueFalse(text); | 31 | this->formatTrueFalse(text); |
| 32 | this->formatQoutedText(text); | 32 | this->formatQuotedText(text); |
| 33 | this->formatComments(text); | 33 | this->formatComments(text); |
| 34 | } | 34 | } |
| 35 | 35 | ||
| @@ -61,14 +61,14 @@ void ScriptHighlighting::formatComments(const QString& text) { · 25 unmodified lines | |||
| 61 | int index = _singleLineComment.indexIn(text); | 61 | int index = _singleLineComment.indexIn(text); |
| 62 | while (index >= 0) { | 62 | while (index >= 0) { |
| 63 | int length = _singleLineComment.matchedLength(); | 63 | int length = _singleLineComment.matchedLength(); |
| 64 | int quoted_index = _qoutedTextRegex.indexIn(text); | 64 | int quoted_index = _quotedTextRegex.indexIn(text); |
| 65 | bool valid = true; | 65 | bool valid = true; |
| 66 | while (quoted_index >= 0 && valid) { | 66 | while (quoted_index >= 0 && valid) { |
| 67 | int quoted_length = _qoutedTextRegex.matchedLength(); | 67 | int quoted_length = _quotedTextRegex.matchedLength(); |
| 68 | if (quoted_index <= index && index <= (quoted_index + quoted_length)) { | 68 | if (quoted_index <= index && index <= (quoted_index + quoted_length)) { |
| 69 | valid = false; | 69 | valid = false; |
| 70 | } | 70 | } |
| 71 | quoted_index = _qoutedTextRegex.indexIn(text, quoted_index + quoted_length); | 71 | quoted_index = _quotedTextRegex.indexIn(text, quoted_index + quoted_length); |
| 72 | } | 72 | } |
| 73 | 73 | ||
| 74 | if (valid) { | 74 | if (valid) { |
| @@ -78,12 +78,12 @@ void ScriptHighlighting::formatComments(const QString& text) { · 3 unmodified lines | |||
| 78 | } | 78 | } |
| 79 | } | 79 | } |
| 80 | 80 | ||
| 81 | void ScriptHighlighting::formatQoutedText(const QString& text){ | 81 | void ScriptHighlighting::formatQuotedText(const QString& text){ |
| 82 | int index = _qoutedTextRegex.indexIn(text); | 82 | int index = _quotedTextRegex.indexIn(text); |
| 83 | while (index >= 0) { | 83 | while (index >= 0) { |
| 84 | int length = _qoutedTextRegex.matchedLength(); | 84 | int length = _quotedTextRegex.matchedLength(); |
| 85 | setFormat(index, length, Qt::red); | 85 | setFormat(index, length, Qt::red); |
| 86 | index = _qoutedTextRegex.indexIn(text, index + length); | 86 | index = _quotedTextRegex.indexIn(text, index + length); |
| 87 | } | 87 | } |
| 88 | } | 88 | } |
| 89 | 89 | ||