File: TileSetExpressionsImpl.mesa
Copyright © 1984 by Xerox Corporation. All rights reserved.
Created by: Bob Mayo, August 5, 1984 8:21:38 pm PDT
Last Edited by: Mayo, August 13, 1984 5:02:51 pm PDT
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.