DIRECTORY Atom USING [MakeAtom], PFS USING [PathFromRope], Rope USING [IsEmpty, ROPE], TextEdit USING [ChangeLooks, ChangeStyle, PutFormat, ReplaceByRope], TextNode USING [LastChild, NewTextNode, Root], Tioga USING [Looks, noLooks, Node, NodeRep], TiogaFileOps, TiogaIO USING [ToFile]; TiogaFileOpsImpl: CEDAR PROGRAM IMPORTS Atom, PFS, Rope, TextEdit, TextNode, TiogaIO EXPORTS TiogaFileOps = BEGIN OPEN TiogaFileOps; Ref: TYPE = Tioga.Node; -- points to a Tioga node NodeBody: PUBLIC TYPE = Tioga.NodeRep; CreateRoot: PUBLIC PROC RETURNS [root: Ref] = { root ¬ TextNode.NewTextNode[]; }; InsertNode: PUBLIC PROC [x: Ref, child: BOOL ¬ FALSE] RETURNS [new: Ref] = { new ¬ TextNode.NewTextNode[]; IF child THEN { new.next ¬ x.child; x.child ¬ new; new.parent ¬ x } ELSE { new.next ¬ x.next; x.next ¬ new; new.parent ¬ x.parent }; }; InsertAsLastChild: PUBLIC PROC [x: Ref, prevLast: Ref ¬ NIL] RETURNS [new: Ref] = { IF NOT(prevLast#NIL AND prevLast.next=NIL AND prevLast.parent=x) THEN prevLast ¬ TextNode.LastChild[x]; new ¬ IF prevLast=NIL THEN InsertNode[x, TRUE] ELSE InsertNode[prevLast, FALSE]; }; SetContents: PUBLIC PROC [x: Ref, txt: Rope.ROPE] = { [] ¬ TextEdit.ReplaceByRope[root: TextNode.Root[x], dest: x, rope: txt]; }; AddLooks: PUBLIC PROC [x: Ref, start, len: INT, look: CHAR ['a..'z], root: Ref ¬ NIL] = { looks: Tioga.Looks ¬ Tioga.noLooks; looks[look] ¬ TRUE; IF root = NIL THEN root ¬ TextNode.Root[x]; TextEdit.ChangeLooks[root: root, text: x, add: looks, start: start, len: len]; }; SetFormat: PUBLIC PROC [x: Ref, format: Rope.ROPE] = { name: ATOM ¬ IF format.IsEmpty THEN NIL ELSE Atom.MakeAtom[format]; TextEdit.PutFormat[x, name]; }; SetStyle: PUBLIC PROC [x: Ref, style: Rope.ROPE] = { TextEdit.ChangeStyle[x, style] }; Store: PUBLIC PROC [x: Ref, filename: Rope.ROPE] = { [] ¬ TiogaIO.ToFile[PFS.PathFromRope[filename], x]; }; END. Ϊ TiogaFileOpsImpl.mesa Copyright Σ 1985, 1991, 1992 by Xerox Corporation. All rights reserved. written by Bill Paxton, June 1982 last written by Paxton. September 22, 1982 1:19 pm Last Edited by: Maxwell, January 6, 1983 11:48 am Rick Beach, March 28, 1985 10:02:14 am PST Michael Plass, March 27, 1985 5:06:37 pm PST Doug Wyatt, December 23, 1991 5:37 pm PST -- if ~child then new is sibling of x -- else new is first child of x -- prevLast is optional accelerator Κ–(cedarcode) style•NewlineDelimiter ™codešœ™Kšœ Οeœ<™HKšœ!™!Kšœ2™2K™1K™*K™,K™)K™—šΟk ˜ Kšœžœ ˜Kšžœžœ˜Kšœžœ žœ˜Kšœ žœ6˜DKšœ žœ ˜.Kšœžœ!˜,Kšœ ˜ Kšœžœ ˜—K˜KšΟnœžœž˜Kšžœžœ#˜4Kšžœ ˜Kšœžœžœ˜˜KšœžœΟc˜1Kšœ žœžœ˜&K˜šŸ œžœžœžœ˜/K˜Kšœ˜K˜—š Ÿ œžœžœžœžœžœ˜LKš %™%Kš ™K˜šžœ˜Kšžœ6˜:Kšžœ<˜@—Kšœ˜K˜—š Ÿœžœžœžœžœ˜SKš #™#š žœžœ žœžœžœžœ˜@Kšžœ"˜&—šœžœ ž˜Kšžœžœ˜Kšžœžœ˜!—Kšœ˜K˜—šŸ œžœžœžœ˜5K˜HKšœ˜—K˜š Ÿœžœžœžœžœžœ˜YK˜#Kšœžœ˜Kšžœžœžœ˜+K˜NK˜K˜—šŸ œžœžœžœ˜6Kš œžœžœžœžœžœ˜CK˜K˜K˜—KšŸœžœžœžœ'˜VK˜šŸœžœžœžœ˜4Kšœžœ˜3Kšœ˜——K˜Kšžœ˜—…—R C