This post is related to this older one:
- Code: Select all Expand view
- http://forums.fivetechsupport.com/viewtopic.php?f=3&t=30429
I had compiled the program you suggested and also this one
- Code: Select all Expand view
- dbgtmenu.prg
I cannot make this last one to compile. I'm going nuts, hehehe, but I need urgently to implement this console menu. Can you take a look and tell me what it is wrong ? I'm compiling with xBuilder to then move forward and buildx it. The error I'm getting is:
- Code: Select all Expand view
- Line 60 Error E0030 Syntax error: "syntax error at 'STATIC'"
Thank you very much !!!
- Code: Select all Expand view
- #pragma -b-
#xcommand MENU [<oMenu>] => [ <oMenu> := ] HBDbMenu():New()
#xcommand MENUITEM [ <oMenuItem> PROMPT ] <cPrompt> ;
[ IDENT <nIdent> ] [ ACTION <uAction,...> ] ;
[ CHECKED <bChecked> ] => ;
[ <oMenuItem> := ] HBDbMenu():AddItem( HBDbMenuItem():New( <cPrompt>,;
[{||<uAction>}], [<bChecked>], [<nIdent>] ) )
#xcommand SEPARATOR => HBDbMenu():AddItem( HBDbMenuItem():New( "-" ) )
#xcommand ENDMENU => ATail( HBDbMenu():aMenus ):Build()
FUNCTION __dbgBuildMenu( oDebugger ) // Builds the debugger pulldown menu
LOCAL oMenu
MENU oMenu
MENUITEM " ~File "
MENU
MENUITEM " ~Open..." ACTION oDebugger:Open()
MENUITEM " ~Resume" ACTION oDebugger:Resume()
MENUITEM " O~S Shell" ACTION oDebugger:OSShell()
SEPARATOR
MENUITEM " e~Xit Alt-X " ACTION oDebugger:Quit()
ENDMENU
MENUITEM " ~Locate "
MENU
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 " IDENT "CASE" ;
ACTION oDebugger:ToggleCaseSensitive() ;
CHECKED oDebugger:lCaseSensitive
ENDMENU
MENUITEM " ~View "
MENU
MENUITEM " ~Sets" ACTION oDebugger:ViewSets()
MENUITEM " ~WorkAreas F6" ACTION oDebugger:ShowWorkAreas()
MENUITEM " ~App Screen F4 " ACTION oDebugger:ShowAppScreen()
SEPARATOR
MENUITEM " ~CallStack" IDENT "CALLSTACK";
ACTION oDebugger:Stack() ;
CHECKED oDebugger:lShowCallStack
ENDMENU
MENUITEM " ~Run "
MENU
MENUITEM " ~Animate" IDENT "ANIMATE" ;
ACTION ( oDebugger:ToggleAnimate(), oDebugger:Animate() ) ;
CHECKED oDebugger:lAnimate
MENUITEM " ~Step F8" ACTION oDebugger:Step()
MENUITEM " ~Trace F10" ACTION oDebugger:Trace()
MENUITEM " ~Go F5" ACTION oDebugger:Go()
MENUITEM " to ~Cursor F7" ACTION oDebugger:ToCursor()
MENUITEM " ~Next routine Ctrl-F5" ACTION oDebugger:NextRoutine()
SEPARATOR
MENUITEM " s~Peed..." ACTION oDebugger:Speed()
ENDMENU
MENUITEM " ~Point "
MENU
MENUITEM " ~Watchpoint..." ACTION oDebugger:WatchPointAdd()
MENUITEM " ~Tracepoint..." ACTION oDebugger:TracePointAdd()
MENUITEM " ~Breakpoint F9 " ACTION oDebugger:ToggleBreakPoint()
MENUITEM " ~Delete..." ACTION oDebugger:WatchPointDel()
ENDMENU
MENUITEM " ~Monitor "
MENU
MENUITEM " ~Public" IDENT "PUBLIC" ;
ACTION oDebugger:Public() ;
CHECKED oDebugger:lShowPublics
MENUITEM " pri~Vate " IDENT "PRIVATE" ;
ACTION oDebugger:Private() ;
CHECKED oDebugger:lShowPrivates
MENUITEM " ~Static" IDENT "STATIC" ;
ACTION oDebugger:Static() ;
CHECKED oDebugger:lShowStatics
MENUITEM " ~Local" IDENT "LOCAL" ;
ACTION oDebugger:Local() ;
CHECKED oDebugger:lShowLocals
MENUITEM " ~Global" IDENT "GLOBAL" ;
ACTION oDebugger:Global() ;
CHECKED oDebugger:lShowGlobals
SEPARATOR
MENUITEM " ~All" IDENT "ALL" ;
ACTION oDebugger:All() ;
CHECKED oDebugger:lAll
MENUITEM " S~how all Globals" IDENT "SHOWALLGLOBALS" ;
ACTION oDebugger:ShowAllGlobals() ;
CHECKED oDebugger:lShowAllGlobals
MENUITEM " s~Ort" ACTION oDebugger:Sort()
ENDMENU
MENUITEM " ~Options "
MENU
MENUITEM " ~Preprocessed Code" IDENT "PPO" ;
ACTION oDebugger:OpenPPO() ;
CHECKED oDebugger:lPPO
MENUITEM " ~Line Numbers" IDENT "LINE" ;
ACTION oDebugger:LineNumbers() ;
CHECKED oDebugger:lLineNumbers
MENUITEM " ~Exchange Screens" ACTION oDebugger:NotSupported()
MENUITEM " swap on ~Input" ACTION oDebugger:NotSupported()
MENUITEM " code~Block Trace" IDENT "CODEBLOCK" ;
ACTION oDebugger:CodeblockTrace() ;
CHECKED oDebugger:lCBTrace
MENUITEM " ~Menu Bar" ACTION oDebugger:NotSupported()
MENUITEM " mono ~Display" IDENT "MONO";
ACTION oDebugger:MonoDisplay() ;
CHECKED oDebugger:lMonoDisplay
MENUITEM " ~Colors..." ACTION oDebugger:Colors()
MENUITEM " ~Tab Width..." ACTION oDebugger:TabWidth()
MENUITEM " path for ~Files..." ACTION oDebugger:PathForFiles()
MENUITEM " R~un at startup" IDENT "ALTD" ;
ACTION oDebugger:RunAtStartup() ;
CHECKED oDebugger:lRunAtStartup
SEPARATOR
MENUITEM " ~Save Settings..." ACTION oDebugger:SaveSettings()
MENUITEM " ~Restore Settings... " ACTION oDebugger:RestoreSettings()
ENDMENU
MENUITEM " ~Window "
MENU
MENUITEM " ~Next Tab " ACTION oDebugger:NextWindow()
MENUITEM " ~Prev Sh-Tab" ACTION oDebugger:PrevWindow()
MENUITEM " ~Move" ACTION oDebugger:NotSupported()
MENUITEM " ~Size" ACTION oDebugger:NotSupported()
MENUITEM " ~Zoom F2" ACTION oDebugger:NotSupported()
MENUITEM " ~Iconize" ACTION oDebugger:NotSupported()
SEPARATOR
MENUITEM " ~Tile" ACTION oDebugger:NotSupported()
ENDMENU
MENUITEM " ~Help "
MENU
MENUITEM " ~About Help " ACTION oDebugger:ShowHelp()
SEPARATOR
MENUITEM " ~Keys" ACTION oDebugger:ShowHelp( "Keys" )
MENUITEM " ~Windows" ACTION oDebugger:ShowHelp( "Windows" )
MENUITEM " ~Menus" ACTION oDebugger:ShowHelp( "Menus" )
MENUITEM " ~Commands" ACTION oDebugger:ShowHelp( "Commands" )
ENDMENU
ENDMENU
RETURN oMenu
- Code: Select all Expand view
/* NOTE: Don't use SAY/DevOut()/DevPos() for screen output, otherwise
the debugger output may interfere with the applications output
redirection, and is also slower. [vszakats] */
#pragma -b-
#define HB_CLS_NOTOBJECT /* do not inherit from HBObject calss */
#include "hbclass.ch"
#include "hbmemvar.ch"
#include "box.ch"
#include "inkey.ch"
#include "setcurs.ch"
CREATE CLASS HBDbMenu
METHOD aMenus SETGET
VAR nTop
VAR nLeft
VAR nBottom
VAR nRight
VAR aItems
VAR cClrHilite
VAR cClrHotKey
VAR cClrHotFocus
VAR cClrPopup
VAR nOpenPopup // zero if no popup is shown
VAR lPopup
VAR cBackImage
METHOD New()
METHOD AddItem( oMenuItem )
METHOD Build()
METHOD ClosePopup( nPopup )
METHOD CLOSE() INLINE ::ClosePopup( ::nOpenPopup ), ::nOpenPopup := 0
METHOD DeHilite()
METHOD DISPLAY()
METHOD EvalAction()
METHOD GetHotKeyPos( cKey )
METHOD GetItemByIdent( uIdent )
METHOD GetItemOrdByCoors( nRow, nCol )
METHOD GoBottom()
METHOD GoDown() INLINE ::aItems[ ::nOpenPopup ]:bAction:GoRight()
METHOD GoLeft()
METHOD GoRight()
METHOD GoTop()
METHOD GoUp() INLINE ::aItems[ ::nOpenPopup ]:bAction:GoLeft()
METHOD IsOpen() INLINE ::nOpenPopup != 0
METHOD LoadColors() // Load current debugger colors settings
METHOD ProcessKey( nKey )
METHOD Refresh() // Repaints the top bar
METHOD ShowPopup( nPopup )
ENDCLASS
METHOD aMenus( xNewVal ) CLASS HBDbMenu
THREAD STATIC t_aMenus
IF PCount() > 0
t_aMenus := xNewVal
ENDIF
RETURN t_aMenus
METHOD New() CLASS HBDbMenu
IF ::aMenus == NIL
::aMenus := {}
::lPopup := .F.
ELSE
::lPopup := .T.
ENDIF
::nTop := 0
::nLeft := 0
::nBottom := 0
::nRight := 0
::aItems := {}
::LoadColors()
::nOpenPopup := 0
AAdd( ::aMenus, Self )
RETURN Self
METHOD AddItem( oMenuItem ) CLASS HBDbMenu
LOCAL oLastMenu := ATail( ::aMenus )
LOCAL oLastMenuItem
IF oLastMenu:lPopup
oMenuItem:nRow := Len( oLastMenu:aItems )
oMenuItem:nCol := oLastMenu:nLeft + 1
ELSE
oMenuItem:nRow := 0
IF Len( oLastMenu:aItems ) > 0
oLastMenuItem := ATail( oLastMenu:aItems )
oMenuItem:nCol := oLastMenuItem:nCol + ;
Len( StrTran( oLastMenuItem:cPrompt, "~" ) )
ELSE
oMenuItem:nCol := 0
ENDIF
ENDIF
AAdd( ATail( ::aMenus ):aItems, oMenuItem )
RETURN oMenuItem
METHOD Build() CLASS HBDbMenu
LOCAL nPos := 0
LOCAL oMenuItem
IF Len( ::aMenus ) == 1 // pulldown menu
FOR EACH oMenuItem IN ::aItems
oMenuItem:nRow := 0
oMenuItem:nCol := nPos
nPos += Len( StrTran( oMenuItem:cPrompt, "~" ) )
NEXT
ELSE
oMenuItem := ATail( ::aMenus[ Len( ::aMenus ) - 1 ]:aItems )
::nTop := oMenuItem:nRow + 1
::nLeft := oMenuItem:nCol
nPos := ::nLeft
FOR EACH oMenuItem IN ::aItems
oMenuItem:nRow := ::nTop + oMenuItem:__enumIndex()
oMenuItem:nCol := ::nLeft + 1
nPos := Max( nPos, ::nLeft + Len( StrTran( oMenuItem:cPrompt, "~" ) ) + 1 )
NEXT
::nRight := nPos + 1
::nBottom := ::nTop + Len( ::aItems ) + 1
FOR EACH oMenuItem IN ::aItems
IF ! hb_LeftEq( oMenuItem:cPrompt, "-" )
oMenuItem:cPrompt := " " + PadR( oMenuItem:cPrompt, ::nRight - ::nLeft - 1 )
ENDIF
NEXT
ATail( ::aMenus[ Len( ::aMenus ) - 1 ]:aItems ):bAction := ATail( ::aMenus )
::aMenus := ASize( ::aMenus, Len( ::aMenus ) - 1 )
ENDIF
RETURN
METHOD ClosePopup( nPopup ) CLASS HBDbMenu
LOCAL oPopup
IF nPopup != 0
oPopup := ::aItems[ nPopup ]:bAction
IF HB_ISOBJECT( oPopup )
__dbgRestScreen( oPopup:nTop, oPopup:nLeft, ;
oPopup:nBottom + 1, oPopup:nRight + 2, ;
oPopup:cBackImage )
oPopup:cBackImage := NIL
ENDIF
::aItems[ nPopup ]:Display( ::cClrPopup, ::cClrHotKey )
ENDIF
RETURN
METHOD DeHilite() CLASS HBDbMenu
LOCAL oMenuItem := ::aItems[ ::nOpenPopup ]
oMenuItem:Display( ::cClrPopup, ::cClrHotKey )
RETURN
METHOD Display() CLASS HBDbMenu
LOCAL oMenuItem
IF ::lPopup
::cBackImage := __dbgSaveScreen( ::nTop, ::nLeft, ::nBottom + 1, ::nRight + 2 )
hb_DispBox( ::nTop, ::nLeft, ::nBottom, ::nRight, HB_B_SINGLE_UNI, ::cClrPopup )
hb_Shadow( ::nTop, ::nLeft, ::nBottom, ::nRight )
ELSE
hb_Scroll( 0, 0, 0, MaxCol(),,, ::cClrPopup )
ENDIF
FOR EACH oMenuItem IN ::aItems
IF oMenuItem:cPrompt == "-" // Separator
hb_DispOutAtBox( oMenuItem:nRow, ::nLeft, ;
hb_UTF8ToStrBox( "?" + Replicate( "?", ::nRight - ::nLeft - 1 ) + "?" ), ::cClrPopup )
ELSE
oMenuItem:Display( ::cClrPopup, ::cClrHotKey )
ENDIF
NEXT
RETURN
METHOD EvalAction() CLASS HBDbMenu
LOCAL oPopup := ::aItems[ ::nOpenPopup ]:bAction
LOCAL oMenuItem := oPopup:aItems[ oPopup:nOpenPopup ]
IF oMenuItem:bAction != NIL
::Close()
Eval( oMenuItem:bAction, oMenuItem )
ENDIF
RETURN
METHOD GetHotKeyPos( cKey ) CLASS HBDbMenu
LOCAL oMenuItem
FOR EACH oMenuItem IN ::aItems
IF Upper( SubStr( oMenuItem:cPrompt, ;
At( "~", oMenuItem:cPrompt ) + 1, 1 ) ) == cKey
RETURN oMenuItem:__enumIndex()
ENDIF
NEXT
RETURN 0
METHOD GetItemOrdByCoors( nRow, nCol ) CLASS HBDbMenu
LOCAL oMenuItem
FOR EACH oMenuItem IN ::aItems
IF oMenuItem:nRow == nRow .AND. nCol >= oMenuItem:nCol .AND. ;
nCol <= oMenuItem:nCol + Len( oMenuItem:cPrompt ) - 2
RETURN oMenuItem:__enumIndex()
ENDIF
NEXT
RETURN 0
METHOD GetItemByIdent( uIdent ) CLASS HBDbMenu
LOCAL oMenuItem
LOCAL oItem
FOR EACH oMenuItem IN ::aItems
IF HB_ISOBJECT( oMenuItem:bAction )
IF ( oItem := oMenuItem:bAction:GetItemByIdent( uIdent ) ) != NIL
RETURN oItem
ENDIF
ELSEIF ValType( oMenuItem:Ident ) == ValType( uIdent ) .AND. ;
oMenuItem:Ident == uIdent
RETURN oMenuItem
ENDIF
NEXT
RETURN NIL
METHOD GoBottom() CLASS HBDbMenu
LOCAL oPopup
IF ::IsOpen()
oPopup := ::aItems[ ::nOpenPopup ]:bAction
oPopup:DeHilite()
oPopup:ShowPopup( Len( oPopup:aItems ) )
ENDIF
RETURN
METHOD GoLeft() CLASS HBDbMenu
LOCAL oMenuItem := ::aItems[ ::nOpenPopup ]
IF ::nOpenPopup != 0
IF ::lPopup
oMenuItem:Display( ::cClrPopup, ::CClrHotKey )
ELSE
::ClosePopup( ::nOpenPopup )
ENDIF
IF ::nOpenPopup > 1
--::nOpenPopup
DO WHILE ::nOpenPopup > 1 .AND. ;
hb_LeftEq( ::aItems[ ::nOpenPopup ]:cPrompt, "-" )
--::nOpenPopup
ENDDO
::ShowPopup( ::nOpenPopup )
ELSE
::ShowPopup( ::nOpenPopup := Len( ::aItems ) )
ENDIF
ENDIF
RETURN
METHOD GoRight() CLASS HBDbMenu
LOCAL oMenuItem := ::aItems[ ::nOpenPopup ]
IF ::nOpenPopup != 0
IF ::lPopup
oMenuItem:Display( ::cClrPopup, ::cClrHotKey )
ELSE
::ClosePopup( ::nOpenPopup )
ENDIF
IF ::nOpenPopup < Len( ::aItems )
++::nOpenPopup
DO WHILE ::nOpenPopup < Len( ::aItems ) .AND. ;
hb_LeftEq( ::aItems[ ::nOpenPopup ]:cPrompt, "-" )
++::nOpenPopup
ENDDO
::ShowPopup( ::nOpenPopup )
ELSE
::ShowPopup( ::nOpenPopup := 1 )
ENDIF
ENDIF
RETURN
METHOD GoTop() CLASS HBDbMenu
LOCAL oPopup
IF ::IsOpen()
oPopup := ::aItems[ ::nOpenPopup ]:bAction
oPopup:DeHilite()
oPopup:ShowPopup( 1 )
ENDIF
RETURN
METHOD LoadColors() CLASS HBDbMenu
LOCAL aColors := __dbgColors()
LOCAL oMenuItem
::cClrPopup := aColors[ 8 ]
::cClrHotKey := aColors[ 9 ]
::cClrHilite := aColors[ 10 ]
::cClrHotFocus := aColors[ 11 ]
FOR EACH oMenuItem IN ::aItems
IF HB_ISOBJECT( oMenuItem:bAction )
oMenuItem:bAction:LoadColors()
ENDIF
NEXT
RETURN
METHOD Refresh() CLASS HBDbMenu
LOCAL oMenuItem
DispBegin()
IF ! ::lPopup
hb_Scroll( 0, 0, 0, MaxCol(),,, ::cClrPopup )
ENDIF
FOR EACH oMenuItem IN ::aItems
oMenuItem:Display( ::cClrPopup, ::cClrHotKey )
NEXT
DispEnd()
RETURN
METHOD ShowPopup( nPopup ) CLASS HBDbMenu
::aItems[ nPopup ]:Display( ::cClrHilite, ::cClrHotFocus )
::nOpenPopup := nPopup
IF HB_ISOBJECT( ::aItems[ nPopup ]:bAction )
::aItems[ nPopup ]:bAction:Display()
::aItems[ nPopup ]:bAction:ShowPopup( 1 )
ENDIF
RETURN
METHOD ProcessKey( nKey ) CLASS HBDbMenu
LOCAL nPopup
LOCAL oPopup
SWITCH nKey
CASE K_LBUTTONDOWN
IF MRow() == 0
IF ( nPopup := ::GetItemOrdByCoors( 0, MCol() ) ) != 0
IF nPopup != ::nOpenPopup
::ClosePopup( ::nOpenPopup )
::ShowPopup( nPopup )
ENDIF
ENDIF
ELSE
oPopup := ::aItems[ ::nOpenPopup ]:bAction
IF ( nPopup := oPopup:GetItemOrdByCoors( MRow(), MCol() ) ) == 0
::Close()
ELSE
oPopup:DeHilite()
oPopup:nOpenPopup := nPopup
oPopup:aItems[ nPopup ]:Display( ::cClrHilite, ::cClrHotFocus )
::EvalAction()
ENDIF
ENDIF
EXIT
CASE K_ESC
::Close()
EXIT
CASE K_LEFT
::GoLeft()
EXIT
CASE K_RIGHT
::GoRight()
EXIT
CASE K_DOWN
::GoDown()
EXIT
CASE K_UP
::GoUp()
EXIT
CASE K_ENTER
::EvalAction()
EXIT
CASE K_HOME
::GoTop()
EXIT
CASE K_END
::GoBottom()
EXIT
DEFAULT
IF ::nOpenPopup > 0
IF IsAlpha( hb_keyChar( nKey ) )
oPopup := ::aItems[ ::nOpenPopup ]:bAction
IF ( nPopup := oPopup:GetHotKeyPos( Upper( hb_keyChar( nKey ) ) ) ) > 0
IF oPopup:nOpenPopup != nPopup
oPopup:DeHilite()
oPopup:ShowPopup( nPopup )
ENDIF
::EvalAction()
ENDIF
ENDIF
ELSEIF ( nPopup := ::GetHotKeyPos( __dbgAltToKey( nKey ) ) ) != ::nOpenPopup
::Close()
::ShowPopup( nPopup )
ENDIF
END
RETURN
FUNCTION __dbgAltToKey( nKey )
LOCAL nIndex := AScan( { ;
K_ALT_A, K_ALT_B, K_ALT_C, K_ALT_D, K_ALT_E, K_ALT_F, ;
K_ALT_G, K_ALT_H, K_ALT_I, K_ALT_J, K_ALT_K, K_ALT_L, ;
K_ALT_M, K_ALT_N, K_ALT_O, K_ALT_P, K_ALT_Q, K_ALT_R, ;
K_ALT_S, K_ALT_T, K_ALT_U, K_ALT_V, K_ALT_W, K_ALT_X, ;
K_ALT_Y, K_ALT_Z, K_ALT_1, K_ALT_2, K_ALT_3, K_ALT_4, ;
K_ALT_5, K_ALT_6, K_ALT_7, K_ALT_8, K_ALT_9, K_ALT_0 }, nKey )
RETURN iif( nIndex > 0, SubStr( "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", nIndex, 1 ), "" )