1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-07-05 22:50:23 +00:00

Merge pull request #129 from QB64Team/IdeTweaks

Ide tweaks
This commit is contained in:
Fellippe Heitor 2021-02-08 11:39:54 -03:00 committed by GitHub
commit 5a82796df0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 1175 additions and 815 deletions

14
.gitignore vendored
View file

@ -1,20 +1,16 @@
internal/c/c_compiler internal/c/c_compiler
internal/temp internal/temp*
internal/temp2
internal/temp3
*.o *.o
*.a *.a
*.exe *.exe
internal/config.txt *.bas
internal/config*.txt
internal/config.ini
internal/help internal/help
internal/config(2).txt
internal/config(1).txt
internal/version.txt internal/version.txt
tempfoldersearch.bin tempfoldersearch.bin
internal/c/mingw32 internal/c/mingw32
internal/c/mingw64 internal/c/mingw64
internal/c/qbx2.cpp internal/c/qbx[2-9].cpp
internal/version.bas
internal/IDEcolor.txt
/run_qb64.sh /run_qb64.sh
/qb64 /qb64

View file

@ -25083,6 +25083,9 @@ void sub_put2(int32 i,int64 offset,void *element,int32 passed){
#if defined(QB64_GUI) && defined(QB64_WINDOWS) && defined(QB64_GLUT) #if defined(QB64_GUI) && defined(QB64_WINDOWS) && defined(QB64_GLUT)
while (!window_exists){Sleep(100);} //Wait for window to be created before checking position while (!window_exists){Sleep(100);} //Wait for window to be created before checking position
return glutGet(GLUT_WINDOW_X) - glutGet(GLUT_WINDOW_BORDER_WIDTH); return glutGet(GLUT_WINDOW_X) - glutGet(GLUT_WINDOW_BORDER_WIDTH);
#elif defined(QB64_GUI) && defined(QB64_GLUT)
while (!window_exists){Sleep(100);} //Wait for window to be created before checking position
return glutGet(GLUT_WINDOW_X);
#endif #endif
return 0; //if not windows then return 0 return 0; //if not windows then return 0
} }
@ -25091,6 +25094,9 @@ void sub_put2(int32 i,int64 offset,void *element,int32 passed){
#if defined(QB64_GUI) && defined(QB64_WINDOWS) && defined(QB64_GLUT) #if defined(QB64_GUI) && defined(QB64_WINDOWS) && defined(QB64_GLUT)
while (!window_exists){Sleep(100);} //Wait for window to be created before checking position while (!window_exists){Sleep(100);} //Wait for window to be created before checking position
return glutGet(GLUT_WINDOW_Y) - glutGet(GLUT_WINDOW_BORDER_WIDTH) - glutGet(GLUT_WINDOW_HEADER_HEIGHT); return glutGet(GLUT_WINDOW_Y) - glutGet(GLUT_WINDOW_BORDER_WIDTH) - glutGet(GLUT_WINDOW_HEADER_HEIGHT);
#elif defined(QB64_GUI) && defined(QB64_GLUT)
while (!window_exists){Sleep(100);} //Wait for window to be created before checking position
return glutGet(GLUT_WINDOW_Y);
#endif #endif
return 0; //if not windows then return 0 return 0; //if not windows then return 0
} }

File diff suppressed because it is too large Load diff

View file

@ -200,7 +200,7 @@ DIM SHARED menus AS INTEGER, idecontextualmenuID AS INTEGER
DIM SHARED ideeditmenuID AS INTEGER, SearchMenuID AS INTEGER DIM SHARED ideeditmenuID AS INTEGER, SearchMenuID AS INTEGER
DIM SHARED OptionsMenuID AS INTEGER, OptionsMenuSwapMouse AS INTEGER, OptionsMenuPasteCursor AS INTEGER DIM SHARED OptionsMenuID AS INTEGER, OptionsMenuSwapMouse AS INTEGER, OptionsMenuPasteCursor AS INTEGER
DIM SHARED OptionsMenuShowErrorsImmediately AS INTEGER, OptionsMenuIgnoreWarnings AS INTEGER DIM SHARED OptionsMenuShowErrorsImmediately AS INTEGER, OptionsMenuIgnoreWarnings AS INTEGER
DIM SHARED OptionsMenuDisableSyntax AS INTEGER, OptionsMenuAutoComplete DIM SHARED OptionsMenuDisableSyntax AS INTEGER ', OptionsMenuAutoComplete
DIM SHARED ViewMenuID AS INTEGER, ViewMenuShowLineNumbersSubMenuID AS INTEGER DIM SHARED ViewMenuID AS INTEGER, ViewMenuShowLineNumbersSubMenuID AS INTEGER
DIM SHARED ViewMenuShowSeparatorID AS INTEGER, ViewMenuShowBGID AS INTEGER DIM SHARED ViewMenuShowSeparatorID AS INTEGER, ViewMenuShowBGID AS INTEGER
DIM SHARED ViewMenuCompilerWarnings AS INTEGER DIM SHARED ViewMenuCompilerWarnings AS INTEGER

View file

