File: GGErrorImpl.mesa
Last edited by: Eric Bier on August 6, 1986 11:42:16 pm PDT
Contents: Routines for handling user error messages throughout Gargoyle.
Pier, October 24, 1986 2:00:58 pm PDT
DIRECTORY
BasicTime, GGError, IO, Labels, Process, Rope, ViewerClasses, ViewerIO, ViewerOps;
GGErrorImpl: CEDAR PROGRAM
IMPORTS BasicTime, IO, Labels, Process, Rope, ViewerIO, ViewerOps
EXPORTS GGError = BEGIN
Problem: PUBLIC SIGNAL [msg: Rope.ROPE] = CODE;
MsgType: TYPE = GGError.MsgType;
Viewer: TYPE = ViewerClasses.Viewer;
gViewer: Viewer;-- there is now one global typescript managed by GGError
gStream: IO.STREAM; -- there is now one global typescript managed by GGError
typeAll: BOOLFALSE;
GetTypescriptStream: PUBLIC PROC RETURNS [IO.STREAM] = {
RETURN[gStream];
};
OpenTypescript: PUBLIC PROC [feedback: Viewer] = {
there is now one global typescript managed by GGError
IF gStream=NIL OR gViewer.destroyed THEN {
gViewer ← ViewerOps.CreateViewer[
flavor: $TypeScript,
info: [name: "Gargoyle TypeScript", menu: NIL, data: NIL, iconic: TRUE, column: right, scrollable: TRUE, icon: unInit], paint: FALSE];
ViewerOps.SetOpenHeight[gViewer, 120];
ViewerOps.OpenIcon[icon: gViewer, closeOthers: FALSE, bottom: TRUE, paint: TRUE];
[, gStream] ← ViewerIO.CreateViewerStreams["Gargoyle TypeScript", gViewer, NIL, TRUE];
IF feedback#NIL THEN PutF[feedback, oneLiner, "Gargoyle Typescript of %t", [time[BasicTime.Now[]]] ];
}
ELSE IF feedback#NIL THEN Append[feedback, "Gargoyle Typescript already exists", oneLiner];
};
Append: PUBLIC PROC [feedback: Viewer, msg: Rope.ROPE, msgType: MsgType] = {
AppendHerald[feedback, msg, msgType];
AppendTypescript[feedback, msg, msgType];
};
AppendHerald: PUBLIC PROC [feedback: Viewer, msg: Rope.ROPE, msgType: MsgType] = {
clearHerald: BOOL ← msgType = oneLiner OR msgType = begin;
addCR: BOOL ← msgType = oneLiner OR msgType = end;
IF feedback#NIL THEN { -- If the feedback region has been created.
oldRope: Rope.ROPENARROW[feedback.class.get[feedback]];
IF Rope.Equal[msg, oldRope, FALSE] THEN RETURN; -- don't repeat messages
IF clearHerald THEN Labels.Set[feedback, msg] ELSE Labels.Set[feedback, Rope.Concat[oldRope, msg]];
};
IF typeAll THEN AppendTypescript[feedback, msg, msgType];
};
AppendTypescript: PUBLIC PROC [feedback: Viewer, msg: Rope.ROPE, msgType: MsgType] = {
clearHerald: BOOL ← msgType = oneLiner OR msgType = begin;
addCR: BOOL ← msgType = oneLiner OR msgType = end;
IF gStream#NIL THEN { -- there is (was) a typescript
ENABLE IO.Error => {
IF ec#StreamClosed THEN {
IF feedback#NIL THEN {
Append[feedback, ". . . Serious typescript IO Error", oneLiner];
Blink[feedback];
};
};
gStream ← NIL; -- stream got closed; probably user destroyed viewer
CONTINUE;
};
gStream.PutF[msg]; -- try writing to typescript
IF addCR THEN gStream.PutChar[IO.CR];
};
};
ClearHerald: PUBLIC PROC [feedback: Viewer] = {
Remove any messages from the herald.
IF feedback#NIL THEN Labels.Set[feedback, ""];
};
PutF: PUBLIC PROC [feedback: Viewer, msgType: MsgType, format: Rope.ROPENIL, v1, v2, v3, v4, v5: IO.Value ← [null[]] ] = {
msg: Rope.ROPEIO.PutFR[format, v1, v2, v3, v4, v5];
Append[feedback, msg, msgType];
};
PutFHerald: PUBLIC PROC [feedback: Viewer, msgType: MsgType, format: Rope.ROPENIL, v1, v2, v3, v4, v5: IO.Value ← [null[]] ] = {
msg: Rope.ROPEIO.PutFR[format, v1, v2, v3, v4, v5];
AppendHerald[feedback, msg, msgType];
};
PutFTypescript: PUBLIC PROC [feedback: Viewer, msgType: MsgType, format: Rope.ROPENIL, v1, v2, v3, v4, v5: IO.Value ← [null[]] ] = {
msg: Rope.ROPEIO.PutFR[format, v1, v2, v3, v4, v5];
AppendTypescript[feedback, msg, msgType];
};
Blink: PUBLIC PROC [feedback: Viewer] = {
IF feedback#NIL THEN {
Labels.SetDisplayStyle[feedback, $WhiteOnBlack];
Process.Pause[Process.MsecToTicks[150]];
Labels.SetDisplayStyle[feedback, $BlackOnWhite];
Process.Pause[Process.MsecToTicks[150]];
Labels.SetDisplayStyle[feedback, $WhiteOnBlack];
Process.Pause[Process.MsecToTicks[150]];
Labels.SetDisplayStyle[feedback, $BlackOnWhite];
Process.Pause[Process.MsecToTicks[150]];
Labels.SetDisplayStyle[feedback, $WhiteOnBlack];
Process.Pause[Process.MsecToTicks[150]];
Labels.SetDisplayStyle[feedback, $BlackOnWhite];
};
};
END.