TiogaStreamsExtras.Mesa
Mike Spreitzer April 24, 1990 6:47 am PDT
DIRECTORY IO, Rope, TextNode, TiogaFileOps;
TiogaStreamsExtras: CEDAR DEFINITIONS =
BEGIN
ROPE: TYPE = Rope.ROPE;
Input
FullCreateInput: PROC [from: TextNode.Ref, commentHandling: FullCommentHandling ← [FALSE[]], levelPrefix: ROPENIL] RETURNS [in: IO.STREAM];
Create a Tioga Input Stream on descendents of from.
Each subnode's chars are prefixed by levelPrefix * (-1 + its depth realtive to from), then maybe prefix for comment nodes.
Each subnode's chars are suffixed by a newline, after the comment suffix (if any).
FullCommentHandling: TYPE = RECORD [variant: SELECT see: BOOL FROM
FALSE => [],
TRUE => [prefix, suffix: ROPENIL],
ENDCASE];
Output
FullCreateOutput: PROC [to: TiogaFileOps.Ref, breakAtNewline: BOOLFALSE, levelPrefix, defaultFormat: ROPENIL, flexilevel: BOOLFALSE, spacesPerTab, normalNestIndent, minFmtIndent: INT ← 0, maxFmtIndent: INT ← -1, commentHandling: FullCommentHandling ← [FALSE[]] ] RETURNS [out: IO.STREAM];
Creates children of to.
IF breakAtNewline, THEN s.PutChar['\n] gets translated to s.EndNode[reset, FALSE].
IF (NOT flexilevel) AND levelPrefix # NIL, THEN every node that begins with N repetitions of levelPrefix will be indented N levels deeper than it otherwise would be.
IF flexilevel, THEN the depth of each node is 1 more than the depth of the most recent node with less leading whitespace. Spaces are white; tabs are white iff spacesPerTab>0; nothing else is white.
Each child node will have format=defaultFormat, unless explicitly overridden by SetFormat.
IF flexilevel AND normalNestIndent>0 AND maxFmtIndent<minFmtIndent, THEN each node whose amout of leading white space exceeds its parent's by an amout different than normalNestIndent gets a Postfix property adjusting its appearance to match the amount of leading white space.
IF flexilevel AND maxFmtIndent >= minFmtIndent, THEN each node whose amount of leading white space exceeds it parent's by N is created with format defaultFormat-N if N IN [minFmtIndent..maxFmtIndent], otherwise with format defaultFormat-M and a postfix property (M IN {minFmtIndent, maxFmtIndent}); normalNestIndent is indentation of children relative to parent.
When commentHandling.see, nodes with the given prefix and suffix become comment nodes without the prefix or suffix.
END.