Changeset View
Changeset View
Standalone View
Standalone View
src/backends/octave/octavehighlighter.cpp
Show First 20 Lines • Show All 87 Lines • ▼ Show 20 Line(s) | |||||
88 | 88 | | |||
89 | void OctaveHighlighter::sessionStatusChanged(Cantor::Session::Status status) | 89 | void OctaveHighlighter::sessionStatusChanged(Cantor::Session::Status status) | ||
90 | { | 90 | { | ||
91 | if (status == Cantor::Session::Status::Disable) | 91 | if (status == Cantor::Session::Status::Disable) | ||
92 | for (const QString& variable: m_variables) | 92 | for (const QString& variable: m_variables) | ||
93 | removeRule(variable); | 93 | removeRule(variable); | ||
94 | rehighlight(); | 94 | rehighlight(); | ||
95 | } | 95 | } | ||
96 | | ||||
97 | DefaultHighlighter::Section OctaveHighlighter::findNextCodeSection(const QString& text, DefaultHighlighter::Section previous) | ||||
98 | { | ||||
99 | DefaultHighlighter::Section section; | ||||
100 | section.state = previous.state; | ||||
101 | | ||||
102 | if (previous.end >= text.size()) | ||||
103 | { | ||||
104 | section.begin = -1; | ||||
105 | section.end = -1; | ||||
106 | } | ||||
107 | else | ||||
108 | switch(previous.state) | ||||
109 | { | ||||
110 | case DefaultHighlighter::Section::State::Finished: | ||||
111 | { | ||||
112 | int begin = text.indexOf(QLatin1String("Example:"), std::max(previous.end, 0)); | ||||
113 | if (begin == -1) | ||||
114 | begin = text.indexOf(QLatin1String("for example:"), std::max(previous.end, 0)); | ||||
115 | if (begin == -1) | ||||
116 | begin = text.indexOf(QLatin1String(" See also:"), std::max(previous.end, 0)); | ||||
117 | | ||||
118 | if (begin != -1) | ||||
119 | { | ||||
120 | section.begin = begin; | ||||
121 | section.end = text.size(); | ||||
122 | section.state = DefaultHighlighter::Section::State::Continue; | ||||
123 | } | ||||
124 | else | ||||
125 | { | ||||
126 | section.begin = -1; | ||||
127 | section.end = -1; | ||||
128 | } | ||||
129 | } | ||||
130 | break; | ||||
131 | | ||||
132 | case DefaultHighlighter::Section::State::Continue: | ||||
133 | { | ||||
134 | section.begin = 0; | ||||
135 | section.end = text.size(); | ||||
136 | if (text.startsWith(QLatin1String(" See also:"))) | ||||
137 | section.state = DefaultHighlighter::Section::State::Finished; | ||||
138 | } | ||||
139 | break; | ||||
140 | } | ||||
141 | | ||||
142 | return section; | ||||
143 | } |