UndoEventImpl.mesa
Copyright © 1985, 1986 by Xerox Corporation. All rights reserved.
written by Bill Paxton, June 1981
last edit by Bill Paxton, April 5, 1982 12:38 pm
Doug Wyatt, September 17, 1986 11:11:43 am PDT
DIRECTORY
TiogaPrivate USING [Change, Event, EventBody, SubEvent, SubEventBody, UndoProc, World];
UndoEventImpl: CEDAR PROGRAM
EXPORTS TiogaPrivate =
BEGIN OPEN TiogaPrivate;
CreateEvent: PUBLIC PROC RETURNS [Event] = { RETURN [NEW[EventBody ← [subevents: NIL]]] };
NoteEvent:
PUBLIC
PROC [world: World, undoProc: UndoProc, undoRef:
REF Change] = {
event: Event ~ IF world=NIL THEN NIL ELSE world.currentEvent;
IF event = NIL THEN RETURN;
event.subevents ←
NEW[SubEventBody ←
[next: event.subevents, undoProc: undoProc, undoRef: undoRef]];
UndoEvent:
PUBLIC
PROC [world: World, undoEvent: Event] = {
calls undoProc[undoRef] for each subevent
in reverse order that subevents originally happened
sub: SubEvent;
IF undoEvent=NIL THEN RETURN;
sub ← undoEvent.subevents; undoEvent.subevents ← NIL;
UNTIL sub=NIL DO sub.undoProc[world, sub.undoRef]; sub ← sub.next; ENDLOOP;
};
ResetEvent: PUBLIC PROC [event: Event] = { IF event # NIL THEN event.subevents ← NIL };
EmptyEvent: PUBLIC PROC [event: Event] RETURNS [BOOL] = { RETURN [event=NIL OR event.subevents=NIL] };
END.