1
1
Fork 0
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:
Samuel Gomes 2023-08-25 20:51:34 +05:30 committed by GitHub
commit cd5f7a420b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -20292,51 +20292,57 @@ end sub
' Download = MKI$(0) 'still working
'END FUNCTION
Function SaveFile$ (IdeOpenFile as string)
STATIC Default_StartDir$
FUNCTION SaveFile$ (IdeOpenFile AS STRING)
SHARED Default_StartDir$
IF Default_StartDir$ = "" THEN
Default_StartDir$ = _STARTDIR$
if Right$(Default_StartDir$, 1) <> idepathsep$ then Default_StartDir$ = Default_StartDir$ + idepathsep$
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
f$ = _SaveFileDialog$("Save As", Default_StartDir$ + path$ + IdeOpenFile, ".bas", "QB64PE BAS file")
if f$ = "" THEN EXIT FUNCTION 'someone canceled the input.
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)
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
ideprogname$ = f$
_TITLE ideprogname$ + " - " + WindowTitle
idesave path$ + idepathsep$ + f$
idepath$ = path$
IdeAddRecent path$ + idepathsep$ + f$
IdeSaveBookmarks path$ + idepathsep$ + f$
CLOSE #150
end sub
END FUNCTION
Function OpenFile$ (IdeOpenFile as string)'load routine copied/pasted from the old IDE file load/save dialog routines
STATIC Default_StartDir$
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$
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$)
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 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
@ -20409,7 +20415,8 @@ Function OpenFile$ (IdeOpenFile as string)'load routine copied/pasted from the o
idepath$ = path$
IdeAddRecent idepath$ + idepathsep$ + ideprogname$
IdeImportBookmarks idepath$ + idepathsep$ + ideprogname$
end sub
END FUNCTION
SUB ExportCodeAs (docFormat$)
' Get the current source code, convert it to the desired document format and