From a6fe260a5e13a53fadf7665ade3168efa8eb1176 Mon Sep 17 00:00:00 2001 From: Fellippe Heitor Date: Thu, 4 Feb 2021 23:48:14 -0300 Subject: [PATCH] Adds item in Options menu to disable auto-complete. Fixes IgnoreWarnings not being saved in macOS/Linux. --- source/global/IDEsettings.bas | 38 +++++++++++++++++++++++++---------- source/ide/ide_global.bas | 2 +- source/ide/ide_methods.bas | 34 ++++++++++++++++++++++++------- 3 files changed, 55 insertions(+), 19 deletions(-) diff --git a/source/global/IDEsettings.bas b/source/global/IDEsettings.bas index e702454ba..fde3641cf 100644 --- a/source/global/IDEsettings.bas +++ b/source/global/IDEsettings.bas @@ -16,6 +16,7 @@ DIM SHARED ShowLineNumbersSeparator AS _BYTE, ShowLineNumbersUseBG AS _BYTE DIM SHARED IgnoreWarnings AS _BYTE, qb64versionprinted AS _BYTE DIM SHARED DisableSyntaxHighlighter AS _BYTE, ExeToSourceFolderFirstTimeMsg AS _BYTE DIM SHARED WhiteListQB64FirstTimeMsg AS _BYTE, ideautolayoutkwcapitals AS _BYTE +DIM SHARED IdeAutoComplete AS _BYTE IF LoadedIDESettings = 0 THEN 'We only want to load the file once when QB64 first starts @@ -352,6 +353,32 @@ IF LoadedIDESettings = 0 THEN multihighlight = -1 END IF + result = ReadConfigSetting("IgnoreWarnings", value$) + IF result THEN + IF UCASE$(value$) = "TRUE" OR ABS(VAL(value$)) = 1 THEN + IgnoreWarnings = -1 + ELSE + IgnoreWarnings = 0 + WriteConfigSetting "'[GENERAL SETTINGS]", "IgnoreWarnings", "FALSE" + END IF + ELSE + WriteConfigSetting "'[GENERAL SETTINGS]", "IgnoreWarnings", "FALSE" + IgnoreWarnings = 0 + END IF + + result = ReadConfigSetting("IdeAutoComplete", value$) + IF result THEN + IF UCASE$(value$) = "TRUE" OR ABS(VAL(value$)) = 1 THEN + IdeAutoComplete = -1 + ELSE + IdeAutoComplete = 0 + WriteConfigSetting "'[GENERAL SETTINGS]", "IdeAutoComplete", "FALSE" + END IF + ELSE + WriteConfigSetting "'[GENERAL SETTINGS]", "IdeAutoComplete", "TRUE" + IdeAutoComplete = -1 + END IF + IF INSTR(_OS$, "WIN") THEN result = ReadConfigSetting("IDE_AutoPosition", value$) IF result THEN @@ -382,17 +409,6 @@ IF LoadedIDESettings = 0 THEN IDE_LeftPosition = 0 END IF - result = ReadConfigSetting("IgnoreWarnings", value$) - IF result THEN - IF UCASE$(value$) = "TRUE" OR ABS(VAL(value$)) = 1 THEN - IgnoreWarnings = -1 - ELSE - IgnoreWarnings = 0 - WriteConfigSetting "'[GENERAL SETTINGS]", "IgnoreWarnings", "FALSE" - END IF - END IF - - 'I was going to do some basic error checking for screen position to make certain that we appeared on the monitor, 'but I decided not to. Some people (like me) may have multiple monitors set up and may wish for QB64 to pop-up at 'a coordinate which seems insane at first glance (-1000,0 for instance), but which may move the IDE window to the diff --git a/source/ide/ide_global.bas b/source/ide/ide_global.bas index fba027b07..d3141b51b 100644 --- a/source/ide/ide_global.bas +++ b/source/ide/ide_global.bas @@ -199,7 +199,7 @@ DIM SHARED menus AS INTEGER, idecontextualmenuID AS INTEGER DIM SHARED ideeditmenuID AS INTEGER, SearchMenuID AS INTEGER DIM SHARED OptionsMenuID AS INTEGER, OptionsMenuSwapMouse AS INTEGER, OptionsMenuPasteCursor AS INTEGER DIM SHARED OptionsMenuShowErrorsImmediately AS INTEGER, OptionsMenuIgnoreWarnings AS INTEGER -DIM SHARED OptionsMenuDisableSyntax AS INTEGER +DIM SHARED OptionsMenuDisableSyntax AS INTEGER, OptionsMenuAutoComplete DIM SHARED ViewMenuID AS INTEGER, ViewMenuShowLineNumbersSubMenuID AS INTEGER DIM SHARED ViewMenuShowSeparatorID AS INTEGER, ViewMenuShowBGID AS INTEGER DIM SHARED ViewMenuCompilerWarnings AS INTEGER diff --git a/source/ide/ide_methods.bas b/source/ide/ide_methods.bas index 88a1f5d63..a2239a10a 100644 --- a/source/ide/ide_methods.bas +++ b/source/ide/ide_methods.bas @@ -351,6 +351,11 @@ FUNCTION ide2 (ignore) menu$(m, i) = "Ignore #Warnings": i = i + 1 IF IgnoreWarnings THEN menu$(OptionsMenuID, OptionsMenuIgnoreWarnings) = CHR$(7) + "Ignore #Warnings" + OptionsMenuAutoComplete = i + menu$(m, i) = "Code Suggest#ions": i = i + 1 + IF IdeAutoComplete THEN menu$(OptionsMenuID, OptionsMenuAutoComplete) = CHR$(7) + "Code Suggest#ions" + + menusize(m) = i - 1 m = m + 1: i = 0 @@ -3549,8 +3554,7 @@ FUNCTION ide2 (ignore) HideBracketHighlight keywordHighlight = oldkeywordHighlight retval$ = idergbmixer$(0) - ELSEIF idefocusline > 0 AND LEN(_TRIM$(a$)) = 0 THEN - + ELSEIF IdeAutoComplete AND idefocusline > 0 AND LEN(_TRIM$(a$)) = 0 THEN 'close open block IF idefocusline = definingtypeerror THEN insertAtCursor SCase$("End Type"): GOTO specialchar @@ -4720,12 +4724,12 @@ FUNCTION ide2 (ignore) IF RIGHT$(menu$(m, s), 16) = "Ignore #Warnings" THEN PCOPY 2, 0 - IF Ignorewarnings = 0 THEN - Ignorewarnings = -1 + IF IgnoreWarnings = 0 THEN + IgnoreWarnings = -1 WriteConfigSetting "'[GENERAL SETTINGS]", "IgnoreWarnings", "TRUE" menu$(OptionsMenuID, OptionsMenuIgnoreWarnings) = CHR$(7) + "Ignore #Warnings" ELSE - Ignorewarnings = 0 + IgnoreWarnings = 0 WriteConfigSetting "'[GENERAL SETTINGS]", "IgnoreWarnings", "FALSE" menu$(OptionsMenuID, OptionsMenuIgnoreWarnings) = "Ignore #Warnings" END IF @@ -4734,6 +4738,22 @@ FUNCTION ide2 (ignore) GOTO ideloop END IF + IF RIGHT$(menu$(m, s), 17) = "Code Suggest#ions" THEN + PCOPY 2, 0 + IF IdeAutoComplete = 0 THEN + IdeAutoComplete = -1 + WriteConfigSetting "'[GENERAL SETTINGS]", "IdeAutoComplete", "TRUE" + menu$(OptionsMenuID, OptionsMenuAutoComplete) = CHR$(7) + "Code Suggest#ions" + ELSE + IdeAutoComplete = 0 + WriteConfigSetting "'[GENERAL SETTINGS]", "IdeAutoComplete", "FALSE" + menu$(OptionsMenuID, OptionsMenuAutoComplete) = "Code Suggest#ions" + END IF + idechangemade = 1 + 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 @@ -8163,7 +8183,7 @@ SUB ideshowtext 'an _RGB(, _RGB32(, _RGBA( or _RGBA32(, we'll offer the RGB 'color mixer. a2$ = UCASE$(a$) - IF 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 (RIGHT$(a2$, 5) = "_RGB(" OR _ RIGHT$(a2$, 7) = "_RGB32(" OR _ RIGHT$(a2$, 6) = "_RGBA(" OR _ @@ -8201,7 +8221,7 @@ SUB ideshowtext END IF ELSE temp_a$ = idegetline(idecy) - IF 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 'working on. This bit will offer to close said blocks. IF idefocusline = definingtypeerror THEN