EditNotify.mesa
Copyright © 1985 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, March 2, 1985 3:29:41 pm PST
DIRECTORY
TextNode USING [Location, Ref, RefTextNode, Span],
TextLooks USING [Runs],
Rope USING [ROPE],
ViewerClasses USING [Viewer];
EditNotify: CEDAR DEFINITIONS
= BEGIN
Ref: TYPE = TextNode.Ref;
RefTextNode: TYPE = TextNode.RefTextNode;
Offset: TYPE = INT;
ROPE: TYPE = Rope.ROPE;
**** Change Record ****
ChangeType:
TYPE = {
ChangingView, ChangingText, ChangingTextForPaste, ChangingSpanForPaste,
ChangingFormat, ChangingProp, MovingNodes, NodeNesting, InsertingNode
};
Change: TYPE = RECORD [SELECT kind: ChangeType FROM
ChangingView => [
viewer: ViewerClasses.Viewer,
old: TextNode.Location
],
ChangingText => [
root: Ref, text: RefTextNode,
start, newlen, oldlen: INT,
oldRope: ROPE,
oldRuns: TextLooks.Runs,
oldCharSets: REF,
oldCharProps: REF
],
ChangingTextForPaste => [
rope: ROPE,
runs: TextLooks.Runs,
charSets: REF,
charProps: REF,
start, len: INT ],
ChangingSpanForPaste => [
span: TextNode.Span
],
ChangingFormat => [
-- change format for node
root: Ref, node: Ref,
newFormatName, oldFormatName: ATOM
],
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
];
ChangeSet: TYPE = PACKED ARRAY ChangeType OF Flag;
Flag: TYPE = BOOL ← FALSE;
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.