-- UndoEvent.mesa
-- written by Bill Paxton, June 1981
-- last edit by Bill Paxton, April 5, 1982 12:39 pm
-- an undo event is a series of actions that are to be undone as a unit
-- the event record contains sufficient information to undo the actions
DIRECTORY
EditNotify;
UndoEvent: CEDAR DEFINITIONS =
BEGIN
Ref: TYPE = REF EventBody;
EventBody: PUBLIC TYPE = RECORD [subevents: SubEvent];
SubEvent: TYPE = REF SubEventBody;
SubEventBody:
TYPE =
RECORD [
next: SubEvent,
undoProc: UndoProc,
undoRef: REF Change
];
Change:
TYPE = EditNotify.Change;
-- undo list contains changes.
UndoProc:
TYPE =
PROC [undoRef:
REF Change, currentEvent: Ref];
-- procedure supplied by client to undo the effects of a particular subevent
Create: PROC RETURNS [Ref];
Note:
PROC [event: Ref, undoProc: UndoProc, undoRef:
REF Change];
-- adds <undoProc, undoRef> to list of subevents
Undo:
PROC [undoEvent: Ref, currentEvent: Ref ←
NIL];
-- otherwise, calls undoProc[undoRef,currentEvent] for each subevent
-- in reverse order that subevents originally happened
-- currentEvent arg is to record the effects of Undo so it too will be undoable
Reset:
PROC [event: Ref];
-- resets the list of subevents to NIL
-- Undo automatically does a Reset when it is finished
Empty:
PROC [event: Ref]
RETURNS [
BOOLEAN];
-- returns true if subevents list is empty
Start: PROC; -- initialization
END.