diff --git a/harbour/source/debug/dbgmenu.prg b/harbour/source/debug/dbgmenu.prg index e6f68a2b83..a43b284a3a 100644 --- a/harbour/source/debug/dbgmenu.prg +++ b/harbour/source/debug/dbgmenu.prg @@ -47,6 +47,7 @@ function __dbgBuildMenu( oDebugger ) // Builds the debugger pulldown menu local oMenu local oLineNumbers + local oCaseSensitive MENU oMenu MENUITEM " ~File " @@ -60,12 +61,13 @@ function __dbgBuildMenu( oDebugger ) // Builds the debugger pulldown menu MENUITEM " ~Locate " MENU - MENUITEM " ~Find" ACTION Alert( "Not implemented yet!" ) - MENUITEM " ~Next" ACTION Alert( "Not implemented yet!" ) - MENUITEM " ~Previous" ACTION Alert( "Not implemented yet!" ) - MENUITEM " ~Goto line..." ACTION Alert( "Not implemented yet!" ) + MENUITEM " ~Find" ACTION oDebugger:Locate() + MENUITEM " ~Next" ACTION oDebugger:FindNext() + MENUITEM " ~Previous" ACTION oDebugger:FindPrevious() + MENUITEM " ~Goto line..." ACTION oDebugger:SearchLine() SEPARATOR - MENUITEM " ~Case sensitive " ACTION Alert( "Not implemented yet!" ) + MENUITEM oCaseSensitive PROMPT " ~Case sensitive " ; + ACTION ( oDebugger:ToggleCaseSensitive(), oCaseSensitive:Toggle() ) ENDMENU MENUITEM " ~View " diff --git a/harbour/source/debug/debugger.prg b/harbour/source/debug/debugger.prg index a3884669ad..cf2207cd61 100644 --- a/harbour/source/debug/debugger.prg +++ b/harbour/source/debug/debugger.prg @@ -135,6 +135,8 @@ CLASS TDebugger DATA lGo DATA cClrDialog DATA aColors + DATA lCaseSensitive + DATA cSearchString METHOD New() METHOD Activate( cModuleName ) @@ -166,6 +168,11 @@ CLASS TDebugger METHOD ViewSets() METHOD WndVarsLButtonDown( nMRow, nMCol ) METHOD LineNumbers() // Toggles numbering of source code lines + METHOD Locate() + METHOD FindNext() + METHOD FindPrevious() + METHOD SearchLine() + METHOD ToggleCaseSensitive() INLINE ::lCaseSensitive := !::lCaseSensitive ENDCLASS @@ -194,6 +201,8 @@ METHOD New() CLASS TDebugger ::aCallStack := {} ::lGo := .f. ::aVars := {} + ::lCaseSensitive := .f. + ::cSearchString := "" return Self @@ -1032,6 +1041,65 @@ METHOD LineNumbers() CLASS TDebugger return Self +METHOD Locate( nMode ) CLASS TDebugger + + local cValue + + DEFAULT nMode TO 0 + + cValue := ::InputBox( "Search string", ::cSearchString ) + + if empty( cValue ) + return nil + endif + + ::cSearchString := cValue + +return ::oBrwText:Search( ::cSearchString, ::lCaseSensitive, 0 ) + +METHOD FindNext() CLASS TDebugger + + local lFound + + if Empty( ::cSearchString ) + lFound := ::Locate( 1 ) + else + lFound := ::oBrwText:Search( ::cSearchString, ::lCaseSensitive, 1 ) + endif + +return lFound + +METHOD FindPrevious() CLASS TDebugger + + local lFound + + if Empty( ::cSearchString ) + lFound := ::Locate( 2 ) + else + lFound := ::oBrwText:Search( ::cSearchString, ::lCaseSensitive, 2 ) + endif + +return lFound + +METHOD SearchLine() CLASS TDebugger + + local cLine + + cLine := ::InputBox( "Line number", "1" ) + + if Val( cLine ) > 0 + ::oBrwText:GotoLine ( Val( cLine ) ) + endif + +return nil + +METHOD CaseSensitive() CLASS TDebugger + + ::lCaseSensitive := !::lCaseSensitive + +return nil + + function __DbgColors() return s_oDebugger:aColors \ No newline at end of file diff --git a/harbour/source/debug/tbrwtext.prg b/harbour/source/debug/tbrwtext.prg index b9b9a7fb8b..cc187d8f40 100644 --- a/harbour/source/debug/tbrwtext.prg +++ b/harbour/source/debug/tbrwtext.prg @@ -74,6 +74,8 @@ CLASS TBrwText FROM TEditor METHOD ToggleBreakPoint(nRow, lSet) // if lSet is .T. there is a BreakPoint active at nRow, // if lSet is .F. BreakPoint at nRow has to be removed + METHOD Search( cString, lCaseSensitive, nMode ) // 0 from Begining to end, 1 Forward, 2 Backwards + ENDCLASS @@ -219,3 +221,42 @@ METHOD ToggleBreakPoint(nRow, lSet) CLASS TBrwText return Self +METHOD Search( cString, lCaseSensitive, nMode ) CLASS TBrwText + + local nFrom, nTo, nStep, nFor + local lFound + + DEFAULT lCaseSensitive TO .f., ; + nMode TO 0 + + lFound := .f. + + if !lCaseSensitive + cString := Upper( cString ) + endif + + do case + case nMode == 0 // From Top + nFrom := 1 + nTo := ::naTextLen + nStep := 1 + case nMode == 1 // Forward + nFrom := Min( ::nRow + 1, ::naTextLen ) + nTo := ::naTextLen + nStep := 1 + case nMode == 2 // Forward + nFrom := Max( ::nRow - 1, 1 ) + nTo := 1 + nStep := -1 + end case + + for nFor := nFrom to nTo Step nStep + if cString $ iif( lCaseSensitive, ::GetLine( nFor ), Upper( ::GetLine( nFor ) ) ) + lFound := .t. + ::GotoLine( nFor ) + exit + endif + next + +return lFound +