mirror of
https://github.com/QB64Official/qb64.git
synced 2024-07-20 10:25:15 +00:00
Restore SUB/FUNCTION sorting
This commit is contained in:
parent
6e8fbb5332
commit
380c7bc15e
|
@ -8038,12 +8038,17 @@ FUNCTION idesubs$
|
||||||
'-------- init --------
|
'-------- init --------
|
||||||
|
|
||||||
ly$ = MKL$(1)
|
ly$ = MKL$(1)
|
||||||
|
lySorted$ = ly$
|
||||||
CurrentlyViewingWhichSUBFUNC = 1
|
CurrentlyViewingWhichSUBFUNC = 1
|
||||||
PreferCurrentCursorSUBFUNC = 0
|
PreferCurrentCursorSUBFUNC = 0
|
||||||
InsideDECLARE = 0
|
InsideDECLARE = 0
|
||||||
FoundExternalSUBFUNC = 0
|
FoundExternalSUBFUNC = 0
|
||||||
l$ = ideprogname$
|
l$ = ideprogname$
|
||||||
IF l$ = "" THEN l$ = "Untitled" + tempfolderindexstr$
|
IF l$ = "" THEN l$ = "Untitled" + tempfolderindexstr$
|
||||||
|
lSorted$ = l$
|
||||||
|
|
||||||
|
TotalSUBs = 0
|
||||||
|
SortedSubsFlag = idesortsubs
|
||||||
|
|
||||||
FOR y = 1 TO iden
|
FOR y = 1 TO iden
|
||||||
a$ = idegetline(y)
|
a$ = idegetline(y)
|
||||||
|
@ -8114,6 +8119,16 @@ FUNCTION idesubs$
|
||||||
args$ = LEFT$(args$, (idewx - 44)) + STRING$(3, 250)
|
args$ = LEFT$(args$, (idewx - 44)) + STRING$(3, 250)
|
||||||
END IF
|
END IF
|
||||||
l$ = l$ + sep + CHR$(195) + CHR$(196) + n$ + " " + sf$ + args$
|
l$ = l$ + sep + CHR$(195) + CHR$(196) + n$ + " " + sf$ + args$
|
||||||
|
|
||||||
|
'Populate SortedSubsList()
|
||||||
|
TotalSUBs = TotalSUBs + 1
|
||||||
|
ListItemLength = LEN(n$ + " " + sf$ + args$)
|
||||||
|
REDIM _PRESERVE SortedSubsList(1 TO TotalSUBs) AS STRING * 998
|
||||||
|
REDIM _PRESERVE CaseBkpSubsList(1 TO TotalSUBs) AS STRING * 998
|
||||||
|
CaseBkpSubsList(TotalSUBs) = n$ + " " + sf$ + args$
|
||||||
|
SortedSubsList(TotalSUBs) = UCASE$(CaseBkpSubsList(TotalSUBs))
|
||||||
|
MID$(CaseBkpSubsList(TotalSUBs), 992, 6) = MKL$(y) + MKI$(ListItemLength)
|
||||||
|
MID$(SortedSubsList(TotalSUBs), 992, 6) = MKL$(y) + MKI$(ListItemLength)
|
||||||
END IF
|
END IF
|
||||||
NEXT
|
NEXT
|
||||||
|
|
||||||
|
@ -8122,6 +8137,28 @@ FUNCTION idesubs$
|
||||||
IF a$ = CHR$(195) THEN MID$(l$, x, 1) = CHR$(192): EXIT FOR
|
IF a$ = CHR$(195) THEN MID$(l$, x, 1) = CHR$(192): EXIT FOR
|
||||||
NEXT
|
NEXT
|
||||||
|
|
||||||
|
IF TotalSUBs > 1 THEN
|
||||||
|
sort SortedSubsList()
|
||||||
|
FOR x = 1 TO TotalSUBs
|
||||||
|
ListItemLength = CVI(MID$(SortedSubsList(x), LEN(SortedSubsList(x)) - 2, 2))
|
||||||
|
lySorted$ = lySorted$ + MID$(SortedSubsList(x), LEN(SortedSubsList(x)) - 6, 4)
|
||||||
|
FOR RestoreCaseBkp = 1 TO TotalSUBs
|
||||||
|
IF MID$(SortedSubsList(x), LEN(SortedSubsList(x)) - 6, 4) = MID$(CaseBkpSubsList(RestoreCaseBkp), LEN(CaseBkpSubsList(RestoreCaseBkp)) - 6, 4) THEN
|
||||||
|
lSorted$ = lSorted$ + sep + CHR$(195) + CHR$(196) + LEFT$(CaseBkpSubsList(RestoreCaseBkp), ListItemLength)
|
||||||
|
EXIT FOR
|
||||||
|
END IF
|
||||||
|
NEXT
|
||||||
|
NEXT
|
||||||
|
|
||||||
|
FOR x = LEN(lSorted$) TO 1 STEP -1
|
||||||
|
a$ = MID$(lSorted$, x, 1)
|
||||||
|
IF a$ = CHR$(195) THEN MID$(lSorted$, x, 1) = CHR$(192): EXIT FOR
|
||||||
|
NEXT
|
||||||
|
SortedSubsFlag = idesortsubs
|
||||||
|
ELSE
|
||||||
|
SortedSubsFlag = 0 'Override idesortsubs if the current program doesn't have more than 1 subprocedure
|
||||||
|
END IF
|
||||||
|
|
||||||
'72,19
|
'72,19
|
||||||
i = 0
|
i = 0
|
||||||
idepar p, idewx - 8, idewy + idesubwindow - 6, "SUBs"
|
idepar p, idewx - 8, idewy + idesubwindow - 6, "SUBs"
|
||||||
|
@ -8132,11 +8169,30 @@ FUNCTION idesubs$
|
||||||
'68
|
'68
|
||||||
o(i).w = idewx - 12: o(i).h = idewy + idesubwindow - 9
|
o(i).w = idewx - 12: o(i).h = idewy + idesubwindow - 9
|
||||||
o(i).txt = idenewtxt(l$)
|
o(i).txt = idenewtxt(l$)
|
||||||
|
IF SortedSubsFlag = 0 THEN
|
||||||
IF PreferCurrentCursorSUBFUNC <> 0 THEN
|
IF PreferCurrentCursorSUBFUNC <> 0 THEN
|
||||||
o(i).sel = PreferCurrentCursorSUBFUNC
|
o(i).sel = PreferCurrentCursorSUBFUNC
|
||||||
ELSE
|
ELSE
|
||||||
o(i).sel = CurrentlyViewingWhichSUBFUNC
|
o(i).sel = CurrentlyViewingWhichSUBFUNC
|
||||||
END IF
|
END IF
|
||||||
|
ELSE
|
||||||
|
idetxt(o(i).txt) = lSorted$
|
||||||
|
IF PreferCurrentCursorSUBFUNC <> 0 THEN
|
||||||
|
FOR x = 1 TO TotalSUBs
|
||||||
|
IF MID$(ly$, PreferCurrentCursorSUBFUNC * 4 - 3, 4) = MID$(SortedSubsList(x), LEN(SortedSubsList(x)) - 6, 4) THEN
|
||||||
|
o(i).sel = x + 1 'The sorted list items array doesn't contain the first line (ideprogname$)
|
||||||
|
EXIT FOR
|
||||||
|
END IF
|
||||||
|
NEXT
|
||||||
|
ELSE
|
||||||
|
FOR x = 1 TO TotalSUBs
|
||||||
|
IF MID$(ly$, CurrentlyViewingWhichSUBFUNC * 4 - 3, 4) = MID$(SortedSubsList(x), LEN(SortedSubsList(x)) - 6, 4) THEN
|
||||||
|
o(i).sel = x + 1 'The sorted list items array doesn't contain the first line (ideprogname$)
|
||||||
|
EXIT FOR
|
||||||
|
END IF
|
||||||
|
NEXT
|
||||||
|
END IF
|
||||||
|
END IF
|
||||||
o(i).nam = idenewtxt("Program Items")
|
o(i).nam = idenewtxt("Program Items")
|
||||||
|
|
||||||
|
|
||||||
|
@ -8146,6 +8202,16 @@ FUNCTION idesubs$
|
||||||
o(i).txt = idenewtxt("#Edit" + sep + "#Cancel")
|
o(i).txt = idenewtxt("#Edit" + sep + "#Cancel")
|
||||||
o(i).dft = 1
|
o(i).dft = 1
|
||||||
|
|
||||||
|
IF TotalSUBs > 1 THEN
|
||||||
|
i = i + 1
|
||||||
|
o(i).typ = 4 'check box
|
||||||
|
o(i).x = idewx - 22
|
||||||
|
o(i).y = idewy + idesubwindow - 6
|
||||||
|
o(i).nam = idenewtxt("#Sorted A-Z")
|
||||||
|
o(i).sel = SortedSubsFlag
|
||||||
|
END IF
|
||||||
|
|
||||||
|
|
||||||
'-------- end of init --------
|
'-------- end of init --------
|
||||||
|
|
||||||
'-------- generic init --------
|
'-------- generic init --------
|
||||||
|
@ -8224,6 +8290,7 @@ FUNCTION idesubs$
|
||||||
|
|
||||||
IF K$ = CHR$(27) OR (focus = 3 AND info <> 0) THEN
|
IF K$ = CHR$(27) OR (focus = 3 AND info <> 0) THEN
|
||||||
idesubs$ = "C"
|
idesubs$ = "C"
|
||||||
|
GOSUB SaveSortSettings
|
||||||
EXIT FUNCTION
|
EXIT FUNCTION
|
||||||
END IF
|
END IF
|
||||||
|
|
||||||
|
@ -8231,18 +8298,74 @@ FUNCTION idesubs$
|
||||||
y = o(1).sel
|
y = o(1).sel
|
||||||
IF y < 1 THEN y = -y
|
IF y < 1 THEN y = -y
|
||||||
AddQuickNavHistory idecy
|
AddQuickNavHistory idecy
|
||||||
|
IF SortedSubsFlag = 0 THEN
|
||||||
idecy = CVL(MID$(ly$, y * 4 - 3, 4))
|
idecy = CVL(MID$(ly$, y * 4 - 3, 4))
|
||||||
|
ELSE
|
||||||
|
idecy = CVL(MID$(lySorted$, y * 4 - 3, 4))
|
||||||
|
END IF
|
||||||
idesy = idecy
|
idesy = idecy
|
||||||
idecx = 1
|
idecx = 1
|
||||||
idesx = 1
|
idesx = 1
|
||||||
|
|
||||||
|
GOSUB SaveSortSettings
|
||||||
EXIT FUNCTION
|
EXIT FUNCTION
|
||||||
END IF
|
END IF
|
||||||
|
|
||||||
|
IF TotalSUBs > 1 THEN
|
||||||
|
IF o(3).sel <> SortedSubsFlag THEN
|
||||||
|
SortedSubsFlag = o(3).sel
|
||||||
|
|
||||||
|
IF SortedSubsFlag = 0 THEN
|
||||||
|
'Replace list contents with unsorted version while mantaining current selection.
|
||||||
|
PreviousSelection = -1
|
||||||
|
IF o(1).sel > 0 THEN
|
||||||
|
TargetSourceLine$ = MID$(lySorted$, o(1).sel * 4 - 3, 4)
|
||||||
|
FOR x = 1 TO TotalSUBs
|
||||||
|
IF MID$(ly$, x * 4 - 3, 4) = TargetSourceLine$ THEN
|
||||||
|
PreviousSelection = x
|
||||||
|
END IF
|
||||||
|
NEXT
|
||||||
|
END IF
|
||||||
|
|
||||||
|
idetxt(o(1).txt) = l$
|
||||||
|
o(1).sel = PreviousSelection
|
||||||
|
focus = 1
|
||||||
|
ELSE
|
||||||
|
'Replace list contents with sorted version while mantaining current selection.
|
||||||
|
PreviousSelection = -1
|
||||||
|
IF o(1).sel > 0 THEN
|
||||||
|
TargetSourceLine$ = MID$(ly$, o(1).sel * 4 - 3, 4)
|
||||||
|
FOR x = 1 TO TotalSUBs
|
||||||
|
IF MID$(lySorted$, x * 4 - 3, 4) = TargetSourceLine$ THEN
|
||||||
|
PreviousSelection = x
|
||||||
|
END IF
|
||||||
|
NEXT
|
||||||
|
END IF
|
||||||
|
|
||||||
|
idetxt(o(1).txt) = lSorted$
|
||||||
|
o(1).sel = PreviousSelection
|
||||||
|
focus = 1
|
||||||
|
END IF
|
||||||
|
END IF
|
||||||
|
END IF
|
||||||
|
|
||||||
'end of custom controls
|
'end of custom controls
|
||||||
mousedown = 0
|
mousedown = 0
|
||||||
mouseup = 0
|
mouseup = 0
|
||||||
LOOP
|
LOOP
|
||||||
|
|
||||||
|
EXIT FUNCTION
|
||||||
|
SaveSortSettings:
|
||||||
|
IF TotalSUBs > 1 AND idesortsubs <> SortedSubsFlag THEN
|
||||||
|
idesortsubs = SortedSubsFlag
|
||||||
|
IF idesortsubs THEN
|
||||||
|
WriteConfigSetting "'[IDE DISPLAY SETTINGS]", "IDE_SortSUBs", "TRUE"
|
||||||
|
ELSE
|
||||||
|
WriteConfigSetting "'[IDE DISPLAY SETTINGS]", "IDE_SortSUBs", "FALSE"
|
||||||
|
END IF
|
||||||
|
END IF
|
||||||
|
RETURN
|
||||||
|
|
||||||
END FUNCTION
|
END FUNCTION
|
||||||
|
|
||||||
|
|
||||||
|
@ -13534,6 +13657,20 @@ SUB Mathbox
|
||||||
idecx = idecx + LEN(messagestr$)
|
idecx = idecx + LEN(messagestr$)
|
||||||
END SUB
|
END SUB
|
||||||
|
|
||||||
|
'After Cormen, Leiserson, Rivest & Stein "Introduction To Algoritms" via Wikipedia
|
||||||
|
SUB sort (arr() AS STRING * 998)
|
||||||
|
FOR i& = LBOUND(arr) + 1 TO UBOUND(arr)
|
||||||
|
x$ = arr(i&)
|
||||||
|
j& = i& - 1
|
||||||
|
WHILE j& >= LBOUND(arr)
|
||||||
|
IF arr(j&) <= x$ THEN EXIT WHILE
|
||||||
|
arr$(j& + 1) = arr$(j&)
|
||||||
|
j& = j& - 1
|
||||||
|
WEND
|
||||||
|
arr$(j& + 1) = x$
|
||||||
|
NEXT i&
|
||||||
|
END SUB
|
||||||
|
|
||||||
FUNCTION FindProposedTitle$
|
FUNCTION FindProposedTitle$
|
||||||
'Finds the first occurence of _TITLE to suggest a file name
|
'Finds the first occurence of _TITLE to suggest a file name
|
||||||
'when saving for the first time or saving as.
|
'when saving for the first time or saving as.
|
||||||
|
|
Loading…
Reference in a new issue