Undo is an interaction technique which is implemented in many computer programs. It erases the last change done to the document, reverting it to an older state. In some more advanced programs, such as
graphic processing, undo will negate the last command done to the file being edited. With the possibility of undo, users can explore and work without fear of making mistakes, because they can easily be undone.
The expectations for undo are easy to understand: to have a predictable functionality, and to include all "undoable" commands.
Usually undo is available until the user undoes all executed operations. But there are some actions which are not stored in the undo list, and thus they cannot be undone. For example, ''save file'' is not undoable, but is queued in the list to show that it was executed. Another action which is usually not stored, and thus not undoable, is ''scrolling'' or ''selection''.
The opposite of to undo is to redo. The redo command reverses the undo or advances the buffer to a more recent state.
The common components of undo functionality are the ''commands'' which were executed of the user, the ''history buffer(s)'' which stores the completed actions, the ''undo/redo manager'' for controlling the history buffer, and the ''user interface'' for interacting with the user.
In most graphical applications for the majority of the mainstream
operating systems
An operating system (OS) is system software that manages computer hardware and software resources, and provides common daemon (computing), services for computer programs.
Time-sharing operating systems scheduler (computing), schedule tasks for ...
(such as
Microsoft Windows
Windows is a Product lining, product line of Proprietary software, proprietary graphical user interface, graphical operating systems developed and marketed by Microsoft. It is grouped into families and subfamilies that cater to particular sec ...
,
Linux
Linux ( ) is a family of open source Unix-like operating systems based on the Linux kernel, an kernel (operating system), operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically package manager, pac ...
and
BSDs), the
keyboard shortcut
In computing, a keyboard shortcut (also hotkey/hot key or key binding) is a software-based assignment of an action to one or more keys on a computer keyboard. Most Operating system, operating systems and Application software, applications come ...
for the undo command is
Ctrl+Z or Alt+Backspace, and the shortcut for redo is
Ctrl+Y or
Ctrl+
Shift+Z. In most macOS applications, the shortcut for the undo command is
Command
Command may refer to:
Computing
* Command (computing), a statement in a computer language
* command (Unix), a Unix command
* COMMAND.COM, the default operating system shell and command-line interpreter for DOS
* Command key, a modifier key on A ...
-Z, and the shortcut for redo is
Command
Command may refer to:
Computing
* Command (computing), a statement in a computer language
* command (Unix), a Unix command
* COMMAND.COM, the default operating system shell and command-line interpreter for DOS
* Command key, a modifier key on A ...
-
Shift-Z. On all platforms, the undo/redo functions can also be accessed via the
Edit menu.
History
The ability to undo an operation on a computer was independently invented multiple times, in response to how people used computers.
The
File Retrieval and Editing System
The File Retrieval and Editing SyStem, or FRESS, was a hypertext system developed at Brown University starting in 1968 by Andries van Dam and his students, including Bob Wallace (computer scientist), Bob Wallace. It was the first hypertext system ...
, developed starting in 1968 at
Brown University
Brown University is a Private university, private Ivy League research university in Providence, Rhode Island, United States. It is the List of colonial colleges, seventh-oldest institution of higher education in the US, founded in 1764 as the ' ...
, is reported to be the first computer-based system to have had an "undo" feature.
Warren Teitelman developed a ''Programmer's Assistant'' as part of BBN-LISP with an Undo function, by 1971.
The
Xerox PARC Bravo text editor had an Undo command in 1974.
A 1976 research report by Lance A. Miller and John C. Thomas of
IBM
International Business Machines Corporation (using the trademark IBM), nicknamed Big Blue, is an American Multinational corporation, multinational technology company headquartered in Armonk, New York, and present in over 175 countries. It is ...
, ''Behavioral Issues in the Use of Interactive Systems'', noted that "it would be quite useful to permit users to 'take back' at least the immediately preceding command (by issuing some special 'undo' command)." The programmers at the
Xerox PARC research center assigned the keyboard shortcut Ctrl-Z to the undo command, which became a crucial feature of text editors and word processors in the
personal computer
A personal computer, commonly referred to as PC or computer, is a computer designed for individual use. It is typically used for tasks such as Word processor, word processing, web browser, internet browsing, email, multimedia playback, and PC ...
era.
In 1980,
Larry Tesler
Lawrence Gordon Tesler (April 24, 1945 – February 16, 2020) was an American computer scientist who worked in the field of human–computer interaction. Tesler worked at Xerox PARC, Apple Inc., Apple, Amazon.com, Amazon, and Yahoo!.
While at PA ...
of Xerox PARC began working at
Apple Computer
Apple Inc. is an American multinational corporation and technology company headquartered in Cupertino, California, in Silicon Valley. It is best known for its consumer electronics, software, and services. Founded in 1976 as Apple Computer Co ...
. There, he and
Bill Atkinson advocated for the presence of an undo command as a standard fixture on the
Apple Lisa
Lisa is a desktop computer developed by Apple, produced from January 19, 1983, to August 1, 1986, and succeeded by Macintosh. It is generally considered the first mass-market personal computer operable through a graphical user interface (GUI). I ...
. Atkinson was able to convince the individual developers of the Lisa's
application software
Application software is any computer program that is intended for end-user use not operating, administering or programming the computer. An application (app, application program, software application) is any program that can be categorized as ...
to include a single level of undo and redo, but was unsuccessful in lobbying for multiple levels. When Apple introduced the Lisa's successor, the
Macintosh
Mac is a brand of personal computers designed and marketed by Apple Inc., Apple since 1984. The name is short for Macintosh (its official name until 1999), a reference to the McIntosh (apple), McIntosh apple. The current product lineup inclu ...
, it stipulated that all standard applications should include an “Undo” as the first command in the “Edit” menu, which has remained the standard on
macOS
macOS, previously OS X and originally Mac OS X, is a Unix, Unix-based operating system developed and marketed by Apple Inc., Apple since 2001. It is the current operating system for Apple's Mac (computer), Mac computers. With ...
and
Windows
Windows is a Product lining, product line of Proprietary software, proprietary graphical user interface, graphical operating systems developed and marketed by Microsoft. It is grouped into families and subfamilies that cater to particular sec ...
to this day.
Multi-level undo commands were introduced in the 1980s, allowing the users to take back a series of actions, not just the most recent one.
EMACS
Emacs (), originally named EMACS (an acronym for "Editor Macros"), is a family of text editors that are characterized by their extensibility. The manual for the most widely used variant, GNU Emacs, describes it as "the extensible, customizable, s ...
and other timeshared screen editors had it before personal computer software.
CygnusEd was the first Amiga text editor with an unlimited undo/redo feature.
AtariWriter, a word-processing application introduced in 1982, featured undo. NewWord, another word-processing program released by NewStar in 1984, had an unerase command.
IBM's VisiWord also had an undelete command.
Undo and redo models
Undo models can be categorized as linear or non-linear. The non-linear undo model can be sub-classified in script model, us&r model, triadic model, and selective undo.
Some common properties of models are:
* ''stable execution property:'' A state is represented as an ordered list of commands. This means that a command "is always undone in the state that was reached after the original execution."
* ''weakened stable execution:'' This means that if undo is executed all commands which depend on the undone command are undone dependent on the command.
* ''stable result property:'' This property has the similar meaning like the ''stable execution property'' except for the list. The ordered list of commands includes that they were executed instead of only the commands.
* ''commutative:'' That means that the reached state after undo and redo two different commands is the same when they are executed in the converse order.
* ''minimalistic undo property:'' It describes that "undo operation of command C undoes only command C and all commands younger than C which are dependent on C."
Linear undo
Linear undo is implemented with a
stack
Stack may refer to:
Places
* Stack Island, an island game reserve in Bass Strait, south-eastern Australia, in Tasmania’s Hunter Island Group
* Blue Stack Mountains, in Co. Donegal, Ireland
People
* Stack (surname) (including a list of people ...
(last in first out (LIFO)
data structure
In computer science, a data structure is a data organization and storage format that is usually chosen for Efficiency, efficient Data access, access to data. More precisely, a data structure is a collection of data values, the relationships amo ...
) that stores a history of all executed commands. When a new command is executed it is added to the top of stack. Therefore, only the last executed command can be undone and removed from the history. Undo can be repeated as long as the history is not empty.
Restricted linear model
The restricted linear model is an augmentation of the linear undo model. It satisfies the above described ''stable execution property'' for linear undo, because this model does not keep the property if a command is done while the history list includes other commands. The restricted linear model clears the history list before a new command is added. But other restrictions are available, too. For example, the size of the history list can be restricted or when a defined size is reached, the first executed command is deleted from the list.
Non-linear undo
The main difference between linear undo and non-linear undo is the possibility of the user to undo the executed commands in an arbitrary order. They have the chance to undo not the most recently command but rather choose a command from the list.
For non linear model there are subclasses which implement this model.
Script model
The script model handles user actions as editing a script of commands. The history list of the executed commands are interpreted "as a script, the effect of an undo is defined to be the same as if the undone action had never occurred in the first place."
As the result of undo the state has to be the way as if the undone command was never executed. A disadvantage of this model is that the user has to know the connection between undone command and the current state to avoid side effects. One of this can be for example duplication. Other problems are that if "subsequent commands are redone in a different state that they were originally executed in direct manipulation interfaces, this reinterpretation of the original user action is not always obvious or well defined".
US&R model
The special feature of this model is that it has the option of skipping a command. This means that redoing a command can be skipped. The command which is skipped is marked as skipped but not deleted. When new commands are executed, the history list is retained, so the order of the executed commands can be reproducible with that. The order can be described through a history tree which is a directed graph, "because it is possible to continue redoing commands from another branch creating a link in the graph".
Even though the set of commands is simple and easy to understand, the complex structure with skipping and linking branches is hard to comprehend and to remember, when the user wants to undo more than one step.
Triadic model
This non-linear undo model has besides undo and redo the possibility to rotate. It has the same data structure as the above-mentioned models with a history list and a separated redo list which includes the redo operations. The rotate operation sets the last command of the redo list in front of it. On one hand this means that the next command to be redone can be selected by placing it in front. On the other hand, rotation can be used "to select the place in the redo list where the next undo operation will put the command".
The list of redo is therefore unordered. "To undo an isolated command, the user has to undo a number of steps, rotate the redo list, and then redo a number of steps".
For redo the list has to be rotated until the wanted command is above.
Selective undo
Jakubec et al. say that selective undo is a feature which a model can offer but for selective undo there is no clear definition.
The authors selected functions which a model should have when it supports selective undo. It should be possible to "undo any executed action in the history buffer. Actions independent of the action being undone should be left untouched".
Just like that redo has to be possible to any undone command. The third function for selective undo is that "no command can be automatically discarded from history buffer without direct user’s request."
For selective undo applies that undo and redo is executable outside of any context. There are three main issues. The first is that undone commands can be outside of the originally context. Through this there can be dead references which have to be handled. The second issue that modified commands can be undone and so it has to be solved which state after undo will be presented. The third issue is discarding command problems. Selective undo has no pointer in the lists, so this means that no command should be discarded of the stack.
Direct selective undo
Direct selective undo is an extension of restricted linear undo with a history tree. The operation creates a copy of the selected command, executes this and add it to the history list. There two non-linear operations selective undo and selective redo are defined, so it is more symmetric.
Multiuser application
When multiple users can edit the same document simultaneously, a multi-user undo is needed. ''Global'' multi-user undo reverts the latest action made to the document, regardless of who performed the edit. ''Local'' multi-user undo only reverts actions done by the local user, which requires a non-linear undo implementation.
Where undo can be used to backtrack through multiple edits, the redo command goes forward through the action history. Making a new edit usually clears the redo list. If a branching redo model is used, the new edit ''branches'' the action history.
The number of previous actions that can be undone varies by program, version, and hardware or software capabilities. For example, the default undo/redo stack size in
Adobe Photoshop
Adobe Photoshop is a raster graphics editor developed and published by Adobe Inc., Adobe for Microsoft Windows, Windows and macOS. It was created in 1987 by Thomas Knoll, Thomas and John Knoll. It is the most used tool for professional digital ...
is 20 but can be changed by the user. As another example, earlier versions of
Microsoft Paint only allowed up to three edits to be undone; the version introduced in
Windows 7
Windows 7 is a major release of the Windows NT operating system developed by Microsoft. It was Software release life cycle#Release to manufacturing (RTM), released to manufacturing on July 22, 2009, and became generally available on October 22, ...
increased this limit to 50.
Simplistic, single-edit undo features sometimes do away with "redo" by treating the undo command itself as an action that can be undone. This is known as the flip undo model, because the user can flip between two program states using the undo command.
[Roberta Mancini, Alan Dix and Stefano Levialdi. 2006]
"Reflections on Undo"
/ref> This was the standard model prior to the widespread adoption of multiple-level undo in the early 1990s.
Undo implementation
Undo can be implemented through different patterns. The most common patterns are command pattern
In object-oriented programming, the command pattern is a Behavioral pattern, behavioral Design pattern (computer science), design pattern in which an object is used to Information hiding, encapsulate all information needed to perform an action or ...
and memento pattern.
Command pattern
The command pattern
In object-oriented programming, the command pattern is a Behavioral pattern, behavioral Design pattern (computer science), design pattern in which an object is used to Information hiding, encapsulate all information needed to perform an action or ...
is a software design pattern
In software engineering, a software design pattern or design pattern is a general, reusable solution to a commonly occurring problem in many contexts in software design. A design pattern is not a rigid structure to be transplanted directly into s ...
which encapsulates information from the operation into command objects. This means that every action is stored in an object. The abstract command class implements an abstract execute operation, so every command object has an execute operation. For undo there also have to be unexecuted operation, which undoes the effect of the executed command, which are stored in a history list. Undo and redo are implemented so that the list is run through forwards and backwards when the execute or unexecute command is called.
For single undo only the executed command is stored. In contrast to the multi level undo where not only the history list with the commands is saved but also the number of undo levels can be determined of the maximum length of the list.
Memento pattern
With memento pattern the internal state of an object is stored. The object in which the state is saved, is called memento and is organized through the memento originator. This returns a memento, initialized with information of the current state, when undo is executed, so that the state can be checked. The memento is only visible for the originator.
In memento pattern the undo mechanism is called caretaker. It is responsible for the safekeeping of the mementos but never change the contents of these. For undo the caretaker requests a memento of the originator and then applying the undo.
The most part of undo mechanism can implemented without dependency to specific applications or command classes. This includes "the management of history list, the history scroller, menu entries for undo and redo and update of the menu entries depending on the name of the next available command."
Every command class has a do method which is called when a command is executed. The undo-method implements the reverse operation of the do-method. To implement the reverse, there are several different strategies.
* ''full checkpoint:'' That means that the complete state is saved after a command is executed. This is the easiest implementation, but is not highly efficient and therefore not often used.
* ''complete rerun:'' Therefore, the initial state is saved and every state in the history list can be reached through "starting with the initial state and redoing all commands from the beginning of the history."
* ''partial checkpoint:'' This is the most used strategy. The changed application state is saved and with undo the part of the state is set back to the forward value.
* ''inverse function:'' Inverse function needs no saved state information. "For example, moving can be reversed by moving the object back by relative amount." For selective undo there is not enough information for saving the state.
See also
*Reversible computing
Reversible computing is any model of computation where every step of the process is time-reversible. This means that, given the output of a computation, it's possible to perfectly reconstruct the input. In systems that progress deterministica ...
*Rollback (data management)
In database technologies, a rollback is an operation which returns the database to some previous state. Rollbacks are important for database integrity, because they mean that the database can be restored to a clean copy even after erroneous operati ...
*Undeletion
Undeletion is a feature for restoring computer files which have been removed from a file system by file deletion. Deleted data can be recovered on many file systems, but not all file systems provide an undeletion feature. Recovering data with ...
*Version control
Version control (also known as revision control, source control, and source code management) is the software engineering practice of controlling, organizing, and tracking different versions in history of computer files; primarily source code t ...
( native file format)
References
External links
{{wiktionary
*The Age of Undoing - Article about the linguistic history of Undo at The New York Times Magazine.
*Cascading undo control - a paper focused on what is cascading undo and how it might be presented to users
Text editor features
Reversible computing
Computer-related introductions in 1968