Donner SVG main
0.8.0 ยท 382bd0190.8.0 main
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
donner::editor::UndoRecord Class Reference

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.

Detailed Description

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.

Constructor & Destructor Documentation

◆ UndoRecord()

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.

Parameters
addedInserted text.
addedStartStart of the inserted range.
addedEndEnd of the inserted range.
removedRemoved text.
removedStartStart of the removed range.
removedEndEnd of the removed range.
beforeState before the edit.
afterState after the edit.

Member Function Documentation

◆ redo()

void donner::editor::UndoRecord::redo ( TextEditorCore * core)

Reapply this edit in the owning text editor.

Parameters
coreEditor whose buffer and selection are updated.

◆ undo()

void donner::editor::UndoRecord::undo ( TextEditorCore * core)

Reverse this edit in the owning text editor.

Parameters
coreEditor whose buffer and selection are restored.

The documentation for this class was generated from the following file: