From 8f67d403307b43418a17cbe3504f60ae11044414 Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Tue, 21 Jun 2016 03:38:42 -0300 Subject: [PATCH] Add "Save EXE in the source folder" to the Run menu. (Windows only for now) When active, this new setting will instruct the compiler to save the .EXE in the same folder as the source file. If the current program is not yet saved, the .EXE is placed in the same folder as QB64.EXE, as usual. Also: - When "Make EXE only (F11)" is used, the status area will show "Location: " and a link to the folder where the .EXE was saved. Clicking it launches Windows Explorer. --- source/global/IDEsettings.bas | 15 +++++++++++++- source/global/version.bas | 2 +- source/ide/ide_global.bas | 1 + source/ide/ide_methods.bas | 37 +++++++++++++++++++++++++++++++++-- source/qb64.bas | 24 ++++++++++++++++------- 5 files changed, 68 insertions(+), 11 deletions(-) diff --git a/source/global/IDEsettings.bas b/source/global/IDEsettings.bas index 86fb5cb96..1272b6192 100644 --- a/source/global/IDEsettings.bas +++ b/source/global/IDEsettings.bas @@ -7,6 +7,7 @@ DIM SHARED IDE_Index$ DIM SHARED LoadedIDESettings AS INTEGER DIM SHARED MouseButtonSwapped AS _BYTE DIM SHARED PasteCursorAtEnd AS _BYTE +DIM SHARED SaveExeWithSource AS _BYTE IF LoadedIDESettings = 0 THEN 'We only want to load the file once when QB64 first starts @@ -117,8 +118,20 @@ IF LoadedIDESettings = 0 THEN PasteCursorAtEnd = 0 END IF - IF INSTR(_OS$, "WIN") THEN + result = ReadConfigSetting("SaveExeWithSource", value$) + IF result THEN + IF value$ = "TRUE" OR VAL(value$) = -1 THEN + SaveExeWithSource = -1 + ELSE + SaveExeWithSource = 0 + WriteConfigSetting "'[GENERAL SETTINGS]", "SaveExeWithSource", "FALSE" + END IF + ELSE + WriteConfigSetting "'[GENERAL SETTINGS]", "SaveExeWithSource", "FALSE" + SaveExeWithSource = 0 + END IF + IF INSTR(_OS$, "WIN") THEN result = ReadConfigSetting("IDE_AutoPosition", value$) IF result THEN IF UCASE$(value$) = "TRUE" OR ABS(VAL(value$)) = 1 THEN diff --git a/source/global/version.bas b/source/global/version.bas index d424194d1..5c6f6219a 100644 --- a/source/global/version.bas +++ b/source/global/version.bas @@ -3,5 +3,5 @@ DIM SHARED BuildNum AS STRING Version$ = "1.000" '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$ = "20160621/20" +BuildNum$ = "20160621/21" diff --git a/source/ide/ide_global.bas b/source/ide/ide_global.bas index 1483acbc4..5739fcd31 100644 --- a/source/ide/ide_global.bas +++ b/source/ide/ide_global.bas @@ -194,6 +194,7 @@ DIM SHARED menusize(1 TO 10) 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 RunMenuID AS INTEGER, RunMenuSaveExeWithSource AS INTEGER DIM SHARED menubar$, idecontextualSearch$ DIM SHARED ideundocombo, ideundocombochr, idenoundo, idemergeundo DIM SHARED idealthighlight, ideentermenu diff --git a/source/ide/ide_methods.bas b/source/ide/ide_methods.bas index 6d995031e..6f2345f6b 100644 --- a/source/ide/ide_methods.bas +++ b/source/ide/ide_methods.bas @@ -245,11 +245,19 @@ IF idelaunched = 0 THEN menusize(m) = i - 1 - m = m + 1: i = 0 + m = m + 1: i = 0: RunMenuID = m menu$(m, i) = "Run": i = i + 1 menu$(m, i) = "#Start F5": i = i + 1 menu$(m, i) = "Modify #COMMAND$...": i = i + 1 menu$(m, i) = "-": i = i + 1 + IF INSTR(_OS$, "WIN") THEN + RunMenuSaveExeWithSource = i + menu$(m, i) = "Save EXE in the source #folder": i = i + 1 + IF SaveExeWithSource THEN + menu$(RunMenuID, RunMenuSaveExeWithSource) = CHR$(7) + menu$(RunMenuID, RunMenuSaveExeWithSource) + ENDIF + menu$(m, i) = "-": i = i + 1 + END IF menu$(m, i) = "Start (#Detached) Ctrl+F5": i = i + 1 IF os$ = "LNX" THEN menu$(m, i) = "Make E#xecutable Only F11": i = i + 1 @@ -264,7 +272,6 @@ IF idelaunched = 0 THEN menu$(m, i) = "Make #Android Project": i = i + 1 IF IdeAndroidMenu THEN menusize(m) = i - 1 - m = m + 1: i = 0: OptionsMenuID = m menu$(m, i) = "Options": i = i + 1 menu$(m, i) = "#Display...": i = i + 1 @@ -633,6 +640,17 @@ IF skipdisplay = 0 THEN PRINT "Executable file created"; ELSE PRINT ".EXE file created"; + IF SaveExeWithSource THEN + LOCATE idewy - 2, 2 + PRINT "Location: "; + COLOR 11, 1 + IF path.exe$ = "" THEN path.exe$ = _STARTDIR$ + pathsep$ + IF POS(0) + LEN(path.exe$) > idewx THEN + PRINT "..."; RIGHT$(path.exe$, idewx - 15); + ELSE + PRINT path.exe$; + END IF + END IF END IF END IF @@ -1249,6 +1267,7 @@ DO IF mX >= 2 AND mX <= idewx AND mY >= idewy - 3 AND mY <= idewy - 1 THEN IF SCREEN(mY, mX, 1) = 11 + 1 * 16 THEN IF idefocusline THEN idecx = 1: AddQuickNavHistory idecy: idecy = idefocusline: ideselect = 0: GOTO specialchar + SHELL _DONTWAIT "EXPLORER " + QuotedFilename$(path.exe$) END IF END IF END IF @@ -3837,6 +3856,20 @@ DO GOTO ideloop END IF + IF RIGHT$(menu$(m, s), 30) = "Save EXE in the 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" + else + WriteConfigSetting "'[GENERAL SETTINGS]", "SaveExeWithSource", "FALSE" + menu$(RunMenuID, RunMenuSaveExeWithSource) = "Save EXE in the source #folder" + end if + PCOPY 3, 0: SCREEN , , 3, 0: idewait4mous: idewait4alt + GOTO ideloop + END IF + IF menu$(m, s) = "#Code layout..." THEN PCOPY 2, 0 retval = idelayoutbox diff --git a/source/qb64.bas b/source/qb64.bas index 54d19bfba..8ad9f6971 100644 --- a/source/qb64.bas +++ b/source/qb64.bas @@ -205,6 +205,7 @@ NEXT DIM SHARED extension AS STRING +DIM SHARED path.exe$ extension$ = ".exe" IF os$ = "LNX" THEN extension$ = "" 'no extension under Linux @@ -934,12 +935,18 @@ IF C = 9 THEN 'run 'locate accessible file and truncate f$ = file$ + + path.exe$ = "" + IF SaveExeWithSource THEN + IF LEN(ideprogname) THEN path.exe$ = idepath$ + pathsep$ + END IF + i = 1 nextexeindex: - IF _FILEEXISTS(file$ + extension$) THEN + IF _FILEEXISTS(path.exe$ + file$ + extension$) THEN E = 0 ON ERROR GOTO qberror_test - KILL file$ + extension$ + KILL path.exe$ + file$ + extension$ ON ERROR GOTO qberror IF E = 1 THEN i = i + 1 @@ -948,6 +955,8 @@ IF C = 9 THEN 'run END IF END IF + IF path.exe$ = "" THEN path.exe$ = "..\..\" + 'inform IDE of name change if necessary (IDE will respond with message 9 and corrected name) IF i <> 1 THEN sendc$ = CHR$(12) + file$ @@ -1104,10 +1113,10 @@ IF C = 9 THEN 'run 'execute program IF iderunmode = 1 THEN - IF os$ = "WIN" THEN SHELL _DONTWAIT QuotedFilename$(CHR$(34) + file$ + extension$ + CHR$(34)) + ModifyCOMMAND$ + IF os$ = "WIN" THEN SHELL _DONTWAIT QuotedFilename$(CHR$(34) + path.exe$ + file$ + extension$ + CHR$(34)) + ModifyCOMMAND$ IF os$ = "LNX" THEN SHELL _DONTWAIT QuotedFilename$("./" + file$ + extension$) + ModifyCOMMAND$ ELSE - IF os$ = "WIN" THEN SHELL QuotedFilename$(CHR$(34) + file$ + extension$ + CHR$(34)) + ModifyCOMMAND$ + IF os$ = "WIN" THEN SHELL QuotedFilename$(CHR$(34) + path.exe$ + file$ + extension$ + CHR$(34)) + ModifyCOMMAND$ IF os$ = "LNX" THEN SHELL QuotedFilename$("./" + file$ + extension$) + ModifyCOMMAND$ END IF @@ -2951,7 +2960,7 @@ DO END IF END IF - IF ExecLevel(ExecCounter) THEN 'don't check for any more metacommands except the one's which worth with the precompiler + IF ExecLevel(ExecCounter) THEN 'don't check for any more metacommands except the one's which worth with the precompiler layoutdone = 0 GOTO finishednonexec 'we don't check for anything inside lines that we've marked for skipping END IF @@ -11739,7 +11748,7 @@ IF os$ = "WIN" THEN a$ = LEFT$(a$, x - 1) + libqb$ + RIGHT$(a$, LEN(a$) - x + 1) END IF - a$ = a$ + QuotedFilename$("..\..\" + file$ + extension$) + a$ = a$ + QuotedFilename$(path.exe$ + file$ + extension$) ffh = FREEFILE OPEN tmpdir$ + "recompile_win.bat" FOR OUTPUT AS #ffh @@ -12077,7 +12086,8 @@ IF os$ = "LNX" THEN END IF IF No_C_Compile_Mode THEN compfailed = 0: GOTO No_C_Compile -IF _FILEEXISTS(file$ + extension$) THEN compfailed = 0 ELSE compfailed = 1 'detect compilation failure +IF LEFT$(path.exe$, 2) = ".." THEN path.exe$ = "" +IF _FILEEXISTS(path.exe$ + file$ + extension$) THEN compfailed = 0 ELSE compfailed = 1 'detect compilation failure IF compfailed THEN IF idemode THEN