EditNotify.mesa; written by Bill Paxton, March 1981
edited by Bill Paxton, July 27, 1983 3:34 pm
edited by McGregor, February 8, 1983 11:48 am
edited by Maxwell, January 5, 1983 8:42 am
DIRECTORY
TiogaNode,
TiogaLooks,
TiogaTreeOps,
Rope,
ViewerClasses;
EditNotify: CEDAR DEFINITIONS =
BEGIN
Ref: TYPE = TiogaNode.Ref;
RefBranchNode: TYPE = TiogaNode.RefBranchNode;
RefTextNode: TYPE = TiogaNode.RefTextNode;
Looks: TYPE = TiogaLooks.Looks;
Offset: TYPE = TiogaNode.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 OfChange OF Flag;
Flag: TYPE = BOOLEAN ← FALSE;
defaultChangeSet: ChangeSet = ALL[TRUE];
**** Change Record ****
Change: TYPE = RECORD [SELECT kind:OfChange FROM
ChangingView => [
viewer: ViewerClasses.Viewer,
old: TiogaNode.Location ],
ChangingText => [
root: RefBranchNode, text: RefTextNode,
start, newlen, oldlen: Offset,
oldRope: ROPE,
oldRuns: TiogaLooks.Runs ],
ChangingTextForPaste => [
rope: ROPE,
runs: TiogaLooks.Runs,
start, len: Offset ],
ChangingSpanForPaste => [
span: TiogaTreeOps.TreeSpan ],
ChangingFormat => [
-- change format for node
root: RefBranchNode, node: Ref,
newFormatName, oldFormatName: TiogaNode.Name],
ChangingProp => [
-- change property for node
root: RefBranchNode, node: Ref, propName: ROPE, propAtom: ATOM, newval, oldval: REF],
MovingGroup => [
destRoot, sourceRoot: RefBranchNode,
dest, sourceStart, sourceEnd, from: Ref, contents:
BOOL],
from is the node before sourceStart. from and contents used for undo
MovingNodes => [
destRoot, sourceRoot, dest, first, last: RefBranchNode,
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: RefBranchNode, change: INTEGER],
InsertingNode => [
-- insert new node
root: RefBranchNode, new, old: Ref, where: Place],
Misc => [
-- for other kinds of edits. root tells document which must be locked if undo
root: RefBranchNode, info: REF],
Misc2 => [
-- for other kinds of edits. roots tell documents which must be locked if undo
root1, root2: RefBranchNode, info: REF],
ENDCASE ];
Place: TYPE = { before, after, sibling, child };
OfChange:
TYPE = {
ChangingView, ChangingText, ChangingTextForPaste, ChangingSpanForPaste, ChangingFormat, ChangingProp, MovingGroup, MovingNodes, NodeNesting, InsertingNode, Misc, Misc2 };
END.