| 211 | } |
| 212 | |
| 213 | MappedWstring SpellChecker::get_visible_text() { |
| 214 | auto top_visible_line = m_editor.get_first_visible_line(); |
| 215 | auto top_visible_line_index = m_editor.get_document_line_from_visible(top_visible_line); |
| 216 | auto bottom_visible_line_index = m_editor.get_document_line_from_visible(top_visible_line + m_editor.get_lines_on_screen() - 1); |
| 217 | auto rect = m_editor.editor_rect(); |
| 218 | auto len = m_editor.get_active_document_length(); |
| 219 | MappedWstring result; |
| 220 | for (auto line = top_visible_line_index; line <= bottom_visible_line_index; ++line) { |
| 221 | if (!m_editor.is_line_visible(line)) |
| 222 | continue; |
| 223 | auto start = m_editor.get_line_start_position(line); |
| 224 | if (start >= len) // skipping possible empty lines when document is too short |
| 225 | continue; |
| 226 | auto start_point = m_editor.get_point_from_position(start); |
| 227 | if (start_point.y < rect.top) { |
| 228 | start = m_editor.char_position_from_point({0, 0}); |
| 229 | start = prev_token_begin_in_document(start); |
| 230 | } else if (start_point.x < rect.left) { |
| 231 | start = m_editor.char_position_from_point({0, start_point.y}); |
| 232 | start = prev_token_begin_in_document(start); |
| 233 | } |
| 234 | auto end = m_editor.get_line_end_position(line); |
| 235 | auto end_point = m_editor.get_point_from_position(end); |
| 236 | if (end_point.y > rect.bottom - rect.top) { |
| 237 | end = m_editor.char_position_from_point({rect.right - rect.left, rect.bottom - rect.top}); |
| 238 | end = next_token_end_in_document(end); |
| 239 | } else if (end_point.x > rect.right) { |
| 240 | end = m_editor.char_position_from_point({rect.right - rect.left, end_point.y}); |
| 241 | end = next_token_end_in_document(end); |
| 242 | } |
| 243 | auto new_str = m_editor.get_mapped_wstring_range(start, end); |
| 244 | result.append(new_str); |
| 245 | } |
| 246 | return result; |
| 247 | } |
| 248 | |
| 249 | void SpellChecker::clear_all_underlines() const { |
| 250 | auto length = m_editor.get_active_document_length(); |
nothing calls this directly
no test coverage detected