TiogaAccess.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Michael Plass, March 25, 1985 10:04:18 am PST
Doug Wyatt, April 2, 1985 3:25:44 pm PST
Provides for sequential processing of Tioga documents, including looks and formatting information.
DIRECTORY
Atom USING [PropList],
FS USING [ErrorGroup, OpenFile],
Rope USING [ROPE],
ViewerClasses USING [Viewer];
TiogaAccess: CEDAR DEFINITIONS ~ BEGIN
ROPE: TYPE ~ Rope.ROPE;
Viewer: TYPE ~ ViewerClasses.Viewer;
Basic types
CharSet: TYPE ~ [0..256);
invalidCharSet: CharSet = 255;
Look: TYPE ~ CHAR['a..'a+32);
Looks: TYPE ~ PACKED ARRAY Look OF BOOL;
TiogaChar: TYPE ~ RECORD [
charSet: CharSet, -- used with char to represent a Xerox Network Sytems 16-bit character
char: CHAR,
looks: Looks,
format: ATOM,
comment: BOOL,
endOfNode: BOOL,
deltaLevel: [-16000..1],
propList: Atom.PropList
Immutable! This is the character property list unless endOfNode is TRUE, in which case it is the node property list.
];
Property lists
The property lists have ATOMs for keys and REFs for values, the values being in their internal representation. Use GetExternalProp and GetInternalProp to translate between the internal REF ANY form and the external ROPE form. The format, comment, charsets and charprops properties are not replicated in the node property list. The property lists should be regarded as immutable.
GetExternalProp: PROC [key: ATOM, value: REF] RETURNS [ROPE];
GetInternalProp: PROC [key: ATOM, value: ROPE] RETURNS [REF];
Errors
Error: ERROR [group: FS.ErrorGroup, expl: ROPE];
Clients may get errors from FS or IO from the file-oriented operations.
The Reader type and its basic operations
Reader: TYPE ~ REF ReaderRep;
ReaderRep: TYPE;
FromNothing: PROC RETURNS [Reader];
Not good for much except PutBack.
FromFile: PROC [fileName: ROPE] RETURNS [Reader];
FromOpenFile: PROC [openFile: FS.OpenFile] RETURNS [Reader];
The OpenFile is closed by this call.
FromSelection: PROC RETURNS [Reader];
Makes a reader on a copy of the contents of the primary selection.
FromViewer: PROC [viewer: Viewer] RETURNS [Reader];
Must be a text or typescript viewer.
Makes a reader on a copy of the viewer contents.
EndOf: PROC [reader: Reader] RETURNS [BOOL];
Get: PROC [reader: Reader] RETURNS [TiogaChar];
GetNodeProps: PROC [reader: Reader] RETURNS [Atom.PropList];
Provides an advanced look at the property list that will accompany the next endOfNode.
The Writer type and its operations
Writer: TYPE ~ REF WriterRep;
WriterRep: TYPE;
Create: PROC RETURNS [Writer];
Put: PROC [writer: Writer, tiogaChar: TiogaChar];
format and comment fields are ignored unless tiogaChar.endOfNode is TRUE.
Nest: PROC [writer: Writer, delta: INT];
Changes the nesting level of the current node by the specified amount. May raise Error if an attempt is made to change the nesting level to an illegal value.
WriteFile: PROC [writer: Writer, fileName: ROPE];
The write operations do the write, and reset the writer to a clean state.
WriteOpenFile: PROC [writer: Writer, openFile: FS.OpenFile];
Closes the OpenFile after writing it.
WriteSelection: PROC [writer: Writer];
Replaces the primary selection. Clients should use TiogaOps.CallWithLocks or equivalent to avoid race conditions with the user.
WriteViewer: PROC [writer: Writer, viewer: Viewer];
Must be a text or typescript viewer.
Replaces the contents of the viewer.
WriteReader: PROC [writer: Writer] RETURNS [Reader];
Good for processing the whole document again.
Reset: PROC [writer: Writer];
Throws the currently accumulated contents away.
Subsidiary Reader operations
DoneWith: PROC [reader: Reader];
Optional; frees up storage and locks sooner than garbage collector.
Peek: PROC [reader: Reader] RETURNS [TiogaChar];
PeekRope: PROC [reader: Reader] RETURNS [ROPE];
Returns the contents of the remainder of the node as a rope.
SkipToNextNode: PROC [reader: Reader] RETURNS [deltaLevel: INT];
Discards data until the end of the current node.
CopyNode: PROC [writer: Writer, reader: Reader,
maxLength: INTINT.LAST] RETURNS [nodeEnd: BOOL];
Copies data until the end of the current node, or until maxLength chars have been copied.
Returns TRUE if current node was copied all the way to its end.
GetNodeRefs: PROC [reader: Reader] RETURNS [root, current: REF, offset: INT];
Returns the root and current node of the document, and the offset into the current node.
Each REF may be narrowed into a TextNode.Ref
Provided for clients that need access to Tioga's lower level machinery.
GetIndex: PROC [reader: Reader] RETURNS [index: INT];
Counts one per character, plus one per node; ignores anything created by PutBack.
GetLength: PROC [reader: Reader] RETURNS [INT];
Value of GetIndex[reader] when EndOf[reader] is TRUE.
GetPosition: PROC [reader: Reader] RETURNS [position: INT];
Like GetIndex, but doesn't count comment nodes. Corresponds to Tioga's Position button.
SetIndex: PROC [reader: Reader, index: INT];
Discards anything created by PutBack before setting index.
SetPosition: PROC [reader: Reader, position: INT];
PutBack: PROC [reader: Reader, tiogaChar: TiogaChar];
Contents may differ from what was originally read.
END.