# History
Class
## About
`History` holds an editor's undo and redo stacks. Each `Editor` creates one when it is constructed; read it from the editor's read-only `History` property.
```xojo
If Editor.History.CanUndo Then Editor.History.Undo
Editor.History.Redo
```
Call `Reset` after loading or building a document that should not be undoable, such as an initial document built in `Opening`. `FromJSON`, `FromHTML`, and `FromMarkdown` reset the history themselves.
```xojo
Editor.AddNode(New GraffitiProEditor.TextNode("Start writing here."))
Editor.History.Reset
Editor.IsChanged = False
```
## Delegates
| Name | Parameters | Return Type | Description |
| --- | :---: | :---: | --- |
| EntryHandler | entry As HistoryEntry <br> undoing As Boolean) As HistoryEntry | entry As HistoryEntry, undoing As Boolean) As HistoryEntry | (None) |
## Methods
| Name | Parameters | Return Type | Description |
| --- | :---: | :---: | --- |
| Redo | (None) | (None) | Applies the most recently undone change again. Does nothing when there is nothing to redo or the editor is read-only. |
| Reset | (None) | (None) | Clears the undo and redo stacks without changing the document or selection. |
| Undo | (None) | (None) | Reverses the most recent change. Does nothing when there is nothing to undo or the editor is read-only. |
## Properties
| Name | Type | Default Value | Description |
| --- | :---: | :---: | --- |
| CanRedo | Boolean | (None) | Returns True when there is an undone change to apply again and the editor is not read-only. |
| CanUndo | Boolean | (None) | Returns True when there is a change to undo and the editor is not read-only. |
| Owner | GraffitiProEditor.Editor | (None) | Returns the editor whose changes this history records. |
| RedoCount | Integer | (None) | Returns the number of undone changes that can be applied again. |
| UndoCount | Integer | (None) | Returns the number of changes that can be undone. |
## Notes
The editor records every change it makes: typing, pasting, formatting, toolbar and popover actions, inspector edits, adding and deleting nodes, and document properties. Consecutive word characters typed at the caret are undone together. Undoing or redoing raises the editor's usual content and selection notifications, and sets `IsChanged`.
`Undo` and `Redo` do nothing while the editor is `ReadOnly`, and `CanUndo` and `CanRedo` return `False`. The editor's context menu and Command-Z and Shift-Command-Z (Control-Z and Shift-Control-Z on Windows and Linux) call the same methods. To connect a menu bar's Undo and Redo items, enable them from `CanUndo` and `CanRedo` and call `Undo` and `Redo` from their handlers.
Live previews from pickers and the color panel add no steps of their own: a preview that is taken back leaves the history as it was, and a color chosen from the system color panel is one step however many colors were tried.