From 2147911ec30329e94ed2723e3901994672abc464 Mon Sep 17 00:00:00 2001 From: SteveMcNeill Date: Mon, 14 Nov 2022 17:47:27 -0500 Subject: [PATCH 1/2] Swap in Optional New Load File Dialog And without screwing up the keyword casing this time! ;) --- source/ide/ide_methods.bas | 112 ++++++++++++++++++++++++++++++++++++- source/qb64pe.bas | 1 + 2 files changed, 112 insertions(+), 1 deletion(-) diff --git a/source/ide/ide_methods.bas b/source/ide/ide_methods.bas index edcb80c9f..7882aa9ba 100644 --- a/source/ide/ide_methods.bas +++ b/source/ide/ide_methods.bas @@ -447,6 +447,14 @@ FUNCTION ide2 (ignore) menuDesc$(m, i - 1) = "Toggles display of warning messages (unused variables, etc)" IF IgnoreWarnings THEN menu$(OptionsMenuID, OptionsMenuIgnoreWarnings) = CHR$(7) + "Ignore #Warnings" + OptionsMenuNewDialogs = i + menu$(m, i) = "New Dialogs": i = i + 1 + menuDesc$(m, i - 1) = "Uses New File Dialog Windows" + IF NewDialogs THEN + menu$(OptionsMenuID, i - 1) = CHR$(7) + menu$(OptionsMenuID, i - 1) + END IF + + 'OptionsMenuAutoComplete = i 'menu$(m, i) = "Code Suggest#ions": i = i + 1 'menuDesc$(m, i - 1) = "Toggles code suggestions/auto-complete" @@ -5044,6 +5052,25 @@ FUNCTION ide2 (ignore) GOTO ideloop END IF + IF RIGHT$(menu$(m, s), 11) = "New Dialogs" THEN + PCOPY 2, 0 + + IF NewDialogs = 0 THEN + NewDialogs = -1 + menu$(OptionsMenuID, OptionsMenuNewDialogs) = CHR$(7) + "New Dialogs" + ELSE + NewDialogs = 0 + menu$(OptionsMenuID, OptionsMenuNewDialogs) = "New Dialogs" + END IF + idechangemade = 1 + startPausedPending = 0 + PCOPY 3, 0: SCREEN , , 3, 0 + GOTO ideloop + END IF + + + + IF RIGHT$(menu$(m, s), 28) = "Output EXE to Source #Folder" THEN PCOPY 2, 0 SaveExeWithSource = NOT SaveExeWithSource @@ -6257,7 +6284,11 @@ FUNCTION ide2 (ignore) PCOPY 3, 0: SCREEN , , 3, 0 END IF '"Y" END IF 'unsaved - r$ = idefiledialog$("", 1) + IF NewDialogs Then + r$ = OpenFile$ (IdeOpenFile$) 'for new dialog file open routine. + ELSE + r$ = idefiledialog$("", 1) 'for old dialog file open routine. + END IF IF ideerror > 1 THEN PCOPY 3, 0: SCREEN , , 3, 0: GOTO IDEerrorMessage IF r$ <> "C" THEN ideunsaved = -1: idechangemade = 1: idelayoutallow = 2: ideundobase = 0: QuickNavTotal = 0: ModifyCOMMAND$ = "": idefocusline = 0: startPausedPending = 0 PCOPY 3, 0: SCREEN , , 3, 0 @@ -20192,4 +20223,83 @@ end sub ' Download = MKI$(0) 'still working 'END FUNCTION +Function OpenFile$ (IdeOpenFile as string)'load routine copied/pasted from the old IDE file load/save dialog routines + + ideopenloop: + if IdeOpenFile = "" THEN f$ = _OpenFileDialog$("Open Source File", "", "*.bas|*.BAS|*.Bas|*.bi|*.BI|*.Bi|*.bm|*.BM|*.Bm", "QB64-PE Source Files", 0) ELSE f$ = IdeOpenFile + if f$ = "" THEN OpenFile$ = "C":EXIT FUNCTION + path$ = ideztakepath$ (f$) + + IF _FILEEXISTS(path$ + idepathsep$ + f$) = 0 THEN 'see if the user forgot the .bas extension and check for the file + + IF (LCASE$(RIGHT$(f$, 4)) <> ".bas") AND AllFiles = 0 THEN f$ = f$ + ".bas" + + 'recheck to see if file exists with bas extension + ideerror = 2 + IF _FILEEXISTS(path$ + idepathsep$ + f$) = 0 THEN EXIT FUNCTION + + IdeOpenFile = path$ + idepathsep$ + f$ + + IF BinaryFormatCheck%(path$, idepathsep$, f$) > 0 THEN + IF LEN(IdeOpenFile) THEN + OpenFile$ = "C" + EXIT FUNCTION + ELSE + info = 0: GOTO ideopenloop 'tried to open a zero length file. Retry? + END IF + END IF + END IF + + 'load file + ideerror = 3 + idet$ = MKL$(0) + MKL$(0): idel = 1: ideli = 1: iden = 1: IdeBmkN = 0 + idesx = 1 + idesy = 1 + idecx = 1 + idecy = 1 + ideselect = 0 + idefocusline = 0 + lineinput3load path$ + idepathsep$ + f$ + idet$ = SPACE$(LEN(lineinput3buffer) * 8) + i2 = 1 + n = 0 + chrtab$ = CHR$(9) + space1$ = " ": space2$ = " ": space3$ = " ": space4$ = " " + chr7$ = CHR$(7): chr11$ = CHR$(11): chr12$ = CHR$(12): chr28$ = CHR$(28): chr29$ = CHR$(29): chr30$ = CHR$(30): chr31$ = CHR$(31) + DO + a$ = lineinput3$ + l = LEN(a$) + IF l THEN asca = ASC(a$) ELSE asca = -1 + IF asca <> 13 THEN + IF asca <> -1 THEN + 'fix tabs + ideopenfixtabs: + x = INSTR(a$, chrtab$) + IF x THEN + x2 = (x - 1) MOD 4 + IF x2 = 0 THEN a$ = LEFT$(a$, x - 1) + space4$ + RIGHT$(a$, l - x): l = l + 3: GOTO ideopenfixtabs + IF x2 = 1 THEN a$ = LEFT$(a$, x - 1) + space3$ + RIGHT$(a$, l - x): l = l + 2: GOTO ideopenfixtabs + IF x2 = 2 THEN a$ = LEFT$(a$, x - 1) + space2$ + RIGHT$(a$, l - x): l = l + 1: GOTO ideopenfixtabs + IF x2 = 3 THEN a$ = LEFT$(a$, x - 1) + space1$ + RIGHT$(a$, l - x): GOTO ideopenfixtabs + END IF + END IF 'asca<>-1 + MID$(idet$, i2, l + 8) = MKL$(l) + a$ + MKL$(l): i2 = i2 + l + 8: n = n + 1 + END IF + LOOP UNTIL asca = 13 + lineinput3buffer = "" + iden = n: IF n = 0 THEN idet$ = MKL$(0) + MKL$(0): iden = 1 ELSE idet$ = LEFT$(idet$, i2 - 1) + REDIM IdeBreakpoints(iden) AS _BYTE + REDIM IdeSkipLines(iden) AS _BYTE + variableWatchList$ = "" + backupVariableWatchList$ = "": REDIM backupUsedVariableList(1000) AS usedVarList + backupTypeDefinitions$ = "" + callstacklist$ = "": callStackLength = 0 + + ideerror = 1 + ideprogname = f$: _TITLE ideprogname + " - " + WindowTitle + listOfCustomKeywords$ = LEFT$(listOfCustomKeywords$, customKeywordsLength) + idepath$ = path$ + IdeAddRecent idepath$ + idepathsep$ + ideprogname$ + IdeImportBookmarks idepath$ + idepathsep$ + ideprogname$ +end sub diff --git a/source/qb64pe.bas b/source/qb64pe.bas index 58f29cbf8..e324565b0 100644 --- a/source/qb64pe.bas +++ b/source/qb64pe.bas @@ -74,6 +74,7 @@ IF INSTR(_OS$, "32BIT") THEN UserDefine(1, 5) = "-1": UserDefine(1, 6) = "0" ELS UserDefine(1, 7) = Version$ DIM SHARED QB64_uptime! +DIM SHARED AS INTEGER NewDialogs, OptionsMenuNewDialogs: NewDialogs = -1 QB64_uptime! = TIMER From 65cfbda3b72eba2b4be4067082079d2f795b7abf Mon Sep 17 00:00:00 2001 From: Matthew Kilgore Date: Tue, 15 Nov 2022 21:51:19 -0500 Subject: [PATCH 2/2] Rename 'New Dialogs' to 'GUI Dialogs', Persist setting The 'New Dialogs' menu option was renamed to 'GUI Dialogs' to better explain what it does. Additionally the setting of which dialogs to use is saved to the config.ini file so that it presists across multiple runs of QB64-PE. --- source/global/IDEsettings.bas | 3 +++ source/ide/ide_global.bas | 1 + source/ide/ide_methods.bas | 23 ++++++++++++----------- source/qb64pe.bas | 1 - 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/source/global/IDEsettings.bas b/source/global/IDEsettings.bas index c99c8193e..faca26d15 100644 --- a/source/global/IDEsettings.bas +++ b/source/global/IDEsettings.bas @@ -27,6 +27,7 @@ DIM SHARED StripDebugSymbols AS _UNSIGNED LONG DIM SHARED OptimizeCppProgram AS _UNSIGNED LONG DIM SHARED UseMiniaudioBackend AS _UNSIGNED LONG DIM SHARED GenerateLicenseFile AS _UNSIGNED LONG +DIM SHARED UseGuiDialogs AS _UNSIGNED LONG ConfigFile$ = "internal/config.ini" iniFolderIndex$ = STR$(tempfolderindex) @@ -231,6 +232,7 @@ IF ReadConfigSetting(generalSettingsSection$, "WikiBaseAddress", value$) THEN ELSE WriteConfigSetting generalSettingsSection$, "WikiBaseAddress", wikiBaseAddress$ END IF +UseGuiDialogs = ReadWriteBooleanSettingValue%(generalSettingsSection$, "UseGuiDialogs", -1) 'Mouse settings --------------------------------------------------------------- result = ReadConfigSetting(mouseSettingsSection$, "SwapMouseButton", value$) @@ -540,5 +542,6 @@ ExtraLinkerFlags = ReadWriteStringSettingValue$(compilerSettingsSection$, "Extra UseMiniaudioBackend = ReadWriteBooleanSettingValue%(compilerSettingsSection$, "UseMiniaudioBackend", -1) GenerateLicenseFile = ReadWriteBooleanSettingValue%(compilerSettingsSection$, "GenerateLicenseFile", 0) + 'End of initial settings ------------------------------------------------------ diff --git a/source/ide/ide_global.bas b/source/ide/ide_global.bas index 284e92c1e..bb763a406 100644 --- a/source/ide/ide_global.bas +++ b/source/ide/ide_global.bas @@ -223,6 +223,7 @@ DIM SHARED ViewMenuShowSeparatorID AS INTEGER, ViewMenuShowBGID AS INTEGER DIM SHARED ViewMenuCompilerWarnings AS INTEGER DIM SHARED RunMenuID AS INTEGER, RunMenuSaveExeWithSource AS INTEGER, brackethighlight AS INTEGER DIM SHARED GenerateLicenseEnableMenu AS INTEGER +DIM SHARED OptionsMenuGuiDialogs AS INTEGER DIM SHARED DebugMenuID AS INTEGER, DebugMenuCallStack AS INTEGER, DebugMenuWatchListToConsole AS INTEGER DIM SHARED DebugMenuAutoAddCommand AS INTEGER DIM SHARED multihighlight AS INTEGER, keywordHighlight AS INTEGER diff --git a/source/ide/ide_methods.bas b/source/ide/ide_methods.bas index 7882aa9ba..2bc1c9c8a 100644 --- a/source/ide/ide_methods.bas +++ b/source/ide/ide_methods.bas @@ -447,10 +447,10 @@ FUNCTION ide2 (ignore) menuDesc$(m, i - 1) = "Toggles display of warning messages (unused variables, etc)" IF IgnoreWarnings THEN menu$(OptionsMenuID, OptionsMenuIgnoreWarnings) = CHR$(7) + "Ignore #Warnings" - OptionsMenuNewDialogs = i - menu$(m, i) = "New Dialogs": i = i + 1 - menuDesc$(m, i - 1) = "Uses New File Dialog Windows" - IF NewDialogs THEN + OptionsMenuGuiDialogs = i + menu$(m, i) = "GUI Dialogs": i = i + 1 + menuDesc$(m, i - 1) = "Uses GUI-based File Dialog Windows" + IF UseGuiDialogs THEN menu$(OptionsMenuID, i - 1) = CHR$(7) + menu$(OptionsMenuID, i - 1) END IF @@ -5052,16 +5052,17 @@ FUNCTION ide2 (ignore) GOTO ideloop END IF - IF RIGHT$(menu$(m, s), 11) = "New Dialogs" THEN + IF RIGHT$(menu$(m, s), 11) = "GUI Dialogs" THEN PCOPY 2, 0 + UseGuiDialogs = NOT UseGuiDialogs + WriteConfigSetting generalSettingsSection$, "UseGuiDialogs", BoolToTFString$(UseGuiDialogs) - IF NewDialogs = 0 THEN - NewDialogs = -1 - menu$(OptionsMenuID, OptionsMenuNewDialogs) = CHR$(7) + "New Dialogs" + IF UseGuiDialogs THEN + menu$(OptionsMenuID, OptionsMenuGuiDialogs) = CHR$(7) + "GUI Dialogs" ELSE - NewDialogs = 0 - menu$(OptionsMenuID, OptionsMenuNewDialogs) = "New Dialogs" + menu$(OptionsMenuID, OptionsMenuGuiDialogs) = "GUI Dialogs" END IF + idechangemade = 1 startPausedPending = 0 PCOPY 3, 0: SCREEN , , 3, 0 @@ -6284,7 +6285,7 @@ FUNCTION ide2 (ignore) PCOPY 3, 0: SCREEN , , 3, 0 END IF '"Y" END IF 'unsaved - IF NewDialogs Then + IF UseGuiDialogs Then r$ = OpenFile$ (IdeOpenFile$) 'for new dialog file open routine. ELSE r$ = idefiledialog$("", 1) 'for old dialog file open routine. diff --git a/source/qb64pe.bas b/source/qb64pe.bas index e324565b0..58f29cbf8 100644 --- a/source/qb64pe.bas +++ b/source/qb64pe.bas @@ -74,7 +74,6 @@ IF INSTR(_OS$, "32BIT") THEN UserDefine(1, 5) = "-1": UserDefine(1, 6) = "0" ELS UserDefine(1, 7) = Version$ DIM SHARED QB64_uptime! -DIM SHARED AS INTEGER NewDialogs, OptionsMenuNewDialogs: NewDialogs = -1 QB64_uptime! = TIMER