Record of a single text mutation for undo/redo. More...
#include "donner/editor/TextEditorCore.h"
Public Member Functions | |
| UndoRecord (std::string_view added, const Coordinates &addedStart, const Coordinates &addedEnd, std::string_view removed, const Coordinates &removedStart, const Coordinates &removedEnd, const EditorState &before, const EditorState &after) | |
| Records inserted and removed text with their ranges and surrounding editor states. | |
| void | undo (TextEditorCore *core) |
| Reverse this edit in the owning text editor. | |
| void | redo (TextEditorCore *core) |
| Reapply this edit in the owning text editor. | |
Public Attributes | |
| RcString | added |
| Text inserted by the original edit. | |
| Coordinates | addedStart |
| Start of the inserted range. | |
| Coordinates | addedEnd |
| End of the inserted range. | |
| RcString | removed |
| Text displaced by the original edit. | |
| Coordinates | removedStart |
| Start of the removed range. | |
| Coordinates | removedEnd |
| End of the removed range. | |
| EditorState | before |
| Editor state before the edit. | |
| EditorState | after |
| Editor state after the edit. | |
Record of a single text mutation for undo/redo.
Stores the text added, the text removed, and the editor state before and after the mutation. undo reverses the mutation by removing the added text and re-inserting the removed text; redo replays it.
| donner::editor::UndoRecord::UndoRecord | ( | std::string_view | added, |
| const Coordinates & | addedStart, | ||
| const Coordinates & | addedEnd, | ||
| std::string_view | removed, | ||
| const Coordinates & | removedStart, | ||
| const Coordinates & | removedEnd, | ||
| const EditorState & | before, | ||
| const EditorState & | after ) |
Records inserted and removed text with their ranges and surrounding editor states.
| added | Inserted text. |
| addedStart | Start of the inserted range. |
| addedEnd | End of the inserted range. |
| removed | Removed text. |
| removedStart | Start of the removed range. |
| removedEnd | End of the removed range. |
| before | State before the edit. |
| after | State after the edit. |
| void donner::editor::UndoRecord::redo | ( | TextEditorCore * | core | ) |
Reapply this edit in the owning text editor.
| core | Editor whose buffer and selection are updated. |
| void donner::editor::UndoRecord::undo | ( | TextEditorCore * | core | ) |
Reverse this edit in the owning text editor.
| core | Editor whose buffer and selection are restored. |