mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-14 14:09:20 +02:00
Save and return to last directory in next Textmode IDE session
This commit is contained in:
parent
97b79b3d4e
commit
530f08d9d3
@ -450,6 +450,9 @@ BEGIN
|
|||||||
InitDesktopFile;
|
InitDesktopFile;
|
||||||
LoadDesktop;
|
LoadDesktop;
|
||||||
|
|
||||||
|
{Adjust to current directory, might be changed by LoadDesktop.}
|
||||||
|
IDEapp.CurDirChanged;
|
||||||
|
|
||||||
{Menubar might be changed because of loading INI file.}
|
{Menubar might be changed because of loading INI file.}
|
||||||
IDEapp.reload_menubar;
|
IDEapp.reload_menubar;
|
||||||
|
|
||||||
|
@ -126,6 +126,7 @@ const
|
|||||||
dfSymbolInformation = $00000020;
|
dfSymbolInformation = $00000020;
|
||||||
dfCodeCompleteWords = $00000040;
|
dfCodeCompleteWords = $00000040;
|
||||||
dfCodeTemplates = $00000080;
|
dfCodeTemplates = $00000080;
|
||||||
|
dfReturnToLastDir = $00000100;
|
||||||
|
|
||||||
{ Auto Save flag constants }
|
{ Auto Save flag constants }
|
||||||
asEditorFiles = $00000001; { Editor files }
|
asEditorFiles = $00000001; { Editor files }
|
||||||
|
@ -33,6 +33,7 @@ const
|
|||||||
ResSymbols = 'SYMBOLS';
|
ResSymbols = 'SYMBOLS';
|
||||||
ResCodeComplete = 'CODECOMPLETE';
|
ResCodeComplete = 'CODECOMPLETE';
|
||||||
ResCodeTemplates = 'CODETEMPLATES';
|
ResCodeTemplates = 'CODETEMPLATES';
|
||||||
|
ResLastDirectory = 'LASTDIRECTORY';
|
||||||
ResKeys = 'KEYS';
|
ResKeys = 'KEYS';
|
||||||
|
|
||||||
procedure InitDesktopFile;
|
procedure InitDesktopFile;
|
||||||
@ -91,6 +92,8 @@ const
|
|||||||
msg_storingcodecompletewordlist = 'Writing CodeComplete wordlist...';
|
msg_storingcodecompletewordlist = 'Writing CodeComplete wordlist...';
|
||||||
msg_readingcodetemplates = 'Reading CodeTemplates...';
|
msg_readingcodetemplates = 'Reading CodeTemplates...';
|
||||||
msg_storingcodetemplates = 'Writing CodeTemplates...';
|
msg_storingcodetemplates = 'Writing CodeTemplates...';
|
||||||
|
msg_readingreturntolastdir = 'Reading Last directory to return...';
|
||||||
|
msg_storingreturntolastdir = 'Writing Last directory to return...';
|
||||||
msg_readingsymbolinformation = 'Reading symbol information...';
|
msg_readingsymbolinformation = 'Reading symbol information...';
|
||||||
msg_storingsymbolinformation = 'Storing symbol information...';
|
msg_storingsymbolinformation = 'Storing symbol information...';
|
||||||
msg_failedtoreplacedesktopfile = 'Failed to replace desktop file.';
|
msg_failedtoreplacedesktopfile = 'Failed to replace desktop file.';
|
||||||
@ -110,6 +113,8 @@ const
|
|||||||
msg_errorstoringvideomode = 'Error storing video mode';
|
msg_errorstoringvideomode = 'Error storing video mode';
|
||||||
msg_errorloadingcodetemplates = 'Error loading CodeTemplates';
|
msg_errorloadingcodetemplates = 'Error loading CodeTemplates';
|
||||||
msg_errorstoringcodetemplates = 'Error writing CodeTemplates';
|
msg_errorstoringcodetemplates = 'Error writing CodeTemplates';
|
||||||
|
msg_errorloadingreturntolastdir = 'Error loading Last directory to return';
|
||||||
|
msg_errorstoringreturntolastdir = 'Error writing Last directory to return';
|
||||||
msg_errorloadingsymbolinformation = 'Error loading symbol information';
|
msg_errorloadingsymbolinformation = 'Error loading symbol information';
|
||||||
msg_errorstoringsymbolinformation = 'Error storing symbol information';
|
msg_errorstoringsymbolinformation = 'Error storing symbol information';
|
||||||
msg_errorloadingcodecompletewordlist = 'Error loading CodeComplete wordlist';
|
msg_errorloadingcodecompletewordlist = 'Error loading CodeComplete wordlist';
|
||||||
@ -845,6 +850,61 @@ begin
|
|||||||
WriteCodeTemplates:=OK;
|
WriteCodeTemplates:=OK;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function ReadReturnToLastDir(F: PResourceFile): boolean;
|
||||||
|
var S: PMemoryStream;
|
||||||
|
OK: boolean;
|
||||||
|
Dir:AnsiString;
|
||||||
|
Size:sw_integer;
|
||||||
|
begin
|
||||||
|
PushStatus(msg_readingreturntolastdir);
|
||||||
|
New(S, Init(1024,4096));
|
||||||
|
OK:=F^.ReadResourceEntryToStream(ResLastDirectory,langDefault,S^);
|
||||||
|
S^.Seek(0);
|
||||||
|
if OK then
|
||||||
|
begin
|
||||||
|
S^.Read(Size, sizeof(Size)); { Read directory size }
|
||||||
|
if Size>0 then
|
||||||
|
begin
|
||||||
|
Setlength(Dir,Size);
|
||||||
|
S^.Read(Dir[1], Size); { Read the directory }
|
||||||
|
{$i-}ChDir(Dir);{$i+}
|
||||||
|
IOResult; {eat io result so it does not affect leater operations}
|
||||||
|
GetDir(0,StartUpDir);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
Dispose(S, Done);
|
||||||
|
if OK=false then
|
||||||
|
ErrorBox(msg_errorloadingreturntolastdir,nil);
|
||||||
|
PopStatus;
|
||||||
|
ReadReturnToLastDir:=OK;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function WriteReturnToLastDir(F: PResourceFile): boolean;
|
||||||
|
var OK: boolean;
|
||||||
|
S: PMemoryStream;
|
||||||
|
Dir:AnsiString;
|
||||||
|
Size:sw_integer;
|
||||||
|
begin
|
||||||
|
PushStatus(msg_storingreturntolastdir);
|
||||||
|
New(S, Init(1024,4096));
|
||||||
|
OK:=true;
|
||||||
|
{$i-}GetDir(0,Dir);{$i+}
|
||||||
|
if IOResult=0 then
|
||||||
|
begin
|
||||||
|
Size:=length(Dir);
|
||||||
|
S^.Write(Size, sizeof(Size));
|
||||||
|
if Size>0 then S^.Write(Dir[1],Size);
|
||||||
|
S^.Seek(0);
|
||||||
|
F^.CreateResource(ResLastDirectory,rcBinary,0);
|
||||||
|
OK:=F^.AddResourceEntryFromStream(ResLastDirectory,langDefault,0,S^,S^.GetSize);
|
||||||
|
end;
|
||||||
|
Dispose(S, Done);
|
||||||
|
if OK=false then
|
||||||
|
ErrorBox(msg_errorstoringreturntolastdir,nil);
|
||||||
|
PopStatus;
|
||||||
|
WriteReturnToLastDir:=OK;
|
||||||
|
end;
|
||||||
|
|
||||||
function ReadFlags(F: PResourceFile): boolean;
|
function ReadFlags(F: PResourceFile): boolean;
|
||||||
var
|
var
|
||||||
OK: boolean;
|
OK: boolean;
|
||||||
@ -967,6 +1027,8 @@ begin
|
|||||||
OK:=ReadCodeComplete(F) and OK;
|
OK:=ReadCodeComplete(F) and OK;
|
||||||
if ((DesktopFileFlags and dfCodeTemplates)<>0) then
|
if ((DesktopFileFlags and dfCodeTemplates)<>0) then
|
||||||
OK:=ReadCodeTemplates(F) and OK;
|
OK:=ReadCodeTemplates(F) and OK;
|
||||||
|
if ((DesktopFileFlags and dfReturnToLastDir)<>0) then
|
||||||
|
OK:=WriteReturnToLastDir(F) and OK;
|
||||||
{$ifdef Unix}
|
{$ifdef Unix}
|
||||||
OK:=ReadKeys(F) and OK;
|
OK:=ReadKeys(F) and OK;
|
||||||
{$endif Unix}
|
{$endif Unix}
|
||||||
@ -1012,6 +1074,8 @@ begin
|
|||||||
OK:=OK and WriteCodeComplete(F);
|
OK:=OK and WriteCodeComplete(F);
|
||||||
if ((DesktopFileFlags and dfCodeTemplates)<>0) then
|
if ((DesktopFileFlags and dfCodeTemplates)<>0) then
|
||||||
OK:=OK and WriteCodeTemplates(F);
|
OK:=OK and WriteCodeTemplates(F);
|
||||||
|
if ((DesktopFileFlags and dfReturnToLastDir)<>0) then
|
||||||
|
OK:=WriteReturnToLastDir(F) and OK;
|
||||||
{$ifdef Unix}
|
{$ifdef Unix}
|
||||||
OK:=OK and WriteKeys(F);
|
OK:=OK and WriteKeys(F);
|
||||||
{$endif Unix}
|
{$endif Unix}
|
||||||
|
@ -153,7 +153,9 @@ type
|
|||||||
procedure AddRecentFile(AFileName: string; CurX, CurY: sw_integer);
|
procedure AddRecentFile(AFileName: string; CurX, CurY: sw_integer);
|
||||||
function SearchRecentFile(AFileName: string): integer;
|
function SearchRecentFile(AFileName: string): integer;
|
||||||
procedure RemoveRecentFile(Index: integer);
|
procedure RemoveRecentFile(Index: integer);
|
||||||
|
public
|
||||||
procedure CurDirChanged;
|
procedure CurDirChanged;
|
||||||
|
private
|
||||||
procedure UpdatePrimaryFile;
|
procedure UpdatePrimaryFile;
|
||||||
procedure UpdateINIFile;
|
procedure UpdateINIFile;
|
||||||
procedure UpdateRecentFileList;
|
procedure UpdateRecentFileList;
|
||||||
@ -664,6 +666,7 @@ resourcestring menu_local_gotosource = '~G~oto source';
|
|||||||
label_desktop_symbolinfo = '~S~ymbol information';
|
label_desktop_symbolinfo = '~S~ymbol information';
|
||||||
label_desktop_codecompletewords = 'Co~d~eComplete wordlist';
|
label_desktop_codecompletewords = 'Co~d~eComplete wordlist';
|
||||||
label_desktop_codetemplates = 'Code~T~emplates';
|
label_desktop_codetemplates = 'Code~T~emplates';
|
||||||
|
label_desktop_returntolastdir = '~R~eturn to last directory';
|
||||||
label_desktop_preservedacrosssessions = '~P~reserved across sessions';
|
label_desktop_preservedacrosssessions = '~P~reserved across sessions';
|
||||||
|
|
||||||
{Mouse options dialog.}
|
{Mouse options dialog.}
|
||||||
@ -862,7 +865,6 @@ begin
|
|||||||
CompilerMessageWindow^.Hide;
|
CompilerMessageWindow^.Hide;
|
||||||
Desktop^.Insert(CompilerMessageWindow);
|
Desktop^.Insert(CompilerMessageWindow);
|
||||||
Message(@Self,evBroadcast,cmUpdate,nil);
|
Message(@Self,evBroadcast,cmUpdate,nil);
|
||||||
CurDirChanged;
|
|
||||||
{ heap viewer }
|
{ heap viewer }
|
||||||
GetExtent(R); Dec(R.B.X); R.A.X:=R.B.X-9; R.A.Y:=R.B.Y-1;
|
GetExtent(R); Dec(R.B.X); R.A.X:=R.B.X-9; R.A.Y:=R.B.Y-1;
|
||||||
New(HeapView, InitKb(R));
|
New(HeapView, InitKb(R));
|
||||||
|
@ -1422,12 +1422,12 @@ var R: TRect;
|
|||||||
D: PCenterDialog;
|
D: PCenterDialog;
|
||||||
CB: PCheckBoxes;
|
CB: PCheckBoxes;
|
||||||
begin
|
begin
|
||||||
R.Assign(0,0,40,12);
|
R.Assign(0,0,40,13);
|
||||||
New(D, Init(R, dialog_desktoppreferences));
|
New(D, Init(R, dialog_desktoppreferences));
|
||||||
with D^ do
|
with D^ do
|
||||||
begin
|
begin
|
||||||
HelpCtx:=hcDesktopOptions;
|
HelpCtx:=hcDesktopOptions;
|
||||||
GetExtent(R); R.Grow(-2,-2); Inc(R.A.Y); R.B.Y:=R.A.Y+8;
|
GetExtent(R); R.Grow(-2,-2); Inc(R.A.Y); R.B.Y:=R.A.Y+9;
|
||||||
New(CB, Init(R,
|
New(CB, Init(R,
|
||||||
NewSItem(label_desktop_historylists,
|
NewSItem(label_desktop_historylists,
|
||||||
NewSItem(label_desktop_clipboard,
|
NewSItem(label_desktop_clipboard,
|
||||||
@ -1437,7 +1437,8 @@ begin
|
|||||||
NewSItem(label_desktop_symbolinfo,
|
NewSItem(label_desktop_symbolinfo,
|
||||||
NewSItem(label_desktop_codecompletewords,
|
NewSItem(label_desktop_codecompletewords,
|
||||||
NewSItem(label_desktop_codetemplates,
|
NewSItem(label_desktop_codetemplates,
|
||||||
nil))))))))));
|
NewSItem(label_desktop_returntolastdir,
|
||||||
|
nil)))))))))));
|
||||||
CB^.Value:=DesktopFileFlags;
|
CB^.Value:=DesktopFileFlags;
|
||||||
Insert(CB);
|
Insert(CB);
|
||||||
R.Move(0,-1); R.B.Y:=R.A.Y+1;
|
R.Move(0,-1); R.B.Y:=R.A.Y+1;
|
||||||
|
Loading…
Reference in New Issue
Block a user