1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-06-29 11:40:38 +00:00

Allows disabling the Syntax Highlighter entirely (Options menu). Also:

- Disables Syntax Highlighter automatically if rendering takes longer than a second.
This commit is contained in:
FellippeHeitor 2020-12-28 23:35:00 -03:00
parent 2f29af1dc0
commit 529a162816
3 changed files with 531 additions and 417 deletions

View file

@ -14,6 +14,7 @@ DIM SHARED SaveExeWithSource AS _BYTE, EnableQuickNav AS _BYTE
DIM SHARED IDEShowErrorsImmediately AS _BYTE
DIM SHARED ShowLineNumbersSeparator AS _BYTE, ShowLineNumbersUseBG AS _BYTE
DIM SHARED IgnoreWarnings AS _BYTE, qb64versionprinted AS _BYTE
DIM SHARED DisableSyntaxHighlighter AS _BYTE
IF LoadedIDESettings = 0 THEN
'We only want to load the file once when QB64 first starts
@ -154,6 +155,15 @@ IF LoadedIDESettings = 0 THEN
WriteConfigSetting "'[MOUSE SETTINGS]", "SwapMouseButton", "FALSE"
end if
result = ReadConfigSetting("DisableSyntaxHighlighter", value$)
IF value$ = "TRUE" OR VAL(value$) = -1 THEN
DisableSyntaxHighlighter = -1
WriteConfigSetting "'[GENERAL SETTINGS]", "DisableSyntaxHighlighter", "TRUE"
ELSE
DisableSyntaxHighlighter = 0
WriteConfigSetting "'[GENERAL SETTINGS]", "DisableSyntaxHighlighter", "FALSE"
END IF
result = ReadConfigSetting("PasteCursorAtEnd", value$)
IF result THEN
IF value$ = "TRUE" OR VAL(value$) = -1 THEN

View file

@ -202,6 +202,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 ViewMenuID AS INTEGER, ViewMenuShowLineNumbersSubMenuID AS INTEGER
DIM SHARED ViewMenuShowSeparatorID AS INTEGER, ViewMenuShowBGID AS INTEGER
DIM SHARED ViewMenuCompilerWarnings AS INTEGER

View file

