NodeAddrs.mesa
Copyright Ó 1985, 1986, 1991, 1992 by Xerox Corporation. All rights reserved.
written by Paxton. March 1981
last written by Paxton. December 28, 1982 10:40 am
Last Edited by: Maxwell, January 5, 1983 8:42 am
Doug Wyatt, January 30, 1992 6:28 pm PST
Persistent addressing for characters in text node.
DIRECTORY
Tioga USING [Node];
NodeAddrs: CEDAR DEFINITIONS ~ BEGIN
Node: TYPE ~ Tioga.Node;
RefAddrs: TYPE = REF Body;
Body: TYPE = RECORD [addrs: Pair];
Pair: TYPE = REF PairBody;
PairBody: TYPE = RECORD [
next: Pair,
pinned: BOOL ¬ FALSE, -- if true, then don't modify location when edits take place
addr: REF,
movedTo: Node, -- NIL if hasn't been moved
location: INT
];
AddrsProp: PROC RETURNS [ATOM];
PutTextAddr: PROC [n: Node, addr: REF, location: INT];
assigns addr to location in text
ok if addr was previously assigned elsewhere in the text
location automatically updated when text is edited
RemTextAddr: PROC [n: Node, addr: REF];
removes the given addr
if addr has been moved, does RemTextAddr on new location also
PinTextAddr: PROC [n: Node, addr: REF];
don't modify location when edits take place
UnpinTextAddr: PROC [n: Node, addr: REF];
UnpinAll: PROC [n: Node];
MoveTextAddr: PROC [from, to: Node, addr: REF, location: INT];
does RemTextAddr[from, addr]; PutTextAddr[to, addr, location];
add leaves forwarding address for use by GetTextAddr
GetTextAddr: PROC [n: Node, addr: REF] RETURNS [node: Node, location: INT];
generates ERROR TextAddrNotFound if the addr is not in the mapping
node may be different than n if addr has been moved
TryGetTextAddr: PROC [n: Node, addr: REF]
RETURNS [found: BOOL, node: Node, location: INT];
TextAddrNotFound: ERROR;
MapTextAddrs: PROC [n: Node, action: TextAddrsAction] RETURNS [BOOL];
apply the action to each addr&location pair for the text
returns true if&when an action returns true
skips pinned or moved addresses
TextAddrsAction: TYPE = PROC [addr: REF, location: INT] RETURNS [BOOL];
Notify proc registration
AddNotifyProc: PROC [proc: AddrNotifyProc];
RemoveNotifyProc: PROC [proc: AddrNotifyProc];
AddrNotifyProc: TYPE = PROC [node: Node, new: PROC [old: INT] RETURNS [INT]];
Editing Operations for persistent addrs
Replace: PROC [node: Node, start, len, newlen: INT];
replace chars in [start..start+len) by newlen chars
addrs that are in the replaced section move to start
add (newlen-len) to addrs that are after the replaced section
Update Functions for persistent addrs
AfterReplace: PROC [initLoc, start, len, newlen: INT] RETURNS [newLoc: INT];
END.