Command
CommandHandler
InteractiveReplaceCommand
InteractiveReplaceCommand::PlainTextRep
InteractiveReplaceCommand::SavedTextRep
MultiLevelUndoCommandHandler
SingleUndoCommandHandler
SnoopingCommandHandler
Module for supporting UNDO. Command
objects encapsulate a sequence of operations the user has
done, and the information needed to undo/redo them. These objects are organized, and kept track of by
a CommandHandler
object. Two sorts of CommandHandler
s are provided, SingleUndoCommandHandler
, and
MultiLevelUndoCommandHandler
- depending on whether you want to support multilevel undo or not.
Command [public]
CommandHandler
via CommandHandler::Post
().
Member Details |
---|
Construct a Command object. The constructor takes an optional bool arg |
Perform the actual commands action. |
The done, and redone states are considered identical. This returns true if the command has either been done, or redone (not most recently undone). |
Returns the name associated with a command. This is used for UI purposes in constructing the text of the Undo command name. |
Redo a command which has been done (or perhaps redone), and more recently undone. |
Undo an already done command. |
CommandHandler [public]
This is the guy you post new Command
s to, and ask for the text of the
undo message, etc. You call undo/redo on him to get actual undo/redo etc to
happen. It is responsable for committing commands, and disposing of them.
Typically, you would have one of this in your TextInteractor to handle undo.
Member Details |
---|
Some commands are plausibly chunked together. These are mostly tying, insert-character commands.
But, in principle, we could bundle together other commands as well. Call this method to signify that previous
commands should not be chunked together with commads about to be posted ( |
Are there commands which have been undone, which can now be redone? |
Are there commands posted which can be undone? |
Commit all currently done actions. This means no further undo will be possible (deletes the currently done/redone objects). This can be called when low on memory, to retrive some. Or when some logical user-action happens which would prevent further undos (save?). |
Redo the last undone action. See |
Perform a single undo action. This will undo all the command objects in the current group of commands
(or all, depending on the subtype of this CommandHandler; see |
Retreives the text associated with each command to denote in a UI what command is being undone, or redone. |
Notify the CommandHandler of a newly created (and done) |
InteractiveReplaceCommand [public]
Command
This subsumes basic typing and cut/paste type commands. Grab the text range BEFORE the command, and externize it. Do the command, and then grab the range of text AFTER the command and externalize that. The before/after text/ranges allow us to undo and redo. Note we 'externalize' before/after text so we get font info, and any embeddings...
Member Details |
---|
This constructor takes a |
InteractiveReplaceCommand::PlainTextRep [public]
InteractiveReplaceCommand::SavedTextRep
Keep track of only the text, and no font, or misc embedding info.
InteractiveReplaceCommand::SavedTextRep [public]
Abstraction for what to keep track of in a typical text editing command.
Note: This fSelStart/fSelEnd refers to the users selection in the text. It has NOTHING todo with the region of text which is saved.
Member Details |
---|
|
|
MultiLevelUndoCommandHandler [public]
CommandHandler
CommandHandler which allows for undo the last command several commands. The number of undo levels is specified in a constructor argument.
Member Details |
---|
Gets the maximum number of undo levels the |
|
SingleUndoCommandHandler [public]
CommandHandler
CommandHandler which only allows for undo the last command.
SnoopingCommandHandler [public]
CommandHandler
Useful for things like recording keyboard macros. Simply install this as your command handler, and hand it as argument the OLD one. Later, when you are done recording, re-install the old and extract the accumulated commands from this one.
Basicily all this does is delegate to the given REAL command handler, and call the Snoop () method YOU provide in your subclass. There - you can extract what information you like from the argument Command object.