1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-06-26 17:10:38 +00:00

Switches focus to IDE automatically when breakpoint is reached.

Windows-only.
This commit is contained in:
FellippeHeitor 2021-08-12 23:00:43 -03:00
parent f9ab61ad51
commit cca1593f79
4 changed files with 35 additions and 2 deletions

View file

@ -12675,6 +12675,13 @@ qbs *func__title(){
}
}
void set_foreground_window(ptrszint i) {
#ifdef QB64_WINDOWS
BOOL result = SetForegroundWindow((HWND) i);
#endif
return;
}
int32 func__hasfocus() {
#ifdef QB64_GUI
#ifdef QB64_WINDOWS

View file

@ -187,6 +187,7 @@ extern int32 func__controlchr();
extern void sub__blink(int32);
extern int32 func__blink();
extern int32 func__hasfocus();
extern void set_foreground_window(ptrszint i);
extern qbs *func__title();
extern int32 func__handle();
extern int32 func__fileexists(qbs*);

View file

@ -4,6 +4,7 @@ SUB vwatch (globalVariables AS _OFFSET, localVariables AS _OFFSET)
STATIC AS LONG vw_ideHost, vw_breakpointCount, vw_skipCount, vw_timeout, vw_startLevel, vw_lastLine
STATIC AS LONG vw_runToLine
STATIC AS _BYTE vw_pauseMode, vw_stepOver, vw_bypass, vw_setNextLine
STATIC AS _OFFSET vw_idehwnd
STATIC vw_buffer$, vw_endc$
DIM AS LONG vw_i, vw_tempIndex, vw_localIndex, vw_varSize, vw_sequence
DIM AS _OFFSET vw_address
@ -18,6 +19,12 @@ SUB vwatch (globalVariables AS _OFFSET, localVariables AS _OFFSET)
FUNCTION stop_program_state&
END DECLARE
$IF WIN THEN
DECLARE DYNAMIC LIBRARY "user32"
FUNCTION SetForegroundWindow& (BYVAL hWnd AS _OFFSET)
END DECLARE
$END IF
IF vw_bypass THEN EXIT SUB
vwatch_goto = 0
@ -32,6 +39,8 @@ SUB vwatch (globalVariables AS _OFFSET, localVariables AS _OFFSET)
'send this binary's path/exe name
vw_cmd$ = "me:" + COMMAND$(0)
GOSUB SendCommand
vw_cmd$ = "hwnd:" + _MK$(_OFFSET, _WINDOWHANDLE)
GOSUB SendCommand
DO
GOSUB GetCommand
@ -59,6 +68,8 @@ SUB vwatch (globalVariables AS _OFFSET, localVariables AS _OFFSET)
vw_temp$ = MID$(vw_value$, vw_i * 4 - 3, 4)
vwatch_breakpoints(CVL(vw_temp$)) = -1
NEXT
CASE "hwnd"
vw_idehwnd = _CV(_OFFSET, vw_value$)
CASE "skip count"
vw_skipCount = CVL(vw_value$)
CASE "skip list"
@ -167,6 +178,10 @@ SUB vwatch (globalVariables AS _OFFSET, localVariables AS _OFFSET)
vw_cmd$ = "current sub:" + LEFT$(vwatch_stack(vwatch_sublevel), INSTR(vwatch_stack(vwatch_sublevel), ",") - 1)
GOSUB SendCommand
$IF WIN THEN
vw_i = SetForegroundWindow&(vw_idehwnd)
$END IF
DO 'main loop
IF stop_program_state& THEN vw_bypass = -1: EXIT DO
SELECT CASE vw_cmd$

View file

@ -6345,6 +6345,11 @@ SUB DebugMode
STATIC buffer$
STATIC endc$
STATIC currentSub$
STATIC debuggeehwnd AS _OFFSET
DECLARE LIBRARY
SUB set_foreground_window (BYVAL hwnd AS _OFFSET)
END DECLARE
timeout = 10
_KEYCLEAR
@ -6395,6 +6400,7 @@ SUB DebugMode
callstacklist$ = ""
buffer$ = ""
debugClient& = 0
debuggeepid = 0
IF LEN(variableWatchList$) = 0 THEN
totalVisibleVariables = 0
@ -6518,14 +6524,17 @@ SUB DebugMode
CLOSE #debugClient&
WHILE _MOUSEINPUT: WEND
EXIT SUB
ELSE
EXIT DO
END IF
CASE "hwnd"
debuggeehwnd = _CV(_OFFSET, value$)
EXIT DO
END SELECT
LOOP
cmd$ = "vwatch:ok"
GOSUB SendCommand
cmd$ = "hwnd:" + _MK$(_OFFSET, _WINDOWHANDLE)
GOSUB SendCommand
cmd$ = "line count:" + MKL$(iden)
GOSUB SendCommand
@ -7173,6 +7182,7 @@ SUB DebugMode
setStatusMessage 1, "Running...", 10
GOSUB UpdateDisplay
dummy = DarkenFGBG(1)
set_foreground_window debuggeehwnd
CASE 16384 'F6
F6:
requestStepOut: