<> <> <> <> <> DIRECTORY TileSetExpressions, IO USING [RIS], CD USING [Design], ExprRead USING [ReadStream], Rope USING [ROPE, Cat], CDRopeViewer USING [Edit, SaveProc], CDMenus USING [CreateEntry], SymTab USING [Ref], TerminalIO USING [WriteRope], CDProperties USING [GetProp, PutProp, RegisterProperty], CDSequencer USING [Command, ImplementCommand]; TileSetExpressionsImpl: CEDAR PROGRAM IMPORTS CDRopeViewer, CDMenus, IO, ExprRead, TerminalIO, CDSequencer, CDProperties, Rope EXPORTS TileSetExpressions = BEGIN OPEN TileSetExpressions; Error: PUBLIC ERROR[ec: ErrorCode, msg: Rope.ROPE] = CODE; ourProp: ATOM ~ $TileSetExpressions; PutRope: PROC [design: CD.Design, val: Rope.ROPE] = BEGIN CDProperties.PutProp[design, ourProp, val]; END; GetRope: PROC [design: CD.Design] RETURNS [Rope.ROPE] = BEGIN ref: REF ANY _ CDProperties.GetProp[design, ourProp]; IF ref = NIL THEN RETURN[NIL]; WITH ref SELECT FROM r: Rope.ROPE => RETURN[r]; ENDCASE => ERROR Error[PropNotRope, "TileSetExpression property is not a rope!"]; END; <<-- return a symbol table containing the parameters set by the tile set>> GetParams: PUBLIC PROC [design: CD.Design] RETURNS [SymTab.Ref] = BEGIN symTab: SymTab.Ref _ NIL; rope: Rope.ROPE _ GetRope[design]; IF rope # NIL THEN { symTab _ ExprRead.ReadStream[IO.RIS[rope]]; }; RETURN[symTab]; END; <<-- let the user edit the expressions using a tioga viewer>> Edit: PUBLIC PROC [design: CD.Design] = BEGIN caption: Rope.ROPE _ Rope.Cat["Tile Set Expressions for", design.name]; text: Rope.ROPE _ GetRope[design]; Save: CDRopeViewer.SaveProc = { IF ~discard THEN text _ contents }; CDRopeViewer.Edit[contents: text, caption: caption, fork: FALSE, save: Save]; PutRope[design, text]; END; EditExpressions: PROC [comm: CDSequencer.Command] = BEGIN TerminalIO.WriteRope["Edit tile set expressions....\n"]; Edit[comm.design]; TerminalIO.WriteRope["....tile set expressions stored.\n"]; END; [] _ CDProperties.RegisterProperty[ourProp, $AtomAntStrikesAgain]; CDSequencer.ImplementCommand[$EditExpressions, EditExpressions]; CDMenus.CreateEntry[$ProgramMenu, "Tile Set Expressions", $EditExpressions]; END.