1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-06-29 09:20:38 +00:00

Improves on management of watch list (arrays).

`variableWatchList$` now contains:
- MKL$(length of the longest var name)
- MKL$(index in usedVariableList) + MKL$(array index) (= 0 if not an array)
- ...
This commit is contained in:
FellippeHeitor 2021-08-07 01:38:42 -03:00
parent 8e69b49304
commit da76d340c9

View file

@ -739,24 +739,6 @@ FUNCTION ide2 (ignore)
usedVariableList(x).mostRecentValue = "" usedVariableList(x).mostRecentValue = ""
NEXT NEXT
'variableWatchList$ = ""
'longestVarName = 0
'FOR y = 1 TO totalVariablesCreated
' IF usedVariableList(y).watch THEN
' thisLen = LEN(usedVariableList(y).name)
' IF usedVariableList(y).isarray THEN
' thisLen = thisLen + LEN(STR$(CVL(RIGHT$(usedVariableList(y).indexes, 4)))) - 1
' END IF
' IF thisLen > longestVarName THEN
' longestVarName = thisLen
' IF variableWatchList$ = "" THEN variableWatchList$ = SPACE$(4)
' MID$(variableWatchList$, 1, 4) = MKL$(longestVarName)
' END IF
' variableWatchList$ = variableWatchList$ + MKL$(y)
' END IF
'NEXT
EnterDebugMode: EnterDebugMode:
IF idehelp THEN IF idehelp THEN
idewy = idewy + idesubwindow idewy = idewy + idesubwindow
@ -5734,7 +5716,7 @@ FUNCTION ide2 (ignore)
PCOPY 3, 0: SCREEN , , 3, 0 PCOPY 3, 0: SCREEN , , 3, 0
GOTO ideloop GOTO ideloop
ELSE ELSE
result$ = idevariablewatchbox$("", "", 0) result$ = idevariablewatchbox$("", "", 0, 0)
PCOPY 3, 0: SCREEN , , 3, 0 PCOPY 3, 0: SCREEN , , 3, 0
GOTO ideloop GOTO ideloop
END IF END IF
@ -6389,12 +6371,7 @@ SUB DebugMode
buffer$ = "" buffer$ = ""
debugClient& = 0 debugClient& = 0
IF LEN(variableWatchList$) THEN IF LEN(variableWatchList$) = 0 THEN
totalVisibleVariables = (LEN(variableWatchList$) - 4) \ 4
vWatchPanel.h = totalVisibleVariables + 2
IF vWatchPanel.h > idewy - 10 THEN vWatchPanel.h = idewy - 10
IF vWatchPanel.h < 5 THEN vWatchPanel.h = 5
ELSE
totalVisibleVariables = 0 totalVisibleVariables = 0
vWatchPanel.h = 5 vWatchPanel.h = 5
END IF END IF
@ -7054,16 +7031,10 @@ SUB DebugMode
selectVar = 1 selectVar = 1
filter$ = "" filter$ = ""
DO DO
result$ = idevariablewatchbox$(currentSub$, filter$, selectVar) result$ = idevariablewatchbox$(currentSub$, filter$, selectVar, returnAction)
IF LEN(result$) THEN IF returnAction = 1 THEN
'set address 'set address
tempIndex& = CVL(LEFT$(result$, 4)) tempIndex& = CVL(LEFT$(result$, 4))
IF tempIndex& = 0 THEN
PCOPY 3, 0: SCREEN , , 3, 0
WHILE _MOUSEINPUT: WEND
GOSUB UpdateDisplay
_CONTINUE
END IF
usedVariableList(tempIndex&).watch = -1 usedVariableList(tempIndex&).watch = -1
value$ = MID$(result$, 5) value$ = MID$(result$, 5)
@ -7150,20 +7121,21 @@ SUB DebugMode
PCOPY 3, 0: SCREEN , , 3, 0 PCOPY 3, 0: SCREEN , , 3, 0
WHILE _MOUSEINPUT: WEND WHILE _MOUSEINPUT: WEND
GOSUB UpdateDisplay GOSUB UpdateDisplay
ELSEIF returnAction = 2 THEN
PCOPY 3, 0: SCREEN , , 3, 0
WHILE _MOUSEINPUT: WEND
GOSUB UpdateDisplay
_CONTINUE
ELSE ELSE
EXIT DO EXIT DO
END IF END IF
LOOP LOOP
IF LEN(variableWatchList$) THEN
totalVisibleVariables = (LEN(variableWatchList$) - 4) \ 4
vWatchPanel.h = totalVisibleVariables + 2
IF vWatchPanel.h > idewy - 10 THEN vWatchPanel.h = idewy - 10
IF vWatchPanel.h < 5 THEN vWatchPanel.h = 5
GOTO requestVariableValues
END IF
PCOPY 3, 0: SCREEN , , 3, 0 PCOPY 3, 0: SCREEN , , 3, 0
WHILE _MOUSEINPUT: WEND WHILE _MOUSEINPUT: WEND
GOSUB UpdateDisplay GOSUB UpdateDisplay
IF LEN(variableWatchList$) THEN
GOTO requestVariableValues
END IF
END IF END IF
CASE 16128 'F5 CASE 16128 'F5
F5: F5:
@ -7371,7 +7343,8 @@ SUB DebugMode
temp$ = MID$(variableWatchList$, 5) temp$ = MID$(variableWatchList$, 5)
DO WHILE LEN(temp$) DO WHILE LEN(temp$)
tempIndex& = CVL(LEFT$(temp$, 4)) tempIndex& = CVL(LEFT$(temp$, 4))
temp$ = MID$(temp$, 5) tempArrayIndex& = CVL(MID$(temp$, 5, 4))
temp$ = MID$(temp$, 9)
cmd$ = "" cmd$ = ""
IF LEN(usedVariableList(tempIndex&).subfunc) = 0 THEN IF LEN(usedVariableList(tempIndex&).subfunc) = 0 THEN
cmd$ = "global var:" cmd$ = "global var:"
@ -7556,7 +7529,7 @@ SUB DebugMode
ideshowtext ideshowtext
UpdateTitleOfMainWindow UpdateTitleOfMainWindow
IF PauseMode <> 0 AND LEN(variableWatchList$) > 0 THEN showvWatchPanel vWatchPanel, currentSub$ IF PauseMode <> 0 AND LEN(variableWatchList$) > 0 THEN showvWatchPanel vWatchPanel, currentSub$, totalVisibleVariables
PCOPY 3, 0 PCOPY 3, 0
RETURN RETURN
@ -7582,12 +7555,23 @@ Function map! (value!, minRange!, maxRange!, newMinRange!, newMaxRange!)
map! = ((value! - minRange!) / (maxRange! - minRange!)) * (newMaxRange! - newMinRange!) + newMinRange! map! = ((value! - minRange!) / (maxRange! - minRange!)) * (newMaxRange! - newMinRange!) + newMinRange!
End Function End Function
SUB showvWatchPanel (this AS vWatchPanelType, currentScope$) SUB showvWatchPanel (this AS vWatchPanelType, currentScope$, totalVisibleVariables)
STATIC previousVariableWatchList$
STATIC longestVarName
IF previousVariableWatchList$ <> variableWatchList$ THEN
'new setup
previousVariableWatchList$ = variableWatchList$
longestVarName = CVL(LEFT$(variableWatchList$, 4))
expandedList$ = ""
totalVisibleVariables = (LEN(variableWatchList$) - 4) \ 8
this.h = totalVisibleVariables + 2
IF this.h > idewy - 10 THEN this.h = idewy - 10
IF this.h < 5 THEN this.h = 5
END IF
totalVisibleVariables = (LEN(variableWatchList$) - 4) \ 4
fg = 0: bg = 7 fg = 0: bg = 7
title$ = "Watch List" title$ = "Watch List"
IF LEN(currentScope$) THEN title$ = title$ + " - " + currentScope$ IF LEN(currentScope$) THEN title$ = title$ + " - " + currentScope$
IF this.w < LEN(title$) + 4 THEN IF this.w < LEN(title$) + 4 THEN
@ -7597,8 +7581,8 @@ SUB showvWatchPanel (this AS vWatchPanelType, currentScope$)
COLOR fg, bg COLOR fg, bg
ideboxshadow this.x, this.y, this.w, this.h ideboxshadow this.x, this.y, this.w, this.h
color 15, bg COLOR 15, bg
_PRINTSTRING (this.x + this.w - 1, this.y + this.h - 1), CHR$(254) 'resize handle _PRINTSTRING (this.x + this.w - 1, this.y + this.h - 1), CHR$(18) 'resize handle
x = LEN(title$) + 2 x = LEN(title$) + 2
COLOR fg, bg COLOR fg, bg
@ -7608,45 +7592,35 @@ SUB showvWatchPanel (this AS vWatchPanelType, currentScope$)
COLOR , bg COLOR , bg
y = 0 y = 0
i = 0
this.contentWidth = 0 this.contentWidth = 0
IF this.hPos = 0 THEN this.hPos = 1 IF this.hPos = 0 THEN this.hPos = 1
IF LEN(variableWatchList$) THEN temp$ = MID$(variableWatchList$, 5)
longestVarName = CVL(LEFT$(variableWatchList$, 4)) DO WHILE LEN(temp$)
temp$ = MID$(variableWatchList$, 5) tempIndex& = CVL(LEFT$(temp$, 4))
previousTempIndex& = 0 tempArrayIndex& = CVL(MID$(temp$, 5, 4))
DO WHILE LEN(temp$) temp$ = MID$(temp$, 9)
tempIndex& = CVL(LEFT$(temp$, 4)) i = i + 1
temp$ = MID$(temp$, 5) IF this.firstVisible > i THEN _CONTINUE
i = i + 1 y = y + 1
IF this.firstVisible > i THEN _CONTINUE IF y > this.h - 2 THEN EXIT DO
y = y + 1
IF y > this.h - 2 THEN EXIT DO
IF usedVariableList(tempIndex&).isarray THEN thisName$ = usedVariableList(tempIndex&).name
IF tempIndex& <> previousTempIndex& THEN IF usedVariableList(tempIndex&).isarray THEN
previousTempIndex& = tempIndex& thisName$ = LEFT$(thisName$, LEN(thisName$) - 1) + _
thisArrayElement = 0 LTRIM$(STR$(tempArrayIndex&)) + ")"
tempElements$ = usedVariableList(tempIndex&).indexes END IF
END IF item$ = thisName$ + SPACE$(longestVarName - LEN(thisName$)) + " = "
thisArrayElement = thisArrayElement + 1 IF usedVariableList(tempIndex&).subfunc = currentScope$ OR usedVariableList(tempIndex&).subfunc = "" THEN
END IF item$ = item$ + usedVariableList(tempIndex&).mostRecentValue
thisName$ = usedVariableList(tempIndex&).name COLOR fg
IF usedVariableList(tempIndex&).isarray THEN ELSE
thisName$ = LEFT$(thisName$, LEN(thisName$) - 1) + _ item$ = item$ + "<out of scope>"
LTRIM$(STR$(CVL(MID$(tempElements$, thisArrayElement * 4 - 3, 4)))) + ")" COLOR 2
END IF END IF
item$ = thisName$ + SPACE$(longestVarName - LEN(thisName$)) + " = " IF LEN(item$) > this.contentWidth THEN this.contentWidth = LEN(item$)
IF usedVariableList(tempIndex&).subfunc = currentScope$ OR usedVariableList(tempIndex&).subfunc = "" THEN _PRINTSTRING (this.x + 2, this.y + y), MID$(item$, this.hPos, this.w - 4)
item$ = item$ + usedVariableList(tempIndex&).mostRecentValue LOOP
COLOR fg
ELSE
item$ = item$ + "<out of scope>"
COLOR 2
END IF
IF LEN(item$) > this.contentWidth THEN this.contentWidth = LEN(item$)
_PRINTSTRING (this.x + 2, this.y + y), MID$(item$, this.hPos, this.w - 4)
LOOP
END IF
IF totalVisibleVariables > this.h - 2 THEN IF totalVisibleVariables > this.h - 2 THEN
y = idevbar(this.x + this.w - 1, this.y + 1, this.h - 2, this.firstVisible, totalVisibleVariables - (this.h - 2) + 1) y = idevbar(this.x + this.w - 1, this.y + 1, this.h - 2, this.firstVisible, totalVisibleVariables - (this.h - 2) + 1)
@ -7669,7 +7643,7 @@ SUB showvWatchPanel (this AS vWatchPanelType, currentScope$)
END IF END IF
END SUB END SUB
FUNCTION idevariablewatchbox$(currentScope$, filter$, selectVar) FUNCTION idevariablewatchbox$(currentScope$, filter$, selectVar, returnAction)
'-------- generic dialog box header -------- '-------- generic dialog box header --------
PCOPY 0, 2 PCOPY 0, 2
@ -7684,6 +7658,7 @@ FUNCTION idevariablewatchbox$(currentScope$, filter$, selectVar)
'-------- init -------- '-------- init --------
returnAction = 0
mainmodule$ = "GLOBAL" mainmodule$ = "GLOBAL"
maxModuleNameLen = LEN(mainmodule$) maxModuleNameLen = LEN(mainmodule$)
maxTypeLen = LEN("Type") maxTypeLen = LEN("Type")
@ -7692,13 +7667,12 @@ FUNCTION idevariablewatchbox$(currentScope$, filter$, selectVar)
selectedBG = 2 selectedBG = 2
TYPE varDlgList TYPE varDlgList
AS LONG index, bgColorFlag, colorFlag, colorFlag2, indicator, arrayElement AS LONG index, bgColorFlag, colorFlag, colorFlag2, indicator
END TYPE END TYPE
REDIM varDlgList(1 TO totalVariablesCreated) AS varDlgList REDIM varDlgList(1 TO totalVariablesCreated) AS varDlgList
'calculate longest module name, longest var name, longest type name 'calculate longest module name, longest var name, longest type name
totalArrayElements = 0
FOR x = 1 TO totalVariablesCreated FOR x = 1 TO totalVariablesCreated
IF LEN(usedVariableList(x).subfunc) > maxModuleNameLen THEN IF LEN(usedVariableList(x).subfunc) > maxModuleNameLen THEN
maxModuleNameLen = LEN(usedVariableList(x).subfunc) maxModuleNameLen = LEN(usedVariableList(x).subfunc)
@ -7885,8 +7859,9 @@ FUNCTION idevariablewatchbox$(currentScope$, filter$, selectVar)
v$ = ideinputbox$("Change Value", "#New value", a2$, "", thisWidth, 0, ok) v$ = ideinputbox$("Change Value", "#New value", a2$, "", thisWidth, 0, ok)
IF ok THEN IF ok THEN
idevariablewatchbox$ = MKL$(varDlgList(i).index) + v$ idevariablewatchbox$ = MKL$(varDlgList(i).index) + v$
returnAction = 1 'actually send value
ELSE ELSE
idevariablewatchbox$ = MKL$(0) returnAction = 2 'redraw and carry on
END IF END IF
selectVar = i selectVar = i
EXIT FUNCTION EXIT FUNCTION
@ -7916,7 +7891,15 @@ FUNCTION idevariablewatchbox$(currentScope$, filter$, selectVar)
IF variableWatchList$ = "" THEN variableWatchList$ = SPACE$(4) IF variableWatchList$ = "" THEN variableWatchList$ = SPACE$(4)
MID$(variableWatchList$, 1, 4) = MKL$(longestVarName) MID$(variableWatchList$, 1, 4) = MKL$(longestVarName)
END IF END IF
variableWatchList$ = variableWatchList$ + MKL$(varDlgList(y).index) IF usedVariableList(varDlgList(y).index).isarray THEN
temp$ = usedVariableList(varDlgList(y).index).indexes
DO WHILE LEN(temp$)
variableWatchList$ = variableWatchList$ + MKL$(varDlgList(y).index) + LEFT$(temp$, 4)
temp$ = MID$(temp$, 5)
LOOP
ELSE
variableWatchList$ = variableWatchList$ + MKL$(varDlgList(y).index) + MKL$(0)
END IF
END IF END IF
NEXT NEXT
EXIT FUNCTION EXIT FUNCTION