diff --git a/Userland/Libraries/LibGUI/UndoStack.cpp b/Userland/Libraries/LibGUI/UndoStack.cpp index 759b97b5f4..ea7aa2a125 100644 --- a/Userland/Libraries/LibGUI/UndoStack.cpp +++ b/Userland/Libraries/LibGUI/UndoStack.cpp @@ -109,4 +109,18 @@ void UndoStack::clear() on_state_change(); } +Optional UndoStack::undo_action_text() const +{ + if (!can_undo()) + return {}; + return m_stack[m_stack_index - 1].action_text(); +} + +Optional UndoStack::redo_action_text() const +{ + if (!can_redo()) + return {}; + return m_stack[m_stack_index].action_text(); +} + } diff --git a/Userland/Libraries/LibGUI/UndoStack.h b/Userland/Libraries/LibGUI/UndoStack.h index 2957ca0b97..44dd9ca0bf 100644 --- a/Userland/Libraries/LibGUI/UndoStack.h +++ b/Userland/Libraries/LibGUI/UndoStack.h @@ -30,6 +30,9 @@ public: void clear(); + Optional undo_action_text() const; + Optional redo_action_text() const; + Function on_state_change; private: