Global undo/redo history for the application.
More...
#include <edit_history.hpp>
|
| | EditHistory (size_t max_depth=100) |
| void | perform (std::unique_ptr< EditAction > action) |
| | Execute an action and add it to the history.
|
| void | set_coalesce (bool enabled) |
| | Enable/disable description-based coalescing (merge rapid changes with same description).
|
| void | set_coalesce_window (std::chrono::milliseconds window) |
| | Time-window coalescing.
|
| std::chrono::milliseconds | coalesce_window () const |
| void | perform (std::function< void()> do_fn, std::function< void()> undo_fn, const std::string &desc="") |
| | Convenience: perform a lambda-based action.
|
| bool | undo () |
| | Undo the most recent action.
|
| bool | redo () |
| | Redo the most recently undone action.
|
| bool | can_undo () const |
| bool | can_redo () const |
| size_t | undo_count () const |
| size_t | redo_count () const |
| void | clear () |
| | Clear all history.
|
| std::string | undo_description () const |
| | Get the description of the next undo action.
|
| void | set_max_depth (size_t depth) |
| size_t | max_depth () const |
Global undo/redo history for the application.
Supports coalescing (rapid small changes merge into one undo step) and configurable depth limits.
◆ EditHistory()
| pulp::state::EditHistory::EditHistory |
( |
size_t | max_depth = 100 | ) |
|
|
inlineexplicit |
◆ can_redo()
| bool pulp::state::EditHistory::can_redo |
( |
| ) |
const |
|
inline |
◆ can_undo()
| bool pulp::state::EditHistory::can_undo |
( |
| ) |
const |
|
inline |
◆ clear()
| void pulp::state::EditHistory::clear |
( |
| ) |
|
|
inline |
◆ coalesce_window()
| std::chrono::milliseconds pulp::state::EditHistory::coalesce_window |
( |
| ) |
const |
|
inline |
◆ max_depth()
| size_t pulp::state::EditHistory::max_depth |
( |
| ) |
const |
|
inline |
◆ perform() [1/2]
| void pulp::state::EditHistory::perform |
( |
std::function< void()> | do_fn, |
|
|
std::function< void()> | undo_fn, |
|
|
const std::string & | desc = "" ) |
|
inline |
Convenience: perform a lambda-based action.
◆ perform() [2/2]
| void pulp::state::EditHistory::perform |
( |
std::unique_ptr< EditAction > | action | ) |
|
|
inline |
Execute an action and add it to the history.
If coalescing is enabled and the last action has the same description, replaces it (merging rapid small changes into one undo step). If set_coalesce_window is set to a non-zero duration, two consecutive actions also coalesce when they arrive within that window even if their descriptions differ.
◆ redo()
| bool pulp::state::EditHistory::redo |
( |
| ) |
|
|
inline |
Redo the most recently undone action.
◆ redo_count()
| size_t pulp::state::EditHistory::redo_count |
( |
| ) |
const |
|
inline |
◆ set_coalesce()
| void pulp::state::EditHistory::set_coalesce |
( |
bool | enabled | ) |
|
|
inline |
Enable/disable description-based coalescing (merge rapid changes with same description).
Defaults to true.
◆ set_coalesce_window()
| void pulp::state::EditHistory::set_coalesce_window |
( |
std::chrono::milliseconds | window | ) |
|
|
inline |
Time-window coalescing.
When window > 0, two consecutive perform() calls that arrive within this duration are merged into one undo step even if their descriptions differ. Use 0 to disable (description-only coalescing). 0 by default to preserve existing behavior.
◆ set_max_depth()
| void pulp::state::EditHistory::set_max_depth |
( |
size_t | depth | ) |
|
|
inline |
◆ undo()
| bool pulp::state::EditHistory::undo |
( |
| ) |
|
|
inline |
Undo the most recent action.
◆ undo_count()
| size_t pulp::state::EditHistory::undo_count |
( |
| ) |
const |
|
inline |
◆ undo_description()
| std::string pulp::state::EditHistory::undo_description |
( |
| ) |
const |
|
inline |
Get the description of the next undo action.
The documentation for this class was generated from the following file: