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)');  }
         ' (('+FrameName+' + 12)^ <> 0)');  }
 {$endif FrameNameKnown}
 {$endif FrameNameKnown}
       SetArgs(GetRunParameters);
       SetArgs(GetRunParameters);
-      SetDir(GetRunDir);
       SetSourceDirs;
       SetSourceDirs;
       InsertBreakpoints;
       InsertBreakpoints;
       ReadWatches;
       ReadWatches;
@@ -814,7 +813,11 @@ begin
     Command('continue');
     Command('continue');
   end else
   end else
 {$endif SUPPORT_REMOTE}
 {$endif SUPPORT_REMOTE}
+  { Set cwd for debuggee }
+  SetDir(GetRunDir);
   inherited Run;
   inherited Run;
+  { Restore cwd for IDE }
+  SetDir(StartupDir);
   DebuggerScreen;
   DebuggerScreen;
   If assigned(GDBWindow) then
   If assigned(GDBWindow) then
     GDBWindow^.Editor^.UnLock;
     GDBWindow^.Editor^.UnLock;
@@ -3589,7 +3592,11 @@ end.
 
 
 {
 {
   $Log$
   $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
     * Breakpoints are now deleted when removed from source, disabling is
       still possible from the breakpoint list
       still possible from the breakpoint list
     * COMPILER_1_0, FVISION, GABOR defines removed, only support new
     * COMPILER_1_0, FVISION, GABOR defines removed, only support new

+ 18 - 3
ide/fpide.pas

@@ -34,7 +34,7 @@ type
       procedure   InitDesktop; virtual;
       procedure   InitDesktop; virtual;
       procedure   InitMenuBar; virtual;
       procedure   InitMenuBar; virtual;
       procedure   InitStatusLine; virtual;
       procedure   InitStatusLine; virtual;
-      procedure   Open(FileName: string);
+      procedure   Open(FileName: string;FileDir:string);
       function    OpenSearch(FileName: string) : boolean;
       function    OpenSearch(FileName: string) : boolean;
       function    AskSaveAll: boolean;
       function    AskSaveAll: boolean;
       function    SaveAll: boolean;
       function    SaveAll: boolean;
@@ -598,6 +598,10 @@ procedure TIDEApp.HandleEvent(var Event: TEvent);
 var DontClear: boolean;
 var DontClear: boolean;
     TempS: string;
     TempS: string;
     ForceDlg: boolean;
     ForceDlg: boolean;
+    W  : PSourceWindow;
+    DS : DirStr;
+    NS : NameStr;
+    ES : ExtStr;
 {$ifdef HasSignal}
 {$ifdef HasSignal}
     CtrlCCatched : boolean;
     CtrlCCatched : boolean;
 {$endif HasSignal}
 {$endif HasSignal}
@@ -642,7 +646,14 @@ begin
                                  if ForceDlg then
                                  if ForceDlg then
                                    OpenSearch(OpenFileName)
                                    OpenSearch(OpenFileName)
                                  else
                                  else
-                                   Open(OpenFileName);
+                                   begin
+                                     W:=LastSourceEditor;
+                                     if assigned(W) then
+                                       FSplit(W^.Editor^.FileName,DS,NS,ES)
+                                     else
+                                       DS:='';
+                                     Open(OpenFileName,DS);
+                                   end;
                                  OpenFileName:='';
                                  OpenFileName:='';
                                end;
                                end;
              cmSaveAll       : SaveAll;
              cmSaveAll       : SaveAll;
@@ -1229,7 +1240,11 @@ end;
 END.
 END.
 {
 {
   $Log$
   $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
     * Breakpoints are now deleted when removed from source, disabling is
       still possible from the breakpoint list
       still possible from the breakpoint list
     * COMPILER_1_0, FVISION, GABOR defines removed, only support new
     * COMPILER_1_0, FVISION, GABOR defines removed, only support new

+ 6 - 2
ide/fpmfile.inc

@@ -74,7 +74,7 @@ begin
 end;
 end;
 
 
 
 
-procedure TIDEApp.Open(FileName: string);
+procedure TIDEApp.Open(FileName: string;FileDir:string);
 var D: PFileDialog;
 var D: PFileDialog;
     OpenIt: boolean;
     OpenIt: boolean;
     DriveNumber : byte;
     DriveNumber : byte;
@@ -225,7 +225,11 @@ end;
 
 
 {
 {
   $Log$
   $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
     * Breakpoints are now deleted when removed from source, disabling is
       still possible from the breakpoint list
       still possible from the breakpoint list
     * COMPILER_1_0, FVISION, GABOR defines removed, only support new
     * 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 GetNextEditorBounds(var Bounds: TRect): boolean;
 function OpenEditorWindow(Bounds: PRect; FileName: string; CurX,CurY: sw_integer): PSourceWindow;
 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 IOpenEditorWindow(Bounds: PRect; FileName: string; CurX,CurY: sw_integer; ShowIt: boolean): PSourceWindow;
+function LastSourceEditor : PSourceWindow;
 function SearchOnDesktop(FileName : string;tryexts:boolean) : PSourceWindow;
 function SearchOnDesktop(FileName : string;tryexts:boolean) : PSourceWindow;
 function TryToOpenFile(Bounds: PRect; FileName: string; CurX,CurY: sw_integer;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,
 function ITryToOpenFile(Bounds: PRect; FileName: string; CurX,CurY: sw_integer;tryexts, ShowIt,
@@ -3711,6 +3712,23 @@ begin
   OpenEditorWindow:=IOpenEditorWindow(Bounds,FileName,CurX,CurY,true);
   OpenEditorWindow:=IOpenEditorWindow(Bounds,FileName,CurX,CurY,true);
 end;
 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;
 function SearchOnDesktop(FileName : string;tryexts:boolean) : PSourceWindow;
 var
 var
     D,DS : DirStr;
     D,DS : DirStr;
@@ -4437,7 +4455,11 @@ end;
 END.
 END.
 {
 {
   $Log$
   $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
     * Breakpoints are now deleted when removed from source, disabling is
       still possible from the breakpoint list
       still possible from the breakpoint list
     * COMPILER_1_0, FVISION, GABOR defines removed, only support new
     * COMPILER_1_0, FVISION, GABOR defines removed, only support new

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

@@ -21,7 +21,8 @@ uses
 type
 type
   PGDBController=^TGDBController;
   PGDBController=^TGDBController;
   TGDBController=object(TGDBInterface)
   TGDBController=object(TGDBInterface)
-    progname   : pchar;
+    progname,
+    progdir,
     progargs   : pchar;
     progargs   : pchar;
     in_command,
     in_command,
     init_count : longint;
     init_count : longint;
@@ -45,6 +46,7 @@ type
     function  GetOutput : Pchar;
     function  GetOutput : Pchar;
     function  GetError : Pchar;
     function  GetError : Pchar;
     function  LoadFile(var fn:string):boolean;
     function  LoadFile(var fn:string):boolean;
+    procedure SetDir(const s : string);
     procedure SetArgs(const s : string);
     procedure SetArgs(const s : string);
     procedure ClearSymbols;
     procedure ClearSymbols;
   end;
   end;
@@ -145,6 +147,8 @@ destructor TGDBController.Done;
 begin
 begin
   if assigned(progname) then
   if assigned(progname) then
     strdispose(progname);
     strdispose(progname);
+  if assigned(progdir) then
+    strdispose(progdir);
   if assigned(progargs) then
   if assigned(progargs) then
     strdispose(progargs);
     strdispose(progargs);
   inherited done;
   inherited done;
@@ -201,6 +205,19 @@ begin
   LoadFile:=true;
   LoadFile:=true;
 end;
 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);
 procedure TGDBController.SetArgs(const s : string);
 begin
 begin
   if assigned(progargs) then
   if assigned(progargs) then
@@ -330,7 +347,11 @@ end;
 end.
 end.
 {
 {
   $Log$
   $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
     * increment in_command before calling CommandBegin
       and after calling CommandEnd to be able to count
       and after calling CommandEnd to be able to count
       command levels inside these methods.
       command levels inside these methods.