MCPcopy Create free account
hub / github.com/Predelnik/DSpellCheck / get_visible_text

Method get_visible_text

src/core/SpellChecker.cpp:213–247  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

211}
212
213MappedWstring 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
249void SpellChecker::clear_all_underlines() const {
250 auto length = m_editor.get_active_document_length();

Callers

nothing calls this directly

Calls 12

appendMethod · 0.80
get_lines_on_screenMethod · 0.45
editor_rectMethod · 0.45
is_line_visibleMethod · 0.45
get_line_end_positionMethod · 0.45

Tested by

no test coverage detected