| AHELP for CIAO 4.5 ChIPS v1 | redo |
Context: undo |
Synopsis
Re-executes the last undone command or series of commands.
Syntax
redo([count]) redo(tag)
Description
- count - the number of commands to redo (default is 1)
- tag - the name of a previously set tag
The redo command allows the user to re-execute one or more commands that have been undone via the undo command. If called without any arguments, the last command is redone. The redo functionality is extended by using tags and blocks, which are described below.
The undo command is used to undo the last command or series of commands; see "ahelp undo" for more information.
Using Tags
A tag may be set to mark a point in the command history. The tag can later be used to undo and redo all commands back to that point. The command to create a tag is set_undo_tag(tagname). To remove an existing tag, use clear_undo_tag(tagname).
Using Blocks
Multiple commands may be grouped together in blocks so that they are treated as a unit by the redo command. When an undo is issued on a block, all of the commands in the block are undone as a single step. A redo command can then reverse the block undo. The commands open_undo_block and close_undo_block are used to open and close the block. These commands are part of the advanced ChIPS module; refer to "ahelp chips" for information. To load the module:
from pychips.advanced import *
The Undo and Redo Stacks
ChIPS maintains two stacks - an undo stack and a redo stack. When commands are executed, they are added to the undo stack. When undo is called, ChIPS pops the commands off the undo stack and pushes them onto the redo stack. Redoing the commands pops them off the redo stack and back onto the undo stack.
Redo only works if commands have been undone and exist in the redo stack. After an undo command, if any command is issued that gets added to the undo stack, the redo stack gets cleared and those undone actions are no longer available.
Example 1
chips> set_frame(["bgcolor","red"]) chips> undo() chips> redo()
Make the frame background red, then undo and redo the command.
Example 2
chips> set_frame(["bgcolor","red"])
chips> set_frame(["bgcolor","orange"])
chips> set_frame(["bgcolor","yellow"])
chips> set_undo_tag("yellow")
chips> set_frame(["bgcolor","green"])
chips> set_undo_tag("green")
chips> set_frame(["bgcolor","blue"])
chips> undo("yellow")
chips> undo(2)
chips> redo("green")A tag is added to the undo stack after the frame background color is set to yellow. The color is then changed to green and another tag is added. After changing the background color to blue, undo is called with the yellow tag. Undo is then called with the value "2" to return to the red background, which is two commands prior to the yellow tag. Calling redo with the green tag moves the state back to the green background.
Example 3
chips> add_contour([1,2,5,3,3,6,0,0,1],3,3)
chips> open_undo_block()
chips> set_preference("region.fill.style", "1")
chips> add_region([1,1,2,2.32,2],[1.5,2,2,1,1],"fill.color=blue")
chips> add_region([3,2.67,3],[1,2,2.2],"fill.color=lime")
chips> add_label(1.7,1.7,r"\lambda")
chips> close_undo_block()
chips> undo()
chips> redo()Three commands - two add_region and one add_label - are marked as a block. The undo command undoes all three commands, then they are reinserted with redo.
Bugs
See the bugs pages on the ChIPS website for an up-to-date listing of known bugs.
See Also
- undo
- undo

![[ChIPS Logo]](../imgs/chips_logo_navbar.gif)