A class in Root.Township, the global namespace.
Undo and redo history in a fixed size ring buffer. The oldest action is released and dropped when it fills up.
Constructors
| Member | What it is |
|---|
HistoryManager(int maxCount) | Creates a HistoryManager from maxCount. |
Fields
5 private and internal fields
| Member | What it is |
|---|
private T[] actions | The ring buffer of actions. |
private int firstIndex | Slot of the oldest action. |
private bool isModifying | True while an undo or redo is running. |
private int lastIndex | Slot after the newest action, the redo limit. |
private int nextIndex | Cursor: slot where the next action goes. |
Properties
| Member | What it is |
|---|
bool IsPushPossible { get; } | False while an undo or redo is running, so actions made by it aren't recorded. |
bool IsRedoPossible { get; } | True if there is an undone action to redo. |
bool IsUndoPossible { get; } | True if there is an action to undo. |
Events
| Member | What it is |
|---|
event Action ItemPushed | Raised after an action is added. |
Methods
| Member | What it is |
|---|
void Clear() | Releases every stored action and empties the history. |
void Push(T item) | Adds an action at the cursor, dropping any redo history; ignored during undo or redo. |
void Redo() | Redoes the action at the cursor and moves forward. |
void Undo() | Moves back and undoes that action. |
2 private and internal methods
| Member | What it is |
|---|
private void Back() | Moves the cursor back one slot, wrapping around. |
private void Forward() | Moves the cursor forward one slot, wrapping around. |