The Undo Mechanism |
||||
|
The text widget has an unlimited undo and redo mechanism (when the #:undo widget option is true) which records every insert and delete action on a stack. Boundaries (called "separators") are inserted between edit actions. The purpose of these separators is to group inserts and deletes into one compound edit action. When undoing a change everything between two separators will be undone. The undone changes are then moved to the redo stack, so that an undone edit can be redone again. The redo stack is cleared whenever new edit actions are recorded on the undo stack. The undo and redo stacks can be cleared to keep their depth under control. Separators are inserted automatically when the #:autoseparators widget option is #t. You can insert separators programatically as well. If a separator is already present at the top of the undo stack no other will be inserted. That means that two separators on the undo stack are always separated by at least one insert or delete action. The undo mechanism is also linked to the modified flag. This means that undoing or redoing changes can take a modified text widget back to the unmodified state or vice versa. The modified flag will be set automatically to the appropriate state. This automatic coupling does not work when the modified flag has been set by the user, until the flag has been reset again. See below for the edit widget command that controls the undo mechanism. |