1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 18:57:45 +00:00

LibGUI: Use UndoStack::on_state_change inside TextDocument/TextEditor

Have TextDocument listen for state changes on the internal undo stack,
and forward those to all clients via a new virtual function.

This simplifies updating the can_undo / can_redo states of TextEditor.
This commit is contained in:
Andreas Kling 2021-05-08 13:16:37 +02:00
parent 0cb6103928
commit ee19f7c0aa
5 changed files with 17 additions and 2 deletions

View file

@ -1324,8 +1324,6 @@ void TextEditor::did_change()
{
update_content_size();
recompute_all_visual_lines();
m_undo_action->set_enabled(can_undo());
m_redo_action->set_enabled(can_redo());
if (m_autocomplete_box && !m_should_keep_autocomplete_box) {
m_autocomplete_box->close();
if (m_autocomplete_timer)
@ -1636,6 +1634,12 @@ void TextEditor::document_did_change()
update();
}
void TextEditor::document_did_update_undo_stack()
{
m_undo_action->set_enabled(can_undo());
m_redo_action->set_enabled(can_redo());
}
void TextEditor::document_did_set_text()
{
m_line_visual_data.clear();