mirror of
https://github.com/QB64-Phoenix-Edition/QB64pe.git
synced 2024-07-01 12:40:36 +00:00
Indent code in SUBs and FUNCTIONs by one level, with the option to turn on/off.
Adds option IDE_IndentSUBs to the config file. Credit to Fellippe Heitor for doing the research and writing on the bulk of this commit.
This commit is contained in:
parent
18a05b79ee
commit
86acbbbcdd
|
@ -179,6 +179,20 @@ IF LoadedIDESettings = 0 THEN
|
||||||
end if
|
end if
|
||||||
END IF
|
END IF
|
||||||
|
|
||||||
|
result = ReadConfigSetting("IDE_IndentSUBs", value$)
|
||||||
|
ideindentsubs = VAL(value$)
|
||||||
|
IF UCASE$(value$) = "TRUE" OR ideindentsubs <> 0 THEN
|
||||||
|
ideindentsubs = 1
|
||||||
|
elseif result = 0 then
|
||||||
|
WriteConfigSetting "'[IDE DISPLAY SETTINGS]", "IDE_IndentSUBs", "FALSE"
|
||||||
|
ideindentsubs = 0
|
||||||
|
ELSEIF UCASE$(value$) <> "FALSE" AND value$ <> "0" THEN
|
||||||
|
WriteConfigSetting "'[IDE DISPLAY SETTINGS]", "IDE_IndentSUBs", "TRUE"
|
||||||
|
ideindentsubs = 1
|
||||||
|
else
|
||||||
|
ideindentsubs = 0
|
||||||
|
end if
|
||||||
|
|
||||||
result = ReadConfigSetting("IDE_IndentSize", value$)
|
result = ReadConfigSetting("IDE_IndentSize", value$)
|
||||||
ideautoindentsize = VAL(value$)
|
ideautoindentsize = VAL(value$)
|
||||||
if ideautoindentsize < 1 OR ideautoindentsize > 64 then
|
if ideautoindentsize < 1 OR ideautoindentsize > 64 then
|
||||||
|
|
|
@ -189,7 +189,7 @@ DIM SHARED menus AS INTEGER
|
||||||
DIM SHARED menubar$
|
DIM SHARED menubar$
|
||||||
DIM SHARED ideundocombo, ideundocombochr, idenoundo, idemergeundo
|
DIM SHARED ideundocombo, ideundocombochr, idenoundo, idemergeundo
|
||||||
DIM SHARED idealthighlight, ideentermenu
|
DIM SHARED idealthighlight, ideentermenu
|
||||||
DIM SHARED ideautolayout, ideautoindent, ideautoindentsize, idebackupsize
|
DIM SHARED ideautolayout, ideautoindent, ideautoindentsize, ideindentsubs, idebackupsize
|
||||||
DIM SHARED idewx, idewy, idecustomfont, idecustomfontfile$, idecustomfontheight, idecustomfonthandle
|
DIM SHARED idewx, idewy, idecustomfont, idecustomfontfile$, idecustomfontheight, idecustomfonthandle
|
||||||
DIM SHARED iderunmode
|
DIM SHARED iderunmode
|
||||||
'IDE MODULE SECTION END: shared data & definitions
|
'IDE MODULE SECTION END: shared data & definitions
|
||||||
|
|
|
@ -7490,6 +7490,12 @@ o(i).nam = idenewtxt("#Spacing")
|
||||||
o(i).txt = idenewtxt(a2$)
|
o(i).txt = idenewtxt(a2$)
|
||||||
o(i).v1 = LEN(a2$)
|
o(i).v1 = LEN(a2$)
|
||||||
|
|
||||||
|
i = i + 1
|
||||||
|
o(i).typ = 4
|
||||||
|
o(i).y = 6
|
||||||
|
o(i).nam = idenewtxt("Indent #SUBs and FUNCTIONs")
|
||||||
|
o(i).sel = ideindentsubs
|
||||||
|
|
||||||
i = i + 1
|
i = i + 1
|
||||||
o(i).typ = 3
|
o(i).typ = 3
|
||||||
o(i).y = 7
|
o(i).y = 7
|
||||||
|
@ -7584,8 +7590,8 @@ DO 'main loop
|
||||||
END IF
|
END IF
|
||||||
idetxt(o(3).txt) = a$
|
idetxt(o(3).txt) = a$
|
||||||
|
|
||||||
IF K$ = CHR$(27) OR (focus = 5 AND info <> 0) THEN EXIT FUNCTION
|
IF K$ = CHR$(27) OR (focus = 6 AND info <> 0) THEN EXIT FUNCTION
|
||||||
IF K$ = CHR$(13) OR (focus = 4 AND info <> 0) THEN
|
IF K$ = CHR$(13) OR (focus = 5 AND info <> 0) THEN
|
||||||
'save changes
|
'save changes
|
||||||
v% = o(1).sel: IF v% <> 0 THEN v% = 1 'ideautolayout
|
v% = o(1).sel: IF v% <> 0 THEN v% = 1 'ideautolayout
|
||||||
|
|
||||||
|
@ -7602,6 +7608,9 @@ DO 'main loop
|
||||||
IF ideautoindent <> 0 THEN idelayoutbox = 1
|
IF ideautoindent <> 0 THEN idelayoutbox = 1
|
||||||
END IF
|
END IF
|
||||||
|
|
||||||
|
v% = o(4).sel: IF v% <> 0 THEN v% = 1 'ideindentsubs
|
||||||
|
IF ideindentsubs <> v% THEN ideindentsubs = v%: idelayoutbox = 1
|
||||||
|
|
||||||
if ideautolayout then
|
if ideautolayout then
|
||||||
WriteConfigSetting "'[IDE DISPLAY SETTINGS]", "IDE_AutoFormat", "TRUE"
|
WriteConfigSetting "'[IDE DISPLAY SETTINGS]", "IDE_AutoFormat", "TRUE"
|
||||||
else
|
else
|
||||||
|
@ -7613,7 +7622,11 @@ else
|
||||||
WriteConfigSetting "'[IDE DISPLAY SETTINGS]", "IDE_AutoIndent", "FALSE"
|
WriteConfigSetting "'[IDE DISPLAY SETTINGS]", "IDE_AutoIndent", "FALSE"
|
||||||
end if
|
end if
|
||||||
WriteConfigSetting "'[IDE DISPLAY SETTINGS]", "IDE_IndentSize", str$(ideautoindentsize)
|
WriteConfigSetting "'[IDE DISPLAY SETTINGS]", "IDE_IndentSize", str$(ideautoindentsize)
|
||||||
|
if ideindentsubs then
|
||||||
|
WriteConfigSetting "'[IDE DISPLAY SETTINGS]", "IDE_IndentSUBs", "TRUE"
|
||||||
|
else
|
||||||
|
WriteConfigSetting "'[IDE DISPLAY SETTINGS]", "IDE_IndentSUBs", "FALSE"
|
||||||
|
end if
|
||||||
EXIT FUNCTION
|
EXIT FUNCTION
|
||||||
END IF
|
END IF
|
||||||
|
|
||||||
|
|
|
@ -4384,6 +4384,11 @@ DO
|
||||||
GOTO errmes
|
GOTO errmes
|
||||||
END IF
|
END IF
|
||||||
|
|
||||||
|
if ideindentsubs then
|
||||||
|
controllevel = controllevel + 1
|
||||||
|
controltype(controllevel) = 32
|
||||||
|
end if
|
||||||
|
|
||||||
subfunc = RTRIM$(id.callname) 'SUB_..."
|
subfunc = RTRIM$(id.callname) 'SUB_..."
|
||||||
subfuncn = subfuncn + 1
|
subfuncn = subfuncn + 1
|
||||||
subfuncid = targetid
|
subfuncid = targetid
|
||||||
|
@ -4851,7 +4856,7 @@ DO
|
||||||
IF LEN(subfunc) = 0 THEN a$ = "END " + secondelement$ + " without " + secondelement$: GOTO errmes
|
IF LEN(subfunc) = 0 THEN a$ = "END " + secondelement$ + " without " + secondelement$: GOTO errmes
|
||||||
|
|
||||||
'check for open controls (copy #3)
|
'check for open controls (copy #3)
|
||||||
IF controllevel <> 0 AND controltype(controllevel) <> 6 THEN 'It's OK for subs to be inside $IF blocks
|
IF controllevel <> 0 AND controltype(controllevel) <> 6 AND controltype(controllevel) <> 32 THEN 'It's OK for subs to be inside $IF blocks
|
||||||
x = controltype(controllevel)
|
x = controltype(controllevel)
|
||||||
IF x = 1 THEN a$ = "IF without END IF"
|
IF x = 1 THEN a$ = "IF without END IF"
|
||||||
IF x = 2 THEN a$ = "FOR without NEXT"
|
IF x = 2 THEN a$ = "FOR without NEXT"
|
||||||
|
@ -4862,6 +4867,11 @@ DO
|
||||||
GOTO errmes
|
GOTO errmes
|
||||||
END IF
|
END IF
|
||||||
|
|
||||||
|
IF controltype(controllevel) = 32 and ideindentsubs THEN
|
||||||
|
controltype(controllevel) = 0
|
||||||
|
controllevel = controllevel - 1
|
||||||
|
END IF
|
||||||
|
|
||||||
l$ = firstelement$ + sp + secondelement$
|
l$ = firstelement$ + sp + secondelement$
|
||||||
layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$
|
layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue