Browse Source

* source tracking from Gabor

peter 26 years ago
parent
commit
1ef56abc07
8 changed files with 238 additions and 56 deletions
  1. 7 3
      ide/text/fpcompil.pas
  2. 5 3
      ide/text/fpide.pas
  3. 4 31
      ide/text/fpmfile.inc
  4. 8 5
      ide/text/fpmrun.inc
  5. 5 2
      ide/text/fpmsrch.inc
  6. 37 5
      ide/text/fpsymbol.pas
  7. 171 7
      ide/text/fpviews.pas
  8. 1 0
      ide/text/test2.pas

+ 7 - 3
ide/text/fpcompil.pas

@@ -34,6 +34,8 @@ type
 
 procedure DoCompile(Mode: TCompileMode);
 
+const SD: PCompileStatusDialog = nil;
+
 implementation
 
 uses
@@ -42,8 +44,6 @@ uses
   CompHook,
   FPConst,FPVars,FPUtils,FPIntf,FPSwitches;
 
-const SD: PCompileStatusDialog = nil;
-
 constructor TCompileStatusDialog.Init;
 var R: TRect;
 begin
@@ -185,6 +185,7 @@ begin
        end;
       FileName:=P^.Editor^.FileName;
     end;
+  WriteSwitches(SwitchesPath);
   MainFile:=FExpand(FileName);
   EXEFile:=GetEXEPath+NameAndExtOf(MainFile);
 { Reset }
@@ -231,7 +232,10 @@ end;
 end.
 {
   $Log$
-  Revision 1.4  1999-01-12 14:29:32  peter
+  Revision 1.5  1999-01-14 21:42:19  peter
+    * source tracking from Gabor
+
+  Revision 1.4  1999/01/12 14:29:32  peter
     + Implemented still missing 'switch' entries in Options menu
     + Pressing Ctrl-B sets ASCII mode in editor, after which keypresses (even
       ones with ASCII < 32 ; entered with Alt+<###>) are interpreted always as

+ 5 - 3
ide/text/fpide.pas

@@ -32,7 +32,6 @@ type
       procedure   DosShell; virtual;
       destructor  Done; virtual;
     private
-      function  OpenEditorWindow(FileName: string; CurX,CurY: integer): PSourceWindow;
       procedure NewEditor;
       procedure NewFromTemplate;
       procedure OpenRecentFile(RecentIndex: integer);
@@ -101,7 +100,7 @@ uses
 
 function IDEUseSyntaxHighlight(Editor: PFileEditor): boolean; {$ifndef FPC}far;{$endif}
 begin
-  IDEUseSyntaxHighlight:=MatchesFileList(NameAndExtOf(Editor^.FileName),HighlightExts);
+  IDEUseSyntaxHighlight:=(Editor^.FileName='') or MatchesFileList(NameAndExtOf(Editor^.FileName),HighlightExts);
 end;
 
 constructor TIDEApp.Init;
@@ -530,7 +529,10 @@ end;
 END.
 {
   $Log$
-  Revision 1.1  1999-01-12 14:29:34  peter
+  Revision 1.2  1999-01-14 21:42:20  peter
+    * source tracking from Gabor
+
+  Revision 1.1  1999/01/12 14:29:34  peter
     + Implemented still missing 'switch' entries in Options menu
     + Pressing Ctrl-B sets ASCII mode in editor, after which keypresses (even
       ones with ASCII < 32 ; entered with Alt+<###>) are interpreted always as

+ 4 - 31
ide/text/fpmfile.inc

@@ -14,36 +14,6 @@
 
  **********************************************************************}
 
-function TIDEApp.OpenEditorWindow(FileName: string; CurX,CurY: integer): PSourceWindow;
-var P: PView;
-    R: TRect;
-    W: PSourceWindow;
-begin
-  P:=Message(Desktop,evBroadcast,cmSearchWindow,nil);
-  if P=nil then Desktop^.GetExtent(R) else
-     begin
-       P^.GetBounds(R);
-       Inc(R.A.X); Inc(R.A.Y);
-     end;
-  PushStatus('Opening source file... ('+SmartPath(FileName)+')');
-  New(W, Init(R, FileName));
-  if W<>nil then
-  begin
-    if (CurX<>0) or (CurY<>0) then
-       with W^.Editor^ do
-       begin
-         SetCurPtr(CurX,CurY);
-         TrackCursor(true);
-       end;
-    W^.HelpCtx:=hcSourceWindow;
-    Desktop^.Insert(W);
-    Message(Application,evBroadcast,cmUpdate,nil);
-  end;
-  PopStatus;
-  OpenEditorWindow:=W;
-end;
-
-
 procedure TIDEApp.NewEditor;
 begin
   OpenEditorWindow('',0,0);
@@ -150,7 +120,10 @@ end;
 
 {
   $Log$
-  Revision 1.3  1999-01-04 11:49:46  peter
+  Revision 1.4  1999-01-14 21:42:21  peter
+    * source tracking from Gabor
+
+  Revision 1.3  1999/01/04 11:49:46  peter
    * 'Use tab characters' now works correctly
    + Syntax highlight now acts on File|Save As...
    + Added a new class to syntax highlight: 'hex numbers'.

+ 8 - 5
ide/text/fpmrun.inc

@@ -40,14 +40,14 @@ begin
   DoneMouse;
   DoneVideo;
 
-{  if Assigned(UserScreen) then
-    UserScreen^.SwitchTo; }
+  if Assigned(UserScreen) then
+    UserScreen^.SwitchTo;
 
   Exec(ExeFile,GetRunParameters);
   LastExitCode:=DosExitCode;
 
-{  if Assigned(UserScreen) then
-    UserScreen^.SwitchBack; }
+  if Assigned(UserScreen) then
+    UserScreen^.SwitchBack;
 
   InitVideo;
   InitMouse;
@@ -83,7 +83,10 @@ end;
 
 {
   $Log$
-  Revision 1.3  1999-01-12 14:29:36  peter
+  Revision 1.4  1999-01-14 21:42:22  peter
+    * source tracking from Gabor
+
+  Revision 1.3  1999/01/12 14:29:36  peter
     + Implemented still missing 'switch' entries in Options menu
     + Pressing Ctrl-B sets ASCII mode in editor, after which keypresses (even
       ones with ASCII < 32 ; entered with Alt+<###>) are interpreted always as

+ 5 - 2
ide/text/fpmsrch.inc

@@ -50,7 +50,7 @@ begin
     WarningBox('Too many symbols. Can''t display all of them.',nil);
   Desktop^.GetExtent(R); R.A.X:=R.B.X-35;
   Desktop^.Insert(New(PBrowserWindow, Init(R,
-    'Browse: Globals',0,'Global scope',S,nil)));
+    'Browse: Globals',SearchFreeWindowNo,'Global scope',S,nil)));
 end;
 
 procedure TIDEApp.Modules;
@@ -70,7 +70,10 @@ end;
 
 {
   $Log$
-  Revision 1.1  1999-01-12 14:29:37  peter
+  Revision 1.2  1999-01-14 21:42:23  peter
+    * source tracking from Gabor
+
+  Revision 1.1  1999/01/12 14:29:37  peter
     + Implemented still missing 'switch' entries in Options menu
     + Pressing Ctrl-B sets ASCII mode in editor, after which keypresses (even
       ones with ASCII < 32 ; entered with Alt+<###>) are interpreted always as

+ 37 - 5
ide/text/fpsymbol.pas

@@ -32,6 +32,7 @@ type
     TSymbolView = object(TListBox)
       constructor  Init(var Bounds: TRect; AHScrollBar, AVScrollBar: PScrollBar);
       procedure    HandleEvent(var Event: TEvent); virtual;
+      procedure    GotoItem(Item: sw_integer); virtual;
       function     GetPalette: PPalette; virtual;
     end;
 
@@ -48,6 +49,9 @@ type
       constructor Init(var Bounds: TRect; AReferences: PReferenceCollection; AHScrollBar, AVScrollBar: PScrollBar);
       function    GetText(Item,MaxLen: Sw_Integer): String; virtual;
       procedure   SelectItem(Item: Sw_Integer); virtual;
+      procedure   GotoItem(Item: sw_integer); virtual;
+      procedure   GotoSource; virtual;
+      procedure   TrackSource; virtual;
     private
       References: PReferenceCollection;
     end;
@@ -218,7 +222,7 @@ begin
         DontClear:=false;
         case Event.KeyCode of
           kbEnter :
-            SelectItem(Focused);
+            GotoItem(Focused);
           kbRight,kbLeft :
             if HScrollBar<>nil then
               HScrollBar^.HandleEvent(Event);
@@ -238,6 +242,11 @@ begin
 end;
 
 
+procedure TSymbolView.GotoItem(Item: sw_integer);
+begin
+  SelectItem(Item);
+end;
+
 {****************************************************************************
                                TSymbolScopeView
 ****************************************************************************}
@@ -280,8 +289,30 @@ begin
   GetText:=copy(S,1,MaxLen);
 end;
 
+procedure TSymbolReferenceView.GotoSource;
+var R: PReference;
+    W: PSourceWindow;
+begin
+  if Range=0 then Exit;
+  R:=References^.At(Focused);
+  Desktop^.Lock;
+  W:=TryToOpenFile(R^.GetFileName,R^.Position.X-1,R^.Position.Y-1);
+  if W<>nil then W^.Select;
+  Desktop^.UnLock;
+end;
+
+procedure TSymbolReferenceView.TrackSource;
+begin
+end;
+
+procedure TSymbolReferenceView.GotoItem(Item: sw_integer);
+begin
+  GotoSource;
+end;
+
 procedure TSymbolReferenceView.SelectItem(Item: Sw_Integer);
 begin
+  TrackSource;
 end;
 
 
@@ -411,13 +442,11 @@ begin
               MakeGlobal(ScopeView^.Origin,P);
               Desktop^.MakeLocal(P,P); Inc(P.Y,ScopeView^.Focused-ScopeView^.TopItem);
               Inc(P.Y);
+              if (S^.GetReferenceCount>0) or (S^.GetItemCount>0) then
               OpenSymbolBrowser(Origin.X-1,P.Y,
                 S^.GetName,
                 ScopeView^.GetText(ScopeView^.Focused,255),
                 S^.Items,S^.References);
-            end else
-          if Event.InfoPtr=ReferenceView then
-            begin
             end;
       end;
     evKeyDown :
@@ -483,7 +512,10 @@ end;
 END.
 {
   $Log$
-  Revision 1.1  1999-01-12 14:29:40  peter
+  Revision 1.2  1999-01-14 21:42:24  peter
+    * source tracking from Gabor
+
+  Revision 1.1  1999/01/12 14:29:40  peter
     + Implemented still missing 'switch' entries in Options menu
     + Pressing Ctrl-B sets ASCII mode in editor, after which keypresses (even
       ones with ASCII < 32 ; entered with Alt+<###>) are interpreted always as

+ 171 - 7
ide/text/fpviews.pas

@@ -173,6 +173,7 @@ type
       constructor Init(AClass: longint; AText, AModule: string; AID: longint);
       function    GetText(MaxLen: integer): string; virtual;
       procedure   Selected; virtual;
+      function    GetModuleName: string; virtual;
       destructor  Done; virtual;
     end;
 
@@ -297,6 +298,9 @@ procedure InitReservedWords;
 
 procedure TranslateMouseClick(View: PView; var Event: TEvent);
 
+function OpenEditorWindow(FileName: string; CurX,CurY: integer): PSourceWindow;
+function TryToOpenFile(FileName: string; CurX,CurY: integer): PSourceWindow;
+
 const
       SourceCmds  : TCommandSet =
         ([cmSave,cmSaveAs,cmCompile]);
@@ -321,7 +325,7 @@ implementation
 uses
   Keyboard,Memory,MsgBox,Validate,
   Tokens,
-  FPVars,FPUtils,FPHelp;
+  FPVars,FPUtils,FPHelp,FPCompile;
 
 const
   NoNameCount    : integer = 0;
@@ -540,7 +544,7 @@ end;
                                SearchWindow
 *****************************************************************************}
 
-function SearchWindowWithNo(No: integer): PSourceWindow;
+function SearchWindowWithNo(No: integer): PWindow;
 var P: PSourceWindow;
 begin
   P:=Message(Desktop,evBroadcast,cmSearchWindow+No,nil);
@@ -2063,12 +2067,21 @@ procedure TMessageListBox.HandleEvent(var Event: TEvent);
 var DontClear: boolean;
 begin
   case Event.What of
+    evKeyDown :
+      begin
+        DontClear:=false;
+        case Event.KeyCode of
+          kbEnter :
+            if Owner<>pointer(SD) then
+              Message(@Self,evCommand,cmMsgGotoSource,nil);
+        else DontClear:=true;
+        end;
+        if DontClear=false then ClearEvent(Event);
+      end;
     evCommand :
       begin
         DontClear:=false;
-        case Event.What of
-          cmDefault :
-            Message(@Self,evCommand,cmMsgGotoSource,nil);
+        case Event.Command of
           cmMsgGotoSource :
             if Range>0 then
             GotoSource;
@@ -2119,12 +2132,40 @@ begin
 end;
 
 procedure TMessageListBox.TrackSource;
+var W: PSourceWindow;
+    P: PMessageItem;
+    R: TRect;
 begin
+  if Range=0 then Exit;
+  P:=List^.At(Focused);
+  if P^.ID=0 then Exit;
+  Desktop^.Lock;
+  W:=TryToOpenFile(P^.GetModuleName,0,P^.ID-1);
+  if W<>nil then
+    begin
+      Desktop^.GetExtent(R);
+      W^.Locate(R);
+    end;
+  Desktop^.UnLock;
 end;
 
 procedure TMessageListBox.GotoSource;
+var W: PSourceWindow;
+    P: PMessageItem;
+    R: TRect;
 begin
-{  if TryToOpenSource(}
+  if Range=0 then Exit;
+  P:=List^.At(Focused);
+  if P^.ID=0 then Exit;
+  Desktop^.Lock;
+  W:=TryToOpenFile(P^.GetModuleName,0,P^.ID-1);
+  if W<>nil then
+    begin
+      Desktop^.GetExtent(R);
+      W^.Locate(R);
+    end;
+  Message(Owner,evCommand,cmClose,nil);
+  Desktop^.UnLock;
 end;
 
 procedure TMessageListBox.Draw;
@@ -2222,6 +2263,11 @@ procedure TMessageItem.Selected;
 begin
 end;
 
+function TMessageItem.GetModuleName: string;
+begin
+  GetModuleName:=GetStr(Module);
+end;
+
 destructor TMessageItem.Done;
 begin
   inherited Done;
@@ -2840,10 +2886,128 @@ begin
   InTranslate:=false;
 end;
 
+function OpenEditorWindow(FileName: string; CurX,CurY: integer): PSourceWindow;
+var P: PView;
+    R: TRect;
+    W: PSourceWindow;
+begin
+{  P:=Message(Desktop,evBroadcast,cmSearchWindow,nil);}
+  P:=Desktop^.First;
+  while P<>nil do
+  begin
+    if P^.HelpCtx=hcSourceWindow then Break;
+    P:=P^.NextView;
+  end;
+  if P=nil then Desktop^.GetExtent(R) else
+     begin
+       P^.GetBounds(R);
+       Inc(R.A.X); Inc(R.A.Y);
+     end;
+  PushStatus('Opening source file... ('+SmartPath(FileName)+')');
+  New(W, Init(R, FileName));
+  if W<>nil then
+  begin
+    if (CurX<>0) or (CurY<>0) then
+       with W^.Editor^ do
+       begin
+         SetCurPtr(CurX,CurY);
+         TrackCursor(true);
+       end;
+    W^.HelpCtx:=hcSourceWindow;
+    Desktop^.Insert(W);
+    Message(Application,evBroadcast,cmUpdate,nil);
+  end;
+  PopStatus;
+  OpenEditorWindow:=W;
+end;
+
+function TryToOpenFile(FileName: string; CurX,CurY: integer): PSourceWindow;
+var D : DirStr;
+    N : NameStr;
+    E : ExtStr;
+function CheckDir(NewDir: DirStr; NewName: NameStr; NewExt: ExtStr): boolean;
+var OK: boolean;
+begin
+  NewDir:=CompleteDir(NewDir);
+  OK:=ExistsFile(NewDir+NewName+NewExt);
+  if OK then begin D:=NewDir; N:=NewName; E:=NewExt; end;
+  CheckDir:=OK;
+end;
+function CheckExt(NewExt: ExtStr): boolean;
+var OK: boolean;
+begin
+  OK:=false;
+  if D<>'' then OK:=CheckDir(D,N,NewExt) else
+    if CheckDir('.\',N,NewExt) then OK:=true;
+  CheckExt:=OK;
+end;
+function TryToOpen: PSourceWindow;
+var Found: boolean;
+    W : PSourceWindow;
+begin
+  Found:=true;
+  if E='' then
+    if CheckExt('.pp') then Found:=true else
+      if CheckExt('.pas') then Found:=true else
+        if CheckExt('.inc')=false then
+          Found:=false;
+  if Found=false then W:=nil else
+    begin
+      FileName:=FExpand(D+N+E);
+      W:=OpenEditorWindow(FileName,CurX,CurY);
+    end;
+  TryToOpen:=W;
+end;
+function SearchOnDesktop: PSourceWindow;
+var W: PWindow;
+    I: integer;
+    Found: boolean;
+    SName: string;
+begin
+  for I:=1 to 100 do
+  begin
+    W:=SearchWindowWithNo(I);
+    if (W<>nil) and (W^.HelpCtx=hcSourceWindow) then
+      begin
+        if (D='') then
+          SName:=NameAndExtOf(PSourceWindow(W)^.Editor^.FileName)
+        else
+          SName:=PSourceWindow(W)^.Editor^.FileName;
+        SName:=UpcaseStr(SName);
+
+        if E<>'' then Found:=SName=UpcaseStr(N+E) else
+          begin
+            Found:=SName=UpcaseStr(N+'.pp');
+            if Found=false then
+              Found:=SName=UpcaseStr(N+'.pas');
+          end;
+        if Found then Break;
+      end;
+  end;
+  if Found=false then W:=nil;
+  SearchOnDesktop:=PSourceWindow(W);
+end;
+var W: PSourceWindow;
+begin
+  FSplit(FileName,D,N,E);
+  W:=SearchOnDesktop;
+  if W<>nil then
+    begin
+      W^.Editor^.SetCurPtr(CurX,CurY);
+    end
+  else
+    W:=TryToOpen;
+  TryToOpenFile:=W;
+end;
+
+
 END.
 {
   $Log$
-  Revision 1.4  1999-01-12 14:29:42  peter
+  Revision 1.5  1999-01-14 21:42:25  peter
+    * source tracking from Gabor
+
+  Revision 1.4  1999/01/12 14:29:42  peter
     + Implemented still missing 'switch' entries in Options menu
     + Pressing Ctrl-B sets ASCII mode in editor, after which keypresses (even
       ones with ASCII < 32 ; entered with Alt+<###>) are interpreted always as

+ 1 - 0
ide/text/test2.pas

@@ -15,6 +15,7 @@ implementation
 
 function IsOdd(X: integer): boolean;
 begin
+  X:=X*Test8087;
   IsOdd:=(X mod 2)=1;
 end;