Browse Source

* fixed run directory
* Open dialog starts in dir of last editted file

peter 21 years ago
parent
commit
9c8a96c6dc
5 changed files with 79 additions and 10 deletions
  1. 9 2
      ide/fpdebug.pas
  2. 18 3
      ide/fpide.pas
  3. 6 2
      ide/fpmfile.inc
  4. 23 1
      ide/fpviews.pas
  5. 23 2
      packages/base/gdbint/gdbcon.pp

+ 9 - 2
ide/fpdebug.pas

@@ -567,7 +567,6 @@ begin
         ' (('+FrameName+' + 12)^ <> 0)');  }
 {$endif FrameNameKnown}
       SetArgs(GetRunParameters);
-      SetDir(GetRunDir);
       SetSourceDirs;
       InsertBreakpoints;
       ReadWatches;
@@ -814,7 +813,11 @@ begin
     Command('continue');
   end else
 {$endif SUPPORT_REMOTE}
+  { Set cwd for debuggee }
+  SetDir(GetRunDir);
   inherited Run;
+  { Restore cwd for IDE }
+  SetDir(StartupDir);
   DebuggerScreen;
   If assigned(GDBWindow) then
     GDBWindow^.Editor^.UnLock;
@@ -3589,7 +3592,11 @@ end.
 
 {
   $Log$
-  Revision 1.53  2004-11-08 20:28:26  peter
+  Revision 1.54  2004-11-08 21:55:09  peter
+    * fixed run directory
+    * Open dialog starts in dir of last editted file
+
+  Revision 1.53  2004/11/08 20:28:26  peter
     * Breakpoints are now deleted when removed from source, disabling is
       still possible from the breakpoint list
     * COMPILER_1_0, FVISION, GABOR defines removed, only support new

+ 18 - 3
ide/fpide.pas

@@ -34,7 +34,7 @@ type
       procedure   InitDesktop; virtual;
       procedure   InitMenuBar; virtual;
       procedure   InitStatusLine; virtual;
-      procedure   Open(FileName: string);
+      procedure   Open(FileName: string;FileDir:string);
       function    OpenSearch(FileName: string) : boolean;
       function    AskSaveAll: boolean;
       function    SaveAll: boolean;
@@ -598,6 +598,10 @@ procedure TIDEApp.HandleEvent(var Event: TEvent);
 var DontClear: boolean;
     TempS: string;
     ForceDlg: boolean;
+    W  : PSourceWindow;
+    DS : DirStr;
+    NS : NameStr;
+    ES : ExtStr;
 {$ifdef HasSignal}
     CtrlCCatched : boolean;
 {$endif HasSignal}
@@ -642,7 +646,14 @@ begin
                                  if ForceDlg then
                                    OpenSearch(OpenFileName)
                                  else
-                                   Open(OpenFileName);
+                                   begin
+                                     W:=LastSourceEditor;
+                                     if assigned(W) then
+                                       FSplit(W^.Editor^.FileName,DS,NS,ES)
+                                     else
+                                       DS:='';
+                                     Open(OpenFileName,DS);
+                                   end;
                                  OpenFileName:='';
                                end;
              cmSaveAll       : SaveAll;
@@ -1229,7 +1240,11 @@ end;
 END.
 {
   $Log$
-  Revision 1.30  2004-11-08 20:28:26  peter
+  Revision 1.31  2004-11-08 21:55:09  peter
+    * fixed run directory
+    * Open dialog starts in dir of last editted file
+
+  Revision 1.30  2004/11/08 20:28:26  peter
     * Breakpoints are now deleted when removed from source, disabling is
       still possible from the breakpoint list
     * COMPILER_1_0, FVISION, GABOR defines removed, only support new

+ 6 - 2
ide/fpmfile.inc

@@ -74,7 +74,7 @@ begin
 end;
 
 
-procedure TIDEApp.Open(FileName: string);
+procedure TIDEApp.Open(FileName: string;FileDir:string);
 var D: PFileDialog;
     OpenIt: boolean;
     DriveNumber : byte;
@@ -225,7 +225,11 @@ end;
 
 {
   $Log$
-  Revision 1.8  2004-11-08 20:28:26  peter
+  Revision 1.9  2004-11-08 21:55:09  peter
+    * fixed run directory
+    * Open dialog starts in dir of last editted file
+
+  Revision 1.8  2004/11/08 20:28:26  peter
     * Breakpoints are now deleted when removed from source, disabling is
       still possible from the breakpoint list
     * COMPILER_1_0, FVISION, GABOR defines removed, only support new

+ 23 - 1
ide/fpviews.pas

@@ -454,6 +454,7 @@ procedure TranslateMouseClick(View: PView; var Event: TEvent);
 function GetNextEditorBounds(var Bounds: TRect): boolean;
 function OpenEditorWindow(Bounds: PRect; FileName: string; CurX,CurY: sw_integer): PSourceWindow;
 function IOpenEditorWindow(Bounds: PRect; FileName: string; CurX,CurY: sw_integer; ShowIt: boolean): PSourceWindow;
+function LastSourceEditor : PSourceWindow;
 function SearchOnDesktop(FileName : string;tryexts:boolean) : PSourceWindow;
 function TryToOpenFile(Bounds: PRect; FileName: string; CurX,CurY: sw_integer;tryexts: boolean): PSourceWindow;
 function ITryToOpenFile(Bounds: PRect; FileName: string; CurX,CurY: sw_integer;tryexts, ShowIt,
@@ -3711,6 +3712,23 @@ begin
   OpenEditorWindow:=IOpenEditorWindow(Bounds,FileName,CurX,CurY,true);
 end;
 
+
+function LastSourceEditor : PSourceWindow;
+
+  function IsSearchedSource(P: PView) : boolean; {$ifndef FPC}far;{$endif}
+  begin
+    if assigned(P) and
+       (TypeOf(P^)=TypeOf(TSourceWindow)) then
+         IsSearchedSource:=true
+       else
+         IsSearchedSource:=false;
+  end;
+
+begin
+  LastSourceEditor:=PSourceWindow(Desktop^.FirstThat(@IsSearchedSource));
+end;
+
+
 function SearchOnDesktop(FileName : string;tryexts:boolean) : PSourceWindow;
 var
     D,DS : DirStr;
@@ -4437,7 +4455,11 @@ end;
 END.
 {
   $Log$
-  Revision 1.47  2004-11-08 20:28:29  peter
+  Revision 1.48  2004-11-08 21:55:09  peter
+    * fixed run directory
+    * Open dialog starts in dir of last editted file
+
+  Revision 1.47  2004/11/08 20:28:29  peter
     * Breakpoints are now deleted when removed from source, disabling is
       still possible from the breakpoint list
     * COMPILER_1_0, FVISION, GABOR defines removed, only support new

+ 23 - 2
packages/base/gdbint/gdbcon.pp

@@ -21,7 +21,8 @@ uses
 type
   PGDBController=^TGDBController;
   TGDBController=object(TGDBInterface)
-    progname   : pchar;
+    progname,
+    progdir,
     progargs   : pchar;
     in_command,
     init_count : longint;
@@ -45,6 +46,7 @@ type
     function  GetOutput : Pchar;
     function  GetError : Pchar;
     function  LoadFile(var fn:string):boolean;
+    procedure SetDir(const s : string);
     procedure SetArgs(const s : string);
     procedure ClearSymbols;
   end;
@@ -145,6 +147,8 @@ destructor TGDBController.Done;
 begin
   if assigned(progname) then
     strdispose(progname);
+  if assigned(progdir) then
+    strdispose(progdir);
   if assigned(progargs) then
     strdispose(progargs);
   inherited done;
@@ -201,6 +205,19 @@ begin
   LoadFile:=true;
 end;
 
+procedure TGDBController.SetDir(const s : string);
+var
+  hs : string;
+begin
+  hs:=s;
+  UnixDir(hs);
+  if assigned(progdir) then
+    strdispose(progdir);
+  getmem(progdir,length(hs)+1);
+  strpcopy(progdir,hs);
+  command('cd '+hs);
+end;
+
 procedure TGDBController.SetArgs(const s : string);
 begin
   if assigned(progargs) then
@@ -330,7 +347,11 @@ end;
 end.
 {
   $Log$
-  Revision 1.5  2002-09-17 20:57:04  pierre
+  Revision 1.6  2004-11-08 21:55:09  peter
+    * fixed run directory
+    * Open dialog starts in dir of last editted file
+
+  Revision 1.5  2002/09/17 20:57:04  pierre
     * increment in_command before calling CommandBegin
       and after calling CommandEnd to be able to count
       command levels inside these methods.