<> <> <> <> DIRECTORY TileSetExpressions, IO USING [RIS], CD USING [Design], ExprRead USING [ReadStream], Rope USING [ROPE, Cat], RopeViewer USING [Edit], TilerMenu USING [Register], SymTab USING [Ref], TerminalIO USING [WriteRope], CDProperties USING [GetProp, PutProp, RegisterProperty], CDSequencer USING [Command, ImplementCommand]; TileSetExpressionsImpl: CEDAR PROGRAM IMPORTS RopeViewer, IO, ExprRead, TilerMenu, 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; IF design.name = NIL THEN caption _ "Tile Set Expressions" ELSE caption _ Rope.Cat["Tile Set Expressions for ", design.name]; PutRope[design, RopeViewer.Edit[GetRope[design], caption]]; 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]; TilerMenu.Register["Edit Tile Set Expressions", $EditExpressions]; END.