/* * Copyright 2006-2012, Stephan Aßmus * Copyright 2021, Andrew Lindesay * Distributed under the terms of the MIT License. */ #ifndef EDIT_MANAGER_H #define EDIT_MANAGER_H #include #include #include "UndoableEdit.h" class BString; class EditContext; class EditManager { public: class Listener { public: virtual ~Listener(); virtual void EditManagerChanged( const EditManager* manager) = 0; }; public: EditManager(); virtual ~EditManager(); status_t Perform(UndoableEdit* edit, EditContext& context); status_t Perform(const UndoableEditRef& edit, EditContext& context); status_t Undo(EditContext& context); status_t Redo(EditContext& context); bool GetUndoName(BString& name); bool GetRedoName(BString& name); void Clear(); void Save(); bool IsSaved(); void AddListener(Listener* listener); void RemoveListener(Listener* listener); private: status_t _AddEdit(const UndoableEditRef& edit); void _NotifyListeners(); private: std::stack fUndoHistory; std::stack fRedoHistory; UndoableEditRef fEditAtSave; std::vector fListeners; }; #endif // EDIT_MANAGER_H