From 70ea1491682c403d743bbef81a373aa2e6a0b99a Mon Sep 17 00:00:00 2001 From: Fellippe Heitor Date: Thu, 4 Feb 2021 22:21:31 -0300 Subject: [PATCH 1/4] Offers to auto-close blocks with Shift+ENTER --- source/ide/ide_global.bas | 1 + source/ide/ide_methods.bas | 56 ++++++++++++++++++++++++++++++++------ source/qb64.bas | 11 ++++---- 3 files changed, 54 insertions(+), 14 deletions(-) diff --git a/source/ide/ide_global.bas b/source/ide/ide_global.bas index cc636937d..fba027b07 100644 --- a/source/ide/ide_global.bas +++ b/source/ide/ide_global.bas @@ -191,6 +191,7 @@ TYPE idedbotype END TYPE '-------------------------------------------------------------------------------- DIM SHARED idefocusline 'simply stores the location of the line to highlight in red +DIM SHARED idecompilererrormessage$ DIM SHARED ideautorun DIM SHARED menu$(1 TO 10, 0 TO 20) DIM SHARED menusize(1 TO 10) diff --git a/source/ide/ide_methods.bas b/source/ide/ide_methods.bas index 948b372b5..88a1f5d63 100644 --- a/source/ide/ide_methods.bas +++ b/source/ide/ide_methods.bas @@ -849,11 +849,12 @@ FUNCTION ide2 (ignore) 'scrolling unavailable, but may span multiple lines IF compfailed THEN a$ = MID$(c$, 2, LEN(c$) - 5) - + idecompilererrormessage$ = a$ x = 1 y = idewy - 3 FOR i = 1 TO LEN(a$) IF ASC(a$, i) = 0 THEN + idecompilererrormessage$ = LEFT$(a$, i - 1) IF _DEFAULTCOLOR = 7 THEN COLOR 11 ELSE COLOR 7 _CONTINUE END IF @@ -864,7 +865,7 @@ FUNCTION ide2 (ignore) statusarealink = 1 ELSE a$ = MID$(c$, 2, LEN(c$) - 5) - + idecompilererrormessage$ = a$ l = CVL(RIGHT$(c$, 4)): IF l <> 0 THEN idefocusline = l @@ -3541,18 +3542,39 @@ FUNCTION ide2 (ignore) IF K$ = CHR$(13) THEN IF KSHIFT THEN retval$ = "" - IF EnteringRGB THEN 'The "Hit Shift+ENTER" message is being shown + a$ = idegetline(idecy) + IF EnteringRGB THEN 'The "Shift+ENTER" message is being shown oldkeywordHighlight = keywordHighlight keywordHighlight = 0 HideBracketHighlight keywordHighlight = oldkeywordHighlight retval$ = idergbmixer$(0) + ELSEIF idefocusline > 0 AND LEN(_TRIM$(a$)) = 0 THEN + + 'close open block + IF idefocusline = definingtypeerror THEN + insertAtCursor SCase$("End Type"): GOTO specialchar + ELSEIF idefocusline = controlref(controllevel) AND INSTR(idecompilererrormessage$, " without ") > 0 THEN + SELECT EVERYCASE controltype(controllevel) + CASE 1: insertAtCursor SCase$("End If"): GOTO specialchar + CASE 2: insertAtCursor SCase$("Next"): GOTO specialchar + CASE 3, 4: insertAtCursor SCase$("Loop"): GOTO specialchar + CASE 5: insertAtCursor SCase$("Wend"): GOTO specialchar + CASE 6: insertAtCursor SCase$("$End If"): GOTO specialchar + CASE 10 TO 19: insertAtCursor SCase$("End Select"): GOTO specialchar + CASE 32 + IF LEFT$(subfunc, 4) = "SUB_" THEN + insertAtCursor SCase$("End Sub"): GOTO specialchar + ELSE + insertAtCursor SCase$("End Function"): GOTO specialchar + END IF + END SELECT + END IF ELSE IF ideselect THEN IF ideselecty1 <> idecy THEN GOTO specialchar 'multi line selected END IF - a$ = idegetline(idecy) Found_RGB = 0 Found_RGB = Found_RGB + INSTR(UCASE$(a$), "RGB(") Found_RGB = Found_RGB + INSTR(UCASE$(a$), "RGB32(") @@ -8070,7 +8092,7 @@ SUB ideshowtext a$ = idegetline(l) link_idecx = 0 - rgb_idecx = 0 + shiftEnter_idecx = 0 IF l = idecy THEN IF idecx <= LEN(a$) AND idecx >= 1 THEN cc = ASC(a$, idecx) @@ -8150,8 +8172,8 @@ SUB ideshowtext RIGHT$(a2$, 6) = "RGB32(" OR _ RIGHT$(a2$, 5) = "RGBA(" OR _ RIGHT$(a2$, 7) = "RGBA32(") AND qb64prefix_set = 1) THEN - rgb_idecx = LEN(a$) - a$ = a$ + " --> Hit Shift+ENTER to open the RGB mixer" + shiftEnter_idecx = LEN(a$) + a$ = a$ + " --> Shift+ENTER to open the RGB mixer" EnteringRGB = -1 END IF ELSEIF idecx_comment + idecx_quote = 0 THEN @@ -8177,6 +8199,22 @@ SUB ideshowtext f$ = p$ + ActiveINCLUDELinkFile IF _FILEEXISTS(f$) THEN a$ = a$ + " --> Double-click to open": ActiveINCLUDELink = idecy END IF + ELSE + temp_a$ = idegetline(idecy) + IF 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 + shiftEnter_idecx = LEN(a$) + a$ = a$ + " --> Shift+ENTER to close block" + ELSEIF idefocusline = controlref(controllevel) AND INSTR(idecompilererrormessage$, " without ") > 0 THEN + SELECT EVERYCASE controltype(controllevel) + CASE 1 to 6,10 to 19,32 + shiftEnter_idecx = LEN(a$) + a$ = a$ + " --> Shift+ENTER to close block" + END SELECT + END IF + END IF END IF 'l = idecy a2$ = SPACE$(idesx + (idewx - 3)) @@ -8320,8 +8358,8 @@ SUB ideshowtext SkipSyntaxHighlighter: - IF l = idecy AND ((link_idecx > 0 AND m > link_idecx) OR _ - (rgb_idecx > 0 AND m > rgb_idecx)) THEN COLOR 10 + IF l = idecy AND (link_idecx > 0 AND m > link_idecx) THEN COLOR 10 + IF (shiftEnter_idecx > 0 AND m > shiftEnter_idecx) THEN COLOR 10 IF l = idecy AND (m = bracket1 OR m = bracket2) THEN COLOR , 5 diff --git a/source/qb64.bas b/source/qb64.bas index a47178ae5..f03c96fcd 100644 --- a/source/qb64.bas +++ b/source/qb64.bas @@ -764,7 +764,7 @@ DIM SHARED findidsecondarg AS STRING DIM SHARED findanotherid AS INTEGER DIM SHARED findidinternal AS LONG DIM SHARED currentid AS LONG 'is the index of the last ID accessed -DIM SHARED linenumber AS LONG, reallinenumber AS LONG, totallinenumber AS LONG +DIM SHARED linenumber AS LONG, reallinenumber AS LONG, totallinenumber AS LONG, definingtypeerror AS LONG DIM SHARED wholeline AS STRING DIM SHARED linefragment AS STRING 'COMMON SHARED bitmask() AS _INTEGER64 @@ -852,8 +852,8 @@ DIM SHARED everycasenewcase AS LONG -DIM controllevel AS INTEGER '0=not in a control block -DIM controltype(1000) AS INTEGER +DIM SHARED controllevel AS INTEGER '0=not in a control block +DIM SHARED controltype(1000) AS INTEGER '1=IF (awaiting END IF) '2=FOR (awaiting NEXT) '3=DO (awaiting LOOP [UNTIL|WHILE param]) @@ -874,7 +874,7 @@ DIM controltype(1000) AS INTEGER DIM controlid(1000) AS LONG DIM controlvalue(1000) AS LONG DIM controlstate(1000) AS INTEGER -DIM controlref(1000) AS LONG 'the line number the control was created on +DIM SHARED controlref(1000) AS LONG 'the line number the control was created on @@ -1376,6 +1376,7 @@ nextrunlineindex = 1 lasttype = 0 lasttypeelement = 0 definingtype = 0 +definingtypeerror = 0 constlast = -1 'constlastshared = -1 defdatahandle = 18 @@ -3619,7 +3620,7 @@ DO GOTO finishednonexec END IF - IF n < 3 THEN 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 definingtype = 2 IF firstelement$ = "AS" THEN l$ = SCase$("As") From a6fe260a5e13a53fadf7665ade3168efa8eb1176 Mon Sep 17 00:00:00 2001 From: Fellippe Heitor Date: Thu, 4 Feb 2021 23:48:14 -0300 Subject: [PATCH 2/4] 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 From 3395cd2d33e0818590bd060ac9ec68bdaae6a465 Mon Sep 17 00:00:00 2001 From: Fellippe Heitor Date: Fri, 5 Feb 2021 00:10:04 -0300 Subject: [PATCH 3/4] Aligns block closings with their opening lines. --- source/ide/ide_methods.bas | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/ide/ide_methods.bas b/source/ide/ide_methods.bas index a2239a10a..b270a14ee 100644 --- a/source/ide/ide_methods.bas +++ b/source/ide/ide_methods.bas @@ -3556,9 +3556,13 @@ FUNCTION ide2 (ignore) retval$ = idergbmixer$(0) ELSEIF IdeAutoComplete AND idefocusline > 0 AND LEN(_TRIM$(a$)) = 0 THEN 'close open block + tempIndent$ = idegetline(idefocusline) + tempIndent$ = SPACE$(LEN(tempIndent$) - LEN(LTRIM$(tempindent$))) IF idefocusline = definingtypeerror THEN + idecx = LEN(tempIndent$) + 1 insertAtCursor SCase$("End Type"): GOTO specialchar ELSEIF idefocusline = controlref(controllevel) AND INSTR(idecompilererrormessage$, " without ") > 0 THEN + idecx = LEN(tempIndent$) + 1 SELECT EVERYCASE controltype(controllevel) CASE 1: insertAtCursor SCase$("End If"): GOTO specialchar CASE 2: insertAtCursor SCase$("Next"): GOTO specialchar From 38ae73e47ec76b76aaed2a86b7d2eefb4851cc6d Mon Sep 17 00:00:00 2001 From: Fellippe Heitor Date: Fri, 5 Feb 2021 00:42:28 -0300 Subject: [PATCH 4/4] Changes "Disable Syntax Highlighter" to "Syntax Highlighter" --- source/ide/ide_methods.bas | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/source/ide/ide_methods.bas b/source/ide/ide_methods.bas index b270a14ee..6a4101b35 100644 --- a/source/ide/ide_methods.bas +++ b/source/ide/ide_methods.bas @@ -324,8 +324,8 @@ FUNCTION ide2 (ignore) menu$(m, i) = "-": i = i + 1 OptionsMenuDisableSyntax = i - menu$(m, i) = "Disable Syntax #Highlighter": i = i + 1 - IF DisableSyntaxHighlighter THEN + menu$(m, i) = "Syntax #Highlighter": i = i + 1 + IF NOT DisableSyntaxHighlighter THEN menu$(OptionsMenuID, OptionsMenuDisableSyntax) = CHR$(7) + menu$(OptionsMenuID, OptionsMenuDisableSyntax) END IF @@ -4683,15 +4683,15 @@ FUNCTION ide2 (ignore) GOTO ideloop END IF - IF RIGHT$(menu$(m, s), 27) = "Disable Syntax #Highlighter" THEN + IF RIGHT$(menu$(m, s), 19) = "Syntax #Highlighter" THEN PCOPY 2, 0 DisableSyntaxHighlighter = NOT DisableSyntaxHighlighter IF DisableSyntaxHighlighter THEN WriteConfigSetting "'[GENERAL SETTINGS]", "DisableSyntaxHighlighter", "TRUE" - menu$(OptionsMenuID, OptionsMenuDisableSyntax) = CHR$(7) + "Disable Syntax #Highlighter" + menu$(OptionsMenuID, OptionsMenuDisableSyntax) = "Syntax #Highlighter" ELSE WriteConfigSetting "'[GENERAL SETTINGS]", "DisableSyntaxHighlighter", "FALSE" - menu$(OptionsMenuID, OptionsMenuDisableSyntax) = "Disable Syntax #Highlighter" + menu$(OptionsMenuID, OptionsMenuDisableSyntax) = CHR$(7) + "Syntax #Highlighter" END IF PCOPY 3, 0: SCREEN , , 3, 0 GOTO ideloop @@ -8258,10 +8258,10 @@ SUB ideshowtext FOR m = 1 TO LEN(a2$) 'print to the screen while checking required color changes IF timeElapsedSince(startTime) > 1 THEN - result = idemessagebox("Syntax Highlighter Disabled", "Syntax Highlighter has been disabled to avoid locking up the IDE.\nThis may have been caused by lines that are too long.\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 WriteConfigSetting "'[GENERAL SETTINGS]", "DisableSyntaxHighlighter", "TRUE" - menu$(OptionsMenuID, OptionsMenuDisableSyntax) = CHR$(7) + "Disable Syntax #Highlighter" + menu$(OptionsMenuID, OptionsMenuDisableSyntax) = "Syntax #Highlighter" GOTO noSyntaxHighlighting END IF IF m > idesx + idewx - 2 THEN EXIT FOR 'stop printing when off screen @@ -11929,7 +11929,7 @@ FUNCTION idechoosecolorsbox IF DisableSyntaxHighlighter THEN DisableSyntaxHighlighter = 0 WriteConfigSetting "'[GENERAL SETTINGS]", "DisableSyntaxHighlighter", "FALSE" - menu$(OptionsMenuID, OptionsMenuDisableSyntax) = "Disable Syntax #Highlighter" + menu$(OptionsMenuID, OptionsMenuDisableSyntax) = CHR$(7) + "Syntax #Highlighter" END IF RETURN END FUNCTION