@ -312,11 +312,18 @@ FUNCTION ide2 (ignore)
menu$(m, i) = "Options": i = i + 1
menu$(m, i) = "#Display...": i = i + 1
menu$(m, i) = "IDE C#olors...": i = i + 1
menu$(m, i) = "-": i = i + 1
menu$(m, i) = "#Language...": i = i + 1
menu$(m, i) = "#Code Layout...": i = i + 1
menu$(m, i) = "#Backup/Undo...": i = i + 1
menu$(m, i) = "-": i = i + 1
menu$(m, i) = "#Advanced...": i = i + 1
menu$(m, i) = "-": i = i + 1
OptionsMenuDisableSyntax = i
menu$(m, i) = "Disable Syntax #Highlighter": i = i + 1
IF DisableSyntaxHighlighter THEN
menu$(OptionsMenuID, OptionsMenuDisableSyntax) = CHR$(7) + menu$(OptionsMenuID, OptionsMenuDisableSyntax)
END IF
OptionsMenuSwapMouse = i
menu$(m, i) = "#Swap Mouse Buttons": i = i + 1
@ -4676,6 +4683,20 @@ FUNCTION ide2 (ignore)
GOTO ideloop
END IF
IF RIGHT$(menu$(m, s), 27) = "Disable 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"
ELSE
WriteConfigSetting "'[GENERAL SETTINGS]", "DisableSyntaxHighlighter", "FALSE"
menu$(OptionsMenuID, OptionsMenuDisableSyntax) = "Disable Syntax #Highlighter"
END IF
PCOPY 3, 0: SCREEN , , 3, 0: idewait4mous: idewait4alt
GOTO ideloop
END IF
IF RIGHT$(menu$(m, s), 28) = "Cursor After #Pasted Content" THEN
PCOPY 2, 0
PasteCursorAtEnd = NOT PasteCursorAtEnd
@ -8455,6 +8476,11 @@ SUB idesetline (i, text$)
END SUB
FUNCTION timeElapsedSince! (startTime!)
IF startTime! > TIMER THEN startTime! = startTime! - 86400
timeElapsedSince! = TIMER - startTime!
END FUNCTION
SUB ideshowtext
_PALETTECOLOR 1, IDEBackgroundColor, 0
@ -8473,7 +8499,11 @@ SUB ideshowtext
num.char$ = "0123456789EDed+-.`%&!#~HBOhboACFacf"
STATIC prevListOfCustomWords$, manualList AS _BYTE
DIM startTime AS SINGLE
startTime = TIMER
IF NOT DisableSyntaxHighlighter THEN
IF idefocusline <> 0 THEN
'there's an error and compilation is halted,
'so we'll build the list of subs/functions
@ -8563,6 +8593,8 @@ SUB ideshowtext
prevListOfCustomWords$ = listOfCustomKeywords$
END IF
END IF
cc = -1
@ -8581,6 +8613,7 @@ SUB ideshowtext
l = idesy
EnteringRGB = 0
IF NOT DisableSyntaxHighlighter THEN
idecy_multilinestart = 0
idecy_multilineend = 0
a$ = idegetline(idecy)
@ -8626,19 +8659,7 @@ SUB ideshowtext
COLOR 7, 1
PRINT CHR$(179); 'clear prev bookmarks from lhs
IF ShowLineNumbers THEN
IF ShowLineNumbersUseBG THEN COLOR , 6
PRINT SPACE$(maxLineNumberLength);
IF l <= iden THEN
l2$ = STR$(l)
IF POS(1) - (LEN(l2$) + 1) >= 2 THEN
LOCATE y + 3, POS(1) - (LEN(l2$) + 1)
PRINT l2$;
END IF
END IF
IF ShowLineNumbersSeparator THEN LOCATE y + 3, 1 + maxLineNumberLength: PRINT CHR$(179);
COLOR , 1
END IF
IF ShowLineNumbers THEN GOSUB ShowLineNumber
IF l = idefocusline AND idecy <> l THEN
COLOR 7, 4 'Line with error gets a red background
@ -8780,6 +8801,13 @@ SUB ideshowtext
prevBG% = _BACKGROUNDCOLOR
FOR m = 1 TO LEN(a2$) 'print to the screen while checking required color changes
IF timeElapsedSince(startTime) > 1 THEN
idemessagebox "Syntax Highlighter Disabled", StrReplace$("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.", "\n", CHR$(10))
DisableSyntaxHighlighter = -1
WriteConfigSetting "'[GENERAL SETTINGS]", "DisableSyntaxHighlighter", "TRUE"
menu$(OptionsMenuID, OptionsMenuDisableSyntax) = CHR$(7) + "Disable Syntax #Highlighter"
GOTO noSyntaxHighlighting
END IF
IF m > idesx + idewx - 2 THEN EXIT FOR 'stop printing when off screen
IF ideselect = 1 AND LEN(ideCurrentSingleLineSelection) > 0 AND multiHighlightLength = 0 AND multihighlight = -1 THEN
IF LCASE$(MID$(a2$, m, LEN(ideCurrentSingleLineSelection))) = LCASE$(ideCurrentSingleLineSelection) THEN
@ -8973,6 +9001,66 @@ SUB ideshowtext
l = l + 1
NEXT
ELSE
noSyntaxHighlighting:
'original SUB ideshowtext routine:
COLOR 13, 1
l = idesy
FOR y = 0 TO (idewy - 9)
LOCATE y + 3, 1
COLOR 7, 1
PRINT CHR$(179); 'clear prev bookmarks from lhs
IF ShowLineNumbers THEN GOSUB ShowLineNumber
IF l = idefocusline AND idecy <> l THEN COLOR 13, 4 ELSE COLOR 13, 1
LOCATE y + 3, 2 + maxLineNumberLength
IF l <= iden THEN
a$ = idegetline(l)
a2$ = SPACE$(idesx + (idewx - 3) - maxLineNumberLength)
MID$(a2$, 1) = a$
a2$ = RIGHT$(a2$, (idewx - 2) - maxLineNumberLength)
ELSE
a2$ = SPACE$((idewx - 2) - maxLineNumberLength)
END IF
PRINT a2$;
IF l = idecy THEN
IF idecx <= LEN(a$) AND idecx >= 1 THEN
cc = ASC(a$, idecx)
IF cc = 32 THEN
IF LTRIM$(LEFT$(a$, idecx)) = "" THEN cc = -1
END IF
END IF
END IF
'apply selection color change if necessary
IF ideselect THEN
IF l >= sy1 AND l <= sy2 THEN
IF sy1 = sy2 THEN 'single line select
COLOR 1, 7
x2 = idesx
FOR x = 2 + maxLineNumberLength TO (idewx - 2)
IF x2 >= sx1 AND x2 < sx2 THEN
a = SCREEN(y + 3, x): LOCATE y + 3, x: PRINT CHR$(a);
END IF
x2 = x2 + 1
NEXT
COLOR 7, 1
ELSE 'multiline select
IF idecx = 1 AND l = sy2 AND idecy > sy1 THEN GOTO nofinalselect0
LOCATE y + 3, 2 + maxLineNumberLength
COLOR 1, 7: PRINT a2$;
COLOR 7, 1
nofinalselect0:
END IF
END IF
END IF
l = l + 1
NEXT
END IF
COLOR 7, 1
FOR b = 1 TO IdeBmkN
@ -9010,6 +9098,21 @@ SUB ideshowtext
END SELECT
NEXT ideshowtext_k
RETURN
ShowLineNumber:
IF ShowLineNumbersUseBG THEN COLOR , 6
PRINT SPACE$(maxLineNumberLength);
IF l <= iden THEN
l2$ = STR$(l)
IF POS(1) - (LEN(l2$) + 1) >= 2 THEN
LOCATE y + 3, POS(1) - (LEN(l2$) + 1)
PRINT l2$;
END IF
END IF
IF ShowLineNumbersSeparator THEN LOCATE y + 3, 1 + maxLineNumberLength: PRINT CHR$(179);
COLOR , 1
RETURN
END SUB
FUNCTION idesubs$