TiogaExtraOps.mesa
Copyright Ó 1985, 1986, 1991 by Xerox Corporation. All rights reserved.
written by Bill Paxton. June 1982
last written by Paxton. December 30, 1982 11:19 am
last written by Teitelman. January 19, 1983 12:02 pm
Last Edited by: Maxwell, January 19, 1983 12:22 pm
Michael Plass, March 18, 1985 11:39:31 am PST
Rick Beach, March 15, 1985 10:23:16 am PST
Doug Wyatt, October 29, 1991 3:07 pm PST
This contains overflow from TiogaOps.mesa
DIRECTORY
Rope USING [ROPE],
TiogaOps USING [CommandProc, Location, Ref, WhichNodes];
TiogaExtraOps:
CEDAR
DEFINITIONS =
BEGIN
ROPE: TYPE ~ Rope.ROPE;
Ref: TYPE ~ TiogaOps.Ref;
Location: TYPE ~ TiogaOps.Location;
Node Property Lists
SetProp: PROC [name: ATOM, value: REF, which: TiogaOps.WhichNodes ¬ selection];
PutProp:
PROC [n: Ref, name:
ATOM, value:
REF];
NIL is a valid value. Use RemProp to remove property. (Although GetProp will not distinguish between property value NIL and no property present, it is useful to be able to have NIL values to avoid creating garbage. Setting to NIL doesn't release the property record, so don't need to reallocate when next set to a non-NIL value.
GetProp:
PROC [n: Ref, name:
ATOM]
RETURNS [
REF];
RemProp:
PROC [n: Ref, name:
ATOM];
MapPropsAction:
TYPE =
PROC [name:
ATOM, value:
REF]
RETURNS [
BOOL];
MapProps:
PROC [n: Ref, action: MapPropsAction,
formatFlag, commentFlag:
BOOL ¬
TRUE]
RETURNS [
BOOL];
apply the action to each name & value pair for the node
returns true if&when an action returns true
if commentFlag is false, skips Comment property; ditto for formatFlag
hack to accelerate Inherit and PutFile operations
Read, write, copy props
RegisterPropProc: PROC [name: ATOM,
reader: ReadSpecsProc, writer: WriteSpecsProc, copier: CopyInfoProc];
registers these procs for this property name
they will be called by DoSpecs, GetSpecs, and CopyInfo
ReadSpecsProc: TYPE = PROC [name: ATOM, specs: ROPE] RETURNS [value: REF];
WriteSpecsProc: TYPE = PROC [name: ATOM, value: REF] RETURNS [specs: ROPE];
CopyInfoProc: TYPE = PROC [name: ATOM, value: REF] RETURNS [new: REF];
NullRead: ReadSpecsProc; -- returns NIL always
NullWrite: WriteSpecsProc; -- returns NIL always
NullCopy: CopyInfoProc; -- returns NIL always
Text keys: persistent "addresses" for characters in text nodes
PutTextKey:
PROC [node: Ref, where:
INT, key:
REF];
Associates the key with the given offset in the text node. Key moves with the text as edits take place in the node. Key can move to new node. (Also defined in TiogaOps)
GetTextKey:
PROC [node: Ref, key:
REF]
RETURNS [loc: Location];
Tells you where the key is in the node at the current time.
loc node may be different if addr has been moved (Also defined in TiogaOps)
TextKeyNotFound: ERROR; -- raised by GetTextKey
RemoveTextKey: PROC [node: Ref, key: REF];
MapTextKeys:
PROC [node: Ref,
proc:
PROC [key:
REF, where:
INT]
RETURNS [
BOOL]
]
RETURNS [
BOOL];
Calls proc for all the keys for the given node.
Returns true if&when an action returns true
File I/O
GetFile: PROC [name: ROPE] RETURNS [root: Ref];
PutFile: PROC [name: ROPE, root: Ref];
FreeTree:
PROC [root: Ref];
If you have gotten access to the root by GetFile and know that there are no remaining references to it, call FreeTree to have all of the intra-tree pointers set to NIL. This causes circular reference chains to be broken so that the garbage collector can reclaim the tree. If you are not sure, don't call this!
Registering Command procedures
UnRegisterCommand:
PROC [name:
ATOM, proc: TiogaOps.CommandProc];
Remove the proc from the list for the atom.
END.