-- EditNotify.mesa
-- written by Bill Paxton, March 1981
-- last edit by Bill Paxton, May 13, 1982 5:04 pm
Last Edited by: Maxwell, January 5, 1983 8:42 am
DIRECTORY
TextNode,
TextLooks,
Rope,
ViewerClasses;
EditNotify: CEDAR DEFINITIONS =
BEGIN
Ref: TYPE = TextNode.Ref;
RefTextNode: TYPE = TextNode.RefTextNode;
RefOtherNode: TYPE = TextNode.RefOtherNode;
Looks: TYPE = TextLooks.Looks;
Offset: TYPE = TextNode.Offset;
ROPE: TYPE = Rope.ROPE;
When: TYPE = { before, after };
-- indicates whether notify before or after the change has taken place
Priority: TYPE = { high, normal, low };
-- high priority procs called before normal, and normal called before low
-- e.g., might use high priority for clearing style cache,
-- normal for redisplay, and
-- low for saving replay info
-- **** Notification Operations ****
EditNotifyProc: TYPE = PROC [change: REF READONLY Change];
AddNotifyProc: PROC [
proc: EditNotifyProc,
time: When ← after,
priority: Priority ← normal,
changeSet: ChangeSet ← defaultChangeSet];
-- add new proc to list of notification procedures
-- call proc before/after any edit in its changeSet
-- use time=before for applications such as saving text for undo
-- use time=after for applications such as reformat & redisplay
RemoveNotifyProc: PROC [
proc: EditNotifyProc,
time: When ← after];
-- remove proc from list of notification procedures
Notify: PROC [change: REF READONLY Change, time: When];
-- call the appropriate edit notify procs
ChangeSet: TYPE = PACKED ARRAY ChangeType OF Flag;
Flag: TYPE = BOOLEANFALSE;
defaultChangeSet: ChangeSet = ALL[TRUE];
-- **** Change Record ****
Change: TYPE = RECORD [SELECT kind:ChangeType FROM
ChangingView => [
viewer: ViewerClasses.Viewer,
old: TextNode.Location ],
ChangingText => [
root: Ref, text: RefTextNode,
start, newlen, oldlen: Offset,
oldRope: ROPE,
oldRuns: TextLooks.Runs ],
ChangingTextForPaste => [
rope: ROPE,
runs: TextLooks.Runs,
start, len: Offset ],
ChangingSpanForPaste => [
span: TextNode.Span ],
ChangingType => [ -- change type for node
root: Ref, node: Ref,
newTypeName, oldTypeName: TextNode.TypeName],
ChangingProp => [ -- change property for node
root, node: Ref, propName: ROPE, propAtom: ATOM, newval, oldval: REF],
MovingNodes => [
destRoot, sourceRoot: Ref,
dest, first, last, pred: Ref, nesting: INTEGER,
afterDest: BOOL],
-- dest cannot be within nodes [first..last]
-- pred is the node before first. pred and nesting used for undo
NodeNesting => [ -- change nesting of nodes [first..last]
root, first, last: Ref, change: INTEGER],
InsertingNode => [ -- insert new node after dest
root, new, dest: Ref],
ENDCASE ];
ChangeType: TYPE = {
ChangingView, ChangingText, ChangingTextForPaste, ChangingSpanForPaste,
ChangingType, ChangingProp, MovingNodes, NodeNesting, InsertingNode };
Start: PROC; -- for initialization only
END.