Undo/redo history management for text editing with efficient diff-based storage.
More...
#include <gin_texthistory.h>
Undo/redo history management for text editing with efficient diff-based storage.
TextHistory provides unlimited undo/redo functionality for text documents using a diff-based approach (binary patches) for memory-efficient storage. Instead of storing complete text snapshots, only the differences between states are stored.
Key Features:
- Unlimited undo/redo with configurable history limit
- Efficient diff-based storage (binary patches)
- Change notification via callback
- Minimal memory footprint
- Linear history (no branching)
The implementation uses binary diff patches (forward and backward) to efficiently store changes, making it suitable for large documents or long editing sessions.
Usage:
DBG("History state changed");
};
{
}
{
}
Undo/redo history management for text editing with efficient diff-based storage.
Definition gin_texthistory.h:65
std::function< void()> onStateChanged
Definition gin_texthistory.h:77
bool addText(const juce::String &)
const juce::String & getCurrentText()
void setHistoryLimit(int numItems)
Implementation Details:
- Uses binary diff algorithm for patch generation
- Maintains stack of forward/backward patches
- Stack pointer tracks current position in history
- Adding new text while mid-history discards forward history
- See also
- juce::UndoManager for alternative undo/redo approach
◆ setHistoryLimit()
| void TextHistory::setHistoryLimit |
( |
int | numItems | ) |
|
◆ undo()
| void TextHistory::undo |
( |
| ) |
|
◆ redo()
| void TextHistory::redo |
( |
| ) |
|
◆ canUndo()
| bool TextHistory::canUndo |
( |
| ) |
|
◆ canRedo()
| bool TextHistory::canRedo |
( |
| ) |
|
◆ addText()
| bool TextHistory::addText |
( |
const juce::String & | | ) |
|
◆ getCurrentText()
| const juce::String & TextHistory::getCurrentText |
( |
| ) |
|
◆ onStateChanged
| std::function<void ()> TextHistory::onStateChanged |
The documentation for this class was generated from the following file: