![]() |
The Scheme interface to the history | ![]() |
The functions below are defined in
build-glue-editor.scm
(they act on the archiver of the current editor) and
build-glue-basic.scm
.
Undo the last step of the current editor's author (see the archiver for the steps of other authors), or redo future number i. The argument of undo must be 0. They first drop the pending cursor modifications, and do nothing while other modifications of the current action are pending, and the C++ undo also resets the graphics editor and refuses to undo inside a graphics while graphics-undo-enabled is false.
The number of possible undos (0 or 1) and of futures. The Edit menu uses them.
Cancel the pending modifications of the current action, then undo the last step and forget it, without creating a future.
Delimit a user action. The event handlers already call them; Scheme code only needs them when it changes documents outside an event, for instance in a delayed block or a callback of a network request, where (commit-changes), the same as end-editing, closes the step.
Confirm the pending modifications as a step now; or reopen the last step of the current author, so that the next modifications become part of it (the graphics editor uses this to merge the start of an operation with its end,
graphics-group.scm:339
).
Markers: a new marker number, and the operations described in the archiver. Every mark-start must be followed by exactly one mark-end or mark-cancel with the same marker, in the same editor.
Record the cursor and the selection in the pending step, so that undoing it restores them.
Authors: a fresh author; the author to which the next modifications are attributed; and the birth of a slave author in the current step.
True while an undo, a redo or a cancellation is being applied. Observers which react to modifications can use it to avoid modifying the document in turn.
Empty the history. Note: this acts on the archivers of all open buffers, see the pitfalls.
Print the history of the current editor on the standard output.
(define my-mark #f)
(define (my-start)
(set! my-mark (mark-new))
(mark-start my-mark)
(archive-state))
(define (my-done ok?)
(if ok? (mark-end my-mark) (mark-cancel my-mark))
(set! my-mark #f)) |
Within one event, the macro try-modification does the same: its changes are kept as one step when the body returns a true value and are cancelled otherwise.
(try-modification
(insert "x")
(my-check-something)) |
format-geometry-edit.scm
, undo the previous preview with (undo 0) before applying the next one. This only works if each preview is a step of its own and nothing else was changed in between.
plugin-eval.scm
does.
check/editing-test.scm
. In a test which runs without events, wrap each simulated action in (start-editing) and (end-editing): otherwise all the modifications end up in one step, or remain pending and are ignored by undo.