TODO: Multiline comments
| 143 | |
| 144 | // TODO: Multiline comments |
| 145 | void ZepSyntax::UpdateSyntax() |
| 146 | { |
| 147 | auto& buffer = m_buffer.GetWorkingBuffer(); |
| 148 | auto itrCurrent = buffer.begin() + m_processedChar; |
| 149 | auto itrEnd = buffer.begin() + m_targetChar; |
| 150 | |
| 151 | assert(std::distance(itrCurrent, itrEnd) < int(m_syntax.size())); |
| 152 | assert(m_syntax.size() == buffer.size()); |
| 153 | |
| 154 | std::string delim; |
| 155 | std::string lineEnd("\n"); |
| 156 | |
| 157 | if (m_flags & ZepSyntaxFlags::LispLike) |
| 158 | { |
| 159 | delim = std::string(" \t.\n(){}[]"); |
| 160 | } |
| 161 | else |
| 162 | { |
| 163 | delim = std::string(" \t.\n;(){}[]=:"); |
| 164 | } |
| 165 | |
| 166 | // Walk backwards to previous delimiter |
| 167 | while (itrCurrent > buffer.begin()) |
| 168 | { |
| 169 | if (std::find(delim.begin(), delim.end(), *itrCurrent) == delim.end()) |
| 170 | { |
| 171 | itrCurrent--; |
| 172 | } |
| 173 | else |
| 174 | { |
| 175 | break; |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | // Back to the previous line |
| 180 | while (itrCurrent > buffer.begin() && *itrCurrent != '\n') |
| 181 | { |
| 182 | itrCurrent--; |
| 183 | } |
| 184 | itrEnd = buffer.find_first_of(itrEnd, buffer.end(), lineEnd.begin(), lineEnd.end()); |
| 185 | |
| 186 | // Mark a region of the syntax buffer with the correct marker |
| 187 | auto mark = [&](GapBuffer<uint8_t>::const_iterator itrA, GapBuffer<uint8_t>::const_iterator itrB, ThemeColor type, ThemeColor background) { |
| 188 | std::fill(m_syntax.begin() + (itrA - buffer.begin()), m_syntax.begin() + (itrB - buffer.begin()), SyntaxData{ type, background }); |
| 189 | }; |
| 190 | |
| 191 | auto markSingle = [&](GapBuffer<uint8_t>::const_iterator itrA, ThemeColor type, ThemeColor background) { |
| 192 | (m_syntax.begin() + (itrA - buffer.begin()))->foreground = type; |
| 193 | (m_syntax.begin() + (itrA - buffer.begin()))->background = background; |
| 194 | }; |
| 195 | |
| 196 | // Update start location |
| 197 | m_processedChar = long(itrCurrent - buffer.begin()); |
| 198 | |
| 199 | // Walk the buffer updating information about syntax coloring |
| 200 | while (itrCurrent != itrEnd) |
| 201 | { |
| 202 | if (m_stop == true) |
nothing calls this directly
no test coverage detected