From ce9a0c07c646265cc41227aad0a6e957d62235e4 Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Thu, 26 Oct 2017 10:20:19 -0200 Subject: [PATCH 01/10] First attempt at line numbers. So far: - Line numbers show (they still get stuck if you create a new empty file). - Text is shifted right accordingly. --- source/ide/ide_methods.bas | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/source/ide/ide_methods.bas b/source/ide/ide_methods.bas index be73f2c1d..286a15411 100644 --- a/source/ide/ide_methods.bas +++ b/source/ide/ide_methods.bas @@ -8203,6 +8203,15 @@ SUB ideshowtext LOCATE y + 3, 1 COLOR 7, 1 PRINT CHR$(179); 'clear prev bookmarks from lhs + + IF l <= iden THEN + LOCATE y + 3, 2 + l$ = SPACE$(LEN(STR$(iden)) + 2) + MID$(l$, 1) = STR$(l) + PRINT l$; + END IF + + IF l = idefocusline AND idecy <> l THEN COLOR 7, 4 'Line with error gets a red background ELSEIF idecy = l OR (l >= idecy_multilinestart AND l <= idecy_multilineend) THEN @@ -8523,8 +8532,8 @@ SUB ideshowtext LOOP ' verifying the code and growing the array during the IDE passes. IF InValidLine(l) AND 1 THEN COLOR 7 - IF 2 + m - idesx >= 2 AND 2 + m - idesx < idewx THEN - LOCATE y + 3, 2 + m - idesx + IF 2 + m - idesx >= 2 AND (2 + m - idesx) + LEN(STR$(iden)) + 2 < idewx - 1 THEN + LOCATE y + 3, (2 + m - idesx) + LEN(STR$(iden)) + 2 PRINT thisChar$; END IF From 88d6911ec97cdf2a07baa37dcd830fbd3b8defcb Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Mon, 30 Oct 2017 01:28:02 -0200 Subject: [PATCH 02/10] Add option to toggle Line Numbers from View menu. Also: - Align line numbers to right; - Highlight line number of current line; --- source/global/IDEsettings.bas | 13 ++++++++++ source/ide/ide_global.bas | 3 ++- source/ide/ide_methods.bas | 46 ++++++++++++++++++++++++++++------- 3 files changed, 52 insertions(+), 10 deletions(-) diff --git a/source/global/IDEsettings.bas b/source/global/IDEsettings.bas index 316f5d81b..3cc438c95 100644 --- a/source/global/IDEsettings.bas +++ b/source/global/IDEsettings.bas @@ -191,6 +191,19 @@ IF LoadedIDESettings = 0 THEN IDEShowErrorsImmediately = -1 END IF + result = ReadConfigSetting("ShowLineNumbers", value$) + IF result THEN + IF value$ = "TRUE" OR VAL(value$) = -1 THEN + ShowLineNumbers = -1 + ELSE + ShowLineNumbers = 0 + WriteConfigSetting "'[GENERAL SETTINGS]", "ShowLineNumbers", "FALSE" + END IF + ELSE + WriteConfigSetting "'[GENERAL SETTINGS]", "ShowLineNumbers", "FALSE" + ShowLineNumbers = 0 + END IF + result = ReadConfigSetting("BracketHighlight", value$) IF result THEN IF value$ = "TRUE" OR VAL(value$) = -1 THEN diff --git a/source/ide/ide_global.bas b/source/ide/ide_global.bas index b632ef372..6ac1d41f4 100644 --- a/source/ide/ide_global.bas +++ b/source/ide/ide_global.bas @@ -166,7 +166,7 @@ DIM SHARED ModifyCOMMAND$ DIM SHARED EnteringRGB AS _BYTE DIM SHARED ActiveINCLUDELink AS LONG DIM SHARED ActiveINCLUDELinkFile AS STRING -DIM SHARED HideCurrentLineHighlight AS _BYTE +DIM SHARED HideCurrentLineHighlight AS _BYTE, ShowLineNumbers AS _BYTE '-------------------------------------------------------------------------------- TYPE idedbptype x AS LONG @@ -205,6 +205,7 @@ DIM SHARED menus AS INTEGER, idecontextualmenuID AS INTEGER DIM SHARED ideeditmenuID AS INTEGER DIM SHARED OptionsMenuID AS INTEGER, OptionsMenuSwapMouse AS INTEGER, OptionsMenuPasteCursor AS INTEGER DIM SHARED OptionsMenuShowErrorsImmediately AS INTEGER +DIM SHARED ViewMenuID AS INTEGER, ViewMenuShowLineNumbers AS INTEGER DIM SHARED RunMenuID AS INTEGER, RunMenuSaveExeWithSource AS INTEGER, brackethighlight AS INTEGER DIM SHARED multihighlight AS INTEGER, keywordHighlight AS INTEGER DIM SHARED PresetColorSchemes AS INTEGER, TotalColorSchemes AS INTEGER, ColorSchemes$(0) diff --git a/source/ide/ide_methods.bas b/source/ide/ide_methods.bas index 286a15411..a4ced6d52 100644 --- a/source/ide/ide_methods.bas +++ b/source/ide/ide_methods.bas @@ -249,9 +249,16 @@ FUNCTION ide2 (ignore) ideeditmenuID = m IdeMakeEditMenu - m = m + 1: i = 0 + m = m + 1: i = 0: ViewMenuID = m menu$(m, i) = "View": i = i + 1 menu$(m, i) = "#SUBs... F2": i = i + 1 + + ViewMenuShowLineNumbers = i + menu$(m, i) = "#Line numbers": i = i + 1 + IF ShowLineNumbers THEN + menu$(ViewMenuID, ViewMenuShowLineNumbers) = CHR$(7) + menu$(ViewMenuID, ViewMenuShowLineNumbers) + END IF + menusize(m) = i - 1 m = m + 1: i = 0 @@ -4810,6 +4817,20 @@ FUNCTION ide2 (ignore) GOTO ideloop END IF + IF RIGHT$(menu$(m, s), 13) = "#Line numbers" THEN + PCOPY 2, 0 + ShowLineNumbers = NOT ShowLineNumbers + IF ShowLineNumbers THEN + WriteConfigSetting "'[GENERAL SETTINGS]", "ShowLineNumbers", "TRUE" + menu$(ViewMenuID, ViewMenuShowLineNumbers) = CHR$(7) + "#Line numbers" + ELSE + WriteConfigSetting "'[GENERAL SETTINGS]", "ShowLineNumbers", "FALSE" + menu$(ViewMenuID, ViewMenuShowLineNumbers) = "#Line numbers" + END IF + PCOPY 3, 0: SCREEN , , 3, 0: idewait4mous: idewait4alt + GOTO ideloop + END IF + IF menu$(m, s) = "#Find... Ctrl+F3" THEN PCOPY 2, 0 idefindjmp: @@ -8202,16 +8223,17 @@ SUB ideshowtext FOR y = 0 TO (idewy - 9) LOCATE y + 3, 1 COLOR 7, 1 + l$ = SPACE$(LEN(STR$(iden)) + 1) PRINT CHR$(179); 'clear prev bookmarks from lhs + IF l = idecy THEN COLOR , 6 + PRINT l$; - IF l <= iden THEN - LOCATE y + 3, 2 - l$ = SPACE$(LEN(STR$(iden)) + 2) - MID$(l$, 1) = STR$(l) + IF l <= iden AND ShowLineNumbers THEN + l$ = STR$(l) + LOCATE y + 3, POS(1) - (LEN(l$) + 1) PRINT l$; END IF - IF l = idefocusline AND idecy <> l THEN COLOR 7, 4 'Line with error gets a red background ELSEIF idecy = l OR (l >= idecy_multilinestart AND l <= idecy_multilineend) THEN @@ -8532,10 +8554,16 @@ SUB ideshowtext LOOP ' verifying the code and growing the array during the IDE passes. IF InValidLine(l) AND 1 THEN COLOR 7 - IF 2 + m - idesx >= 2 AND (2 + m - idesx) + LEN(STR$(iden)) + 2 < idewx - 1 THEN - LOCATE y + 3, (2 + m - idesx) + LEN(STR$(iden)) + 2 - PRINT thisChar$; + IF ShowLineNumbers THEN + IF 2 + m - idesx >= 2 AND (2 + m - idesx) + LEN(STR$(iden)) + 1 < idewx - 1 THEN + LOCATE y + 3, (2 + m - idesx) + LEN(STR$(iden)) + 1 + END IF + ELSE + IF 2 + m - idesx >= 2 AND 2 + m - idesx < idewx THEN + LOCATE y + 3, 2 + m - idesx + END IF END IF + PRINT thisChar$; 'Restore BG color in case a matching bracket was printed with different BG IF l = idecy THEN COLOR , 6 From c09689610530ac10c7f366321d7e4f17157ae192 Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Mon, 30 Oct 2017 02:17:43 -0200 Subject: [PATCH 03/10] Adds -l:line# command line switch to start the ide at a certain line. --- source/ide/ide_global.bas | 2 ++ source/ide/ide_methods.bas | 8 +++++-- source/qb64.bas | 49 ++++++++++++++++---------------------- 3 files changed, 29 insertions(+), 30 deletions(-) diff --git a/source/ide/ide_global.bas b/source/ide/ide_global.bas index 6ac1d41f4..ddf8f8807 100644 --- a/source/ide/ide_global.bas +++ b/source/ide/ide_global.bas @@ -167,6 +167,8 @@ DIM SHARED EnteringRGB AS _BYTE DIM SHARED ActiveINCLUDELink AS LONG DIM SHARED ActiveINCLUDELinkFile AS STRING DIM SHARED HideCurrentLineHighlight AS _BYTE, ShowLineNumbers AS _BYTE +DIM SHARED idegotobox_LastLineNum AS LONG + '-------------------------------------------------------------------------------- TYPE idedbptype x AS LONG diff --git a/source/ide/ide_methods.bas b/source/ide/ide_methods.bas index a4ced6d52..5163ec22b 100644 --- a/source/ide/ide_methods.bas +++ b/source/ide/ide_methods.bas @@ -507,6 +507,12 @@ FUNCTION ide2 (ignore) LOOP UNTIL asca = 13 lineinput3buffer = "" iden = n: IF n = 0 THEN idet$ = MKL$(0) + MKL$(0): iden = 1 ELSE idet$ = LEFT$(idet$, i2 - 1) + IF ideStartAtLine > 0 AND ideStartAtLine <= iden THEN + idecy = ideStartAtLine + IF idecy - 10 >= 1 THEN idesy = idecy - 10 + idegotobox_LastLineNum = ideStartAtLine + ideStartAtLine = 0 + END IF IdeBmkN = 0 ideerror = 1 ideprogname = f$: _TITLE ideprogname + " - QB64" @@ -10559,8 +10565,6 @@ FUNCTION idemodifycommandbox END FUNCTION FUNCTION idegotobox - STATIC idegotobox_LastLineNum AS LONG - '-------- generic dialog box header -------- PCOPY 0, 2 PCOPY 0, 1 diff --git a/source/qb64.bas b/source/qb64.bas index e89e79049..dbee22487 100644 --- a/source/qb64.bas +++ b/source/qb64.bas @@ -338,6 +338,7 @@ DIM SHARED idemessage AS STRING 'set by qb64-error(...) to the error message to DIM SHARED optionexplicit AS _BYTE DIM SHARED optionexplicit_cmd AS _BYTE +DIM SHARED ideStartAtLine AS LONG DIM SHARED outputfile_cmd$ DIM SHARED compilelog$ @@ -12663,16 +12664,12 @@ FUNCTION ParseCMDLineArgs$ () 'in which case they're simply asking for trouble). FOR i = 1 TO _COMMANDCOUNT token$ = COMMAND$(i) + IF LCASE$(token$) = "-help" OR LCASE$(token$) = "/help" THEN token$ = "-?" SELECT CASE LCASE$(LEFT$(token$, 2)) - CASE "/?", "-?", "-h" 'Command-line help + CASE "-?", "/?" 'Command-line help _DEST _CONSOLE PRINT "QB64 COMPILER V" + Version$ PRINT - IF LCASE$(token$) <> "-help" AND LCASE$(token$) <> "-h" AND token$ <> "-?" AND token$ <> "/?" THEN - 'Ended up being a filename? - PassedFileName$ = token$ - GOTO NextCase - END IF PRINT "USAGE: qb64 [switches] " PRINT PRINT "OPTIONS:" @@ -12681,42 +12678,41 @@ FOR i = 1 TO _COMMANDCOUNT PRINT " -x Compile instead of edit and output the result to the" PRINT " console" PRINT " -z Generate C code without compiling to executable" - 'PRINT " -g Non-GUI environment (uses $CONSOLE:ONLY - for G-WAN" - 'PRINT " compilation)" PRINT " -o Write output executable to " PRINT " -e Enables OPTION _EXPLICIT, making variable declaration" PRINT " mandatory (per-compilation; doesn't affect the" PRINT " source file or global settings)" PRINT " -s[:switch=true/false] View/edit compiler settings" + PRINT " -l: Starts the IDE at the specified line number" PRINT SYSTEM - CASE "-s" 'Settings + CASE "-s", "/s" 'Settings _DEST _CONSOLE PRINT "QB64 COMPILER V" + Version$ - SELECT CASE LCASE$(token$) - CASE "-s" + SELECT CASE LCASE$(MID$(token$, 3)) + CASE "" PRINT "debuginfo = "; IF idedebuginfo THEN PRINT "TRUE" ELSE PRINT "FALSE" PRINT "exewithsource = "; IF SaveExeWithSource THEN PRINT "TRUE" ELSE PRINT "FALSE" SYSTEM - CASE "-s:exewithsource" + CASE ":exewithsource" PRINT "exewithsource = "; IF SaveExeWithSource THEN PRINT "TRUE" ELSE PRINT "FALSE" SYSTEM - CASE "-s:exewithsource=true" + CASE ":exewithsource=true" WriteConfigSetting "'[GENERAL SETTINGS]", "SaveExeWithSource", "TRUE" PRINT "exewithsource = TRUE" SYSTEM - CASE "-s:exewithsource=false" + CASE ":exewithsource=false" WriteConfigSetting "'[GENERAL SETTINGS]", "SaveExeWithSource", "FALSE" PRINT "exewithsource = FALSE" SYSTEM - CASE "-s:debuginfo" + CASE ":debuginfo" PRINT "debuginfo = "; IF idedebuginfo THEN PRINT "TRUE" ELSE PRINT "FALSE" SYSTEM - CASE "-s:debuginfo=true" + CASE ":debuginfo=true" PRINT "debuginfo = TRUE" WriteConfigSetting "'[GENERAL SETTINGS]", "DebugInfo", "TRUE 'INTERNAL VARIABLE USE ONLY!! DO NOT MANUALLY CHANGE!" idedebuginfo = 1 @@ -12737,7 +12733,7 @@ FOR i = 1 TO _COMMANDCOUNT CHDIR "../.." END IF SYSTEM - CASE "-s:debuginfo=false" + CASE ":debuginfo=false" PRINT "debuginfo = FALSE" WriteConfigSetting "'[GENERAL SETTINGS]", "DebugInfo", "FALSE 'INTERNAL VARIABLE USE ONLY!! DO NOT MANUALLY CHANGE!" idedebuginfo = 0 @@ -12766,27 +12762,24 @@ FOR i = 1 TO _COMMANDCOUNT PRINT " -s:exewithsource=true/false (Save .EXE in the source folder)" SYSTEM END SELECT - CASE "-q" 'Building a Qloud program - Cloud = 1 - ConsoleMode = 1 'Implies -x - NoIDEMode = 1 'Imples -c - CASE "-e" 'Option Explicit + CASE "-e", "/e" 'Option Explicit optionexplicit_cmd = -1 - CASE "-z" 'Not compiling C code + CASE "-z", "/z" 'Not compiling C code No_C_Compile_Mode = 1 ConsoleMode = 1 'Implies -x NoIDEMode = 1 'Implies -c - CASE "-x" 'Use the console + CASE "-x", "/x" 'Use the console ConsoleMode = 1 NoIDEMode = 1 'Implies -c - CASE "-c" 'Compile instead of edit + CASE "-c", "/c" 'Compile instead of edit NoIDEMode = 1 - CASE "-o" 'Specify an output file + CASE "-o", "/o" 'Specify an output file IF LEN(COMMAND$(i + 1)) > 0 THEN outputfile_cmd$ = COMMAND$(i + 1): i = i + 1 + CASE "-l", "/l" 'goto line (ide mode only); -l: + IF MID$(token$, 3, 1) = ":" THEN ideStartAtLine = VAL(MID$(token$, 4)) CASE ELSE 'Something we don't recognise, assume it's a filename - PassedFileName$ = token$ + IF PassedFileName$ = "" THEN PassedFileName$ = token$ END SELECT - NextCase: NEXT i IF LEN(PassedFileName$) THEN ParseCMDLineArgs$ = PassedFileName$ From 6b5cba468fd96e34c7b51da23fb28f065ab156df Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Mon, 30 Oct 2017 10:21:14 -0200 Subject: [PATCH 04/10] Fix retrieval of ideindentsubs from config.txt --- source/global/IDEsettings.bas | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/global/IDEsettings.bas b/source/global/IDEsettings.bas index 3cc438c95..c8a04614f 100644 --- a/source/global/IDEsettings.bas +++ b/source/global/IDEsettings.bas @@ -330,7 +330,7 @@ IF LoadedIDESettings = 0 THEN result = ReadConfigSetting("IDE_IndentSUBs", value$) ideindentsubs = VAL(value$) - IF UCASE$(value$) = "TRUE" OR ideautoindent <> 0 THEN + IF UCASE$(value$) = "TRUE" OR ideindentsubs <> 0 THEN ideindentsubs = 1 ELSE IF UCASE$(value$) <> "FALSE" AND value$ <> "0" THEN From e5b732753353b604250b7d8cf5a38c7527a8578f Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Mon, 30 Oct 2017 10:53:25 -0200 Subject: [PATCH 05/10] Double-clicking an include file name opens the IDE at the error line. When an error in an include file is reported, the IDE also shows what line inside the external file caused the error. Double-clicking the include line will open the file in a second instance of the IDE and position the cursor in the line that caused the last error. --- source/ide/ide_methods.bas | 6 +++++- source/qb64.bas | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/source/ide/ide_methods.bas b/source/ide/ide_methods.bas index 5163ec22b..1e727873f 100644 --- a/source/ide/ide_methods.bas +++ b/source/ide/ide_methods.bas @@ -2706,7 +2706,11 @@ FUNCTION ide2 (ignore) PCOPY 3, 0 _DELAY .2 - SHELL QuotedFilename$(COMMAND$(0)) + " " + QuotedFilename$(f$) + p$ = QuotedFilename$(COMMAND$(0)) + " " + QuotedFilename$(f$) + IF errorLineInInclude > 0 AND idefocusline = idecy THEN + p$ = p$ + " -l:" + str2$(errorLineInInclude) + END IF + SHELL p$ IF IDE_AutoPosition THEN WriteConfigSetting "'[IDE DISPLAY SETTINGS]", "IDE_AutoPosition", "TRUE" diff --git a/source/qb64.bas b/source/qb64.bas index dbee22487..34d495f76 100644 --- a/source/qb64.bas +++ b/source/qb64.bas @@ -338,7 +338,7 @@ DIM SHARED idemessage AS STRING 'set by qb64-error(...) to the error message to DIM SHARED optionexplicit AS _BYTE DIM SHARED optionexplicit_cmd AS _BYTE -DIM SHARED ideStartAtLine AS LONG +DIM SHARED ideStartAtLine AS LONG, errorLineInInclude AS LONG DIM SHARED outputfile_cmd$ DIM SHARED compilelog$ @@ -1500,6 +1500,7 @@ layout = "" layoutok = 0 NoChecks = 0 inclevel = 0 +errorLineInInclude = 0 addmetainclude$ = "" nextrunlineindex = 1 lasttype = 0 @@ -2783,6 +2784,7 @@ DO wholeline$ = x$ inclinenumber(inclevel) = inclinenumber(inclevel) + 1 'create extended error string 'incerror$' + errorLineInInclude = inclinenumber(inclevel) e$ = " in line " + str2(inclinenumber(inclevel)) + " of " + incname$(inclevel) + " included" IF inclevel > 1 THEN e$ = e$ + " (through " @@ -10721,6 +10723,7 @@ DO continuelinefrom = 0 inclinenumber(inclevel) = inclinenumber(inclevel) + 1 'create extended error string 'incerror$' + errorLineInInclude = inclinenumber(inclevel) e$ = " in line " + str2(inclinenumber(inclevel)) + " of " + incname$(inclevel) + " included" IF inclevel > 1 THEN e$ = e$ + " (through " From 867f62bcc7fc383aa0ec54526eb856b4c4d08b8d Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Tue, 31 Oct 2017 01:00:15 -0200 Subject: [PATCH 06/10] Makes possible to edit/navigate with line numbers turned on (keyboard). --- source/ide/ide_methods.bas | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/source/ide/ide_methods.bas b/source/ide/ide_methods.bas index 1e727873f..9fe46df3b 100644 --- a/source/ide/ide_methods.bas +++ b/source/ide/ide_methods.bas @@ -8175,9 +8175,11 @@ SUB ideshowtext cc = -1 + IF ShowLineNumbers THEN l1$ = SPACE$(LEN(STR$(iden)) + 1) ELSE l1$ = "" + IF idecx < idesx THEN idesx = idecx IF idecy < idesy THEN idesy = idecy - IF idecx - idesx >= (idewx - 2) THEN idesx = idecx - (idewx - 3) + IF (idecx + LEN(l1$)) - idesx >= (idewx - 2) THEN idesx = (idecx + LEN(l1$)) - (idewx - 3) IF idecy - idesy >= (idewy - 8) THEN idesy = idecy - (idewy - 9) sy1 = ideselecty1 @@ -8233,15 +8235,16 @@ SUB ideshowtext FOR y = 0 TO (idewy - 9) LOCATE y + 3, 1 COLOR 7, 1 - l$ = SPACE$(LEN(STR$(iden)) + 1) PRINT CHR$(179); 'clear prev bookmarks from lhs - IF l = idecy THEN COLOR , 6 - PRINT l$; - IF l <= iden AND ShowLineNumbers THEN - l$ = STR$(l) - LOCATE y + 3, POS(1) - (LEN(l$) + 1) - PRINT l$; + IF ShowLineNumbers THEN + IF l = idecy THEN COLOR , 6 + PRINT l1$; + IF l <= iden THEN + l2$ = STR$(l) + LOCATE y + 3, POS(1) - (LEN(l2$) + 1) + PRINT l2$; + END IF END IF IF l = idefocusline AND idecy <> l THEN @@ -8378,7 +8381,6 @@ SUB ideshowtext a2$ = SPACE$(idesx + (idewx - 3)) MID$(a2$, 1) = a$ - 'a2$ = RIGHT$(a2$, (idewx - 2)) ELSE a2$ = SPACE$((idewx - 2)) END IF @@ -8565,15 +8567,16 @@ SUB ideshowtext IF InValidLine(l) AND 1 THEN COLOR 7 IF ShowLineNumbers THEN - IF 2 + m - idesx >= 2 AND (2 + m - idesx) + LEN(STR$(iden)) + 1 < idewx - 1 THEN - LOCATE y + 3, (2 + m - idesx) + LEN(STR$(iden)) + 1 + IF (2 + m - idesx) + LEN(l1$) >= 2 + LEN(l1$) AND (2 + m - idesx) + LEN(l1$) < idewx THEN + LOCATE y + 3, (2 + m - idesx) + LEN(l1$) + PRINT thisChar$; END IF ELSE IF 2 + m - idesx >= 2 AND 2 + m - idesx < idewx THEN LOCATE y + 3, 2 + m - idesx + PRINT thisChar$; END IF END IF - PRINT thisChar$; 'Restore BG color in case a matching bracket was printed with different BG IF l = idecy THEN COLOR , 6 @@ -8651,7 +8654,7 @@ SUB ideshowtext LOCATE idewy + idesubwindow, (idewx - 10) - LEN(a$) PRINT a$; - SCREEN , , 0, 0: LOCATE idecy - idesy + 3, idecx - idesx + 2: SCREEN , , 3, 0 + SCREEN , , 0, 0: LOCATE idecy - idesy + 3, LEN(l1$) + idecx - idesx + 2: SCREEN , , 3, 0 EXIT SUB FindQuoteComment: From fb9a54a21023d2bf13473686ffe703d9fbf457ed Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Tue, 31 Oct 2017 03:51:19 -0200 Subject: [PATCH 07/10] Mouse input adapted to work when line numbers are visible. Also: Line numbers use the same color assigned to "line highlight". --- source/ide/ide_global.bas | 2 +- source/ide/ide_methods.bas | 84 ++++++++++++++++++++++++-------------- 2 files changed, 55 insertions(+), 31 deletions(-) diff --git a/source/ide/ide_global.bas b/source/ide/ide_global.bas index ddf8f8807..5444c92e0 100644 --- a/source/ide/ide_global.bas +++ b/source/ide/ide_global.bas @@ -167,7 +167,7 @@ DIM SHARED EnteringRGB AS _BYTE DIM SHARED ActiveINCLUDELink AS LONG DIM SHARED ActiveINCLUDELinkFile AS STRING DIM SHARED HideCurrentLineHighlight AS _BYTE, ShowLineNumbers AS _BYTE -DIM SHARED idegotobox_LastLineNum AS LONG +DIM SHARED idegotobox_LastLineNum AS LONG, maxLineNumberLength AS LONG '-------------------------------------------------------------------------------- TYPE idedbptype diff --git a/source/ide/ide_methods.bas b/source/ide/ide_methods.bas index 9fe46df3b..d3d29c0cf 100644 --- a/source/ide/ide_methods.bas +++ b/source/ide/ide_methods.bas @@ -740,6 +740,7 @@ FUNCTION ide2 (ignore) 'main loop DO ideloop: + IF ShowLineNumbers THEN maxLineNumberLength = LEN(STR$(iden)) + 1 ELSE maxLineNumberLength = 0 idecontextualmenu = 0 idedeltxt 'removes temporary strings (typically created by guibox commands) by setting an index to 0 IF idesubwindow <> 0 THEN _RESIZE OFF ELSE _RESIZE ON @@ -2648,7 +2649,7 @@ FUNCTION ide2 (ignore) ideselecty1 = wholeword.selecty1 idecy = wholeword.idecy END IF - newposition = mX - 1 + idesx - 1 + newposition = (mX - 1 + idesx - 1) - maxLineNumberLength a$ = idegetline$(idecy) IF newposition > LEN(a$) THEN idecx = newposition: GOTO DoneWholeWord IF newposition = 1 THEN ideselectx1 = 1: GOTO DoneWholeWord @@ -2674,11 +2675,11 @@ FUNCTION ide2 (ignore) END IF IF mCLICK THEN - IF mX > 1 AND mX < idewx AND mY > 2 AND mY < (idewy - 5) THEN 'inside text box + IF mX > 1 + maxLineNumberLength AND mX < idewx AND mY > 2 AND mY < (idewy - 5) THEN 'inside text box IF old.mX = mX AND old.mY = mY THEN IF TIMER - last.TBclick# > .5 THEN GOTO regularTextBox_click 'Double-click on text box: attempt to select "word" clicked - idecx = mX - 1 + idesx - 1 + idecx = (mX - 1 + idesx - 1) - maxLineNumberLength idecy = mY - 2 + idesy - 1 IF idecy > iden THEN GOTO regularTextBox_click @@ -2769,13 +2770,33 @@ FUNCTION ide2 (ignore) regularTextBox_click: old.mX = mX: old.mY = mY: last.TBclick# = TIMER ideselect = 1 - idecx = mX - 1 + idesx - 1 + idecx = (mX - 1 + idesx - 1) - maxLineNumberLength idecy = mY - 2 + idesy - 1 IF idecy > iden THEN idecy = iden ideselect = 1: ideselectx1 = idecx: ideselecty1 = idecy idemouseselect = 1 wholeword.select = 0 END IF + ELSEIF mX > 1 AND mx =< 1 + maxLineNumberLength AND mY > 2 AND mY < (idewy - 5) AND ShowLineNumbers THEN + 'line numbers are visible and been clicked + ideselect = 1 + idecy = mY - 2 + idesy - 1 + IF idecy < iden THEN + ideselectx1 = 1: ideselecty1 = idecy + idecy = idecy + 1 + idecx = 1 + ELSEIF idecy = iden THEN + a$ = idegetline$(idecy) + ideselectx1 = 1 + ideselecty1 = idecy + idecx = LEN(a$) + 1 + ELSEIF idecy > iden THEN + idecy = iden + ideselect = 0 + idecx = 1 + END IF + wholeword.select = 0 + idemouseselect = 0 END IF END IF @@ -2783,9 +2804,9 @@ FUNCTION ide2 (ignore) IF mCLICK2 THEN 'Second mouse button pressed. invokecontextualmenu: - IF mX > 1 AND mX < idewx AND mY > 2 AND mY < (idewy - 5) THEN 'inside text box + IF mX > 1 + maxLineNumberLength AND mX < idewx AND mY > 2 AND mY < (idewy - 5) THEN 'inside text box IF ideselect = 0 THEN 'Right click only positions the cursor if no selection is active - idecx = mX - 1 + idesx - 1 + idecx = (mX - 1 + idesx - 1) - maxLineNumberLength idecy = mY - 2 + idesy - 1 IF idecy > iden THEN idecy = iden ELSE 'A selection is reported but it may be that the user only clicked the screen. Let's check: @@ -2800,14 +2821,14 @@ FUNCTION ide2 (ignore) IF a2$ = "" THEN 'Told ya. ideselect = 0 - idecx = mX - 1 + idesx - 1 + idecx = (mX - 1 + idesx - 1) - maxLineNumberLength idecy = mY - 2 + idesy - 1 IF idecy > iden THEN idecy = iden ELSE 'Ok, there is a selection. But we'll override it if the click was outside it - IF mX - 1 + idesx - 1 < sx1 OR mX - 1 + idesx - 1 > sx2 THEN + IF (mX - 1 + idesx - 1) - maxLineNumberLength < sx1 OR (mX - 1 + idesx - 1) - maxLineNumberLength > sx2 THEN ideselect = 0 - idecx = mX - 1 + idesx - 1 + idecx = (mX - 1 + idesx - 1) - maxLineNumberLength idecy = mY - 2 + idesy - 1 IF idecy > iden THEN idecy = iden ideshowtext @@ -2815,7 +2836,7 @@ FUNCTION ide2 (ignore) END IF IF mY - 2 + idesy - 1 < idecy OR mY - 2 + idesy - 1 > idecy THEN ideselect = 0 - idecx = mX - 1 + idesx - 1 + idecx = (mX - 1 + idesx - 1) - maxLineNumberLength idecy = mY - 2 + idesy - 1 IF idecy > iden THEN idecy = iden ideshowtext @@ -2829,7 +2850,7 @@ FUNCTION ide2 (ignore) IF sy1 > sy2 THEN SWAP sy1, sy2 IF mY - 2 + idesy - 1 < sy1 OR mY - 2 + idesy - 1 > sy2 THEN ideselect = 0 - idecx = mX - 1 + idesx - 1 + idecx = (mX - 1 + idesx - 1) - maxLineNumberLength idecy = mY - 2 + idesy - 1 IF idecy > iden THEN idecy = iden ideshowtext @@ -2939,9 +2960,10 @@ FUNCTION ide2 (ignore) END IF IF mB AND idemouseselect <= 1 THEN - IF mX > 1 AND mX < idewx AND mY > 2 AND mY < idewy - 5 THEN 'inside text box + IF mX > 1 + maxLineNumberLength AND mX < idewx AND mY > 2 AND mY < idewy - 5 THEN 'inside text box IF idemouseselect = 1 THEN - idecx = mX - 1 + idesx - 1 + idecx = (mX - 1 + idesx - 1) - maxLineNumberLength + IF idecx < 1 THEN idecx = 1 idecy = mY - 2 + idesy - 1 IF idecy > iden THEN idecy = iden END IF @@ -2949,13 +2971,13 @@ FUNCTION ide2 (ignore) END IF IF mB THEN - IF mX = 1 OR mX = idewx OR mY <= 2 OR mY >= idewy - 5 THEN 'off text window area + IF ((mX = 1 AND ShowLineNumbers = 0) OR (mX <= 1 + maxLineNumberLength AND ShowLineNumbers)) OR mX = idewx OR mY <= 2 OR mY >= idewy - 5 THEN 'off text window area IF idemouseselect = 1 THEN 'scroll window IF mY >= idewy - 5 THEN idecy = idecy + 1: IF idecy > iden THEN idecy = iden IF mY <= 2 THEN idecy = idecy - 1: IF idecy < 1 THEN idecy = 1 - IF mX = 1 THEN idecx = idecx - 1: IF idecx < 1 THEN idecx = 1 + IF ((mX = 1 AND ShowLineNumbers = 0) OR (mX <= 1 + maxLineNumberLength AND ShowLineNumbers)) THEN idecx = idecx - 1: IF idecx < 1 THEN idecx = 1 IF mX = idewx THEN idecx = idecx + 1 idewait END IF @@ -8175,11 +8197,9 @@ SUB ideshowtext cc = -1 - IF ShowLineNumbers THEN l1$ = SPACE$(LEN(STR$(iden)) + 1) ELSE l1$ = "" - IF idecx < idesx THEN idesx = idecx IF idecy < idesy THEN idesy = idecy - IF (idecx + LEN(l1$)) - idesx >= (idewx - 2) THEN idesx = (idecx + LEN(l1$)) - (idewx - 3) + IF (idecx + maxLineNumberLength) - idesx >= (idewx - 2) THEN idesx = (idecx + maxLineNumberLength) - (idewx - 3) IF idecy - idesy >= (idewy - 8) THEN idesy = idecy - (idewy - 9) sy1 = ideselecty1 @@ -8238,13 +8258,17 @@ SUB ideshowtext PRINT CHR$(179); 'clear prev bookmarks from lhs IF ShowLineNumbers THEN - IF l = idecy THEN COLOR , 6 - PRINT l1$; + COLOR , 6 + 'IF l = idecy THEN COLOR , 6 + PRINT SPACE$(maxLineNumberLength); IF l <= iden THEN l2$ = STR$(l) - LOCATE y + 3, POS(1) - (LEN(l2$) + 1) - PRINT l2$; + IF POS(1) - (LEN(l2$) + 1) >= 2 THEN + LOCATE y + 3, POS(1) - (LEN(l2$) + 1) + PRINT l2$; 'CHR$(179); + END IF END IF + COLOR , 1 END IF IF l = idefocusline AND idecy <> l THEN @@ -8260,7 +8284,7 @@ SUB ideshowtext link_idecx = 0 rgb_idecx = 0 IF l = idecy THEN - IF idecx <= LEN(a$) 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 @@ -8567,8 +8591,8 @@ SUB ideshowtext IF InValidLine(l) AND 1 THEN COLOR 7 IF ShowLineNumbers THEN - IF (2 + m - idesx) + LEN(l1$) >= 2 + LEN(l1$) AND (2 + m - idesx) + LEN(l1$) < idewx THEN - LOCATE y + 3, (2 + m - idesx) + LEN(l1$) + IF (2 + m - idesx) + maxLineNumberLength >= 2 + maxLineNumberLength AND (2 + m - idesx) + maxLineNumberLength < idewx THEN + LOCATE y + 3, (2 + m - idesx) + maxLineNumberLength PRINT thisChar$; END IF ELSE @@ -8590,7 +8614,7 @@ SUB ideshowtext IF sy1 = sy2 THEN 'single line select COLOR 1, 7 x2 = idesx - FOR x = 2 TO (idewx - 2) + FOR x = 2 + maxLineNumberLength TO (idewx - 2) IF x2 >= sx1 AND x2 < sx2 THEN a = SCREEN(y + 3, x) @@ -8614,10 +8638,10 @@ SUB ideshowtext COLOR 7, 1 ELSE 'multiline select IF idecx = 1 AND l = sy2 AND idecy > sy1 THEN GOTO nofinalselect - LOCATE y + 3, 2 + LOCATE y + 3, 2 + maxLineNumberLength COLOR 1, 7 - FOR x = idesx TO idesx + idewx - 2 + FOR x = idesx TO idesx + idewx - (2 + maxLineNumberLength) PRINT MID$(a2$, x, 1); NEXT @@ -8654,7 +8678,7 @@ SUB ideshowtext LOCATE idewy + idesubwindow, (idewx - 10) - LEN(a$) PRINT a$; - SCREEN , , 0, 0: LOCATE idecy - idesy + 3, LEN(l1$) + idecx - idesx + 2: SCREEN , , 3, 0 + SCREEN , , 0, 0: LOCATE idecy - idesy + 3, maxLineNumberLength + idecx - idesx + 2: SCREEN , , 3, 0 EXIT SUB FindQuoteComment: @@ -13600,7 +13624,7 @@ SUB IdeMakeContextualMenu a$ = idegetline(idecy) a2$ = "" x = idecx - IF x <= LEN(a$) THEN + IF x <= LEN(a$) AND x >= 1 THEN IF alphanumeric(ASC(a$, x)) THEN x1 = x DO WHILE x1 > 1 From 40da21aacd5506b373d45f5bd1d9bed0f8863323 Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Tue, 31 Oct 2017 04:35:20 -0200 Subject: [PATCH 08/10] Add tweaks to Line Numbers in config.txt. - ShowLineNumbersSeparator will separate the line numbers panel from the main text are with CHR$(179); - ShowLineNumbersUseBG will use the same color assigned to current line highlight in the line numbers panel. --- source/global/IDEsettings.bas | 27 +++++++++++++++++++++++++++ source/ide/ide_methods.bas | 6 +++--- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/source/global/IDEsettings.bas b/source/global/IDEsettings.bas index c8a04614f..25c2723ea 100644 --- a/source/global/IDEsettings.bas +++ b/source/global/IDEsettings.bas @@ -12,6 +12,7 @@ DIM SHARED MouseButtonSwapped AS _BYTE DIM SHARED PasteCursorAtEnd AS _BYTE DIM SHARED SaveExeWithSource AS _BYTE DIM SHARED IDEShowErrorsImmediately AS _BYTE +DIM SHARED ShowLineNumbersSeparator AS _BYTE, ShowLineNumbersUseBG AS _BYTE IF LoadedIDESettings = 0 THEN 'We only want to load the file once when QB64 first starts @@ -204,6 +205,32 @@ IF LoadedIDESettings = 0 THEN ShowLineNumbers = 0 END IF + result = ReadConfigSetting("ShowLineNumbersSeparator", value$) + IF result THEN + IF value$ = "TRUE" OR VAL(value$) = -1 THEN + ShowLineNumbersSeparator = -1 + ELSE + ShowLineNumbersSeparator = 0 + WriteConfigSetting "'[GENERAL SETTINGS]", "ShowLineNumbersSeparator", "FALSE" + END IF + ELSE + WriteConfigSetting "'[GENERAL SETTINGS]", "ShowLineNumbersSeparator", "TRUE" + ShowLineNumbersSeparator = -1 + END IF + + result = ReadConfigSetting("ShowLineNumbersUseBG", value$) + IF result THEN + IF value$ = "TRUE" OR VAL(value$) = -1 THEN + ShowLineNumbersUseBG = -1 + ELSE + ShowLineNumbersUseBG = 0 + WriteConfigSetting "'[GENERAL SETTINGS]", "ShowLineNumbersUseBG", "FALSE" + END IF + ELSE + WriteConfigSetting "'[GENERAL SETTINGS]", "ShowLineNumbersUseBG", "TRUE" + ShowLineNumbersUseBG = -1 + END IF + result = ReadConfigSetting("BracketHighlight", value$) IF result THEN IF value$ = "TRUE" OR VAL(value$) = -1 THEN diff --git a/source/ide/ide_methods.bas b/source/ide/ide_methods.bas index d3d29c0cf..ab95fc334 100644 --- a/source/ide/ide_methods.bas +++ b/source/ide/ide_methods.bas @@ -8258,16 +8258,16 @@ SUB ideshowtext PRINT CHR$(179); 'clear prev bookmarks from lhs IF ShowLineNumbers THEN - COLOR , 6 - 'IF l = idecy THEN COLOR , 6 + 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$; 'CHR$(179); + PRINT l2$; END IF END IF + IF ShowLineNumbersSeparator THEN LOCATE y + 3, 1 + maxLineNumberLength: PRINT CHR$(179); COLOR , 1 END IF From 2a51fa6c0e913442e078efc966aecc7b7814fc54 Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Tue, 31 Oct 2017 19:43:22 -0200 Subject: [PATCH 09/10] Allows Shift+Click to select area from cursor. --- source/ide/ide_methods.bas | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/ide/ide_methods.bas b/source/ide/ide_methods.bas index ab95fc334..04680f368 100644 --- a/source/ide/ide_methods.bas +++ b/source/ide/ide_methods.bas @@ -2773,7 +2773,8 @@ FUNCTION ide2 (ignore) idecx = (mX - 1 + idesx - 1) - maxLineNumberLength idecy = mY - 2 + idesy - 1 IF idecy > iden THEN idecy = iden - ideselect = 1: ideselectx1 = idecx: ideselecty1 = idecy + ideselect = 1 + IF (NOT KSHIFT) THEN ideselectx1 = idecx: ideselecty1 = idecy idemouseselect = 1 wholeword.select = 0 END IF @@ -2782,13 +2783,12 @@ FUNCTION ide2 (ignore) ideselect = 1 idecy = mY - 2 + idesy - 1 IF idecy < iden THEN - ideselectx1 = 1: ideselecty1 = idecy + IF (NOT KSHIFT) THEN ideselectx1 = 1: ideselecty1 = idecy idecy = idecy + 1 idecx = 1 ELSEIF idecy = iden THEN a$ = idegetline$(idecy) - ideselectx1 = 1 - ideselecty1 = idecy + IF (NOT KSHIFT) THEN ideselectx1 = 1: ideselecty1 = idecy idecx = LEN(a$) + 1 ELSEIF idecy > iden THEN idecy = iden From fc607aa6134994a050f9b00cd6f11134ad9f5196 Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Tue, 2 Jan 2018 03:11:08 -0200 Subject: [PATCH 10/10] Add Line Number options to submenu in View menu. Also: - Adds submenus. - Renamed "Save EXE in the source folder" to "Output EXE to source folder" in Run menu. - Changed behavior of disabled menu items; instead of closing the menu, do nothing. --- source/global/version.bas | 2 +- source/ide/ide_global.bas | 3 +- source/ide/ide_methods.bas | 192 ++++++++++++++++++++++++++++--------- 3 files changed, 152 insertions(+), 45 deletions(-) diff --git a/source/global/version.bas b/source/global/version.bas index 625f989cd..e178f9269 100644 --- a/source/global/version.bas +++ b/source/global/version.bas @@ -4,5 +4,5 @@ DIM SHARED AutoBuildMsg AS STRING Version$ = "1.2" 'BuildNum format is YYYYMMDD/id, where id is a ever-increasing 'integer. If you make a change, update the date and increase the id! -BuildNum$ = "20171230/83" +BuildNum$ = "20180102/84" diff --git a/source/ide/ide_global.bas b/source/ide/ide_global.bas index 5444c92e0..8dc4183be 100644 --- a/source/ide/ide_global.bas +++ b/source/ide/ide_global.bas @@ -207,7 +207,8 @@ DIM SHARED menus AS INTEGER, idecontextualmenuID AS INTEGER DIM SHARED ideeditmenuID AS INTEGER DIM SHARED OptionsMenuID AS INTEGER, OptionsMenuSwapMouse AS INTEGER, OptionsMenuPasteCursor AS INTEGER DIM SHARED OptionsMenuShowErrorsImmediately AS INTEGER -DIM SHARED ViewMenuID AS INTEGER, ViewMenuShowLineNumbers AS INTEGER +DIM SHARED ViewMenuID AS INTEGER, ViewMenuShowLineNumbersSubMenuID AS INTEGER +DIM SHARED ViewMenuShowSeparatorID AS INTEGER, ViewMenuShowBGID AS INTEGER DIM SHARED RunMenuID AS INTEGER, RunMenuSaveExeWithSource AS INTEGER, brackethighlight AS INTEGER DIM SHARED multihighlight AS INTEGER, keywordHighlight AS INTEGER DIM SHARED PresetColorSchemes AS INTEGER, TotalColorSchemes AS INTEGER, ColorSchemes$(0) diff --git a/source/ide/ide_methods.bas b/source/ide/ide_methods.bas index 59a1cef80..ba5ae4664 100644 --- a/source/ide/ide_methods.bas +++ b/source/ide/ide_methods.bas @@ -252,13 +252,7 @@ FUNCTION ide2 (ignore) m = m + 1: i = 0: ViewMenuID = m menu$(m, i) = "View": i = i + 1 menu$(m, i) = "#SUBs... F2": i = i + 1 - - ViewMenuShowLineNumbers = i - menu$(m, i) = "#Line numbers": i = i + 1 - IF ShowLineNumbers THEN - menu$(ViewMenuID, ViewMenuShowLineNumbers) = CHR$(7) + menu$(ViewMenuID, ViewMenuShowLineNumbers) - END IF - + menu$(m, i) = "#Line numbers " + CHR$(16): i = i + 1 menusize(m) = i - 1 m = m + 1: i = 0 @@ -284,7 +278,7 @@ FUNCTION ide2 (ignore) menu$(m, i) = "-": i = i + 1 RunMenuSaveExeWithSource = i - menu$(m, i) = "Save EXE in the source #folder": i = i + 1 + menu$(m, i) = "Output EXE to source #folder": i = i + 1 IF SaveExeWithSource THEN menu$(RunMenuID, RunMenuSaveExeWithSource) = CHR$(7) + menu$(RunMenuID, RunMenuSaveExeWithSource) END IF @@ -350,6 +344,22 @@ FUNCTION ide2 (ignore) m = m + 1 idecontextualmenuID = m + 'View Menu sub menu for Line Numbers options + m = m + 1: i = 0 + menu$(m, i) = "ViewMenuShowLineNumbersSubMenu": i = i + 1 + ViewMenuShowLineNumbersSubMenuID = m + IF ShowLineNumbers THEN menu$(m, i) = "#Hide line numbers" ELSE menu$(m, i) = "#Show line numbers" + i = i + 1 + menu$(m, i) = "#Background color": IF ShowLineNumbersUseBG THEN menu$(m, i) = CHR$(7) + menu$(m, i) + ViewMenuShowBGID = i + IF ShowLineNumbers = 0 THEN menu$(m, i) = "~" + menu$(m, i) + i = i + 1 + menu$(m, i) = "Sho#w separator": IF ShowLineNumbersSeparator THEN menu$(m, i) = CHR$(7) + menu$(m, i) + ViewMenuShowSeparatorID = i + IF ShowLineNumbers = 0 THEN menu$(m, i) = "~" + menu$(m, i) + i = i + 1 + menusize(m) = i - 1 + IF os$ = "WIN" THEN idepathsep$ = "\" END IF @@ -1410,7 +1420,7 @@ FUNCTION ide2 (ignore) GOTO specialchar END IF - '3- Link to the output folder when "Save EXE in the source folder" is checked: + '3- Link to the output folder when "Output EXE to source #folder" is checked: IF INSTR(_OS$, "WIN") THEN SHELL _DONTWAIT "explorer /select," + QuotedFilename$(path.exe$ + file$ + extension$) ELSEIF INSTR(_OS$, "MAC") THEN @@ -3969,7 +3979,7 @@ FUNCTION ide2 (ignore) GetInput IF oldmx <> mX OR oldmy <> mY THEN - IF mY = 1 AND idecontextualmenu = 0 THEN 'Check if we're hovering on menu bar + IF mY = 1 AND idecontextualmenu <> 1 THEN 'Check if we're hovering on menu bar lastm = m FOR i = 1 TO menus x = CVI(MID$(MenuLocations, i * 2 - 1, 2)) @@ -4082,8 +4092,13 @@ FUNCTION ide2 (ignore) IF IdeSystem = 2 THEN IdeSystem = 1: GOSUB UpdateSearchBar PCOPY 0, 2 SCREEN , , 1, 0 + updateMenuPanel%% = 0 + parentMenuR = r r = 1 + parentMenu = 0 + parentMenuSetup%% = 0 IF idecontextualmenu = 1 THEN idectxmenuX = mX: idectxmenuY = mY: m = idecontextualmenuID + IF idecontextualmenu = 2 THEN idectxmenuX = xx + w + 3: idectxmenuY = yy + r: parentMenu = m: m = ViewMenuShowLineNumbersSubMenuID IdeMakeEditMenu oldmy = mY: oldmx = mX DO @@ -4095,6 +4110,14 @@ FUNCTION ide2 (ignore) IF i = menus - 1 THEN x = idewx - LEN(menu$(menus, 0)) - 1 NEXT: xx = x LOCATE 1, xx - 1: COLOR 7, 0: PRINT " " + menu$(m, 0) + " " + ELSE + IF parentMenu > 0 AND parentMenuSetup%% = 0 THEN + parentMenuSetup%% = -1 + backToParent.x1 = xx - 1 + backToParent.x2 = xx + w + backToParent.y1 = 3 + backToParent.y2 = backToParent.y1 + menusize(parentMenu) + END IF END IF COLOR 0, 7 'calculate menu width @@ -4109,7 +4132,7 @@ FUNCTION ide2 (ignore) IF l > w THEN w = l NEXT yy = 2 - IF idecontextualmenu = 1 THEN + IF idecontextualmenu > 0 THEN actual.idewy = idewy IF idesubwindow <> 0 THEN actual.idewy = idewy + idesubwindow @@ -4131,7 +4154,7 @@ FUNCTION ide2 (ignore) ELSEIF LEFT$(m$, 1) = "~" THEN m$ = RIGHT$(m$, LEN(m$) - 1) 'Remove the tilde before printing IF r = i THEN LOCATE i + yy, xx - 1: COLOR 7, 0: PRINT SPACE$(w + 2); - LOCATE i + yy, xx + IF LEFT$(m$, 1) = CHR$(7) THEN LOCATE i + yy, xx - 1 ELSE LOCATE i + yy, xx h = -1: x = INSTR(m$, "#"): IF x THEN h = x: m$ = LEFT$(m$, x - 1) + RIGHT$(m$, LEN(m$) - x) x = INSTR(m$, " "): IF x THEN m1$ = LEFT$(m$, x - 1): m2$ = RIGHT$(m$, LEN(m$) - x - 1): m$ = m1$ + SPACE$(w - LEN(m1$) - LEN(m2$)) + m2$ FOR x = 1 TO LEN(m$) @@ -4151,15 +4174,13 @@ FUNCTION ide2 (ignore) END IF PRINT MID$(m$, x, 1); NEXT - - - END IF - NEXT PCOPY 1, 0 + IF updateMenuPanel%% THEN GOTO menuChoiceMade + change = 0 DO mousedown = 0: mouseup = 0 @@ -4212,7 +4233,7 @@ FUNCTION ide2 (ignore) GOTO ideloop END IF - IF mCLICK2 AND idecontextualmenu THEN 'A new right click in the text area repositions the contextual menu + IF mCLICK2 AND idecontextualmenu = 1 THEN 'A new right click in the text area repositions the contextual menu IF mX > 1 AND mX < idewx AND mY > 2 AND mY < (idewy - 5) THEN PCOPY 3, 0: SCREEN , , 3, 0 GOTO invokecontextualmenu @@ -4233,12 +4254,33 @@ FUNCTION ide2 (ignore) END IF END IF - IF mX < xx - 2 OR mX >= xx - 2 + w + 4 OR mY > yy + menusize(m) + 1 OR (mY < yy AND idecontextualmenu) THEN + IF parentMenu > 0 AND _ + mX >= backToParent.x1 AND mX =< backToParent.x2 AND _ + mY >= backToParent.y1 AND mY =< backToParent.y2 THEN + m = parentMenu + r = parentMenuR + parentMenu = 0 + idecontextualmenu = 0 + PCOPY 3, 2 + _CONTINUE + END IF + + IF mX < xx - 2 OR mX >= xx - 2 + w + 4 OR mY > yy + menusize(m) + 1 OR (mY < yy AND idecontextualmenu = 1) THEN PCOPY 3, 0: SCREEN , , 3, 0 GOTO ideloop END IF END IF IF NOT mouseup AND NOT mousedown THEN 'Check if we're hovering on menu options + IF parentMenu > 0 AND oldmy <> mY AND oldmx <> mX AND _ + mX >= backToParent.x1 AND mX =< backToParent.x2 AND _ + mY >= backToParent.y1 AND mY =< backToParent.y2 THEN + m = parentMenu + r = parentMenuR + parentMenu = 0 + idecontextualmenu = 0 + PCOPY 3, 2 + _CONTINUE + END IF IF oldmy <> mY THEN IF mX >= xx - 2 AND mX < xx - 2 + w + 4 THEN IF mY > yy AND mY <= menusize(m) + yy THEN @@ -4254,7 +4296,7 @@ FUNCTION ide2 (ignore) END IF IF oldmx <> mX THEN checkmenubarhover: - IF mY = 1 AND idecontextualmenu = 0 THEN 'Check if we're hovering on menu bar + IF mY = 1 AND idecontextualmenu <> 1 THEN 'Check if we're hovering on menu bar lastm = m FOR i = 1 TO menus x = CVI(MID$(MenuLocations, i * 2 - 1, 2)) @@ -4262,6 +4304,7 @@ FUNCTION ide2 (ignore) IF mX >= x AND mX < x2 THEN m = i r = 1 + IF idecontextualmenu > 1 THEN idecontextualmenu = 0: PCOPY 3, 2 EXIT FOR END IF NEXT @@ -4274,7 +4317,6 @@ FUNCTION ide2 (ignore) 'top row IF mY = 1 THEN - idecontextualmenu = 0 lastm = m x = 3 FOR i = 1 TO menus @@ -4283,6 +4325,7 @@ FUNCTION ide2 (ignore) m = i r = 1 IF lastm = m AND mousedown = 1 THEN PCOPY 3, 0: SCREEN , , 3, 0: idewait4mous: GOTO ideloop + idecontextualmenu = 0 EXIT FOR END IF x = x + x2 @@ -4300,8 +4343,31 @@ FUNCTION ide2 (ignore) END IF 'mb - IF KB = KEY_LEFT AND idecontextualmenu = 0 THEN m = m - 1: r = 1 - IF KB = KEY_RIGHT AND idecontextualmenu = 0 THEN m = m + 1: r = 1 + IF KB = KEY_LEFT AND idecontextualmenu = 0 THEN + m = m - 1: r = 1 + ELSEIF KB = KEY_LEFT AND idecontextualmenu > 1 THEN + idecontextualmenu = 0 + PCOPY 3, 2 + m = parentMenu + r = parentMenuR + parentMenu = 0 + END IF + IF KB = KEY_RIGHT AND idecontextualmenu = 0 THEN + IF RIGHT$(menu$(m, r), 1) = CHR$(16) THEN + SELECT CASE LEFT$(menu$(m, r), LEN(menu$(m, r)) - 3) + CASE "#Line numbers" + idecontextualmenu = 2 + GOTO showmenu + END SELECT + ELSE + m = m + 1: r = 1 + END IF + ELSEIF KB = KEY_RIGHT AND idecontextualmenu > 1 THEN + idecontextualmenu = 0 + PCOPY 3, 2 + m = parentMenu + 1 + r = 1 + END IF IF m < 1 THEN m = menus IF m > menus AND idecontextualmenu = 0 THEN m = 1 IF KB = KEY_ESC THEN @@ -4334,13 +4400,14 @@ FUNCTION ide2 (ignore) x = INSTR(menu$(m, r2), "#") IF x THEN a$ = UCASE$(MID$(menu$(m, r2), x + 1, 1)) - IF K$ = a$ THEN s = r2: EXIT FOR + IF K$ = a$ THEN s = r2: updateMenuPanel%% = -1: EXIT FOR END IF NEXT + IF updateMenuPanel%% THEN r = r2: _CONTINUE END IF IF s THEN - + menuChoiceMade: IF KALT THEN idehl = 1 ELSE idehl = 0 'set idehl, a shared variable used by various dialogue boxes IF menu$(m, s) = "Comment (add ') Ctrl+R" THEN @@ -4413,11 +4480,6 @@ FUNCTION ide2 (ignore) GOTO ideloop END IF - IF LEFT$(menu$(m, s), 16) = "~Decrease indent" OR menu$(m, s) = "~Increase indent TAB" THEN - PCOPY 3, 0: SCREEN , , 3, 0: idewait4mous: idewait4alt - GOTO ideloop - END IF - IF menu$(m, s) = "#Language..." THEN PCOPY 2, 0 retval = idelanguagebox @@ -4524,15 +4586,15 @@ FUNCTION ide2 (ignore) GOTO ideloop END IF - IF RIGHT$(menu$(m, s), 30) = "Save EXE in the source #folder" THEN + IF RIGHT$(menu$(m, s), 28) = "Output EXE to source #folder" THEN PCOPY 2, 0 SaveExeWithSource = NOT SaveExeWithSource IF SaveExeWithSource THEN WriteConfigSetting "'[GENERAL SETTINGS]", "SaveExeWithSource", "TRUE" - menu$(RunMenuID, RunMenuSaveExeWithSource) = CHR$(7) + "Save EXE in the source #folder" + menu$(RunMenuID, RunMenuSaveExeWithSource) = CHR$(7) + "Output EXE to source #folder" ELSE WriteConfigSetting "'[GENERAL SETTINGS]", "SaveExeWithSource", "FALSE" - menu$(RunMenuID, RunMenuSaveExeWithSource) = "Save EXE in the source #folder" + menu$(RunMenuID, RunMenuSaveExeWithSource) = "Output EXE to source #folder" END IF PCOPY 3, 0: SCREEN , , 3, 0: idewait4mous: idewait4alt GOTO ideloop @@ -4841,20 +4903,65 @@ FUNCTION ide2 (ignore) GOTO ideloop END IF - IF RIGHT$(menu$(m, s), 13) = "#Line numbers" THEN + IF menu$(m, s) = "#Line numbers " + CHR$(16) THEN + idecontextualmenu = 2 + GOTO showmenu + END IF + + IF menu$(m, s) = "#Show line numbers" THEN PCOPY 2, 0 - ShowLineNumbers = NOT ShowLineNumbers - IF ShowLineNumbers THEN - WriteConfigSetting "'[GENERAL SETTINGS]", "ShowLineNumbers", "TRUE" - menu$(ViewMenuID, ViewMenuShowLineNumbers) = CHR$(7) + "#Line numbers" - ELSE - WriteConfigSetting "'[GENERAL SETTINGS]", "ShowLineNumbers", "FALSE" - menu$(ViewMenuID, ViewMenuShowLineNumbers) = "#Line numbers" - END IF + ShowLineNumbers = -1 + WriteConfigSetting "'[GENERAL SETTINGS]", "ShowLineNumbers", "TRUE" + menu$(m, s) = "#Hide line numbers" + menu$(m, ViewMenuShowBGID) = MID$(menu$(m, ViewMenuShowBGID), 2) + menu$(m, ViewMenuShowSeparatorID) = MID$(menu$(m, ViewMenuShowSeparatorID), 2) PCOPY 3, 0: SCREEN , , 3, 0: idewait4mous: idewait4alt GOTO ideloop END IF + IF menu$(m, s) = "#Hide line numbers" THEN + PCOPY 2, 0 + ShowLineNumbers = 0 + WriteConfigSetting "'[GENERAL SETTINGS]", "ShowLineNumbers", "FALSE" + menu$(m, s) = "#Show line numbers" + menu$(m, ViewMenuShowBGID) = "~" + menu$(m, ViewMenuShowBGID) + menu$(m, ViewMenuShowSeparatorID) = "~" + menu$(m, ViewMenuShowSeparatorID) + PCOPY 3, 0: SCREEN , , 3, 0: idewait4mous: idewait4alt + GOTO ideloop + END IF + + IF RIGHT$(menu$(m, s), 17) = "#Background color" THEN + IF LEFT$(menu$(m, s), 1) <> "~" THEN + PCOPY 2, 0 + ShowLineNumbersUseBG = NOT ShowLineNumbersUseBG + IF ShowLineNumbersUseBG THEN + WriteConfigSetting "'[GENERAL SETTINGS]", "ShowLineNumbersUseBG", "TRUE" + menu$(m, s) = CHR$(7) + "#Background color" + ELSE + WriteConfigSetting "'[GENERAL SETTINGS]", "ShowLineNumbersUseBG", "FALSE" + menu$(m, s) = "#Background color" + END IF + PCOPY 3, 0: SCREEN , , 3, 0: idewait4mous: idewait4alt + GOTO ideloop + END IF + END IF + + IF RIGHT$(menu$(m, s), 15) = "Sho#w separator" THEN + IF LEFT$(menu$(m, s), 1) <> "~" THEN + PCOPY 2, 0 + ShowLineNumbersSeparator = NOT ShowLineNumbersSeparator + IF ShowLineNumbersSeparator THEN + WriteConfigSetting "'[GENERAL SETTINGS]", "ShowLineNumbersSeparator", "TRUE" + menu$(m, s) = CHR$(7) + "Sho#w separator" + ELSE + WriteConfigSetting "'[GENERAL SETTINGS]", "ShowLineNumbersSeparator", "FALSE" + menu$(m, s) = "Sho#w separator" + END IF + PCOPY 3, 0: SCREEN , , 3, 0: idewait4mous: idewait4alt + GOTO ideloop + END IF + END IF + IF menu$(m, s) = "#Find... Ctrl+F3" THEN PCOPY 2, 0 idefindjmp: @@ -5298,10 +5405,9 @@ FUNCTION ide2 (ignore) END IF IF LEFT$(menu$(m, s), 1) = "~" THEN 'Ignore disabled items (starting with "~") - PCOPY 3, 0: SCREEN , , 3, 0: idewait4mous: idewait4alt: GOTO ideloop + _CONTINUE END IF - SCREEN , , 0, 0 CLS: PRINT "MENU ITEM [" + menu$(m, s) + "] NOT IMPLEMENTED!": END END IF