DIRECTORY Atom USING [PropList, PutPropOnList], Rope USING [ROPE, Length, Fetch], FS USING [StreamOpen], IO USING [PutF, PutBlock, Value, STREAM, Close, GetIndex, GetChar], TiogaAccess USING [TiogaChar, WriteFile, GetInternalProp, Put, Looks, Writer, Create], ISMessage; ISMessageImpl: CEDAR PROGRAM IMPORTS Atom, Rope, TiogaAccess, IO, FS EXPORTS ISMessage ~ BEGIN stream: IO.STREAM; Close: PUBLIC PROC ~ { IO.Close[stream]; }; OpenTempFile: PUBLIC PROC ~ { stream _ FS.StreamOpen["ISTest.out", $create]; }; CloseTempFile: PUBLIC PROC ~ { IO.Close[stream]; }; ReopenTempFile: PUBLIC PROC ~ { stream _ FS.StreamOpen["ISTest.out"]; }; GetTempFileChar: PUBLIC PROC RETURNS [c: CHAR] ~ { RETURN[IO.GetChar[stream]]; }; GetIndex: PUBLIC PROC RETURNS [INT] ~ { RETURN[IO.GetIndex[stream]]; }; PutF: PUBLIC PROC [format: Rope.ROPE _ NIL, v1, v2, v3, v4, v5: IO.Value _ [null[]]] ~ { IO.PutF[stream, format, v1, v2, v3, v4, v5]; }; PutBlock: PUBLIC PROC [block: REF READONLY TEXT, startIndex: NAT _ 0, count: NAT _ NAT.LAST] ~ { IO.PutBlock[stream, block, startIndex, count]; }; tc: TiogaAccess.TiogaChar; tcFormat: ATOM _ NIL; pl: Atom.PropList; LooksFromLooksChars: PROC [lookChars: Rope.ROPE] RETURNS [l: TiogaAccess.Looks _ ALL[FALSE]] ~ { FOR j: INT IN [0..Rope.Length[lookChars]) DO l[Rope.Fetch[lookChars, j]] _ TRUE; ENDLOOP; }; tiogaOutputFN: Rope.ROPE; writer: TiogaAccess.Writer; OpenTiogaOutput: PUBLIC PROC [fileName: Rope.ROPE] ~ { tiogaOutputFN _ fileName; writer _ TiogaAccess.Create[]; tc _ [comment: FALSE, charSet: 0, char: 0C, format: NIL, looks: ALL[FALSE], endOfNode: FALSE, deltaLevel: 0]; }; WriteTiogaOutputFile: PUBLIC PROC ~ { IF tc.char=0C THEN ERROR; --A TiogaDeltaLevel[] should have been last thing done-- TiogaAccess.Put[writer, tc]; TiogaAccess.WriteFile[writer, tiogaOutputFN]; }; WriteTiogaRope: PUBLIC PROC [rope: Rope.ROPE, lookChars: Rope.ROPE _ "", comment: BOOL _ FALSE] ~ { looks: TiogaAccess.Looks = LooksFromLooksChars[lookChars]; IF tc.char#0C THEN TiogaAccess.Put[writer, tc]; tc.char _ 0C; tc.comment _ comment; tc.looks _ looks; tc.deltaLevel _ 0; tc.format _ NIL; tc.endOfNode _ FALSE; tc.propList _ NIL; FOR i: INT IN [0..Rope.Length[rope]) DO IF tc.char#0C THEN TiogaAccess.Put[writer, tc]; tc.char _ Rope.Fetch[rope, i]; ENDLOOP; }; TiogaDeltaLevel: PUBLIC PROC [d: INT] ~ { IF tc.char=0C THEN RETURN; --hack hack-- tc.propList _ pl; tc.format _ tcFormat; pl _ NIL; tcFormat _ NIL; tc.deltaLevel _ d; tc.endOfNode _ TRUE; IF tc.char#'\n THEN ERROR; --Tioga nodes should all end in newlines-- }; WriteTiogaProp: PUBLIC PROC [prop: ATOM, value: Rope.ROPE] ~ { pl _ Atom.PutPropOnList[pl, prop, TiogaAccess.GetInternalProp[prop, value]]; }; WriteTiogaFormat: PUBLIC PROC [format: ATOM] ~ { tcFormat _ format; }; END. *ISMessageImpl.mesa Copyright c 1985 by Xerox Corporation. All rights reserved. MKaplan, September 10, 1985 2:36:14 am PDT Write the chars in the rope to tioga output file. Don't write last char, in case next char starts a new node (so properties have to be added to last byte of rope) Set deltaLevel for current TiogaChar, and terminate node No need to write out: will get done on next call to WriteTiogaRope, or before writing to file. Save prop. on plist, to be added to last TiogaChar of this node when deltaLevel given in TiogaDeltaLevel ΚG˜šœ™Icodešœ Οmœ1™Kš‘h™hKšœL˜LK˜—K˜š œžœžœ žœ˜0K˜K˜—K˜—Kšžœ˜—…— ΪK