@ -246,7 +246,7 @@ FUNCTION ide2 (ignore)
idecustomfonthandle = _LOADFONT(idecustomfontfile$, idecustomfontheight, "MONOSPACE") idecustomfonthandle = _LOADFONT(idecustomfontfile$, idecustomfontheight, "MONOSPACE")
IF idecustomfonthandle = -1 THEN IF idecustomfonthandle = -1 THEN
'failed! - revert to default settings 'failed! - revert to default settings
idecustomfont = 0: idecustomfontfile$ = "c:\windows\fonts\lucon.ttf": idecustomfontheight = 21 idecustomfont = 0: idecustomfontfile$ = "C:\Windows\Fonts\lucon.ttf": idecustomfontheight = 21
ELSE ELSE
_FONT idecustomfonthandle _FONT idecustomfonthandle
END IF END IF
@ -379,11 +379,10 @@ FUNCTION ide2 (ignore)
menuDesc$(m, i - 1) = "Toggles display of warning messages (unused variables, etc)" menuDesc$(m, i - 1) = "Toggles display of warning messages (unused variables, etc)"
IF IgnoreWarnings THEN menu$(OptionsMenuID, OptionsMenuIgnoreWarnings) = CHR$(7) + "Ignore #Warnings" IF IgnoreWarnings THEN menu$(OptionsMenuID, OptionsMenuIgnoreWarnings) = CHR$(7) + "Ignore #Warnings"
OptionsMenuAutoComplete = i 'OptionsMenuAutoComplete = i
menu$(m, i) = "Code Suggest#ions": i = i + 1 'menu$(m, i) = "Code Suggest#ions": i = i + 1
menuDesc$(m, i - 1) = "Toggles code suggestions/auto-complete" 'menuDesc$(m, i - 1) = "Toggles code suggestions/auto-complete"
IF IdeAutoComplete THEN menu$(OptionsMenuID, OptionsMenuAutoComplete) = CHR$(7) + "Code Suggest#ions" 'IF IdeAutoComplete THEN menu$(OptionsMenuID, OptionsMenuAutoComplete) = CHR$(7) + "Code Suggest#ions"
menusize(m) = i - 1 menusize(m) = i - 1
@ -856,8 +855,8 @@ FUNCTION ide2 (ignore)
LOOP WHILE _RESIZE LOOP WHILE _RESIZE
IF retval = 1 THEN 'screen dimensions have changed and everything must be redrawn/reapplied IF retval = 1 THEN 'screen dimensions have changed and everything must be redrawn/reapplied
WriteConfigSetting "'[IDE DISPLAY SETTINGS]", "IDE_Width", STR$(idewx) WriteConfigSetting windowSettingsSection$ + iniFolderIndex$, "IDE_Width", STR$(idewx)
WriteConfigSetting "'[IDE DISPLAY SETTINGS]", "IDE_Height", STR$(idewy) WriteConfigSetting windowSettingsSection$ + iniFolderIndex$, "IDE_Height", STR$(idewy)
END IF END IF
retval = 1 retval = 1
@ -1032,16 +1031,17 @@ FUNCTION ide2 (ignore)
END IF 'skipdisplay END IF 'skipdisplay
IF WhiteListQB64FirstTimeMsg = 0 THEN IF WhiteListQB64FirstTimeMsg = 0 THEN
IF INSTR(_OS$, "WIN") THEN whiteListProcess$ = "and the process 'qb64.exe' " ELSE whiteListProcess$ = ""
result = idemessagebox("Welcome to QB64", "QB64 is an independently distributed program, and as such" + CHR$(10) + _ result = idemessagebox("Welcome to QB64", "QB64 is an independently distributed program, and as such" + CHR$(10) + _
"both 'qb64" + extension$ + "' and the programs you create with it may" + CHR$(10) + _ "both 'qb64" + extension$ + "' and the programs you create with it may" + CHR$(10) + _
"eventually be flagged as false positives by your" + CHR$(10) + _ "eventually be flagged as false positives by your" + CHR$(10) + _
"antivirus/antimalware software." + CHR$(10) + CHR$(10) + _ "antivirus/antimalware software." + CHR$(10) + CHR$(10) + _
"It is advisable to whitelist your whole QB64 folder to avoid" + CHR$(10) + _ "It is advisable to whitelist your whole QB64 folder" + CHR$(10) + _
"operation errors.", "#OK;#Don't show this again") whiteListProcess$ + "to avoid operation errors.", "#OK;#Don't show this again")
PCOPY 3, 0: SCREEN , , 3, 0 PCOPY 3, 0: SCREEN , , 3, 0
IF result = 2 THEN IF result = 2 THEN
WriteConfigSetting "'[GENERAL SETTINGS]", "WhiteListQB64FirstTimeMsg", "TRUE" WriteConfigSetting generalSettingsSection$, "WhiteListQB64FirstTimeMsg", "True"
END IF END IF
WhiteListQB64FirstTimeMsg = -1 WhiteListQB64FirstTimeMsg = -1
END IF END IF
@ -1236,8 +1236,8 @@ FUNCTION ide2 (ignore)
IF IDE_AutoPosition THEN IF IDE_AutoPosition THEN
IF IDE_TopPosition <> _SCREENY OR IDE_LeftPosition <> _SCREENX THEN IF IDE_TopPosition <> _SCREENY OR IDE_LeftPosition <> _SCREENX THEN
IF _SCREENY >= -_HEIGHT * _FONTHEIGHT AND _SCREENX >= -_WIDTH * _FONTWIDTH THEN 'Don't record the position if it's off the screen, past the point where we can drag it back into a different position. IF _SCREENY >= -_HEIGHT * _FONTHEIGHT AND _SCREENX >= -_WIDTH * _FONTWIDTH THEN 'Don't record the position if it's off the screen, past the point where we can drag it back into a different position.
WriteConfigSetting "'[IDE DISPLAY SETTINGS]", "IDE_TopPosition", STR$(_SCREENY) WriteConfigSetting windowSettingsSection$ + iniFolderIndex$, "IDE_TopPosition", STR$(_SCREENY)
WriteConfigSetting "'[IDE DISPLAY SETTINGS]", "IDE_LeftPosition", STR$(_SCREENX) WriteConfigSetting windowSettingsSection$ + iniFolderIndex$, "IDE_LeftPosition", STR$(_SCREENX)
IDE_TopPosition = _SCREENY: IDE_LeftPosition = _SCREENX IDE_TopPosition = _SCREENY: IDE_LeftPosition = _SCREENX
END IF END IF
END IF END IF
@ -1518,7 +1518,7 @@ FUNCTION ide2 (ignore)
"Folder' in the Run menu.", "#OK;#Don't show this again;#Cancel") "Folder' in the Run menu.", "#OK;#Don't show this again;#Cancel")
END IF END IF
IF result = 2 THEN IF result = 2 THEN
WriteConfigSetting "'[GENERAL SETTINGS]", "ExeToSourceFolderFirstTimeMsg", "TRUE" WriteConfigSetting generalSettingsSection$, "ExeToSourceFolderFirstTimeMsg", "True"
ExeToSourceFolderFirstTimeMsg = -1 ExeToSourceFolderFirstTimeMsg = -1
ELSEIF result = 3 THEN ELSEIF result = 3 THEN
PCOPY 3, 0: SCREEN , , 3, 0 PCOPY 3, 0: SCREEN , , 3, 0
@ -2775,10 +2775,6 @@ FUNCTION ide2 (ignore)
GET #backupIncludeFile, 1, tempInclude1$ GET #backupIncludeFile, 1, tempInclude1$
CLOSE #backupIncludeFile CLOSE #backupIncludeFile
WriteConfigSetting "'[IDE DISPLAY SETTINGS]", "IDE_AutoPosition", "FALSE"
WriteConfigSetting "'[IDE DISPLAY SETTINGS]", "IDE_Width", "80"
WriteConfigSetting "'[IDE DISPLAY SETTINGS]", "IDE_Height", "25"
SCREEN , , 3, 0 SCREEN , , 3, 0
clearStatusWindow clearStatusWindow
COLOR 15, 1 COLOR 15, 1
@ -2795,12 +2791,6 @@ FUNCTION ide2 (ignore)
END IF END IF
SHELL p$ SHELL p$
IF IDE_AutoPosition THEN
WriteConfigSetting "'[IDE DISPLAY SETTINGS]", "IDE_AutoPosition", "TRUE"
END IF
WriteConfigSetting "'[IDE DISPLAY SETTINGS]", "IDE_Width", STR$(idewx)
WriteConfigSetting "'[IDE DISPLAY SETTINGS]", "IDE_Height", STR$(idewy)
OPEN f$ FOR BINARY AS #backupIncludeFile OPEN f$ FOR BINARY AS #backupIncludeFile
tempInclude2$ = SPACE$(LOF(backupIncludeFile)) tempInclude2$ = SPACE$(LOF(backupIncludeFile))
GET #backupIncludeFile, 1, tempInclude2$ GET #backupIncludeFile, 1, tempInclude2$
@ -3597,30 +3587,30 @@ FUNCTION ide2 (ignore)
HideBracketHighlight HideBracketHighlight
keywordHighlight = oldkeywordHighlight keywordHighlight = oldkeywordHighlight
retval$ = idergbmixer$(0) retval$ = idergbmixer$(0)
ELSEIF IdeAutoComplete AND idefocusline > 0 AND LEN(_TRIM$(a$)) = 0 THEN 'ELSEIF IdeAutoComplete AND idefocusline > 0 AND LEN(_TRIM$(a$)) = 0 THEN
'close open block ' 'close open block
tempIndent$ = idegetline(idefocusline) ' tempIndent$ = idegetline(idefocusline)
tempIndent$ = SPACE$(LEN(tempIndent$) - LEN(LTRIM$(tempindent$))) ' tempIndent$ = SPACE$(LEN(tempIndent$) - LEN(LTRIM$(tempindent$)))
IF idefocusline = definingtypeerror THEN ' IF idefocusline = definingtypeerror THEN
idecx = LEN(tempIndent$) + 1 ' idecx = LEN(tempIndent$) + 1
insertAtCursor SCase$("End Type"): GOTO specialchar ' insertAtCursor SCase$("End Type"): GOTO specialchar
ELSEIF idefocusline = controlref(controllevel) AND INSTR(idecompilererrormessage$, " without ") > 0 THEN ' ELSEIF idefocusline = controlref(controllevel) AND INSTR(idecompilererrormessage$, " without ") > 0 THEN
idecx = LEN(tempIndent$) + 1 ' idecx = LEN(tempIndent$) + 1
SELECT EVERYCASE controltype(controllevel) ' SELECT EVERYCASE controltype(controllevel)
CASE 1: insertAtCursor SCase$("End If"): GOTO specialchar ' CASE 1: insertAtCursor SCase$("End If"): GOTO specialchar
CASE 2: insertAtCursor SCase$("Next"): GOTO specialchar ' CASE 2: insertAtCursor SCase$("Next"): GOTO specialchar
CASE 3, 4: insertAtCursor SCase$("Loop"): GOTO specialchar ' CASE 3, 4: insertAtCursor SCase$("Loop"): GOTO specialchar
CASE 5: insertAtCursor SCase$("Wend"): GOTO specialchar ' CASE 5: insertAtCursor SCase$("Wend"): GOTO specialchar
CASE 6: insertAtCursor SCase$("$End If"): GOTO specialchar ' CASE 6: insertAtCursor SCase$("$End If"): GOTO specialchar
CASE 10 TO 19: insertAtCursor SCase$("End Select"): GOTO specialchar ' CASE 10 TO 19: insertAtCursor SCase$("End Select"): GOTO specialchar
CASE 32 ' CASE 32
IF LEFT$(subfunc, 4) = "SUB_" THEN ' IF LEFT$(subfunc, 4) = "SUB_" THEN
insertAtCursor SCase$("End Sub"): GOTO specialchar ' insertAtCursor SCase$("End Sub"): GOTO specialchar
ELSE ' ELSE
insertAtCursor SCase$("End Function"): GOTO specialchar ' insertAtCursor SCase$("End Function"): GOTO specialchar
END IF ' END IF
END SELECT ' END SELECT
END IF ' END IF
ELSE ELSE
IF ideselect THEN IF ideselect THEN
IF ideselecty1 <> idecy THEN GOTO specialchar 'multi line selected IF ideselecty1 <> idecy THEN GOTO specialchar 'multi line selected
@ -4719,10 +4709,10 @@ FUNCTION ide2 (ignore)
PCOPY 2, 0 PCOPY 2, 0
MouseButtonSwapped = NOT MouseButtonSwapped MouseButtonSwapped = NOT MouseButtonSwapped
IF MouseButtonSwapped THEN IF MouseButtonSwapped THEN
WriteConfigSetting "'[MOUSE SETTINGS]", "SwapMouseButton", "TRUE" WriteConfigSetting mouseSettingsSection$, "SwapMouseButton", "True"
menu$(OptionsMenuID, OptionsMenuSwapMouse) = CHR$(7) + "#Swap Mouse Buttons" menu$(OptionsMenuID, OptionsMenuSwapMouse) = CHR$(7) + "#Swap Mouse Buttons"
ELSE ELSE
WriteConfigSetting "'[MOUSE SETTINGS]", "SwapMouseButton", "FALSE" WriteConfigSetting mouseSettingsSection$, "SwapMouseButton", "False"
menu$(OptionsMenuID, OptionsMenuSwapMouse) = "#Swap Mouse Buttons" menu$(OptionsMenuID, OptionsMenuSwapMouse) = "#Swap Mouse Buttons"
END IF END IF
PCOPY 3, 0: SCREEN , , 3, 0 PCOPY 3, 0: SCREEN , , 3, 0
@ -4733,10 +4723,10 @@ FUNCTION ide2 (ignore)
PCOPY 2, 0 PCOPY 2, 0
DisableSyntaxHighlighter = NOT DisableSyntaxHighlighter DisableSyntaxHighlighter = NOT DisableSyntaxHighlighter
IF DisableSyntaxHighlighter THEN IF DisableSyntaxHighlighter THEN
WriteConfigSetting "'[GENERAL SETTINGS]", "DisableSyntaxHighlighter", "TRUE" WriteConfigSetting generalSettingsSection$, "DisableSyntaxHighlighter", "True"
menu$(OptionsMenuID, OptionsMenuDisableSyntax) = "Syntax #Highlighter" menu$(OptionsMenuID, OptionsMenuDisableSyntax) = "Syntax #Highlighter"
ELSE ELSE
WriteConfigSetting "'[GENERAL SETTINGS]", "DisableSyntaxHighlighter", "FALSE" WriteConfigSetting generalSettingsSection$, "DisableSyntaxHighlighter", "False"
menu$(OptionsMenuID, OptionsMenuDisableSyntax) = CHR$(7) + "Syntax #Highlighter" menu$(OptionsMenuID, OptionsMenuDisableSyntax) = CHR$(7) + "Syntax #Highlighter"
END IF END IF
PCOPY 3, 0: SCREEN , , 3, 0 PCOPY 3, 0: SCREEN , , 3, 0
@ -4747,10 +4737,10 @@ FUNCTION ide2 (ignore)
PCOPY 2, 0 PCOPY 2, 0
PasteCursorAtEnd = NOT PasteCursorAtEnd PasteCursorAtEnd = NOT PasteCursorAtEnd
IF PasteCursorAtEnd THEN IF PasteCursorAtEnd THEN
WriteConfigSetting "'[GENERAL SETTINGS]", "PasteCursorAtEnd", "TRUE" WriteConfigSetting generalSettingsSection$, "PasteCursorAtEnd", "True"
menu$(OptionsMenuID, OptionsMenuPasteCursor) = CHR$(7) + "Cursor After #Paste" menu$(OptionsMenuID, OptionsMenuPasteCursor) = CHR$(7) + "Cursor After #Paste"
ELSE ELSE
WriteConfigSetting "'[GENERAL SETTINGS]", "PasteCursorAtEnd", "FALSE" WriteConfigSetting generalSettingsSection$, "PasteCursorAtEnd", "False"
menu$(OptionsMenuID, OptionsMenuPasteCursor) = "Cursor After #Paste" menu$(OptionsMenuID, OptionsMenuPasteCursor) = "Cursor After #Paste"
END IF END IF
PCOPY 3, 0: SCREEN , , 3, 0 PCOPY 3, 0: SCREEN , , 3, 0
@ -4761,10 +4751,10 @@ FUNCTION ide2 (ignore)
PCOPY 2, 0 PCOPY 2, 0
IDEShowErrorsImmediately = NOT IDEShowErrorsImmediately IDEShowErrorsImmediately = NOT IDEShowErrorsImmediately
IF IDEShowErrorsImmediately THEN IF IDEShowErrorsImmediately THEN
WriteConfigSetting "'[GENERAL SETTINGS]", "ShowErrorsImmediately", "TRUE" WriteConfigSetting generalSettingsSection$, "ShowErrorsImmediately", "True"
menu$(OptionsMenuID, OptionsMenuShowErrorsImmediately) = CHR$(7) + "Syntax Ch#ecker" menu$(OptionsMenuID, OptionsMenuShowErrorsImmediately) = CHR$(7) + "Syntax Ch#ecker"
ELSE ELSE
WriteConfigSetting "'[GENERAL SETTINGS]", "ShowErrorsImmediately", "FALSE" WriteConfigSetting generalSettingsSection$, "ShowErrorsImmediately", "False"
menu$(OptionsMenuID, OptionsMenuShowErrorsImmediately) = "Syntax Ch#ecker" menu$(OptionsMenuID, OptionsMenuShowErrorsImmediately) = "Syntax Ch#ecker"
END IF END IF
idechangemade = 1 idechangemade = 1
@ -4776,11 +4766,11 @@ FUNCTION ide2 (ignore)
PCOPY 2, 0 PCOPY 2, 0
IF IgnoreWarnings = 0 THEN IF IgnoreWarnings = 0 THEN
IgnoreWarnings = -1 IgnoreWarnings = -1
WriteConfigSetting "'[GENERAL SETTINGS]", "IgnoreWarnings", "TRUE" WriteConfigSetting generalSettingsSection$, "IgnoreWarnings", "True"
menu$(OptionsMenuID, OptionsMenuIgnoreWarnings) = CHR$(7) + "Ignore #Warnings" menu$(OptionsMenuID, OptionsMenuIgnoreWarnings) = CHR$(7) + "Ignore #Warnings"
ELSE ELSE
IgnoreWarnings = 0 IgnoreWarnings = 0
WriteConfigSetting "'[GENERAL SETTINGS]", "IgnoreWarnings", "FALSE" WriteConfigSetting generalSettingsSection$, "IgnoreWarnings", "False"
menu$(OptionsMenuID, OptionsMenuIgnoreWarnings) = "Ignore #Warnings" menu$(OptionsMenuID, OptionsMenuIgnoreWarnings) = "Ignore #Warnings"
END IF END IF
idechangemade = 1 idechangemade = 1
@ -4788,30 +4778,30 @@ FUNCTION ide2 (ignore)
GOTO ideloop GOTO ideloop
END IF END IF
IF RIGHT$(menu$(m, s), 17) = "Code Suggest#ions" THEN 'IF RIGHT$(menu$(m, s), 17) = "Code Suggest#ions" THEN
PCOPY 2, 0 ' PCOPY 2, 0
IF IdeAutoComplete = 0 THEN ' IF IdeAutoComplete = 0 THEN
IdeAutoComplete = -1 ' IdeAutoComplete = -1
WriteConfigSetting "'[GENERAL SETTINGS]", "IdeAutoComplete", "TRUE" ' WriteConfigSetting generalSettingsSection$, "IdeAutoComplete", "True"
menu$(OptionsMenuID, OptionsMenuAutoComplete) = CHR$(7) + "Code Suggest#ions" ' menu$(OptionsMenuID, OptionsMenuAutoComplete) = CHR$(7) + "Code Suggest#ions"
ELSE ' ELSE
IdeAutoComplete = 0 ' IdeAutoComplete = 0
WriteConfigSetting "'[GENERAL SETTINGS]", "IdeAutoComplete", "FALSE" ' WriteConfigSetting generalSettingsSection$, "IdeAutoComplete", "False"
menu$(OptionsMenuID, OptionsMenuAutoComplete) = "Code Suggest#ions" ' menu$(OptionsMenuID, OptionsMenuAutoComplete) = "Code Suggest#ions"
END IF ' END IF
idechangemade = 1 ' idechangemade = 1
PCOPY 3, 0: SCREEN , , 3, 0 ' PCOPY 3, 0: SCREEN , , 3, 0
GOTO ideloop ' GOTO ideloop
END IF 'END IF
IF RIGHT$(menu$(m, s), 28) = "Output EXE to Source #Folder" THEN IF RIGHT$(menu$(m, s), 28) = "Output EXE to Source #Folder" THEN
PCOPY 2, 0 PCOPY 2, 0
SaveExeWithSource = NOT SaveExeWithSource SaveExeWithSource = NOT SaveExeWithSource
IF SaveExeWithSource THEN IF SaveExeWithSource THEN
WriteConfigSetting "'[GENERAL SETTINGS]", "SaveExeWithSource", "TRUE" WriteConfigSetting generalSettingsSection$, "SaveExeWithSource", "True"
menu$(RunMenuID, RunMenuSaveExeWithSource) = CHR$(7) + "Output EXE to Source #Folder" menu$(RunMenuID, RunMenuSaveExeWithSource) = CHR$(7) + "Output EXE to Source #Folder"
ELSE ELSE
WriteConfigSetting "'[GENERAL SETTINGS]", "SaveExeWithSource", "FALSE" WriteConfigSetting generalSettingsSection$, "SaveExeWithSource", "False"
menu$(RunMenuID, RunMenuSaveExeWithSource) = "Output EXE to Source #Folder" menu$(RunMenuID, RunMenuSaveExeWithSource) = "Output EXE to Source #Folder"
END IF END IF
PCOPY 3, 0: SCREEN , , 3, 0 PCOPY 3, 0: SCREEN , , 3, 0
@ -4823,10 +4813,10 @@ FUNCTION ide2 (ignore)
PCOPY 2, 0 PCOPY 2, 0
EnableQuickNav = NOT EnableQuickNav EnableQuickNav = NOT EnableQuickNav
IF EnableQuickNav THEN IF EnableQuickNav THEN
WriteConfigSetting "'[GENERAL SETTINGS]", "EnableQuickNav", "TRUE" WriteConfigSetting generalSettingsSection$, "EnableQuickNav", "True"
menu$(SearchMenuID, SearchMenuEnableQuickNav) = CHR$(7) + "#Quick Navigation" menu$(SearchMenuID, SearchMenuEnableQuickNav) = CHR$(7) + "#Quick Navigation"
ELSE ELSE
WriteConfigSetting "'[GENERAL SETTINGS]", "EnableQuickNav", "FALSE" WriteConfigSetting generalSettingsSection$, "EnableQuickNav", "False"
menu$(SearchMenuID, SearchMenuEnableQuickNav) = "#Quick Navigation" menu$(SearchMenuID, SearchMenuEnableQuickNav) = "#Quick Navigation"
END IF END IF
PCOPY 3, 0: SCREEN , , 3, 0 PCOPY 3, 0: SCREEN , , 3, 0
@ -5170,7 +5160,7 @@ FUNCTION ide2 (ignore)
IF menu$(m, s) = "#Show Line Numbers" THEN IF menu$(m, s) = "#Show Line Numbers" THEN
PCOPY 2, 0 PCOPY 2, 0
ShowLineNumbers = -1 ShowLineNumbers = -1
WriteConfigSetting "'[GENERAL SETTINGS]", "ShowLineNumbers", "TRUE" WriteConfigSetting generalSettingsSection$, "ShowLineNumbers", "True"
menu$(m, s) = "#Hide Line Numbers" menu$(m, s) = "#Hide Line Numbers"
menu$(m, ViewMenuShowBGID) = MID$(menu$(m, ViewMenuShowBGID), 2) menu$(m, ViewMenuShowBGID) = MID$(menu$(m, ViewMenuShowBGID), 2)
menu$(m, ViewMenuShowSeparatorID) = MID$(menu$(m, ViewMenuShowSeparatorID), 2) menu$(m, ViewMenuShowSeparatorID) = MID$(menu$(m, ViewMenuShowSeparatorID), 2)
@ -5181,7 +5171,7 @@ FUNCTION ide2 (ignore)
IF menu$(m, s) = "#Hide Line Numbers" THEN IF menu$(m, s) = "#Hide Line Numbers" THEN
PCOPY 2, 0 PCOPY 2, 0
ShowLineNumbers = 0 ShowLineNumbers = 0
WriteConfigSetting "'[GENERAL SETTINGS]", "ShowLineNumbers", "FALSE" WriteConfigSetting generalSettingsSection$, "ShowLineNumbers", "False"
menu$(m, s) = "#Show Line Numbers" menu$(m, s) = "#Show Line Numbers"
menu$(m, ViewMenuShowBGID) = "~" + menu$(m, ViewMenuShowBGID) menu$(m, ViewMenuShowBGID) = "~" + menu$(m, ViewMenuShowBGID)
menu$(m, ViewMenuShowSeparatorID) = "~" + menu$(m, ViewMenuShowSeparatorID) menu$(m, ViewMenuShowSeparatorID) = "~" + menu$(m, ViewMenuShowSeparatorID)
@ -5194,10 +5184,10 @@ FUNCTION ide2 (ignore)
PCOPY 2, 0 PCOPY 2, 0
ShowLineNumbersUseBG = NOT ShowLineNumbersUseBG ShowLineNumbersUseBG = NOT ShowLineNumbersUseBG
IF ShowLineNumbersUseBG THEN IF ShowLineNumbersUseBG THEN
WriteConfigSetting "'[GENERAL SETTINGS]", "ShowLineNumbersUseBG", "TRUE" WriteConfigSetting generalSettingsSection$, "ShowLineNumbersUseBG", "True"
menu$(m, s) = CHR$(7) + "#Background Color" menu$(m, s) = CHR$(7) + "#Background Color"
ELSE ELSE
WriteConfigSetting "'[GENERAL SETTINGS]", "ShowLineNumbersUseBG", "FALSE" WriteConfigSetting generalSettingsSection$, "ShowLineNumbersUseBG", "False"
menu$(m, s) = "#Background Color" menu$(m, s) = "#Background Color"
END IF END IF
PCOPY 3, 0: SCREEN , , 3, 0 PCOPY 3, 0: SCREEN , , 3, 0
@ -5210,10 +5200,10 @@ FUNCTION ide2 (ignore)
PCOPY 2, 0 PCOPY 2, 0
ShowLineNumbersSeparator = NOT ShowLineNumbersSeparator ShowLineNumbersSeparator = NOT ShowLineNumbersSeparator
IF ShowLineNumbersSeparator THEN IF ShowLineNumbersSeparator THEN
WriteConfigSetting "'[GENERAL SETTINGS]", "ShowLineNumbersSeparator", "TRUE" WriteConfigSetting generalSettingsSection$, "ShowLineNumbersSeparator", "True"
menu$(m, s) = CHR$(7) + "Sho#w Separator" menu$(m, s) = CHR$(7) + "Sho#w Separator"
ELSE ELSE
WriteConfigSetting "'[GENERAL SETTINGS]", "ShowLineNumbersSeparator", "FALSE" WriteConfigSetting generalSettingsSection$, "ShowLineNumbersSeparator", "False"
menu$(m, s) = "Sho#w Separator" menu$(m, s) = "Sho#w Separator"
END IF END IF
PCOPY 3, 0: SCREEN , , 3, 0 PCOPY 3, 0: SCREEN , , 3, 0
@ -8233,7 +8223,8 @@ SUB ideshowtext
'an _RGB(, _RGB32(, _RGBA( or _RGBA32(, we'll offer the RGB 'an _RGB(, _RGB32(, _RGBA( or _RGBA32(, we'll offer the RGB
'color mixer. 'color mixer.
a2$ = UCASE$(a$) a2$ = UCASE$(a$)
IF IdeAutoComplete AND idecx = LEN(a$) + 1 AND idecx_comment + idecx_quote = 0 THEN 'IF IdeAutoComplete AND idecx = LEN(a$) + 1 AND idecx_comment + idecx_quote = 0 THEN
IF idecx = LEN(a$) + 1 AND idecx_comment + idecx_quote = 0 THEN
IF (RIGHT$(a2$, 5) = "_RGB(" OR _ IF (RIGHT$(a2$, 5) = "_RGB(" OR _
RIGHT$(a2$, 7) = "_RGB32(" OR _ RIGHT$(a2$, 7) = "_RGB32(" OR _
RIGHT$(a2$, 6) = "_RGBA(" OR _ RIGHT$(a2$, 6) = "_RGBA(" OR _
@ -8269,22 +8260,22 @@ SUB ideshowtext
f$ = p$ + ActiveINCLUDELinkFile f$ = p$ + ActiveINCLUDELinkFile
IF _FILEEXISTS(f$) THEN a$ = a$ + " --> Double-click to open": ActiveINCLUDELink = idecy IF _FILEEXISTS(f$) THEN a$ = a$ + " --> Double-click to open": ActiveINCLUDELink = idecy
END IF END IF
ELSE 'ELSE
temp_a$ = idegetline(idecy) ' temp_a$ = idegetline(idecy)
IF IdeAutoComplete AND idefocusline = l AND LEN(_TRIM$(temp_a$)) = 0 THEN ' IF IdeAutoComplete AND idefocusline = l AND LEN(_TRIM$(temp_a$)) = 0 THEN
'some errors are mere blocks the user just opened and is still ' 'some errors are mere blocks the user just opened and is still
'working on. This bit will offer to close said blocks. ' 'working on. This bit will offer to close said blocks.
IF idefocusline = definingtypeerror THEN ' IF idefocusline = definingtypeerror THEN
shiftEnter_idecx = LEN(a$) ' shiftEnter_idecx = LEN(a$)
a$ = a$ + " --> Shift+ENTER to close block" ' a$ = a$ + " --> Shift+ENTER to close block"
ELSEIF idefocusline = controlref(controllevel) AND INSTR(idecompilererrormessage$, " without ") > 0 THEN ' ELSEIF idefocusline = controlref(controllevel) AND INSTR(idecompilererrormessage$, " without ") > 0 THEN
SELECT EVERYCASE controltype(controllevel) ' SELECT EVERYCASE controltype(controllevel)
CASE 1 to 6,10 to 19,32 ' CASE 1 to 6,10 to 19,32
shiftEnter_idecx = LEN(a$) ' shiftEnter_idecx = LEN(a$)
a$ = a$ + " --> Shift+ENTER to close block" ' a$ = a$ + " --> Shift+ENTER to close block"
END SELECT ' END SELECT
END IF ' END IF
END IF ' END IF
END IF 'l = idecy END IF 'l = idecy
a2$ = SPACE$(idesx + (idewx - 3)) a2$ = SPACE$(idesx + (idewx - 3))
@ -8306,7 +8297,7 @@ SUB ideshowtext
IF timeElapsedSince(startTime) > 1 THEN IF timeElapsedSince(startTime) > 1 THEN
result = idemessagebox("Syntax Highlighter Disabled", "Syntax Highlighter has been disabled to avoid slowing down the IDE.\nYou can reenable the Highlighter in the 'Options' menu.", "") result = idemessagebox("Syntax Highlighter Disabled", "Syntax Highlighter has been disabled to avoid slowing down the IDE.\nYou can reenable the Highlighter in the 'Options' menu.", "")
DisableSyntaxHighlighter = -1 DisableSyntaxHighlighter = -1
WriteConfigSetting "'[GENERAL SETTINGS]", "DisableSyntaxHighlighter", "TRUE" WriteConfigSetting generalSettingsSection$, "DisableSyntaxHighlighter", "True"
menu$(OptionsMenuID, OptionsMenuDisableSyntax) = "Syntax #Highlighter" menu$(OptionsMenuID, OptionsMenuDisableSyntax) = "Syntax #Highlighter"
GOTO noSyntaxHighlighting GOTO noSyntaxHighlighting
END IF END IF
@ -9055,15 +9046,15 @@ FUNCTION idesubs$
SaveSortSettings: SaveSortSettings:
idesortsubs = SortedSubsFlag idesortsubs = SortedSubsFlag
IF idesortsubs THEN IF idesortsubs THEN
WriteConfigSetting "'[IDE DISPLAY SETTINGS]", "IDE_SortSUBs", "TRUE" WriteConfigSetting displaySettingsSection$, "IDE_SortSUBs", "True"
ELSE ELSE
WriteConfigSetting "'[IDE DISPLAY SETTINGS]", "IDE_SortSUBs", "FALSE" WriteConfigSetting displaySettingsSection$, "IDE_SortSUBs", "False"
END IF END IF
IF IDESubsLength THEN IF IDESubsLength THEN
WriteConfigSetting "'[IDE DISPLAY SETTINGS]", "IDE_SUBsLength", "TRUE" WriteConfigSetting displaySettingsSection$, "IDE_SUBsLength", "True"
ELSE ELSE
WriteConfigSetting "'[IDE DISPLAY SETTINGS]", "IDE_SUBsLength", "FALSE" WriteConfigSetting displaySettingsSection$, "IDE_SUBsLength", "False"
END IF END IF
RETURN RETURN
@ -9204,7 +9195,7 @@ FUNCTION idelanguagebox
'save changes 'save changes
v% = y: idecpindex = v% v% = y: idecpindex = v%
WriteConfigSetting "'[IDE DISPLAY SETTINGS]", "IDE_CodePage", STR$(idecpindex) WriteConfigSetting displaySettingsSection$, "IDE_CodePage", STR$(idecpindex)
EXIT FUNCTION EXIT FUNCTION
END IF END IF
@ -10454,25 +10445,25 @@ FUNCTION idelayoutbox
IF ideindentsubs <> v% THEN ideindentsubs = v%: idelayoutbox = 1 IF ideindentsubs <> v% THEN ideindentsubs = v%: idelayoutbox = 1
IF ideautolayout THEN IF ideautolayout THEN
WriteConfigSetting "'[IDE DISPLAY SETTINGS]", "IDE_AutoFormat", "TRUE" WriteConfigSetting displaySettingsSection$, "IDE_AutoFormat", "True"
ELSE ELSE
WriteConfigSetting "'[IDE DISPLAY SETTINGS]", "IDE_AutoFormat", "FALSE" WriteConfigSetting displaySettingsSection$, "IDE_AutoFormat", "False"
END IF END IF
IF ideautolayoutkwcapitals THEN IF ideautolayoutkwcapitals THEN
WriteConfigSetting "'[IDE DISPLAY SETTINGS]", "IDE_KeywordCapital", "TRUE" WriteConfigSetting displaySettingsSection$, "IDE_KeywordCapital", "True"
ELSE ELSE
WriteConfigSetting "'[IDE DISPLAY SETTINGS]", "IDE_KeywordCapital", "FALSE" WriteConfigSetting displaySettingsSection$, "IDE_KeywordCapital", "False"
END IF END IF
IF ideautoindent THEN IF ideautoindent THEN
WriteConfigSetting "'[IDE DISPLAY SETTINGS]", "IDE_AutoIndent", "TRUE" WriteConfigSetting displaySettingsSection$, "IDE_AutoIndent", "True"
ELSE ELSE
WriteConfigSetting "'[IDE DISPLAY SETTINGS]", "IDE_AutoIndent", "FALSE" WriteConfigSetting displaySettingsSection$, "IDE_AutoIndent", "False"
END IF END IF
WriteConfigSetting "'[IDE DISPLAY SETTINGS]", "IDE_IndentSize", STR$(ideautoindentsize) WriteConfigSetting displaySettingsSection$, "IDE_IndentSize", STR$(ideautoindentsize)
IF ideindentsubs THEN IF ideindentsubs THEN
WriteConfigSetting "'[IDE DISPLAY SETTINGS]", "IDE_IndentSUBs", "TRUE" WriteConfigSetting displaySettingsSection$, "IDE_IndentSUBs", "True"
ELSE ELSE
WriteConfigSetting "'[IDE DISPLAY SETTINGS]", "IDE_IndentSUBs", "FALSE" WriteConfigSetting displaySettingsSection$, "IDE_IndentSUBs", "False"
END IF END IF
EXIT FUNCTION EXIT FUNCTION
END IF END IF
@ -10506,7 +10497,7 @@ FUNCTION idebackupbox
END IF END IF
idebackupsize = v& idebackupsize = v&
WriteConfigSetting "'[GENERAL SETTINGS]", "BackupSize", STR$(v&) + " 'in MB" WriteConfigSetting generalSettingsSection$, "BackupSize", STR$(v&) + " 'in MB"
idebackupbox = 1 idebackupbox = 1
END FUNCTION END FUNCTION
@ -10663,9 +10654,9 @@ FUNCTION ideadvancedbox
IF v% <> idedebuginfo THEN IF v% <> idedebuginfo THEN
idedebuginfo = v% idedebuginfo = v%
IF idedebuginfo THEN IF idedebuginfo THEN
WriteConfigSetting "'[GENERAL SETTINGS]", "DebugInfo", "TRUE 'INTERNAL VARIABLE USE ONLY!! DO NOT MANUALLY CHANGE!" WriteConfigSetting generalSettingsSection$, "DebugInfo", "True" + DebugInfoIniWarning$
ELSE ELSE
WriteConfigSetting "'[GENERAL SETTINGS]", "DebugInfo", "FALSE 'INTERNAL VARIABLE USE ONLY!! DO NOT MANUALLY CHANGE!" WriteConfigSetting generalSettingsSection$, "DebugInfo", "False" + DebugInfoIniWarning$
END IF END IF
Include_GDB_Debugging_Info = idedebuginfo Include_GDB_Debugging_Info = idedebuginfo
IF os$ = "WIN" THEN IF os$ = "WIN" THEN
@ -11143,7 +11134,7 @@ FUNCTION idedisplaybox
idecustomfonthandle = _LOADFONT(v$, v%, "MONOSPACE") idecustomfonthandle = _LOADFONT(v$, v%, "MONOSPACE")
IF idecustomfonthandle = -1 THEN IF idecustomfonthandle = -1 THEN
'failed! - revert to default settings 'failed! - revert to default settings
o(5).sel = 0: idetxt(o(6).txt) = "c:\windows\fonts\lucon.ttf": idetxt(o(7).txt) = "21": IF IDE_UseFont8 THEN _FONT 8 ELSE _FONT 16 o(5).sel = 0: idetxt(o(6).txt) = "C:\Windows\Fonts\lucon.ttf": idetxt(o(7).txt) = "21": IF IDE_UseFont8 THEN _FONT 8 ELSE _FONT 16
ELSE ELSE
_FONT idecustomfonthandle _FONT idecustomfonthandle
END IF END IF
@ -11186,25 +11177,25 @@ FUNCTION idedisplaybox
idecustomfontheight = v% idecustomfontheight = v%
WriteConfigSetting "'[IDE DISPLAY SETTINGS]", "IDE_Width", STR$(idewx) WriteConfigSetting windowSettingsSection$ + iniFolderIndex$, "IDE_Width", STR$(idewx)
WriteConfigSetting "'[IDE DISPLAY SETTINGS]", "IDE_Height", STR$(idewy) WriteConfigSetting windowSettingsSection$ + iniFolderIndex$, "IDE_Height", STR$(idewy)
IF idecustomfont THEN IF idecustomfont THEN
WriteConfigSetting "'[IDE DISPLAY SETTINGS]", "IDE_CustomFont", "TRUE" WriteConfigSetting displaySettingsSection$, "IDE_CustomFont", "True"
ELSE ELSE
WriteConfigSetting "'[IDE DISPLAY SETTINGS]", "IDE_CustomFont", "FALSE" WriteConfigSetting displaySettingsSection$, "IDE_CustomFont", "False"
END IF END IF
IF IDE_UseFont8 THEN IF IDE_UseFont8 THEN
WriteConfigSetting "'[IDE DISPLAY SETTINGS]", "IDE_UseFont8", "TRUE" WriteConfigSetting displaySettingsSection$, "IDE_UseFont8", "True"
ELSE ELSE
WriteConfigSetting "'[IDE DISPLAY SETTINGS]", "IDE_UseFont8", "FALSE" WriteConfigSetting displaySettingsSection$, "IDE_UseFont8", "False"
END IF END IF
IF IDE_AutoPosition THEN IF IDE_AutoPosition THEN
WriteConfigSetting "'[IDE DISPLAY SETTINGS]", "IDE_AutoPosition", "TRUE" WriteConfigSetting displaySettingsSection$, "IDE_AutoPosition", "True"
ELSE ELSE
WriteConfigSetting "'[IDE DISPLAY SETTINGS]", "IDE_AutoPosition", "FALSE" WriteConfigSetting displaySettingsSection$, "IDE_AutoPosition", "False"
END IF END IF
WriteConfigSetting "'[IDE DISPLAY SETTINGS]", "IDE_CustomFont$", idecustomfontfile$ WriteConfigSetting displaySettingsSection$, "IDE_CustomFont$", idecustomfontfile$
WriteConfigSetting "'[IDE DISPLAY SETTINGS]", "IDE_CustomFontSize", STR$(idecustomfontheight) WriteConfigSetting displaySettingsSection$, "IDE_CustomFontSize", STR$(idecustomfontheight)
EXIT FUNCTION EXIT FUNCTION
@ -11327,7 +11318,7 @@ FUNCTION idechoosecolorsbox
o(i).txt = idenewtxt("#OK" + sep + "Restore #defaults" + sep + "#Cancel") o(i).txt = idenewtxt("#OK" + sep + "Restore #defaults" + sep + "#Cancel")
o(i).dft = 1 o(i).dft = 1
result = ReadConfigSetting("SchemeID", value$) result = ReadConfigSetting(colorSettingsSection$, "SchemeID", value$)
SchemeID = VAL(value$) SchemeID = VAL(value$)
IF SchemeID > TotalColorSchemes THEN SchemeID = 0 IF SchemeID > TotalColorSchemes THEN SchemeID = 0
@ -11559,7 +11550,7 @@ FUNCTION idechoosecolorsbox
i = 0 i = 0
DO DO
i = i + 1 i = i + 1
result = ReadConfigSetting("Scheme" + str2$(i) + "$", value$) result = ReadConfigSetting(colorSchemesSection$, "Scheme" + str2$(i) + "$", value$)
IF value$ = "" OR value$ = "0" THEN EXIT DO IF value$ = "" OR value$ = "0" THEN EXIT DO
LOOP LOOP
@ -11585,7 +11576,7 @@ FUNCTION idechoosecolorsbox
NEXT j NEXT j
'Save user scheme 'Save user scheme
WriteConfigSetting "'[IDE COLOR SCHEMES]", "Scheme" + str2$(i) + "$", SchemeString$ WriteConfigSetting colorSchemesSection$, "Scheme" + str2$(i) + "$", SchemeString$
LoadColorSchemes LoadColorSchemes
SchemeID = PresetColorSchemes + i SchemeID = PresetColorSchemes + i
ChangedScheme = -1 ChangedScheme = -1
@ -11623,7 +11614,7 @@ FUNCTION idechoosecolorsbox
NEXT j NEXT j
'Save user scheme 'Save user scheme
WriteConfigSetting "'[IDE COLOR SCHEMES]", "Scheme" + str2$(i) + "$", SchemeString$ WriteConfigSetting colorSchemesSection$, "Scheme" + str2$(i) + "$", SchemeString$
LoadColorSchemes LoadColorSchemes
SchemeID = PresetColorSchemes + i SchemeID = PresetColorSchemes + i
ChangedScheme = -1 ChangedScheme = -1
@ -11639,7 +11630,7 @@ FUNCTION idechoosecolorsbox
K$ = "" K$ = ""
IF what$ = "Y" THEN IF what$ = "Y" THEN
i = SchemeID - PresetColorSchemes i = SchemeID - PresetColorSchemes
WriteConfigSetting "'[IDE COLOR SCHEMES]", "Scheme" + str2$(i) + "$", "0" WriteConfigSetting colorSchemesSection$, "Scheme" + str2$(i) + "$", "0"
LoadColorSchemes LoadColorSchemes
SchemeID = SchemeID - 1 SchemeID = SchemeID - 1
ChangedScheme = -1 ChangedScheme = -1
@ -11898,7 +11889,7 @@ FUNCTION idechoosecolorsbox
'save changes 'save changes
GOSUB enableHighlighter GOSUB enableHighlighter
WriteConfigSetting "'[IDE COLOR SETTINGS]", "SchemeID", str2$(SchemeID) WriteConfigSetting colorSettingsSection$, "SchemeID", str2$(SchemeID)
FOR i = 1 TO 9 FOR i = 1 TO 9
SELECT CASE i SELECT CASE i
CASE 1: CurrentColor~& = IDETextColor: colorid$ = "TextColor" CASE 1: CurrentColor~& = IDETextColor: colorid$ = "TextColor"
@ -11911,12 +11902,7 @@ FUNCTION idechoosecolorsbox
CASE 8: CurrentColor~& = IDEBackgroundColor2: colorid$ = "BackgroundColor2" CASE 8: CurrentColor~& = IDEBackgroundColor2: colorid$ = "BackgroundColor2"
CASE 9: CurrentColor~& = IDEBracketHighlightColor: colorid$ = "HighlightColor" CASE 9: CurrentColor~& = IDEBracketHighlightColor: colorid$ = "HighlightColor"
END SELECT END SELECT
r$ = str2$(_RED32(CurrentColor~&)) WriteConfigSetting colorSettingsSection$, colorid$, rgbs$(CurrentColor~&)
g$ = str2$(_GREEN32(CurrentColor~&))
b$ = str2$(_BLUE32(CurrentColor~&))
RGBString$ = "_RGB32(" + r$ + "," + g$ + "," + b$ + ")"
WriteConfigSetting "'[IDE COLOR SETTINGS]", colorid$, RGBString$
NEXT i NEXT i
v% = o(5).sel v% = o(5).sel
@ -11924,9 +11910,9 @@ FUNCTION idechoosecolorsbox
brackethighlight = v% brackethighlight = v%
IF brackethighlight THEN IF brackethighlight THEN
WriteConfigSetting "'[GENERAL SETTINGS]", "BracketHighlight", "TRUE" WriteConfigSetting generalSettingsSection$, "BracketHighlight", "True"
ELSE ELSE
WriteConfigSetting "'[GENERAL SETTINGS]", "BracketHighlight", "FALSE" WriteConfigSetting generalSettingsSection$, "BracketHighlight", "False"
END IF END IF
v% = o(6).sel v% = o(6).sel
@ -11934,9 +11920,9 @@ FUNCTION idechoosecolorsbox
multihighlight = v% multihighlight = v%
IF multihighlight THEN IF multihighlight THEN
WriteConfigSetting "'[GENERAL SETTINGS]", "MultiHighlight", "TRUE" WriteConfigSetting generalSettingsSection$, "MultiHighlight", "True"
ELSE ELSE
WriteConfigSetting "'[GENERAL SETTINGS]", "MultiHighlight", "FALSE" WriteConfigSetting generalSettingsSection$, "MultiHighlight", "False"
END IF END IF
v% = o(7).sel v% = o(7).sel
@ -11944,9 +11930,9 @@ FUNCTION idechoosecolorsbox
keywordHighlight = v% keywordHighlight = v%
IF keywordHighlight THEN IF keywordHighlight THEN
WriteConfigSetting "'[GENERAL SETTINGS]", "KeywordHighlight", "TRUE" WriteConfigSetting generalSettingsSection$, "KeywordHighlight", "True"
ELSE ELSE
WriteConfigSetting "'[GENERAL SETTINGS]", "KeywordHighlight", "FALSE" WriteConfigSetting generalSettingsSection$, "KeywordHighlight", "False"
END IF END IF
EXIT FUNCTION EXIT FUNCTION
@ -11974,7 +11960,7 @@ FUNCTION idechoosecolorsbox
enableHighlighter: enableHighlighter:
IF DisableSyntaxHighlighter THEN IF DisableSyntaxHighlighter THEN
DisableSyntaxHighlighter = 0 DisableSyntaxHighlighter = 0
WriteConfigSetting "'[GENERAL SETTINGS]", "DisableSyntaxHighlighter", "FALSE" WriteConfigSetting generalSettingsSection$, "DisableSyntaxHighlighter", "False"
menu$(OptionsMenuID, OptionsMenuDisableSyntax) = CHR$(7) + "Syntax #Highlighter" menu$(OptionsMenuID, OptionsMenuDisableSyntax) = CHR$(7) + "Syntax #Highlighter"
END IF END IF
RETURN RETURN
@ -14449,7 +14435,7 @@ SUB LoadColorSchemes
i = 0 i = 0
DO DO
i = i + 1 i = i + 1
result = ReadConfigSetting("Scheme" + str2$(i) + "$", value$) result = ReadConfigSetting(colorSchemesSection$, "Scheme" + str2$(i) + "$", value$)
IF result THEN IF result THEN
TotalColorSchemes = TotalColorSchemes + 1 TotalColorSchemes = TotalColorSchemes + 1
IF TotalColorSchemes > UBOUND(ColorSchemes$) THEN IF TotalColorSchemes > UBOUND(ColorSchemes$) THEN
@ -14468,7 +14454,7 @@ SUB LoadColorSchemes
temp$ = temp$ + MID$(value$, FoundPipe + 1, 9) + "069147216245128177" temp$ = temp$ + MID$(value$, FoundPipe + 1, 9) + "069147216245128177"
temp$ = temp$ + MID$(value$, FoundPipe + 10) + "000147177" temp$ = temp$ + MID$(value$, FoundPipe + 10) + "000147177"
ColorSchemes$(TotalColorSchemes) = temp$ ColorSchemes$(TotalColorSchemes) = temp$
WriteConfigSetting "'[IDE COLOR SCHEMES]", "Scheme" + str2$(i) + "$", temp$ WriteConfigSetting colorSchemesSection$, "Scheme" + str2$(i) + "$", temp$
LastValidColorScheme = TotalColorSchemes LastValidColorScheme = TotalColorSchemes
ELSE ELSE
GOTO DiscardInvalid GOTO DiscardInvalid

View file

@ -14,6 +14,7 @@ $SCREENHIDE
'$INCLUDE:'global\settings.bas' '$INCLUDE:'global\settings.bas'
'$INCLUDE:'global\constants.bas' '$INCLUDE:'global\constants.bas'
'$INCLUDE:'subs_functions\extensions\opengl\opengl_global.bas' '$INCLUDE:'subs_functions\extensions\opengl\opengl_global.bas'
'$INCLUDE:'utilities\ini-manager\ini.bi'
DEFLNG A-Z DEFLNG A-Z
@ -3620,7 +3621,8 @@ DO
GOTO finishednonexec GOTO finishednonexec
END IF END IF
IF n < 3 THEN definingtypeerror = linenumber: a$ = "Expected element-name AS type or AS type element-list": GOTO errmes 'IF n < 3 THEN definingtypeerror = linenumber: a$ = "Expected element-name AS type or AS type element-list": GOTO errmes
IF n < 3 THEN a$ = "Expected element-name AS type or AS type element-list": GOTO errmes
definingtype = 2 definingtype = 2
IF firstelement$ = "AS" THEN IF firstelement$ = "AS" THEN
l$ = SCase$("As") l$ = SCase$("As")
@ -12901,7 +12903,13 @@ IF idemode THEN
END IF END IF
'non-ide mode output 'non-ide mode output
PRINT PRINT
IF NOT MonochromeLoggingMode THEN COLOR 4 IF NOT MonochromeLoggingMode THEN
IF INSTR(_OS$, "WIN") THEN
COLOR 4
ELSE
COLOR 9
END IF
END IF
PRINT a$ PRINT a$
IF NOT MonochromeLoggingMode THEN COLOR 7 IF NOT MonochromeLoggingMode THEN COLOR 7
FOR i = 1 TO LEN(linefragment) FOR i = 1 TO LEN(linefragment)
@ -12991,11 +12999,11 @@ FUNCTION ParseCMDLineArgs$ ()
IF SaveExeWithSource THEN PRINT "true" ELSE PRINT "false" IF SaveExeWithSource THEN PRINT "true" ELSE PRINT "false"
SYSTEM SYSTEM
CASE ":exewithsource=true" CASE ":exewithsource=true"
WriteConfigSetting "'[GENERAL SETTINGS]", "SaveExeWithSource", "TRUE" WriteConfigSetting generalSettingsSection$, "SaveExeWithSource", "True"
PRINT "exewithsource = true" PRINT "exewithsource = true"
SaveExeWithSource = -1 SaveExeWithSource = -1
CASE ":exewithsource=false" CASE ":exewithsource=false"
WriteConfigSetting "'[GENERAL SETTINGS]", "SaveExeWithSource", "FALSE" WriteConfigSetting generalSettingsSection$, "SaveExeWithSource", "False"
PRINT "exewithsource = false" PRINT "exewithsource = false"
SaveExeWithSource = 0 SaveExeWithSource = 0
CASE ":debuginfo" CASE ":debuginfo"
@ -13004,7 +13012,7 @@ FUNCTION ParseCMDLineArgs$ ()
SYSTEM SYSTEM
CASE ":debuginfo=true" CASE ":debuginfo=true"
PRINT "debuginfo = true" PRINT "debuginfo = true"
WriteConfigSetting "'[GENERAL SETTINGS]", "DebugInfo", "TRUE 'INTERNAL VARIABLE USE ONLY!! DO NOT MANUALLY CHANGE!" WriteConfigSetting generalSettingsSection$, "DebugInfo", "True" + DebugInfoIniWarning$
idedebuginfo = 1 idedebuginfo = 1
Include_GDB_Debugging_Info = idedebuginfo Include_GDB_Debugging_Info = idedebuginfo
IF os$ = "WIN" THEN IF os$ = "WIN" THEN
@ -13024,7 +13032,7 @@ FUNCTION ParseCMDLineArgs$ ()
END IF END IF
CASE ":debuginfo=false" CASE ":debuginfo=false"
PRINT "debuginfo = false" PRINT "debuginfo = false"
WriteConfigSetting "'[GENERAL SETTINGS]", "DebugInfo", "FALSE 'INTERNAL VARIABLE USE ONLY!! DO NOT MANUALLY CHANGE!" WriteConfigSetting generalSettingsSection$, "DebugInfo", "False" + DebugInfoIniWarning$
idedebuginfo = 0 idedebuginfo = 0
Include_GDB_Debugging_Info = idedebuginfo Include_GDB_Debugging_Info = idedebuginfo
IF os$ = "WIN" THEN IF os$ = "WIN" THEN
@ -25063,124 +25071,39 @@ SUB Give_Error (a$)
Error_Message = a$ Error_Message = a$
END SUB END SUB
SUB WriteConfigSetting (heading$, item$, tvalue$) SUB WriteConfigSetting (section$, item$, value$)
value$ = tvalue$ WriteSetting ConfigFile$, section$, item$, value$
SHARED ConfigFile$, ConfigBak$
InFile = FREEFILE: OPEN ConfigFile$ FOR BINARY AS #InFile
OutFile = FREEFILE: OPEN ConfigBak$ FOR OUTPUT AS #OutFile
placed = 0
'check for quotes where needed for strings
IF RIGHT$(RTRIM$(item$), 1) = "$" THEN
IF LEFT$(value$, 1) <> CHR$(34) THEN value$ = CHR$(34) + value$
IF RIGHT$(value$, 1) <> CHR$(34) THEN value$ = value$ + CHR$(34)
END IF
IF LOF(InFile) THEN
DO UNTIL EOF(InFile)
LINE INPUT #InFile, junk$
'we really don't care about heading$ here; it's only used to make things easier for the user to locate in the config file
junk$ = LTRIM$(RTRIM$(junk$))
l = INSTR(junk$, "=") 'compare the values to the left of the equal sign
compare$ = RTRIM$(LEFT$(junk$, l - 1))
IF UCASE$(compare$) = UCASE$(item$) THEN 'if it's a match, replace it
PRINT #OutFile, item$; " = "; value$
placed = -1
ELSE
PRINT #OutFile, junk$ 'otherwise put that line back and check the next one
END IF
LOOP
END IF
CLOSE #InFile, #OutFile
KILL ConfigFile$
IF NOT placed THEN 'we didn't find the proper setting already in the file somewhere.
'Either the file was corrupted, or the user deleted this particulat setting sometime in the past.
'Now we look to see if the heading exists in the file or not.
'If it does, then we place the new setting under that heading.
'If not then we write that heading to the end of the file to make it easier for the user to locate in the future
'and then we write it below there.
OPEN ConfigBak$ FOR BINARY AS #InFile
OPEN "internal/config.tmp" FOR OUTPUT AS #OutFile
out$ = item$ + " = " + value$
DO UNTIL EOF(InFile) OR LOF(InFile) = 0
LINE INPUT #InFile, temp$
PRINT #OutFile, temp$
IF INSTR(temp$, heading$) THEN PRINT #OutFile, out$: placed = -1 'If we have the heading, we want to print the item after it
LOOP
IF NOT placed THEN 'If the heading doesn't exist already then we'll make the heading and the item
PRINT #OutFile, ""
PRINT #OutFile, heading$
PRINT #OutFile, out$
END IF
CLOSE #InFile, #OutFile
KILL ConfigBak$
NAME "internal/config.tmp" AS ConfigFile$
ELSE
NAME ConfigBak$ AS ConfigFile$
END IF
END SUB END SUB
FUNCTION ReadConfigSetting (item$, value$) FUNCTION ReadConfigSetting (section$, item$, value$)
SHARED ConfigFile$ value$ = ReadSetting$(ConfigFile$, section$, item$)
value$ = "" 'We start by blanking the value$ as a default return state ReadConfigSetting = (LEN(value$) > 0)
InFile = FREEFILE: OPEN ConfigFile$ FOR BINARY AS #InFile
IF LOF(InFile) THEN
found = 0
DO UNTIL EOF(InFile)
LINE INPUT #InFile, temp$
temp$ = LTRIM$(RTRIM$(temp$))
l = INSTR(temp$, "=")
compare$ = LTRIM$(RTRIM$(LEFT$(temp$, l - 1)))
IF UCASE$(compare$) = UCASE$(item$) THEN found = -1: EXIT DO
LOOP
CLOSE #InFile
IF found THEN 'we found what we're looking for
IF l THEN
value$ = MID$(temp$, l + 1)
l = INSTR(value$, CHR$(13)) 'we only want what's before a CR
IF l THEN value$ = LEFT$(value$, l)
l = INSTR(value$, CHR$(10)) 'or a LineFeed
'These are basic text files; they shouldn't have stray CHR$(10) or CHR$(13) characters in them!
IF l THEN value$ = LEFT$(value$, l)
value$ = LTRIM$(RTRIM$(value$))
'check for quotes where needed for strings and remove them so our return value doesn't contain them
IF RIGHT$(RTRIM$(item$), 1) = "$" THEN
IF LEFT$(value$, 1) = CHR$(34) THEN value$ = MID$(value$, 2)
IF RIGHT$(value$, 1) = CHR$(34) THEN value$ = LEFT$(value$, LEN(value$) - 1)
END IF
ReadConfigSetting = -1
EXIT FUNCTION
END IF
END IF
END IF
CLOSE #InFile
ReadConfigSetting = 0 'failed to find the setting
END FUNCTION END FUNCTION
FUNCTION VRGBS (text$, DefaultColor AS _UNSIGNED LONG) FUNCTION VRGBS~& (text$, DefaultColor AS _UNSIGNED LONG)
'Value of RGB String = VRGBS without a ton of typing 'Value of RGB String = VRGBS without a ton of typing
'A function to get the RGB value back from a string such as _RGB32(255,255,255) 'A function to get the RGB value back from a string such as _RGB32(255,255,255)
'text$ is the string that we send to check for a value 'text$ is the string that we send to check for a value
'DefaultColor is the value we send back if the string isn't in the proper format 'DefaultColor is the value we send back if the string isn't in the proper format
VRGBS = DefaultColor 'A return the default value if we can't parse the string properly VRGBS~& = DefaultColor 'A return the default value if we can't parse the string properly
IF UCASE$(LEFT$(text$, 4)) = "_RGB" THEN IF UCASE$(LEFT$(text$, 4)) = "_RGB" THEN
rpos = INSTR(text$, "(") rpos = INSTR(text$, "(")
gpos = INSTR(rpos, text$, ",") gpos = INSTR(rpos, text$, ",")
bpos = INSTR(gpos + 1, text$, ",") bpos = INSTR(gpos + 1, text$, ",")
IF rpos <> 0 AND bpos <> 0 AND gpos <> 0 THEN IF rpos <> 0 AND bpos <> 0 AND gpos <> 0 THEN
red = VAL(MID$(text$, rpos + 1)) red = VAL(_TRIM$(MID$(text$, rpos + 1)))
green = VAL(MID$(text$, gpos + 1)) green = VAL(_TRIM$(MID$(text$, gpos + 1)))
blue = VAL(MID$(text$, bpos + 1)) blue = VAL(_TRIM$(MID$(text$, bpos + 1)))
VRGBS = _RGB32(red, green, blue) VRGBS~& = _RGB32(red, green, blue)
END IF END IF
END IF END IF
END FUNCTION END FUNCTION
FUNCTION rgbs$ (c AS _UNSIGNED LONG)
rgbs$ = "_RGB32(" + _TRIM$(STR$(_RED32(c))) + ", " + _TRIM$(STR$(_GREEN32(c))) + ", " + _TRIM$(STR$(_BLUE32(c))) + ")"
END FUNCTION
FUNCTION EvalPreIF (text$, err$) FUNCTION EvalPreIF (text$, err$)
temp$ = text$ 'so we don't corrupt the string sent to us for evaluation temp$ = text$ 'so we don't corrupt the string sent to us for evaluation
err$ = "" 'null the err message to begin with err$ = "" 'null the err message to begin with
@ -25593,8 +25516,8 @@ FUNCTION SCase2$ (t$)
END FUNCTION END FUNCTION
'$INCLUDE:'utilities\strings.bas' '$INCLUDE:'utilities\strings.bas'
'$INCLUDE:'subs_functions\extensions\opengl\opengl_methods.bas' '$INCLUDE:'subs_functions\extensions\opengl\opengl_methods.bas'
'$INCLUDE:'utilities\ini-manager\ini.bm'
DEFLNG A-Z DEFLNG A-Z

View file

@ -0,0 +1,21 @@
'INI Manager
'Fellippe Heitor, 2017-2021 - fellippe@qb64.org - @fellippeheitor
'This file isn't required to be at the top of your programs,
'unless you intend to use OPTION _EXPLICIT
'Global variables declaration
DIM currentIniFileName$
DIM currentIniFileLOF AS _UNSIGNED LONG
DIM IniWholeFile$
DIM IniSectionData$
DIM IniPosition AS _UNSIGNED LONG
DIM IniNewFile$
DIM IniLastSection$
DIM IniLastKey$
DIM IniLF$
DIM IniDisableAutoCommit
DIM IniCODE
DIM IniAllowBasicComments
DIM IniForceReload
DIM IniDisableAddQuotes

View file

@ -0,0 +1,501 @@
'INI Manager v1.01
'Fellippe Heitor, 2017-2021 - fellippe@qb64.org - @fellippeheitor
SUB IniCommit
SHARED currentIniFileName$, IniWholeFile$, currentIniFileLOF AS _UNSIGNED LONG
SHARED IniNewFile$, IniDisableAutoCommit, IniCODE
IF currentIniFileName$ = "" THEN IniCODE = 18: EXIT SUB
IniWholeFile$ = IniNewFile$
currentIniFileLOF = LEN(IniNewFile$)
IF NOT IniDisableAutoCommit THEN
DIM fileNum AS INTEGER
fileNum = FREEFILE
OPEN currentIniFileName$ FOR BINARY AS #fileNum
IF LEN(IniWholeFile$) < LOF(fileNum) THEN
CLOSE fileNum
OPEN currentIniFileName$ FOR OUTPUT AS #fileNum: CLOSE #fileNum
OPEN currentIniFileName$ FOR BINARY AS #fileNum
END IF
PUT #fileNum, 1, IniNewFile$
CLOSE #fileNum 'flush
END IF
END SUB
FUNCTION IniGetSection$ (__section$)
SHARED IniPosition AS _UNSIGNED LONG, IniCODE, currentIniFileName$
SHARED IniLF$, IniWholeFile$, currentIniFileLOF AS _UNSIGNED LONG
IF currentIniFileName$ = "" THEN IniCODE = 18: EXIT FUNCTION
IF currentIniFileLOF = 0 OR LEN(LTRIM$(RTRIM$(IniWholeFile$))) = 0 THEN IniCODE = 17: EXIT FUNCTION
IniCODE = 0
DIM section$, foundSection AS _UNSIGNED LONG, endSection AS _UNSIGNED LONG
DIM i AS _UNSIGNED LONG, Bracket1 AS _UNSIGNED LONG, sectionStart AS _UNSIGNED LONG
DIM inQuote AS _BYTE
section$ = IniFormatSection$(__section$)
IF IniCODE THEN EXIT FUNCTION
IF section$ = "[]" THEN
'fetch the "global" section, if present
sectionStart = INSTR(IniWholeFile$, "[")
IF sectionStart = 0 THEN IniGetSection$ = IniWholeFile$: EXIT FUNCTION
FOR i = sectionStart - 1 TO 1 STEP -1
IF ASC(IniWholeFile$, i) = 10 THEN foundSection = i + 1: EXIT FOR
IF ASC(IniWholeFile$, i) <> 32 THEN EXIT FOR
NEXT
IF i = 0 THEN foundSection = 1
IniGetSection$ = LEFT$(IniWholeFile$, foundSection - 1)
ELSE
DO
sectionStart = INSTR(sectionStart + 1, LCASE$(IniWholeFile$), LCASE$(section$))
IF sectionStart = 0 THEN IniCODE = 14: EXIT DO
'make sure it's a valid section header
foundSection = 0
FOR i = sectionStart - 1 TO 1 STEP -1
IF ASC(IniWholeFile$, i) = 10 THEN foundSection = i + 1: EXIT FOR
IF ASC(IniWholeFile$, i) <> 32 THEN EXIT FOR
NEXT
IF i = 0 THEN foundSection = 1
IF foundSection > 0 THEN
'we found it; time to identify where this section ends
'(either another [section] or the end of the file
Bracket1 = sectionStart
checkAgain:
Bracket1 = INSTR(Bracket1 + 1, IniWholeFile$, "[")
IF Bracket1 > 0 THEN
'found a bracket; check if it's inside quotes
inQuote = 0
FOR i = 1 TO Bracket1 - 1
IF ASC(IniWholeFile$, i) = 34 THEN inQuote = NOT inQuote
NEXT
IF inQuote THEN GOTO checkAgain
FOR i = Bracket1 - 1 TO 1 STEP -1
IF ASC(IniWholeFile$, i) = 10 THEN endSection = i + 1 - LEN(IniLF$): EXIT FOR
IF ASC(IniWholeFile$, i) = 61 THEN GOTO checkAgain 'bracket is inside a key's value
IF i <= foundSection THEN EXIT FOR
NEXT
IniGetSection$ = MID$(IniWholeFile$, foundSection, endSection - foundSection)
ELSE
IniGetSection$ = MID$(IniWholeFile$, foundSection)
END IF
EXIT FUNCTION
END IF
LOOP
END IF
END FUNCTION
FUNCTION IniFormatSection$ (__section$)
SHARED IniCODE
DIM section$
section$ = LTRIM$(RTRIM$(__section$))
'sections are in the format [section name] - add brackets if not passed
IF LEFT$(section$, 1) <> "[" THEN section$ = "[" + section$
IF RIGHT$(section$, 1) <> "]" THEN section$ = section$ + "]"
IF INSTR(MID$(section$, 2, LEN(section$) - 3), "[") OR INSTR(MID$(section$, 2, LEN(section$) - 3), "]") THEN
IniCODE = 15
EXIT FUNCTION
END IF
IniFormatSection$ = section$
END FUNCTION
FUNCTION ReadSetting$ (file$, __section$, __key$)
SHARED IniLastSection$, IniLastKey$, IniWholeFile$, IniLF$
SHARED IniPosition AS _UNSIGNED LONG, IniSectionData$
SHARED IniCODE, IniAllowBasicComments
SHARED currentIniFileLOF AS _UNSIGNED LONG
IniLoad file$
IF IniCODE THEN EXIT FUNCTION
IF currentIniFileLOF = 0 OR LEN(LTRIM$(RTRIM$(IniWholeFile$))) = 0 THEN IniCODE = 17: EXIT FUNCTION
DIM Equal AS _UNSIGNED LONG, tempValue$, key$, section$
DIM Quote AS _UNSIGNED LONG, Comment AS _UNSIGNED LONG
DIM i AS LONG, FoundLF AS _UNSIGNED LONG
section$ = IniFormatSection(__section$)
IF IniCODE THEN EXIT FUNCTION
'fetch the desired section$
IniSectionData$ = IniGetSection(section$)
IF IniCODE > 0 AND IniCODE <> 17 THEN EXIT FUNCTION
IF LEN(IniSectionData$) = 0 AND section$ <> "[]" THEN IniCODE = 14: EXIT FUNCTION
IniLastSection$ = section$
IniPosition = 0
key$ = LTRIM$(RTRIM$(__key$))
IniLastKey$ = ""
IF key$ = "" THEN IniCODE = 12: EXIT FUNCTION
IF LEFT$(key$, 1) = ";" OR LEFT$(key$, 1) = "'" OR INSTR(key$, "[") > 0 OR INSTR(key$, "]") > 0 OR INSTR(key$, "=") > 0 THEN
IniCODE = 12
EXIT FUNCTION
END IF
IniLastKey$ = key$
IF IniPosition > 0 THEN Equal = IniPosition: GOTO KeyFound
CheckKey:
IniPosition = INSTR(IniPosition + 1, LCASE$(IniSectionData$), LCASE$(key$))
IF IniPosition > 0 THEN
'identify if this occurrence is actually a key and not part of a key name/value
FOR i = IniPosition - 1 TO 1 STEP -1
IF ASC(IniSectionData$, i) = 10 THEN EXIT FOR
IF ASC(IniSectionData$, i) <> 10 AND ASC(IniSectionData$, i) <> 32 THEN
'not a key
GOTO CheckKey
END IF
NEXT
'check if there's nothing but an equal sign ahead
FOR i = IniPosition + LEN(key$) TO LEN(IniSectionData$)
IF ASC(IniSectionData$, i) = ASC("=") THEN EXIT FOR
IF ASC(IniSectionData$, i) <> ASC("=") AND ASC(IniSectionData$, i) <> 32 THEN
'not the key
GOTO CheckKey
END IF
NEXT
'so far so good; check if there is an assignment
Equal = INSTR(IniPosition, IniSectionData$, "=")
KeyFound:
FoundLF = INSTR(IniPosition, IniSectionData$, IniLF$)
IF FoundLF > 0 THEN
IF Equal > FoundLF THEN GOTO CheckKey
ELSE
FoundLF = LEN(IniSectionData$) + 1
IF Equal = 0 THEN GOTO CheckKey
END IF
tempValue$ = LTRIM$(RTRIM$(MID$(IniSectionData$, Equal + 1, FoundLF - Equal - 1)))
IF LEN(tempValue$) > 0 THEN
IF LEFT$(tempValue$, 1) = CHR$(34) THEN
tempValue$ = MID$(tempValue$, 2)
Quote = INSTR(tempValue$, CHR$(34))
IF Quote > 0 THEN
tempValue$ = LEFT$(tempValue$, Quote - 1)
END IF
ELSE
IF IniAllowBasicComments THEN Comment = INSTR(tempValue$, "'") 'BASIC style comments accepted
IF Comment = 0 THEN Comment = INSTR(tempValue$, ";")
IF Comment > 0 THEN
tempValue$ = LTRIM$(RTRIM$(LEFT$(tempValue$, Comment - 1)))
END IF
END IF
ELSE
IniCODE = 2
END IF
ELSE
IniCODE = 3
EXIT FUNCTION
END IF
ReadSetting$ = tempValue$
IniLastSection$ = IniCurrentSection$
END FUNCTION
FUNCTION IniCurrentSection$
SHARED IniPosition AS _UNSIGNED LONG, IniSectionData$, IniWholeFile$
DIM GlobalPosition AS _UNSIGNED LONG, i AS _UNSIGNED LONG
DIM ClosingBracket AS _UNSIGNED LONG
GlobalPosition = INSTR(IniWholeFile$, IniSectionData$) + IniPosition - 1
CheckSection:
FOR i = GlobalPosition - 1 TO 1 STEP -1
IF ASC(IniWholeFile$, i) = ASC("[") THEN
GlobalPosition = i: EXIT FOR
END IF
NEXT
IF i = 0 THEN IniCurrentSection$ = "[]": EXIT FUNCTION
'identify if this occurrence is actually a section header and not something else
FOR i = GlobalPosition - 1 TO 1 STEP -1
IF ASC(IniWholeFile$, i) = 10 THEN EXIT FOR
IF ASC(IniWholeFile$, i) <> 10 AND ASC(IniWholeFile$, i) <> 32 THEN
'not a section header
GOTO CheckSection
END IF
NEXT
ClosingBracket = INSTR(GlobalPosition, IniWholeFile$, "]")
IF ClosingBracket > 0 THEN
IniCurrentSection$ = MID$(IniWholeFile$, GlobalPosition, ClosingBracket - GlobalPosition + 1)
END IF
END FUNCTION
SUB WriteSetting (file$, __section$, __key$, __value$)
SHARED IniPosition AS _UNSIGNED LONG, IniCODE, currentIniFileName$
SHARED IniLF$, IniWholeFile$, IniSectionData$
SHARED IniLastSection$, IniLastKey$, IniNewFile$
SHARED IniDisableAddQuotes
DIM tempValue$, section$, key$, value$
IniCODE = 0
'prepare variables for the write operation
section$ = IniFormatSection$(__section$)
IF IniCODE THEN EXIT SUB
key$ = LTRIM$(RTRIM$(__key$))
IF key$ = "" THEN IniCODE = 12: EXIT SUB
IniLastKey$ = key$
value$ = LTRIM$(RTRIM$(__value$))
IF LTRIM$(STR$(VAL(value$))) <> value$ THEN
IF NOT IniDisableAddQuotes THEN
'if not a numeric value and value contains spaces, add quotation marks
IF INSTR(value$, CHR$(32)) THEN value$ = CHR$(34) + value$ + CHR$(34)
END IF
END IF
'Read the existing key to fill IniPosition
tempValue$ = ReadSetting$(file$, section$, key$)
'map IniPosition (set in the section block) to the global file position
IniPosition = INSTR(IniWholeFile$, IniSectionData$) + IniPosition - 1
IF IniCODE = 1 OR IniCODE = 17 THEN
'file not found or empty; create a new one
IF file$ = "" THEN file$ = currentIniFileName$
IF file$ = "" THEN IniCODE = 21: EXIT SUB
currentIniFileName$ = file$
IF section$ <> "[]" THEN
IniNewFile$ = section$ + IniLF$
END IF
IniNewFile$ = IniNewFile$ + key$ + "=" + value$
IniCODE = 0
IniCommit
IniLoad file$
IF IniCODE = 0 THEN IniCODE = 11
IniLastSection$ = section$
EXIT SUB
END IF
IF IniCODE = 0 OR IniCODE = 2 THEN 'key found and read back; write new value$
IF LCASE$(IniLastSection$) = LCASE$(section$) THEN
IF LTRIM$(RTRIM$(__value$)) = tempValue$ AND LEN(LTRIM$(RTRIM$(__value$))) > 0 THEN
'identical values skip the writing routine
IniCODE = 8
EXIT SUB
END IF
DIM nextLine AS _UNSIGNED LONG
nextLine = INSTR(IniPosition + 1, IniWholeFile$, IniLF$)
'create new file contents
IniNewFile$ = LEFT$(IniWholeFile$, IniPosition - 1)
IniNewFile$ = IniNewFile$ + key$ + "=" + value$
IF nextLine > 0 THEN
IniNewFile$ = IniNewFile$ + MID$(IniWholeFile$, nextLine)
END IF
IniCommit
IniCODE = 4
END IF
ELSEIF IniCODE = 3 OR IniCODE = 14 THEN 'Key not found, Section not found
IniCODE = 0
IF LCASE$(IniLastSection$) = LCASE$(section$) THEN
'find this section$ in the current ini file;
DIM Bracket1 AS _UNSIGNED LONG
DIM beginSection AS _UNSIGNED LONG, endSection AS _UNSIGNED LONG
DIM i AS _UNSIGNED LONG
beginSection = 0
endSection = 0
CheckSection:
beginSection = INSTR(beginSection + 1, LCASE$(IniWholeFile$), LCASE$(section$))
IF beginSection = 0 THEN GOTO CreateSection
'identify if this occurrence is actually the section header and not something else
FOR i = beginSection - 1 TO 1 STEP -1
IF ASC(IniWholeFile$, i) = 10 THEN EXIT FOR
IF ASC(IniWholeFile$, i) <> 10 AND ASC(IniWholeFile$, i) <> 32 THEN
'not the section header
GOTO CheckSection
END IF
NEXT
'we found it; time to identify where this section ends
'(either another [section], a blank line or the end of the file
Bracket1 = INSTR(beginSection + 1, IniWholeFile$, "[")
IF Bracket1 > 0 THEN
FOR i = Bracket1 - 1 TO 1 STEP -1
IF ASC(IniWholeFile$, i) = 10 THEN endSection = i + 1 - LEN(IniLF$): EXIT FOR
IF i <= beginSection THEN EXIT FOR
NEXT
END IF
IF endSection > 0 THEN
'add values to the end of the specified section$
IniNewFile$ = LEFT$(IniWholeFile$, endSection - 1)
IniNewFile$ = IniNewFile$ + key$ + "=" + value$ + IniLF$
IF MID$(IniWholeFile$, endSection, LEN(IniLF$)) <> IniLF$ THEN IniNewFile$ = IniNewFile$ + IniLF$
IniNewFile$ = IniNewFile$ + MID$(IniWholeFile$, endSection)
ELSE
'add values to the end of the file
IniNewFile$ = IniWholeFile$
IF RIGHT$(IniNewFile$, LEN(IniLF$)) = IniLF$ THEN
IniNewFile$ = IniNewFile$ + key$ + "=" + value$
ELSE
IniNewFile$ = IniNewFile$ + IniLF$ + key$ + "=" + value$
END IF
END IF
IniCommit
IF IniCODE = 0 THEN IniCODE = 7
EXIT SUB
ELSE
CreateSection:
IniNewFile$ = IniWholeFile$
IF section$ = "[]" THEN GOTO WriteAtTop
IF RIGHT$(IniNewFile$, LEN(IniLF$) * 2) = IniLF$ + IniLF$ THEN
IniNewFile$ = IniNewFile$ + section$ + IniLF$ + key$ + "=" + value$ + IniLF$
ELSEIF RIGHT$(IniNewFile$, LEN(IniLF$)) = IniLF$ THEN
IniNewFile$ = IniNewFile$ + IniLF$ + section$ + IniLF$ + key$ + "=" + value$ + IniLF$
ELSE
IniNewFile$ = IniNewFile$ + IniLF$ + IniLF$ + section$ + IniLF$ + key$ + "=" + value$ + IniLF$
END IF
IniCommit
IF IniCODE = 0 THEN IniCODE = 9 ELSE IniCODE = 16
EXIT SUB
END IF
'if not found, key$=value$ is written to the beginning of the file
WriteAtTop:
IniNewFile$ = key$ + "=" + value$ + IniLF$
IF LEFT$(LTRIM$(IniWholeFile$), 1) = "[" THEN IniNewFile$ = IniNewFile$ + IniLF$
IniNewFile$ = IniNewFile$ + IniWholeFile$
IniCommit
IniCODE = 5
END IF
END SUB
SUB IniSetAddQuotes (state AS _BYTE)
SHARED IniDisableAddQuotes
IF state THEN
IniDisableAddQuotes = 0
ELSE
IniDisableAddQuotes = -1
END IF
END SUB
SUB IniSetForceReload (state AS _BYTE)
SHARED IniForceReload
IF state THEN
IniForceReload = -1
ELSE
IniForceReload = 0
END IF
END SUB
SUB IniSetAllowBasicComments (state AS _BYTE)
SHARED IniAllowBasicComments
IF state THEN
IniAllowBasicComments = -1
ELSE
IniAllowBasicComments = 0
END IF
END SUB
SUB IniSetAutoCommit (state AS _BYTE)
SHARED IniDisableAutoCommit
IF state THEN
IniDisableAutoCommit = 0
ELSE
IniDisableAutoCommit = -1
END IF
END SUB
SUB IniLoad (file$)
SHARED IniCODE, currentIniFileName$, IniLF$, IniWholeFile$
SHARED currentIniFileLOF AS _UNSIGNED LONG
SHARED IniForceReload
DIM fileNum AS INTEGER
'Error messages are returned with IniCODE
IniCODE = 0
IF file$ <> "" AND currentIniFileName$ <> file$ THEN currentIniFileName$ = ""
IF IniForceReload AND LEN(currentIniFileName$) > 0 THEN
file$ = currentIniFileName$
currentIniFileName$ = ""
END IF
'Passing an empty file$ is allowed if user already
'passed a valid file in this session.
IF currentIniFileName$ = "" THEN
'initialization
IF _FILEEXISTS(file$) THEN
currentIniFileName$ = file$
'Load file into memory
fileNum = FREEFILE
OPEN currentIniFileName$ FOR BINARY AS #fileNum
currentIniFileLOF = LOF(fileNum)
IniWholeFile$ = SPACE$(currentIniFileLOF)
GET #fileNum, 1, IniWholeFile$
CLOSE #fileNum
'Check if this ini file uses CRLF or LF
IF INSTR(IniWholeFile$, CHR$(13)) THEN IniLF$ = CHR$(13) + CHR$(10) ELSE IniLF$ = CHR$(10)
ELSE
IniFileNotFound:
IniCODE = 1
$IF WIN THEN
IniLF$ = CHR$(13) + CHR$(10)
$ELSE
IniLF$ = CHR$(10)
$END IF
EXIT SUB
END IF
ELSEIF NOT _FILEEXISTS(currentIniFileName$) THEN
currentIniFileName$ = ""
GOTO IniFileNotFound
END IF
END SUB

View file

@ -0,0 +1,2 @@
This is a reduced version of INI-Manager. The full package can be downloaded
from https://github.com/FellippeHeitor/INI-Manager.