EditNotify.mesa
Copyright © 1985, 1986 by Xerox Corporation. All rights reserved.
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
Rick Beach, March 27, 1985 1:11:24 pm PST
Michael Plass, March 18, 1985 4:11:48 pm PST
Doug Wyatt, September 5, 1986 3:04:01 pm PDT
DIRECTORY
EditSpan USING [Span],
TextNode USING [Location, Node, Runs],
Rope USING [ROPE],
Rosary USING [ROSARY];
EditNotify: CEDAR DEFINITIONS
= BEGIN
ROPE: TYPE ~ Rope.ROPE;
ROSARY: TYPE ~ Rosary.ROSARY;
Runs: TYPE ~ TextNode.Runs;
Node: TYPE ~ TextNode.Node;
Location: TYPE ~ TextNode.Location;
Span: TYPE ~ EditSpan.Span;
**** Change Record ****
ChangeType: TYPE = {
ChangingView, ChangingText, ChangingTextForPaste, ChangingSpanForPaste,
ChangingFormat, ChangingProp, MovingNodes, NodeNesting, InsertingNode
};
Change: TYPE = RECORD [SELECT kind: ChangeType FROM
ChangingView => [
viewer: REF,
old: Location
],
ChangingText => [
root: Node, text: Node,
start, newlen, oldlen: INT,
oldRope: ROPE,
oldRuns: Runs,
oldCharSets: ROSARY,
oldCharProps: ROSARY
],
ChangingTextForPaste => [
rope: ROPE,
runs: Runs,
charSets: ROSARY,
charProps: ROSARY,
start, len: INT
],
ChangingSpanForPaste => [
span: Span
],
ChangingFormat => [ -- change format for node
root: Node, node: Node,
newFormatName, oldFormatName: ATOM
],
ChangingProp => [ -- change property for node
root, node: Node, propName: ROPE, propAtom: ATOM, newval, oldval: REF
],
MovingNodes => [
destRoot, sourceRoot: Node,
dest, first, last, pred: Node, 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: Node, change: INTEGER
],
InsertingNode => [ -- insert new node after dest
root, new, dest: Node
],
ENDCASE
];
ChangeSet: TYPE = PACKED ARRAY ChangeType OF Flag;
Flag: TYPE = BOOLFALSE;
defaultChangeSet: ChangeSet = ALL[TRUE];
**** Notification Operations ****
EditNotifyProc: TYPE = PROC [change: REF READONLY Change];
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
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
END.