Hello,

This tiny patch implements a feature which can be found in Programmer's Notepad, and which proves to be very useful (at least to me). It makes the File Open dialog open in the directory of the file which is active in source notebook. Thus, each opened file acts as a filesystem bookmark, and whenever you work with sources from several directories, efforts needed to navigate in File Open dialog are greatly reduced.

Maybe this feature must be made configurable (I am ready to do it, let me know if I should), but honestly I cannot imagine any reason to disable it.

Best regards,
Sergei
Index: main.pp
===================================================================
--- main.pp	(revision 15370)
+++ main.pp	(working copy)
@@ -2379,10 +2379,24 @@
   AFilename: string;
   I: Integer;
   OpenFlags: TOpenFlags;
+  PageIndex: Integer;
+  ActiveSrcEdit: TSourceEditor;
+  ActiveUnitInfo: TUnitInfo;
 begin
   OpenDialog:=TOpenDialog.Create(nil);
   try
     InputHistories.ApplyFileDialogSettings(OpenDialog);
+
+    if Assigned(SourceNotebook.Notebook) then
+    begin
+      PageIndex := SourceNoteBook.Notebook.PageIndex;
+      if PageIndex >= 0 then
+      begin
+        GetUnitWithPageIndex(PageIndex,ActiveSrcEdit,ActiveUnitInfo);
+        if ActiveUnitInfo.Filename <> '' then
+          OpenDialog.InitialDir := ExtractFilePath(ActiveUnitInfo.Filename);
+      end;
+    end;
     OpenDialog.Title:=lisOpenFile;
     OpenDialog.Options:=OpenDialog.Options+[ofAllowMultiSelect];
     OpenDialog.Filter:=dlgAllFiles+' ('+GetAllFilesMask+')|'+GetAllFilesMask
_______________________________________________
Lazarus mailing list
[email protected]
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to