ImplErrorsImpl.mesa
Copyright © 1982, 1983, 1984 Xerox Corporation. All rights reserved.
Last Edited by McGregor, November 8, 1982 1:33 pm
Last Edited by: Maxwell, January 3, 1983 12:56 pm
Last Edited by: Paul Rovner, June 16, 1983 8:51 am
Doug Wyatt, September 4, 1984 2:59:00 pm PDT
DIRECTORY
ClassIncreek USING [Increek],
Cursors USING [CursorType, SetCursor],
Imager USING [black, Context, MaskRectangleI, SetColor, SetXYI, ShowRope, white],
ImagerDisplay USING [CreateLF],
ImplErrors USING [Severity],
InputFocus USING [EnableInput, focusTIP],
Interminal USING [terminal],
KeyboardFace USING [DownUp],
MessageWindow USING [Append, Blink, messageWindow],
Process USING [GetPriority, MsecToTicks, Pause, Priority, priorityForeground, SetPriority],
Rope USING [ROPE],
TIPUser USING [DiscardTypeAhead],
UserProfile USING [Boolean, CallWhenProfileChanges, ProfileChangedProc],
Terminal USING [BlinkBWDisplay, GetKeys],
ViewerClasses USING [Viewer],
ViewerOps USING [EnumerateViewers, EnumProc, PaintViewer, SaveAllEdits],
WindowManager USING [RestoreCursor];
ImplErrorsImpl: CEDAR MONITOR
IMPORTS Cursors, Imager, ImagerDisplay, InputFocus, Interminal, MessageWindow, Process, TIPUser, UserProfile, Terminal, ViewerOps, WindowManager
EXPORTS ImplErrors
SHARES InputFocus, MessageWindow, TIPUser
= BEGIN
Error: PUBLIC SIGNAL [severity: ImplErrors.Severity ← fatal, msg: Rope.ROPE ← NIL] = CODE;
UserErrorQuery:
PUBLIC
ENTRY
PROC
RETURNS [continue:
BOOL] =
TRUSTED BEGIN
try to flush current TIP notification to client
only use low-level interfaces to avoid monitors and potentially broken code
ENABLE UNWIND => NULL;
v: ViewerClasses.Viewer ~ MessageWindow.messageWindow;
oldPriority: Process.Priority = Process.GetPriority[];
context: Imager.Context;
IF ~worldSwapDebug THEN RETURN[FALSE];
Process.SetPriority[Process.priorityForeground];
TIPUser.DiscardTypeAhead[InputFocus.focusTIP];
context ← ImagerDisplay.CreateLF[];
Imager.SetColor[context, Imager.white];
Imager.MaskRectangleI[context, v.cx, v.cy, v.cw, v.ch];
Imager.SetColor[context, Imager.black];
Imager.SetXYI[context, v.cx+2, v.cy+2];
THROUGH [0..3)
DO
Interminal.terminal.BlinkBWDisplay[];
Process.Pause[Process.MsecToTicks[100]];
ENDLOOP;
Imager.ShowRope[context,
" Uncaught Signal! Red: Proceed, Yellow: Save edits then rollback, Blue: Reject."];
WHILE Interminal.terminal.GetKeys[][Red] = down
OR Interminal.terminal.GetKeys[][Yellow] = down
OR Interminal.terminal.GetKeys[][Blue] = down
DO
ENDLOOP; -- spin until buttons go up
Cursors.SetCursor[questionMark];
DO
IF Interminal.terminal.GetKeys[][Red] = down
THEN {
continue ← TRUE;
MessageWindow.Append["Pressing on in spite of crash! Maybe you should boot.", TRUE];
EXIT}
ELSE
IF Interminal.terminal.GetKeys[][Yellow] = down
THEN {
continue ← TRUE;
Cursors.SetCursor[hourGlass];
ViewerOps.SaveAllEdits[! ANY => CONTINUE];
Cursors.SetCursor[retry];
--ViewersSnapshot.RollBack[! ANY => CONTINUE]; usually no return
MessageWindow.Append["Rollback failed! Maybe you should boot.", TRUE];
ViewerOps.EnumerateViewers[Paint]; -- update headers of saved viewers
EXIT}
ELSE IF Interminal.terminal.GetKeys[][Blue] = down THEN {continue ← FALSE; EXIT};
ENDLOOP;
InputFocus.EnableInput[];
Process.SetPriority[oldPriority];
IF NOT continue THEN RETURN;
WindowManager.RestoreCursor[];
MessageWindow.Blink[];
END;
Paint: ViewerOps.EnumProc =
BEGIN
IF v.column#static THEN ViewerOps.PaintViewer[v, caption ! ANY => CONTINUE];
RETURN[TRUE];
END;
worldSwapDebug: BOOL;
Init: UserProfile.ProfileChangedProc =
CHECKED
{worldSwapDebug ← UserProfile.Boolean["WorldSwapDebug", FALSE]};
UserProfile.CallWhenProfileChanges[Init];
END.