@@ -61,26 +61,30 @@ A brief example illustrates how editors work. To start, an editor
61
61
]
62
62
63
63
At this point, the editor is fully functional: the user can type text
64
- into the editor, but no cut-and-paste operations are available. We
65
- can support all of the standard operations on an editor via the
66
- menu bar:
64
+ into the editor, but no cut-and-paste or undo operations are
65
+ available. We can support all of the standard operations on an editor
66
+ via the menu bar:
67
67
68
68
@racketblock[
69
69
(define mb (new menu-bar% [parent f]))
70
70
(define m-edit (new menu% [label "Edit " ] [parent mb]))
71
71
(define m-font (new menu% [label "Font " ] [parent mb]))
72
72
(append-editor-operation-menu-items m-edit #f )
73
73
(append-editor-font-menu-items m-font)
74
+ (send t #,(:: editor<%> set-max-undo-history) 100 )
74
75
]
75
76
76
- Now, the standard cut and paste operations work, and the user can even
77
- set font styles. The user can also insert an embedded editor by
78
- selecting @onscreen{Insert Text} from the @onscreen{Edit} menu; after
79
- selecting the menu item, a box appears in the editor with the caret
80
- inside. Typing with the caret in the box stretches the box as text is
81
- added, and font operations apply wherever the caret is active. Text
82
- on the outside of the box is rearranged as the box changes
83
- sizes. Note that the box itself can be copied and pasted.
77
+ Now, the standard cut-and-paste operations work and so does undo, and
78
+ the user can even set font styles. The editor is created with no undo
79
+ history stack, @method[editor<%> set-max-undo-history] is used to set
80
+ a non-zero stack, so undo operations can be recorded. The user can
81
+ also insert an embedded editor by selecting @onscreen{Insert Text}
82
+ from the @onscreen{Edit} menu; after selecting the menu item, a box
83
+ appears in the editor with the caret inside. Typing with the caret in
84
+ the box stretches the box as text is added, and font operations apply
85
+ wherever the caret is active. Text on the outside of the box is
86
+ rearranged as the box changes sizes. Note that the box itself can be
87
+ copied and pasted.
84
88
85
89
The content of an editor is made up of @defterm{@tech{snips}}. An
86
90
embedded editor is a single snip from the embedding editor's
0 commit comments