LocalIagoImpl.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Willie-Sue, February 20, 1986 12:51:40 pm PST
Russ Atkinson (RRA) March 11, 1985 8:38:13 pm PST
DIRECTORY
Commander USING [CommandProc, Register],
BasicTime USING [TimeNotKnown],
EditedStream USING [Rubout],
ExtraIagoOps,
File USING [Error],
FS USING [Error],
IagoOps,
IO,
Loader USING [BCDBuildTime],
Process USING [Detach],
Rope,
ViewerClasses USING [Viewer],
ViewerIO USING [CreateViewerStreams, GetViewerFromStream];
LocalIagoImpl: CEDAR PROGRAM
IMPORTS Commander, BasicTime, EditedStream, ExtraIagoOps, File, FS, IagoOps, IO, Loader, Process, Rope, ViewerIO =
BEGIN OPEN ExtraIagoOps, File;
-- * * * * * * * * commands implementation * * * * * * * *
QuitCommand: PROC [in,out: IO.STREAM] = { ERROR ForceExit };
* * * * * * * Main
Main: PROC = {
in, out: IO.STREAM;
v: ViewerClasses.Viewer;
[in, out] ←
ViewerIO.CreateViewerStreams[name: "LocalIago", backingFile: "///temp/LocalIago.log"];
v← ViewerIO.GetViewerFromStream[in];
v.inhibitDestroy← TRUE;
out.PutF["LocalIago of %g, started at %g",
IO.time[Loader.BCDBuildTime[ExtraIagoOps.GetAddress]], IO.time[]];
out.PutRope["\n\nType \"?\" at any time if you need help.\n"];
DO
ENABLE {
ABORTED => EXIT;
EditedStream.Rubout => { IO.PutRope[out, " XXX"]; LOOP };
};
c: IagoOps.CommandInfo = IagoOps.GetCommand[in: in, out: out, diskReadable: TRUE];
exit, overwritten: BOOL;
[exit, overwritten] ← DoCommand[in, out, c];
IF exit THEN EXIT;
ENDLOOP;
IO.PutRope[out, "\nLeaving LocalIago ...\n"];
v.inhibitDestroy← FALSE;
in.Close[];
out.Close[];
};
DoCommand: PROC [in, out: IO.STREAM, c: IagoOps.CommandInfo] RETURNS [exit: BOOLFALSE, overwritten: BOOLFALSE] = {
ENABLE {
EditedStream.Rubout, IagoOps.Rubout => {
IO.PutRope[out, " XXX"];
GO TO leave
};
File.Error => {
IO.PutRope[out, " ... \n "];
IO.PutRope[out, IagoOps.FileError[why]];
GO TO leave
};
FS.Error => {
IO.PutRope[out, " ... \n "];
IO.PutRope[out,
IF error.explanation.Length[] # 0
THEN error.explanation
ELSE "FS.Error without a message: consult an expert"];
GO TO leave
};
BasicTime.TimeNotKnown => {
IO.PutRope[out, " ... I can't do that without knowing the current time."];
GO TO leave
};
ForceExit => {
exit ← TRUE;
GO TO leave
};
Overwritten => {
overwritten ← TRUE;
GO TO leave
};
};
c.commandProc[in, out];
EXITS leave => {};
};
ForceExit: ERROR = CODE;
Overwritten: ERROR = CODE;
Start: Commander.CommandProc = { TRUSTED {Process.Detach[FORK Main[]] } };
* * * * * * * start code ** register commands with Iago
IagoOps.RegisterCommand[[QuitCommand, "Quit"]];
Commander.Register["LocalIago", Start];
END.