MCPcopy Create free account
hub / github.com/Rezonality/zep / BuildSyntax

Method BuildSyntax

extensions/orca/orca.cpp:169–227  ·  view source on GitHub ↗

Generate the syntax information for the whole buffer

Source from the content-addressed store, hash-verified

167
168// Generate the syntax information for the whole buffer
169void Orca::BuildSyntax()
170{
171 MUtilsZoneScoped;
172
173 m_syntax.resize((m_field.width + 1) * m_field.height);
174
175 for (long y = 0; y < m_field.height; y++)
176 {
177 bool inComment = false;
178 for (long x = 0; x < m_field.width; x++)
179 {
180 auto cursorGrid = m_lastCursorPos / NVec2i(GridModulo, GridModulo);
181 auto valGrid = NVec2i(x, y) / NVec2i(GridModulo, GridModulo);
182
183 // For highlighting the cursor area
184 bool near = false;
185 if (x > (((m_lastCursorPos.x / GridModulo) * GridModulo) - 1) && x <= ((1 + (m_lastCursorPos.x / GridModulo)) * GridModulo) && y > (((m_lastCursorPos.y / GridModulo) * GridModulo) - 1) && y <= ((1 + (m_lastCursorPos.y / GridModulo)) * GridModulo))
186 {
187 // This cell is near the cursor and needs the highlight
188 if (x % 2 == 0 && y % 2 == 0)
189 near = true;
190 }
191
192 // Copy the mark into the bottom of the state
193 auto index = FieldIndex(x, y);
194 auto mark = (uint32_t)m_mbuf_r.buffer[index];
195
196 auto glyph = m_field.buffer[index];
197 auto glyphOld = m_lastField[index];
198
199 // TODO: Do I still want/need this?
200 if (glyph != glyphOld)
201 {
202 mark |= OrcaFlags::Changed;
203 }
204
205 if (y % GridModulo == 0 && x % GridModulo == 0 && glyph == '.')
206 {
207 glyph = Glyph_class_grid_marker;
208 }
209 else if (near && glyph == '.')
210 {
211 glyph = Glyph_class_grid_marker;
212 }
213 else if (glyph == '#')
214 {
215 glyph = Glyph_class_comment;
216 inComment = !inComment;
217 }
218
219 if (inComment)
220 {
221 glyph = Glyph_class_comment;
222 }
223
224 BuildSyntax(x, y, mark, glyph);
225 }
226 }

Callers

nothing calls this directly

Calls 2

glyph_class_ofFunction · 0.85
resizeMethod · 0.80

Tested by

no test coverage detected