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
Last Edited by: Jacobi, December 19, 1984 6:27:55 pm PST
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.