mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 17:10:23 +00:00
LibGUI: Extract repeated code for populating TextEditor per-line data
This commit is contained in:
parent
ba43ee4046
commit
03571b1fa9
Notes:
sideshowbarker
2024-07-16 23:23:26 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/03571b1fa9 Pull-request: https://github.com/SerenityOS/serenity/pull/17864
2 changed files with 13 additions and 7 deletions
|
@ -2203,11 +2203,19 @@ void TextEditor::document_did_update_undo_stack()
|
|||
on_modified_change(document().is_modified());
|
||||
}
|
||||
|
||||
void TextEditor::document_did_set_text(AllowCallback allow_callback)
|
||||
void TextEditor::populate_line_data()
|
||||
{
|
||||
m_line_visual_data.clear();
|
||||
for (size_t i = 0; i < m_document->line_count(); ++i)
|
||||
m_line_visual_data.append(make<LineVisualData>());
|
||||
m_line_visual_data.ensure_capacity(m_document->line_count());
|
||||
|
||||
for (size_t i = 0; i < m_document->line_count(); ++i) {
|
||||
m_line_visual_data.unchecked_append(make<LineVisualData>());
|
||||
}
|
||||
}
|
||||
|
||||
void TextEditor::document_did_set_text(AllowCallback allow_callback)
|
||||
{
|
||||
populate_line_data();
|
||||
document_did_change(allow_callback);
|
||||
}
|
||||
|
||||
|
@ -2233,10 +2241,7 @@ void TextEditor::set_document(TextDocument& document)
|
|||
if (m_document)
|
||||
m_document->unregister_client(*this);
|
||||
m_document = document;
|
||||
m_line_visual_data.clear();
|
||||
for (size_t i = 0; i < m_document->line_count(); ++i) {
|
||||
m_line_visual_data.append(make<LineVisualData>());
|
||||
}
|
||||
populate_line_data();
|
||||
set_cursor(0, 0);
|
||||
if (has_selection())
|
||||
m_selection.clear();
|
||||
|
|
|
@ -363,6 +363,7 @@ private:
|
|||
|
||||
size_t visual_line_containing(size_t line_index, size_t column) const;
|
||||
void recompute_visual_lines(size_t line_index, Vector<TextDocumentFoldingRegion const&>::Iterator& folded_region_iterator);
|
||||
void populate_line_data();
|
||||
|
||||
template<class T, class... Args>
|
||||
inline void execute(Args&&... args)
|
||||
|
|
Loading…
Reference in a new issue