History¶
Undo/redo history via JSON Patch (RFC 6902) diffs.
Stores minimal diffs between project states rather than full snapshots, making history memory-efficient even for large projects.
Usage:
project = load_project(path)
with project.track_changes("add intro clip"):
track.add_clip(...)
clip.add_drop_shadow()
project.undo() # reverts the block
project.redo() # re-applies it
project.history # list of change descriptions
- class camtasia.history.ChangeRecord(description, forward_patch, inverse_patch)[source]¶
Bases:
objectA single recorded change with forward and inverse patches.
- forward_patch: JsonPatch¶
- inverse_patch: JsonPatch¶
- class camtasia.history.ChangeHistory(max_history_depth=100)[source]¶
Bases:
objectManages an undo/redo stack of JSON Patch diffs.
Each entry stores the minimal diff needed to move between states, not a full copy of the project data.
- record(description, snapshot_before, snapshot_after)[source]¶
Record a change by diffing before/after snapshots.
- Return type:
- undo(project_data)[source]¶
Apply the most recent inverse patch. Returns the description.
- Return type:
- redo(project_data)[source]¶
Re-apply the most recently undone patch. Returns the description.
- Return type: