| 121 | } |
| 122 | |
| 123 | void ZepSyntax_Python::UpdateSyntax() { |
| 124 | auto& buffer = m_buffer.GetWorkingBuffer(); |
| 125 | auto itrCurrent = buffer.begin(); |
| 126 | const auto itrEnd = buffer.end(); |
| 127 | |
| 128 | assert(std::distance(itrCurrent, itrEnd) <= int(m_syntax.size())); |
| 129 | assert(m_syntax.size() == buffer.size()); |
| 130 | |
| 131 | auto mark = [&](GapBuffer<uint8_t>::const_iterator itrA, |
| 132 | GapBuffer<uint8_t>::const_iterator itrB, |
| 133 | ThemeColor type, |
| 134 | ThemeColor background) { |
| 135 | std::fill(m_syntax.begin() + (itrA - buffer.begin()), |
| 136 | m_syntax.begin() + (itrB - buffer.begin()), |
| 137 | SyntaxData{type, background}); |
| 138 | }; |
| 139 | |
| 140 | auto mark_single = [&](GapBuffer<uint8_t>::const_iterator itr, |
| 141 | ThemeColor type, |
| 142 | ThemeColor background) { |
| 143 | (m_syntax.begin() + (itr - buffer.begin()))->foreground = type; |
| 144 | (m_syntax.begin() + (itr - buffer.begin()))->background = background; |
| 145 | }; |
| 146 | |
| 147 | auto scan_string = [&](auto start, auto quote_begin) { |
| 148 | auto itr = quote_begin; |
| 149 | const uint8_t quote = *quote_begin; |
| 150 | bool triple = false; |
| 151 | if ((itrEnd - quote_begin) >= 3 && *(quote_begin + 1) == quote && |
| 152 | *(quote_begin + 2) == quote) { |
| 153 | triple = true; |
| 154 | itr += 3; |
| 155 | } else { |
| 156 | ++itr; |
| 157 | } |
| 158 | |
| 159 | while (itr != itrEnd) { |
| 160 | if (!triple && *itr == '\\') { |
| 161 | if ((itrEnd - itr) > 1) { |
| 162 | itr += 2; |
| 163 | } else { |
| 164 | ++itr; |
| 165 | } |
| 166 | continue; |
| 167 | } |
| 168 | |
| 169 | if (*itr == quote) { |
| 170 | if (triple) { |
| 171 | if ((itrEnd - itr) >= 3 && *(itr + 1) == quote && *(itr + 2) == quote) { |
| 172 | itr += 3; |
| 173 | break; |
| 174 | } |
| 175 | } else { |
| 176 | ++itr; |
| 177 | break; |
| 178 | } |
| 179 | } |
| 180 |
nothing calls this directly
no test coverage detected