From ff7a78c1fbc06e15e82a53bdd5f73c7f5778c12c Mon Sep 17 00:00:00 2001 From: Antonio Linares Date: Tue, 9 Jul 2002 08:54:31 +0000 Subject: [PATCH] Command window support for HELP and ?? commands --- harbour/source/debug/debugger.prg | 97 ++++++++++++++++++++++++++----- 1 file changed, 81 insertions(+), 16 deletions(-) diff --git a/harbour/source/debug/debugger.prg b/harbour/source/debug/debugger.prg index f0509b668a..12ccedcd2d 100644 --- a/harbour/source/debug/debugger.prg +++ b/harbour/source/debug/debugger.prg @@ -242,7 +242,8 @@ CLASS TDebugger METHOD HandleEvent() METHOD Hide() METHOD HideVars() - METHOD InputBox( cMsg, uValue, bValid ) + METHOD InputBox( cMsg, uValue, bValid, lEditable ) + METHOD Inspect( uValue, cValueName ) METHOD IsBreakPoint( nLine ) METHOD LoadSettings() METHOD LoadVars() @@ -269,7 +270,7 @@ CLASS TDebugger METHOD ShowAppScreen() METHOD ShowCallStack() METHOD ShowCode( cModuleName ) - METHOD ShowHelp( nTopic ) INLINE __dbgHelp( nTopic ) + METHOD ShowHelp( nTopic ) METHOD ShowVars() /* METHOD Sort() INLINE ASort( ::aVars,,, {|x,y| x[1] < y[1] } ),; @@ -336,8 +337,8 @@ METHOD New() CLASS TDebugger ::lShowLocals := .f. ::lAll := .f. ::lSortVars := .f. - ::cSettingsFileName := "init.cld" + if File( ::cSettingsFileName ) ::LoadSettings() endif @@ -567,13 +568,21 @@ METHOD CommandWindowProcessKey( nKey ) CLASS TDebugger case Empty( cCommand ) lDisplay = .f. + case SubStr( LTrim( cCommand ), 1, 3 ) == "?? " + begin sequence + ::Inspect( AllTrim( SubStr( LTrim( cCommand ), 4 ) ),; + &( AllTrim( SubStr( LTrim( cCommand ), 4 ) ) ) ) + lDisplay = .f. + recover using oE + cResult = "Command error: " + oE:description + lDisplay = .t. + end sequence + case SubStr( LTrim( cCommand ), 1, 2 ) == "? " begin sequence cResult = ValToStr( &( AllTrim( SubStr( LTrim( cCommand ), 3 ) ) ) ) - recover using oE cResult = "Command error: " + oE:description - end sequence lDisplay = .t. @@ -582,6 +591,10 @@ METHOD CommandWindowProcessKey( nKey ) CLASS TDebugger SetCursor( SC_NORMAL ) lDisplay = .f. + case Upper( SubStr( LTrim( cCommand ), 1, 4 ) ) == "HELP" + ::ShowHelp() + lDisplay = .f. + case Upper( SubStr( LTrim( cCommand ), 1, 4 ) ) == "QUIT" ::Exit() ::Hide() @@ -770,7 +783,7 @@ return nil METHOD HandleEvent() CLASS TDebugger - local nPopup, oWnd + local nPopup, oWnd, nCursor local nKey, nMRow, nMCol, n if ::lAnimate @@ -799,6 +812,7 @@ METHOD HandleEvent() CLASS TDebugger ::oPullDown:ProcessKey( nKey ) if ::oPullDown:nOpenPopup == 0 // Closed ::aWindows[ ::nCurrentWindow ]:SetFocus( .t. ) + SetCursor( nCursor ) endif case nKey == K_LDBLCLK @@ -895,7 +909,7 @@ METHOD HandleEvent() CLASS TDebugger otherwise if ( nPopup := ::oPullDown:GetHotKeyPos( __dbgAltToKey( nKey ) ) ) != 0 if ::oPullDown:nOpenPopup != nPopup - SetCursor( SC_NONE ) + nCursor = SetCursor( SC_NONE ) ::oPullDown:ShowPopup( nPopup ) endif endif @@ -1139,6 +1153,15 @@ METHOD LoadVars() CLASS TDebugger // updates monitored variables return nil +METHOD ShowHelp( nTopic ) CLASS TDebugger + + local nCursor := SetCursor( SC_NONE ) + + __dbgHelp( nTopic ) + SetCursor( nCursor ) + +return nil + METHOD ShowVars() CLASS TDebugger local n @@ -1363,32 +1386,69 @@ METHOD HideVars() CLASS TDebugger return nil -METHOD InputBox( cMsg, uValue, bValid ) CLASS TDebugger +METHOD InputBox( cMsg, uValue, bValid, lEditable ) CLASS TDebugger - local nTop := ( MaxRow() / 2 ) - 5 + local nTop := ( MaxRow() / 2 ) - 8 local nLeft := ( MaxCol() / 2 ) - 25 - local nBottom := ( MaxRow() / 2 ) - 3 + local nBottom := ( MaxRow() / 2 ) - 6 local nRight := ( MaxCol() / 2 ) + 25 local cType := ValType( uValue ) local uTemp := PadR( uValue, nRight - nLeft - 1 ) local GetList := {} local nOldCursor local lScoreBoard := Set( _SET_SCOREBOARD, .f. ) + local lExit local oWndInput := TDbWindow():New( nTop, nLeft, nBottom, nRight, cMsg,; ::oPullDown:cClrPopup ) + DEFAULT lEditable TO .t. + oWndInput:lShadow := .t. oWndInput:Show(.t.) - if bValid == nil - @ nTop + 1, nLeft + 1 GET uTemp COLOR "," + __DbgColors()[ 5 ] + if lEditable + if bValid == nil + @ nTop + 1, nLeft + 1 GET uTemp COLOR "," + __DbgColors()[ 5 ] + else + @ nTop + 1, nLeft + 1 GET uTemp VALID bValid COLOR "," + __DbgColors()[ 5 ] + endif + + nOldCursor := SetCursor( SC_NORMAL ) + READ + SetCursor( nOldCursor ) else - @ nTop + 1, nLeft + 1 GET uTemp VALID bValid COLOR "," + __DbgColors()[ 5 ] + @ nTop + 1, nLeft + 1 SAY ValToStr( uValue ) COLOR __DbgColors()[ 5 ] + SetPos( nTop + 1, nLeft + 1 ) + + nOldCursor := SetCursor( SC_NORMAL ) + lExit = .f. + + while ! lExit + Inkey( 0 ) + + do case + case LastKey() == K_ESC + lExit = .t. + + case LastKey() == K_ENTER + if cType == "A" + __DbgArrays( uValue, cMsg, .f. ) + + elseif cType == "O" + __DbgObject( uValue, cMsg, .f. ) + + else + Alert( "Value cannot be edited" ) + endif + + otherwise + Alert( "Value cannot be edited" ) + endcase + end + + SetCursor( nOldCursor ) endif - nOldCursor := SetCursor( SC_NORMAL ) - READ - SetCursor( nOldCursor ) oWndInput:Hide() Set( _SET_SCOREBOARD, lScoreBoard ) @@ -1406,6 +1466,11 @@ METHOD InputBox( cMsg, uValue, bValid ) CLASS TDebugger return iif( LastKey() != K_ESC, uTemp, uValue ) +METHOD Inspect( uValue, cValueName ) CLASS TDebugger + + uValue = ::InputBox( uValue, cValueName,, .f. ) + +return nil METHOD IsBreakPoint( nLine ) CLASS TDebugger