<> <> <> <> <> DIRECTORY Ascii USING [CR, SP], Convert, CSegDebugDefs, IO, Labels, Menus, PrincOps, RESOut, Rope, ViewerTools; CSegDebugCommands: CEDAR PROGRAM IMPORTS Convert, CSegDebugDefs, IO, Labels, RESOut, Rope, ViewerTools EXPORTS CSegDebugDefs, RESOut = BEGIN OPEN CSegDebugDefs; cancelAction: PUBLIC ERROR [endLine: BOOLEAN _ FALSE] = CODE; DoCommand: PUBLIC PROC [handle: Handle, cmd: CmdIndex, button: Menus.MouseButton] = { ENABLE RESOut.cancelAction => GO TO dont; Complain[h: handle, msg: NIL, abort: FALSE]; handle.stopFlag _ FALSE; SELECT cmd FROM wpc => IF button = red THEN { i: INT = GetLongSelectionValue[handle]; IF ~(i IN [0..CARDINAL.LAST/2]) THEN RESOut.Complain[h: handle, msg: "not a valid wpc"]; ViewerTools.SetContents [ handle.cmd.bpcVal, Convert.RopeFromInt[from: 2*i, base: 8, showRadix: TRUE]]}; gfi => IF button = red THEN { i: INT = GetLongSelectionValue[handle]; IF ~(i IN [1..PrincOps.GFTIndex.LAST]) THEN RESOut.Complain[h: handle, msg: "not a valid gfi"]; TRUSTED { gfti: PrincOps.GFTItem _ PrincOps.GFT[i]; gfti.epbias _ 0; ViewerTools.SetContents [ handle.cmd.gfVal, Convert.RopeFromInt[from: LOOPHOLE[gfti, CARDINAL], base: 8, showRadix: TRUE]]}}; pd => {PutAsProcDesc[handle, GetSelectionValue[handle]]}; find => { found: BOOLEAN _ FALSE; found _ Search[handle ! RESOut.cancelAction => CONTINUE]; IF found OR handle.autoNext^ THEN { handle.bytesShown _ handle.bytesSeen; DoNext[handle]}}; code => { PutAsCode[handle ! RESOut.cancelAction => CONTINUE]; IF handle.autoNext^ THEN DoNext[handle]}; octal => { PutAsOctal[handle ! RESOut.cancelAction => CONTINUE]; IF handle.autoNext^ THEN DoNext[handle]}; bytes => { PutAsBytes[handle ! RESOut.cancelAction => CONTINUE]; IF handle.autoNext^ THEN DoNext[handle]}; ascii => { PutAsAscii[handle ! RESOut.cancelAction => CONTINUE]; IF handle.autoNext^ THEN DoNext[handle]}; findEp => FindEP[handle, GetSelectionValue[handle]]; goLf => GoToLf[handle, GetSelectionValue[handle]]; dspLf => DspLf[handle, GetSelectionValue[handle]]; numMop => MopToRope[handle, GetSelectionValue[handle]]; mopNum => RopeToMop[handle, ViewerTools.GetSelectionContents[]]; prefix => DisplayPrefix[handle]; next => DoNext[handle]; back => BackupPc[handle]; link => PutLink[handle, GetSelectionValue[handle]]; evi => PutEntryItem[handle, GetSelectionValue[handle]]; ENDCASE; EXITS dont => RETURN; }; DoNext: PROC [handle: Handle] = BEGIN bytePC: CARDINAL _ CSegDebugDefs.CellCard[handle, handle.cmd.bpcVal]; bytePC _ bytePC + handle.bytesShown; handle.bytesShown _ 0; ViewerTools.SetContents [ handle.cmd.bpcVal, Convert.RopeFromInt[from: bytePC, base: 8, showRadix: TRUE]]; END; RopeToMop: PUBLIC PROC [h: Handle, s: ROPE] = BEGIN OPEN RESOut; inst: BYTE = MopForRope[h, s]; PCr[h]; PRope[h, s]; PRope[h, " = "]; POctal[h, inst]; END; MopToRope: PUBLIC PROC [h: Handle, inst: BYTE] = BEGIN OPEN RESOut; s: ROPE _ RopeForMop[h, inst]; PCr[h]; POctal[h, inst]; PRope[h, " = "]; PRope[h, s]; END; Complain: PUBLIC PROCEDURE [h: REF ANY, msg: ROPE, abort, clear: BOOLEAN _ TRUE] = 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; <> PChar: PUBLIC PROCEDURE [h: REF ANY, c: CHARACTER] = BEGIN handle: Handle = NARROW[h]; IF handle.stopFlag THEN ERROR cancelAction[TRUE]; handle.out.PutChar[c]; handle.charsOnLine _ SELECT c FROM Ascii.CR => 0, ENDCASE => handle.charsOnLine + 1; END; MakeRoom: PUBLIC PROCEDURE [h: REF ANY, chars, indent: CARDINAL] RETURNS [was: BOOLEAN]= BEGIN handle: Handle = NARROW[h]; charsPerLine: CARDINAL = handle.msg.ww/handle.en-3; IF handle.charsOnLine + chars <= charsPerLine THEN RETURN [TRUE]; PChar[h, Ascii.CR]; THROUGH [0..indent) DO PChar[h, Ascii.SP]; ENDLOOP; RETURN[FALSE]; END; END.