be viewed as a combination of data members and. member 55 is provided for the undo button 51 when activated (see
functions. The data members are attributes that are stored in FIG. 3b). A similar context menu 57 (FIG. 3c) is provided
data structures, and the member functions are functions that for the redo button. The context menus 55 (FIG. 3b) and 57
act upon these attributes. The notion of an object is exploited (FIG. 3c) provide two options: "Last Applied" and "All The
in the multiple-level undo/redo mechanism of the preferred 5 Way." These options cause either only a single last applied
embodiment of the present invention in that certain aspects command to be undone/redone or the commands to be
of this mechanism are implemented as objects. undone/redone.
An interface is a group of semantically-related functions The four operations provided by the multiple-level undo/
that are organized into a named unit. Each interface may be redo mechanism of the preferred embodiment of the present
uniquely identified by its identifier. Interfaces have no 10 invention are perhaps best explained by way of example. As
instantiation, that is an interface definition does not include such, examples will be provided below along with the steps
code for implementing the functions that are specified in the performed by the preferred embodiment for each of the
interface. Interfaces specify a set of signatures for functions. respective four operation types.
An object may "support" an interface. When an object piG. 4a is a flowchart illustrating the steps performed by
supports an interface, the object provides code for the 15 the preferred embodiment of the present invention when a
function specified by the interface. The code supplied by the user enters a new command. FIG. 4a will be described in
object, however, must comply with the signatures specified conjunction with the diagram of FIG. 4b. FIG. 4b depicts an
by the interface. example of the list 30 of command element objects. Initially,
The multiple-level undo/redo mechanism of the preferred a user enters a command (step 52 in FIG. 4a). In the example
embodiment of the present invention supports the ability for 20 of FIG. 4b, the list 30 is initially empty. Suppose that the
an application program to maintain a command log of user user then enters command "a". The multiple level undo/redo
commands. The data held in the command log and functions mechanism of the preferred embodiment then checks
for maintaining the data are encapsulated into a command whether there are any commands on the list before the cursor
log object. The command log object includes a list 30 (see 32 (step 54 in FIG. 4a). If there are no commands on the list
FIG. 4b) of command element objects and a cursor 32. The 25 before the cursor 32, such as in the case shown in FIG. 4b,
list 30 of command element objects is a sequential list of the command is added to the front of the list 30 (step 58 in
command element objects specifying user commands. The FIG. 4a), and the cursor is moved to point to the front of the
cursor 32 specifies a current position that corresponds with list (step 60). Thus, as shown in FIG. 4b, after command "a"
the last applied (i.e., last executed) command on the list 30 is entered, an entry 64 (i.e., an entry for a command element
of command element objects. 30 object for command "a") is added to the front of the list 30
Each command entered by a user during the course of and the cursor 32 is moved to point to entry 64. Suppose that
execution of an application program 24 generates an assc- the user now enters another command "b", (hence, repeating
dated command element object 40, like that shown in FIG. steP 52 of HG. 4a). Steps 54,58 and 60 of FIG. 4a are then
2. The command element object 40 includes a field 44 that „ repeated so that an entry 66 (FIG. 4b) is added to the front
specifies the nature of the command and a V-pointer 42. The of the list 30 before the entry 64 for command "a". Cursor
V-pointer 42 points to a V-table 46 (i.e., having a virtual 32 is updated to point to entry 66 for command "b".
table such as found in the C++ programming language) In the above-described fashion, the list 30 of command
having entries for the operations that may be performed on element objects is built. In terms of the object model
the command element object 40. These operations include 4Q described above, each time a user enters a command, an
an undo operation, a redo operation and a merge operation, instance of a command element object 40 (FIG. 2) is created;
for which respective entries 48a, 4Sb and 48c are provided. the new command element object is appended to the front of
Entries 48a, 48i> and 48c point to sections of code 50a, 506 the list; and the cursor position is updated,
and 50c for implementing their associated operations. The jf m step 54 0f FIG. 4a it is determined that there are
undo operation undoes the command at the current cursor 45 commands on the list 30 that are situated before the cursor
position. The redo operation performs the next operation on 32, all the commands on the list that are before the cursor are
the list 30 (FIG. 4b). The merge operation merges command deleted (step 56 in FIG. 4a). FIG. 4c shows an example of
log element objects, if possible. sucn a deletion. Suppose that initially list 30 of command
The command log object does not need to know about the log elements includes entries 68, 70 and 72 for commands
implementation of the code 50a, 50b and 50c for imple- 50 "a", "b" and "c", respectively, as shown in FIG. 4c. The
menting operations on the command element objects 40. The cursor 32 points to entry 70 for command "b". Subsequently,
details of this code 50a, 50i> and 50c are the concern of the a user enters command "d". In step 54 of FIG. 4a, it is
command element objects 40. As such, the command log determined that entry 72 for command "c" is positioned
object can be implemented more easily since it does not need before the cursor on list 30. Hence, entry 72 is deleted in step
to concern itself with such details. 55 56 of FIG. 4a. Further, an entry 73 for command "d" is
The command log object and the command element added to the front of the list 30 (see step 58 in FIG. 4a), and
object 40 are created by the application program 22 (FIG. 1). the cursor 32 (FIG. 4c) is updated to point to entry 73 (see
The operating system 24 provides a multi-level undo/redo steP 60 in FIG. 4a).
facility to support multiple undo/redo operations for the Once a user has built a list 30 of command element
application program. Part of this mechanism is a user 60 objects, such as described above, the user may execute an
interface. The user interface displays buttons 51 and 53 undo command. FIG. 5a is a flowchart of the steps per
(FIG. 3a) that may be activated to cause execution of undo formed when an undo command is requested. FIG. 5b is a
and redo commands, respectively. The undo button 51 and diagram illustrating the state of the list 30 of command
the redo button 53 may be activated multiple times to element objects after multiple undo commands are per
perform multiple undos or redos consecutively. The user is 65 formed on the list. The steps of FIG. 5a will be described in
not limited to undoing only a most recent command or conjunction with the diagram of FIG. 5b. Initially, a user
redoing a most recently undone command. A context menu requests an undo operation by activating the undo button 51