MDebugCommands.mesa
Edited by Bruce, 14-Oct-81 11:06:09
Edited by Sweet, 14-Jan-83 15:48:28
Edited by Haynes, 29-Nov-82 20:27:52
Sweet June 2, 1986 10:28:30 am PDT
DIRECTORY
MDebugDefs USING [
CellCard, ClearCachedFrames, CmdIndex, GetLongSelectionValue, GetSelectionValue,
Handle, PutAsLabelInfoIndex,
PutCurrentBody, PutCurrentExpr,
PutCurrentSource, PutCurrentStmt, PutLabelState],
IO,
Labels USING [Set],
Menus USING [MouseButton],
RESOut USING [],
Rope USING [Concat, ROPE],
STDebugDefs USING [
NextSe, PutAsBti, PutAsCti, PutAsHti, PutAsMdi, PutAsSei, PutAsTree,
PutAsVariousRep],
Symbols USING [ISEIndex, ISENull, SEIndex],
Tree USING [Index],
ViewerTools USING [GetContents];
MDebugCommands: PROGRAM
IMPORTS MDebugDefs, IO, Labels, Rope, STDebugDefs, ViewerTools
EXPORTS MDebugDefs, RESOut, STDebugDefs =
BEGIN OPEN MDebugDefs, STDebugDefs;
ROPE: TYPE = Rope.ROPE;
Handle: TYPE = MDebugDefs.Handle;
cancelAction: PUBLIC ERROR [endLine: BOOLEANFALSE] = CODE;
DoCommand: PUBLIC PROC [h: Handle, cmd: CmdIndex, button: Menus.MouseButton] =
BEGIN
ENABLE cancelAction => GO TO dont;
Complain[h: h, msg: NIL, abort: FALSE];
h.stopFlag ← FALSE;
SELECT cmd FROM
tree => {
index: Tree.Index ← GetSelectionValue[h];
PutAsTree[h, [subtree[index]]]};
lbl => PutLabelState[h];
lii => PutAsLabelInfoIndex[h, GetSelectionValue[h]];
sei => {
sei: Symbols.SEIndex ← GetSelectionValue[h];
IF PutAsSei[h, sei] THEN h.lastId ← LOOPHOLE[sei]};
nextse => {
nsei: Symbols.ISEIndex ← NextSe[h, h.lastId];
IF nsei # Symbols.ISENull THEN {[] ← PutAsSei[h, nsei]; h.lastId ← nsei};
};
hti => PutAsHti[h, GetSelectionValue[h]];
cti => PutAsCti[h, GetSelectionValue[h]];
bti => PutAsBti[h, GetSelectionValue[h]];
mdi => PutAsMdi[h, GetSelectionValue[h]];
rep => PutAsVariousRep[h, GetLongSelectionValue[h]];
body => PutCurrentBody[h];
stmt => PutCurrentStmt[h];
expr => PutCurrentExpr[h];
gFrames => ClearCachedFrames[h];
source => PutCurrentSource[h];
ENDCASE;
EXITS
dont => RETURN;
END;
Things exported to STDebugDefs
TreeDepth: PUBLIC SAFE PROC [h: REF ANY] RETURNS [CARDINAL] = TRUSTED {
han: Handle ← NARROW[h];
RETURN [MDebugDefs.CellCard[han, han.cmd.dVal]]};
ShowLinks: PUBLIC SAFE PROCEDURE [h: REF ANY] RETURNS [BOOL] = TRUSTED {
han: Handle ← NARROW[h];
RETURN[han.showLinks^]};
Complain: PUBLIC SAFE PROCEDURE [h: REF ANY , msg: ROPE, abort, clear: BOOLEANTRUE] =
TRUSTED BEGIN
handle: Handle ← NARROW[h];
IF ~clear THEN msg ← Rope.Concat[ViewerTools.GetContents[handle.msg], msg];
Labels.Set[handle.msg, msg];
IF abort THEN ERROR cancelAction;
END;
log writing procedures
PChar: PUBLIC SAFE PROCEDURE [h: REF ANY , c: CHARACTER] = TRUSTED
BEGIN
handle: Handle = NARROW[h];
IF handle.stopFlag THEN ERROR cancelAction[TRUE];
handle.out.PutChar[c];
handle.charsOnLine ← SELECT c FROM
'\n => 0,
ENDCASE => handle.charsOnLine + 1;
END;
MakeRoom: PUBLIC SAFE PROCEDURE [h: REF ANY , chars, indent: CARDINAL]
RETURNS [was: BOOLEAN] = TRUSTED
BEGIN
handle: Handle = NARROW[h];
charsPerLine: CARDINAL = handle.ts.ww/handle.en-3;
IF handle.charsOnLine + chars <= charsPerLine THEN RETURN [TRUE];
PChar[h, '\n];
THROUGH [0..indent) DO PChar[h, ' ]; ENDLOOP;
RETURN[FALSE];
END;
END.