Changeset View
Changeset View
Standalone View
Standalone View
src/backends/julia/juliahighlighter.cpp
Show All 14 Lines | |||||
15 | * Boston, MA 02110-1301, USA. | 15 | * Boston, MA 02110-1301, USA. | ||
16 | * | 16 | * | ||
17 | * --- | 17 | * --- | ||
18 | * Copyright (C) 2016 Ivan Lakhtanov <ivan.lakhtanov@gmail.com> | 18 | * Copyright (C) 2016 Ivan Lakhtanov <ivan.lakhtanov@gmail.com> | ||
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | #include "juliahighlighter.h" | 21 | #include "juliahighlighter.h" | ||
22 | #include "juliakeywords.h" | 22 | #include "juliakeywords.h" | ||
23 | #include "juliasession.h" | ||||
23 | 24 | | |||
24 | #include <climits> | 25 | #include <climits> | ||
25 | #include <QTextEdit> | 26 | #include <QTextEdit> | ||
26 | #include <QDebug> | 27 | #include <QDebug> | ||
27 | 28 | | |||
28 | JuliaHighlighter::JuliaHighlighter(QObject *parent) | 29 | JuliaHighlighter::JuliaHighlighter(QObject *parent, JuliaSession* session) | ||
29 | : Cantor::DefaultHighlighter(parent) | 30 | : Cantor::DefaultHighlighter(parent, session) | ||
30 | { | 31 | { | ||
31 | addKeywords(JuliaKeywords::instance()->keywords()); | 32 | addKeywords(JuliaKeywords::instance()->keywords()); | ||
32 | addVariables(JuliaKeywords::instance()->variables()); | 33 | addVariables(JuliaKeywords::instance()->variables()); | ||
33 | addFunctions(JuliaKeywords::instance()->functions()); | 34 | addFunctions(JuliaKeywords::instance()->functions()); | ||
34 | addFunctions(JuliaKeywords::instance()->plotShowingCommands()); | 35 | addFunctions(JuliaKeywords::instance()->plotShowingCommands()); | ||
35 | } | 36 | } | ||
36 | 37 | | |||
37 | void JuliaHighlighter::highlightBlock(const QString &text) | 38 | void JuliaHighlighter::highlightBlock(const QString &text) | ||
▲ Show 20 Lines • Show All 120 Lines • ▼ Show 20 Line(s) | 101 | while (pos < text.length()) { | |||
158 | } else { // There is nothing to highlight | 159 | } else { // There is nothing to highlight | ||
159 | break; | 160 | break; | ||
160 | } | 161 | } | ||
161 | } | 162 | } | ||
162 | 163 | | |||
163 | setCurrentBlockState(state); | 164 | setCurrentBlockState(state); | ||
164 | } | 165 | } | ||
165 | 166 | | |||
166 | void JuliaHighlighter::updateHighlight() | | |||
167 | { | | |||
168 | // Remove rules for outdated variables and functions | | |||
169 | for (const auto &var : JuliaKeywords::instance()->removedVariables()) { | | |||
170 | removeRule(var); | | |||
171 | } | | |||
172 | for (const auto &func : JuliaKeywords::instance()->removedFunctions()) { | | |||
173 | removeRule(func); | | |||
174 | } | | |||
175 | | ||||
176 | // Add actual variables and function | | |||
177 | addVariables(JuliaKeywords::instance()->variables()); | | |||
178 | addFunctions(JuliaKeywords::instance()->functions()); | | |||
179 | rehighlight(); | | |||
180 | } | | |||
181 | | ||||
182 | QString JuliaHighlighter::nonSeparatingCharacters() const | 167 | QString JuliaHighlighter::nonSeparatingCharacters() const | ||
183 | { | 168 | { | ||
184 | return QLatin1String("[\\w¡-ﻼ!]"); | 169 | return QLatin1String("[\\w¡-ﻼ!]"); | ||
185 | } | 170 | } |