mirror of
https://github.com/QB64-Phoenix-Edition/QB64pe.git
synced 2024-07-12 23:55:13 +00:00
Merge pull request #361 from a740g/IDE-fixes
IDE Open & Save GUI dialog fixes
This commit is contained in:
commit
cd5f7a420b
|
@ -20292,124 +20292,131 @@ end sub
|
||||||
' Download = MKI$(0) 'still working
|
' Download = MKI$(0) 'still working
|
||||||
'END FUNCTION
|
'END FUNCTION
|
||||||
|
|
||||||
Function SaveFile$ (IdeOpenFile as string)
|
|
||||||
STATIC Default_StartDir$
|
|
||||||
|
|
||||||
IF Default_StartDir$ = "" THEN
|
FUNCTION SaveFile$ (IdeOpenFile AS STRING)
|
||||||
Default_StartDir$ = _STARTDIR$
|
SHARED Default_StartDir$
|
||||||
if Right$(Default_StartDir$, 1) <> idepathsep$ then Default_StartDir$ = Default_StartDir$ + idepathsep$
|
|
||||||
|
IF Default_StartDir$ = "" THEN
|
||||||
|
Default_StartDir$ = _STARTDIR$
|
||||||
|
IF RIGHT$(Default_StartDir$, 1) <> idepathsep$ THEN Default_StartDir$ = Default_StartDir$ + idepathsep$
|
||||||
|
END IF
|
||||||
|
|
||||||
|
f$ = _SAVEFILEDIALOG$("Save Source File", Default_StartDir$ + IdeOpenFile, "*.bas|*.BAS|*.Bas", "QB64-PE BAS File")
|
||||||
|
IF f$ = "" THEN
|
||||||
|
SaveFile$ = "C"
|
||||||
|
EXIT FUNCTION 'someone canceled the input.
|
||||||
|
END IF
|
||||||
|
|
||||||
|
IF FileHasExtension(f$) = 0 THEN f$ = f$ + ".bas"
|
||||||
|
path$ = idezgetfilepath$(ideroot$, f$)
|
||||||
|
pathseppos = _INSTRREV(f$, idepathsep$)
|
||||||
|
IF pathseppos > 0 THEN f$ = MID$(f$, pathseppos + 1)
|
||||||
|
|
||||||
|
Default_StartDir$ = path$
|
||||||
|
IF RIGHT$(Default_StartDir$, 1) <> idepathsep$ THEN Default_StartDir$ = Default_StartDir$ + idepathsep$
|
||||||
|
|
||||||
|
ideerror = 3
|
||||||
|
OPEN path$ + idepathsep$ + f$ FOR BINARY AS #150
|
||||||
|
ideerror = 1
|
||||||
|
ideprogname$ = f$
|
||||||
|
_TITLE ideprogname$ + " - " + WindowTitle
|
||||||
|
idesave path$ + idepathsep$ + f$
|
||||||
|
idepath$ = path$
|
||||||
|
IdeAddRecent path$ + idepathsep$ + f$
|
||||||
|
IdeSaveBookmarks path$ + idepathsep$ + f$
|
||||||
|
CLOSE #150
|
||||||
|
END FUNCTION
|
||||||
|
|
||||||
|
|
||||||
|
FUNCTION OpenFile$ (IdeOpenFile AS STRING) 'load routine copied/pasted from the old IDE file load/save dialog routines
|
||||||
|
SHARED Default_StartDir$
|
||||||
|
|
||||||
|
IF Default_StartDir$ = "" THEN
|
||||||
|
Default_StartDir$ = _STARTDIR$
|
||||||
|
IF RIGHT$(Default_StartDir$, 1) <> idepathsep$ THEN Default_StartDir$ = Default_StartDir$ + idepathsep$
|
||||||
|
END IF
|
||||||
|
|
||||||
|
ideopenloop:
|
||||||
|
IF IdeOpenFile = "" THEN f$ = _OPENFILEDIALOG$("Open Source File", Default_StartDir$, "*.bas|*.BAS|*.Bas|*.bi|*.BI|*.Bi|*.bm|*.BM|*.Bm", "QB64-PE Source Files", 0) ELSE f$ = IdeOpenFile
|
||||||
|
IF f$ = "" THEN OpenFile$ = "C": EXIT FUNCTION
|
||||||
|
path$ = ideztakepath$(f$)
|
||||||
|
|
||||||
|
Default_StartDir$ = path$
|
||||||
|
IF RIGHT$(Default_StartDir$, 1) <> idepathsep$ THEN Default_StartDir$ = Default_StartDir$ + idepathsep$
|
||||||
|
|
||||||
|
IF _FILEEXISTS(path$ + idepathsep$ + f$) = 0 THEN 'see if the user forgot the .bas extension and check for the file
|
||||||
|
|
||||||
|
IF (LCASE$(RIGHT$(f$, 4)) <> ".bas") AND AllFiles = 0 THEN f$ = f$ + ".bas"
|
||||||
|
|
||||||
|
'recheck to see if file exists with bas extension
|
||||||
|
ideerror = 2
|
||||||
|
IF _FILEEXISTS(path$ + idepathsep$ + f$) = 0 THEN EXIT FUNCTION
|
||||||
|
|
||||||
|
IdeOpenFile = path$ + idepathsep$ + f$
|
||||||
|
|
||||||
|
IF BinaryFormatCheck%(path$, idepathsep$, f$) > 0 THEN
|
||||||
|
IF LEN(IdeOpenFile) THEN
|
||||||
|
OpenFile$ = "C"
|
||||||
|
EXIT FUNCTION
|
||||||
|
ELSE
|
||||||
|
info = 0: GOTO ideopenloop 'tried to open a zero length file. Retry?
|
||||||
|
END IF
|
||||||
|
END IF
|
||||||
|
END IF
|
||||||
|
|
||||||
|
'load file
|
||||||
|
ideerror = 3
|
||||||
|
idet$ = MKL$(0) + MKL$(0): idel = 1: ideli = 1: iden = 1: IdeBmkN = 0
|
||||||
|
idesx = 1
|
||||||
|
idesy = 1
|
||||||
|
idecx = 1
|
||||||
|
idecy = 1
|
||||||
|
ideselect = 0
|
||||||
|
idefocusline = 0
|
||||||
|
lineinput3load path$ + idepathsep$ + f$
|
||||||
|
idet$ = SPACE$(LEN(lineinput3buffer) * 8)
|
||||||
|
i2 = 1
|
||||||
|
n = 0
|
||||||
|
chrtab$ = CHR$(9)
|
||||||
|
space1$ = " ": space2$ = " ": space3$ = " ": space4$ = " "
|
||||||
|
chr7$ = CHR$(7): chr11$ = CHR$(11): chr12$ = CHR$(12): chr28$ = CHR$(28): chr29$ = CHR$(29): chr30$ = CHR$(30): chr31$ = CHR$(31)
|
||||||
|
DO
|
||||||
|
a$ = lineinput3$
|
||||||
|
l = LEN(a$)
|
||||||
|
IF l THEN asca = ASC(a$) ELSE asca = -1
|
||||||
|
IF asca <> 13 THEN
|
||||||
|
IF asca <> -1 THEN
|
||||||
|
'fix tabs
|
||||||
|
ideopenfixtabs:
|
||||||
|
x = INSTR(a$, chrtab$)
|
||||||
|
IF x THEN
|
||||||
|
x2 = (x - 1) MOD 4
|
||||||
|
IF x2 = 0 THEN a$ = LEFT$(a$, x - 1) + space4$ + RIGHT$(a$, l - x): l = l + 3: GOTO ideopenfixtabs
|
||||||
|
IF x2 = 1 THEN a$ = LEFT$(a$, x - 1) + space3$ + RIGHT$(a$, l - x): l = l + 2: GOTO ideopenfixtabs
|
||||||
|
IF x2 = 2 THEN a$ = LEFT$(a$, x - 1) + space2$ + RIGHT$(a$, l - x): l = l + 1: GOTO ideopenfixtabs
|
||||||
|
IF x2 = 3 THEN a$ = LEFT$(a$, x - 1) + space1$ + RIGHT$(a$, l - x): GOTO ideopenfixtabs
|
||||||
END IF
|
END IF
|
||||||
|
END IF 'asca<>-1
|
||||||
|
MID$(idet$, i2, l + 8) = MKL$(l) + a$ + MKL$(l): i2 = i2 + l + 8: n = n + 1
|
||||||
|
END IF
|
||||||
|
LOOP UNTIL asca = 13
|
||||||
|
lineinput3buffer = ""
|
||||||
|
iden = n: IF n = 0 THEN idet$ = MKL$(0) + MKL$(0): iden = 1 ELSE idet$ = LEFT$(idet$, i2 - 1)
|
||||||
|
REDIM IdeBreakpoints(iden) AS _BYTE
|
||||||
|
REDIM IdeSkipLines(iden) AS _BYTE
|
||||||
|
variableWatchList$ = ""
|
||||||
|
backupVariableWatchList$ = "": REDIM backupUsedVariableList(1000) AS usedVarList
|
||||||
|
backupTypeDefinitions$ = ""
|
||||||
|
callstacklist$ = "": callStackLength = 0
|
||||||
|
|
||||||
f$ = _SaveFileDialog$("Save As", Default_StartDir$ + path$ + IdeOpenFile, ".bas", "QB64PE BAS file")
|
ideerror = 1
|
||||||
if f$ = "" THEN EXIT FUNCTION 'someone canceled the input.
|
ideprogname = f$: _TITLE ideprogname + " - " + WindowTitle
|
||||||
IF FileHasExtension(f$) = 0 THEN f$ = f$ + ".bas"
|
listOfCustomKeywords$ = LEFT$(listOfCustomKeywords$, customKeywordsLength)
|
||||||
path$ = idezgetfilepath$(ideroot$, f$)
|
idepath$ = path$
|
||||||
pathseppos = _INSTRREV(f$, idepathsep$)
|
IdeAddRecent idepath$ + idepathsep$ + ideprogname$
|
||||||
IF pathseppos > 0 THEN f$ = Mid$(f$, pathseppos +1)
|
IdeImportBookmarks idepath$ + idepathsep$ + ideprogname$
|
||||||
|
END FUNCTION
|
||||||
|
|
||||||
ideerror = 3
|
|
||||||
OPEN path$ + idepathsep$ + f$ FOR BINARY AS #150
|
|
||||||
ideerror = 1
|
|
||||||
ideprogname$ = f$: _TITLE ideprogname + " - " + WindowTitle
|
|
||||||
idesave path$ + idepathsep$ + f$
|
|
||||||
idepath$ = path$
|
|
||||||
IdeAddRecent path$ + idepathsep$ + f$
|
|
||||||
IdeSaveBookmarks path$ + idepathsep$ + f$
|
|
||||||
CLOSE #150
|
|
||||||
end sub
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Function OpenFile$ (IdeOpenFile as string)'load routine copied/pasted from the old IDE file load/save dialog routines
|
|
||||||
|
|
||||||
STATIC Default_StartDir$
|
|
||||||
|
|
||||||
IF Default_StartDir$ = "" THEN
|
|
||||||
Default_StartDir$ = _STARTDIR$
|
|
||||||
if Right$(Default_StartDir$, 1) <> idepathsep$ then Default_StartDir$ = Default_StartDir$ + idepathsep$
|
|
||||||
END IF
|
|
||||||
|
|
||||||
ideopenloop:
|
|
||||||
IF IdeOpenFile = "" THEN f$ = _OpenFileDialog$("Open Source File", Default_StartDir$, "*.bas|*.BAS|*.Bas|*.bi|*.BI|*.Bi|*.bm|*.BM|*.Bm", "QB64-PE Source Files", 0) ELSE f$ = IdeOpenFile
|
|
||||||
IF f$ = "" THEN OpenFile$ = "C":EXIT FUNCTION
|
|
||||||
path$ = ideztakepath$ (f$)
|
|
||||||
|
|
||||||
Default_StartDir$ = path$
|
|
||||||
if Right$(Default_StartDir$, 1) <> idepathsep$ then Default_StartDir$ = Default_StartDir$ + idepathsep$
|
|
||||||
|
|
||||||
IF _FILEEXISTS(path$ + idepathsep$ + f$) = 0 THEN 'see if the user forgot the .bas extension and check for the file
|
|
||||||
|
|
||||||
IF (LCASE$(RIGHT$(f$, 4)) <> ".bas") AND AllFiles = 0 THEN f$ = f$ + ".bas"
|
|
||||||
|
|
||||||
'recheck to see if file exists with bas extension
|
|
||||||
ideerror = 2
|
|
||||||
IF _FILEEXISTS(path$ + idepathsep$ + f$) = 0 THEN EXIT FUNCTION
|
|
||||||
|
|
||||||
IdeOpenFile = path$ + idepathsep$ + f$
|
|
||||||
|
|
||||||
IF BinaryFormatCheck%(path$, idepathsep$, f$) > 0 THEN
|
|
||||||
IF LEN(IdeOpenFile) THEN
|
|
||||||
OpenFile$ = "C"
|
|
||||||
EXIT FUNCTION
|
|
||||||
ELSE
|
|
||||||
info = 0: GOTO ideopenloop 'tried to open a zero length file. Retry?
|
|
||||||
END IF
|
|
||||||
END IF
|
|
||||||
END IF
|
|
||||||
|
|
||||||
'load file
|
|
||||||
ideerror = 3
|
|
||||||
idet$ = MKL$(0) + MKL$(0): idel = 1: ideli = 1: iden = 1: IdeBmkN = 0
|
|
||||||
idesx = 1
|
|
||||||
idesy = 1
|
|
||||||
idecx = 1
|
|
||||||
idecy = 1
|
|
||||||
ideselect = 0
|
|
||||||
idefocusline = 0
|
|
||||||
lineinput3load path$ + idepathsep$ + f$
|
|
||||||
idet$ = SPACE$(LEN(lineinput3buffer) * 8)
|
|
||||||
i2 = 1
|
|
||||||
n = 0
|
|
||||||
chrtab$ = CHR$(9)
|
|
||||||
space1$ = " ": space2$ = " ": space3$ = " ": space4$ = " "
|
|
||||||
chr7$ = CHR$(7): chr11$ = CHR$(11): chr12$ = CHR$(12): chr28$ = CHR$(28): chr29$ = CHR$(29): chr30$ = CHR$(30): chr31$ = CHR$(31)
|
|
||||||
DO
|
|
||||||
a$ = lineinput3$
|
|
||||||
l = LEN(a$)
|
|
||||||
IF l THEN asca = ASC(a$) ELSE asca = -1
|
|
||||||
IF asca <> 13 THEN
|
|
||||||
IF asca <> -1 THEN
|
|
||||||
'fix tabs
|
|
||||||
ideopenfixtabs:
|
|
||||||
x = INSTR(a$, chrtab$)
|
|
||||||
IF x THEN
|
|
||||||
x2 = (x - 1) MOD 4
|
|
||||||
IF x2 = 0 THEN a$ = LEFT$(a$, x - 1) + space4$ + RIGHT$(a$, l - x): l = l + 3: GOTO ideopenfixtabs
|
|
||||||
IF x2 = 1 THEN a$ = LEFT$(a$, x - 1) + space3$ + RIGHT$(a$, l - x): l = l + 2: GOTO ideopenfixtabs
|
|
||||||
IF x2 = 2 THEN a$ = LEFT$(a$, x - 1) + space2$ + RIGHT$(a$, l - x): l = l + 1: GOTO ideopenfixtabs
|
|
||||||
IF x2 = 3 THEN a$ = LEFT$(a$, x - 1) + space1$ + RIGHT$(a$, l - x): GOTO ideopenfixtabs
|
|
||||||
END IF
|
|
||||||
END IF 'asca<>-1
|
|
||||||
MID$(idet$, i2, l + 8) = MKL$(l) + a$ + MKL$(l): i2 = i2 + l + 8: n = n + 1
|
|
||||||
END IF
|
|
||||||
LOOP UNTIL asca = 13
|
|
||||||
lineinput3buffer = ""
|
|
||||||
iden = n: IF n = 0 THEN idet$ = MKL$(0) + MKL$(0): iden = 1 ELSE idet$ = LEFT$(idet$, i2 - 1)
|
|
||||||
REDIM IdeBreakpoints(iden) AS _BYTE
|
|
||||||
REDIM IdeSkipLines(iden) AS _BYTE
|
|
||||||
variableWatchList$ = ""
|
|
||||||
backupVariableWatchList$ = "": REDIM backupUsedVariableList(1000) AS usedVarList
|
|
||||||
backupTypeDefinitions$ = ""
|
|
||||||
callstacklist$ = "": callStackLength = 0
|
|
||||||
|
|
||||||
ideerror = 1
|
|
||||||
ideprogname = f$: _TITLE ideprogname + " - " + WindowTitle
|
|
||||||
listOfCustomKeywords$ = LEFT$(listOfCustomKeywords$, customKeywordsLength)
|
|
||||||
idepath$ = path$
|
|
||||||
IdeAddRecent idepath$ + idepathsep$ + ideprogname$
|
|
||||||
IdeImportBookmarks idepath$ + idepathsep$ + ideprogname$
|
|
||||||
end sub
|
|
||||||
|
|
||||||
SUB ExportCodeAs (docFormat$)
|
SUB ExportCodeAs (docFormat$)
|
||||||
' Get the current source code, convert it to the desired document format and
|
' Get the current source code, convert it to the desired document format and
|
||||||
|
|
Loading…
Reference in a new issue