mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-07 09:57:30 +01:00
IDE: codeexplorer: move codetool access to code explorr
git-svn-id: trunk@26491 -
This commit is contained in:
parent
9b63777a25
commit
1317f884b2
@ -39,7 +39,7 @@ interface
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
// FCL+LCL
|
// FCL+LCL
|
||||||
Classes, SysUtils, LCLProc, LCLType, Forms, Controls, Graphics,
|
Classes, SysUtils, types, LCLProc, LCLType, Forms, Controls, Graphics,
|
||||||
Dialogs, Buttons, ComCtrls, Menus, AvgLvlTree, StdCtrls, ExtCtrls,
|
Dialogs, Buttons, ComCtrls, Menus, AvgLvlTree, StdCtrls, ExtCtrls,
|
||||||
// CodeTools
|
// CodeTools
|
||||||
BasicCodeTools, CustomCodeTool, CodeToolManager, CodeAtom, CodeCache,
|
BasicCodeTools, CustomCodeTool, CodeToolManager, CodeAtom, CodeCache,
|
||||||
@ -54,8 +54,6 @@ uses
|
|||||||
type
|
type
|
||||||
TCodeExplorerView = class;
|
TCodeExplorerView = class;
|
||||||
|
|
||||||
TOnGetCodeTree =
|
|
||||||
procedure(Sender: TObject; var ACodeTool: TCodeTool) of object;
|
|
||||||
TOnGetDirectivesTree =
|
TOnGetDirectivesTree =
|
||||||
procedure(Sender: TObject; var ADirectivesTool: TDirectivesTool) of object;
|
procedure(Sender: TObject; var ADirectivesTool: TDirectivesTool) of object;
|
||||||
TOnJumpToCode = procedure(Sender: TObject; const Filename: string;
|
TOnJumpToCode = procedure(Sender: TObject; const Filename: string;
|
||||||
@ -172,7 +170,7 @@ type
|
|||||||
FMode: TCodeExplorerMode;
|
FMode: TCodeExplorerMode;
|
||||||
FLastMode: TCodeExplorerMode;
|
FLastMode: TCodeExplorerMode;
|
||||||
FLastCodeValid: boolean;
|
FLastCodeValid: boolean;
|
||||||
FOnGetCodeTree: TOnGetCodeTree;
|
FLastCodeXY: TPoint;
|
||||||
FOnGetDirectivesTree: TOnGetDirectivesTree;
|
FOnGetDirectivesTree: TOnGetDirectivesTree;
|
||||||
FOnJumpToCode: TOnJumpToCode;
|
FOnJumpToCode: TOnJumpToCode;
|
||||||
FOnShowOptions: TNotifyEvent;
|
FOnShowOptions: TNotifyEvent;
|
||||||
@ -250,8 +248,6 @@ type
|
|||||||
function FilterFits(const NodeText, TheFilter: string): boolean; virtual;
|
function FilterFits(const NodeText, TheFilter: string): boolean; virtual;
|
||||||
function GetCurrentTreeView: TCustomTreeView;
|
function GetCurrentTreeView: TCustomTreeView;
|
||||||
public
|
public
|
||||||
property OnGetCodeTree: TOnGetCodeTree read FOnGetCodeTree
|
|
||||||
write FOnGetCodeTree;
|
|
||||||
property OnGetDirectivesTree: TOnGetDirectivesTree read FOnGetDirectivesTree
|
property OnGetDirectivesTree: TOnGetDirectivesTree read FOnGetDirectivesTree
|
||||||
write FOnGetDirectivesTree;
|
write FOnGetDirectivesTree;
|
||||||
property OnJumpToCode: TOnJumpToCode read FOnJumpToCode write FOnJumpToCode;
|
property OnJumpToCode: TOnJumpToCode read FOnJumpToCode write FOnJumpToCode;
|
||||||
@ -1713,6 +1709,11 @@ var
|
|||||||
ACodeTool: TCodeTool;
|
ACodeTool: TCodeTool;
|
||||||
c: TCodeExplorerCategory;
|
c: TCodeExplorerCategory;
|
||||||
f: TCEObserverCategory;
|
f: TCEObserverCategory;
|
||||||
|
SrcEdit: TSourceEditorInterface;
|
||||||
|
Filename: String;
|
||||||
|
Code: TCodeBuffer;
|
||||||
|
NewXY: TPoint;
|
||||||
|
OnlyXYChanged: Boolean;
|
||||||
begin
|
begin
|
||||||
if (FUpdateCount>0)
|
if (FUpdateCount>0)
|
||||||
or (OnlyVisible and ((CurrentPage<>cepCode) or (not IsVisible))) then begin
|
or (OnlyVisible and ((CurrentPage<>cepCode) or (not IsVisible))) then begin
|
||||||
@ -1725,13 +1726,23 @@ begin
|
|||||||
try
|
try
|
||||||
Include(FFlags,cevRefreshing);
|
Include(FFlags,cevRefreshing);
|
||||||
|
|
||||||
// get the codetool with the updated codetree
|
// get the current editor
|
||||||
|
if not LazarusIDE.BeginCodeTools then exit;
|
||||||
|
SrcEdit:=SourceEditorManagerIntf.ActiveEditor;
|
||||||
|
if SrcEdit=nil then exit;
|
||||||
|
// get the codetool for the current editor
|
||||||
|
Filename:=SrcEdit.FileName;
|
||||||
|
Code:=CodeToolBoss.FindFile(Filename);
|
||||||
|
if Code=nil then exit;
|
||||||
ACodeTool:=nil;
|
ACodeTool:=nil;
|
||||||
if Assigned(OnGetCodeTree) then
|
// ToDo: check if something changed (file stamp, codebuffer stamp, defines stamp)
|
||||||
OnGetCodeTree(Self,ACodeTool);
|
CodeToolBoss.Explore(Code,ACodeTool,false);
|
||||||
|
if ACodeTool=nil then exit;
|
||||||
|
|
||||||
fLastCodeTool:=ACodeTool;
|
fLastCodeTool:=ACodeTool;
|
||||||
|
|
||||||
// check for changes in the codetools
|
// check for changes in the codetool
|
||||||
|
OnlyXYChanged:=false;
|
||||||
if (ACodeTool=nil) then begin
|
if (ACodeTool=nil) then begin
|
||||||
if (FCodeFilename='') then begin
|
if (FCodeFilename='') then begin
|
||||||
// still no tool
|
// still no tool
|
||||||
@ -1753,13 +1764,25 @@ begin
|
|||||||
//debugln(['TCodeExplorerView.RefreshCode Options changed ',fLastCodeOptionsChangeStep,' ',CodeExplorerOptions.ChangeStep])
|
//debugln(['TCodeExplorerView.RefreshCode Options changed ',fLastCodeOptionsChangeStep,' ',CodeExplorerOptions.ChangeStep])
|
||||||
end else begin
|
end else begin
|
||||||
// still the same source and options
|
// still the same source and options
|
||||||
exit;
|
OnlyXYChanged:=true;
|
||||||
|
if not CodeExplorerOptions.FollowCursor then
|
||||||
|
exit;
|
||||||
|
NewXY:=SrcEdit.CursorTextXY;
|
||||||
|
if ComparePoints(NewXY,FLastCodeXY)=0 then begin
|
||||||
|
// still the same cursor position
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
if OnlyXYChanged then begin
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
FLastCodeValid:=true;
|
FLastCodeValid:=true;
|
||||||
FLastMode:=Mode;
|
FLastMode:=Mode;
|
||||||
fLastCodeOptionsChangeStep:=CodeExplorerOptions.ChangeStep;
|
fLastCodeOptionsChangeStep:=CodeExplorerOptions.ChangeStep;
|
||||||
|
FLastCodeXY:=SrcEdit.CursorTextXY;
|
||||||
// remember the codetools ChangeStep
|
// remember the codetools ChangeStep
|
||||||
if ACodeTool<>nil then begin
|
if ACodeTool<>nil then begin
|
||||||
FCodeFilename:=ACodeTool.MainFilename;
|
FCodeFilename:=ACodeTool.MainFilename;
|
||||||
@ -1770,7 +1793,7 @@ begin
|
|||||||
|
|
||||||
if fCodeSortedForStartPos<>nil then
|
if fCodeSortedForStartPos<>nil then
|
||||||
fCodeSortedForStartPos.Clear;
|
fCodeSortedForStartPos.Clear;
|
||||||
|
|
||||||
//DebugLn(['TCodeExplorerView.RefreshCode ',FCodeFilename]);
|
//DebugLn(['TCodeExplorerView.RefreshCode ',FCodeFilename]);
|
||||||
|
|
||||||
// start updating the CodeTreeView
|
// start updating the CodeTreeView
|
||||||
|
|||||||
@ -12,7 +12,7 @@ inherited CodeExplorerUpdateOptionsFrame: TCodeExplorerUpdateOptionsFrame
|
|||||||
AnchorSideRight.Control = Owner
|
AnchorSideRight.Control = Owner
|
||||||
AnchorSideRight.Side = asrBottom
|
AnchorSideRight.Side = asrBottom
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 53
|
Height = 55
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 400
|
Width = 400
|
||||||
Anchors = [akTop, akLeft, akRight]
|
Anchors = [akTop, akLeft, akRight]
|
||||||
@ -28,7 +28,7 @@ inherited CodeExplorerUpdateOptionsFrame: TCodeExplorerUpdateOptionsFrame
|
|||||||
ChildSizing.Layout = cclLeftToRightThenTopToBottom
|
ChildSizing.Layout = cclLeftToRightThenTopToBottom
|
||||||
ChildSizing.ControlsPerLine = 2
|
ChildSizing.ControlsPerLine = 2
|
||||||
ClientHeight = 34
|
ClientHeight = 34
|
||||||
ClientWidth = 396
|
ClientWidth = 392
|
||||||
Columns = 2
|
Columns = 2
|
||||||
ItemIndex = 0
|
ItemIndex = 0
|
||||||
Items.Strings = (
|
Items.Strings = (
|
||||||
@ -45,8 +45,8 @@ inherited CodeExplorerUpdateOptionsFrame: TCodeExplorerUpdateOptionsFrame
|
|||||||
AnchorSideRight.Control = Owner
|
AnchorSideRight.Control = Owner
|
||||||
AnchorSideRight.Side = asrBottom
|
AnchorSideRight.Side = asrBottom
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 97
|
Height = 99
|
||||||
Top = 59
|
Top = 61
|
||||||
Width = 400
|
Width = 400
|
||||||
Anchors = [akTop, akLeft, akRight]
|
Anchors = [akTop, akLeft, akRight]
|
||||||
AutoFill = True
|
AutoFill = True
|
||||||
@ -62,7 +62,7 @@ inherited CodeExplorerUpdateOptionsFrame: TCodeExplorerUpdateOptionsFrame
|
|||||||
ChildSizing.Layout = cclLeftToRightThenTopToBottom
|
ChildSizing.Layout = cclLeftToRightThenTopToBottom
|
||||||
ChildSizing.ControlsPerLine = 1
|
ChildSizing.ControlsPerLine = 1
|
||||||
ClientHeight = 78
|
ClientHeight = 78
|
||||||
ClientWidth = 396
|
ClientWidth = 392
|
||||||
Items.Strings = (
|
Items.Strings = (
|
||||||
'Manual'
|
'Manual'
|
||||||
'SwitchPage'
|
'SwitchPage'
|
||||||
@ -77,11 +77,13 @@ inherited CodeExplorerUpdateOptionsFrame: TCodeExplorerUpdateOptionsFrame
|
|||||||
AnchorSideTop.Side = asrBottom
|
AnchorSideTop.Side = asrBottom
|
||||||
Left = 6
|
Left = 6
|
||||||
Height = 22
|
Height = 22
|
||||||
Top = 162
|
Top = 166
|
||||||
Width = 167
|
Width = 178
|
||||||
BorderSpacing.Left = 6
|
BorderSpacing.Left = 6
|
||||||
BorderSpacing.Top = 6
|
BorderSpacing.Top = 6
|
||||||
Caption = 'FollowCursorCheckBox'
|
Caption = 'FollowCursorCheckBox'
|
||||||
|
ParentShowHint = False
|
||||||
|
ShowHint = True
|
||||||
TabOrder = 2
|
TabOrder = 2
|
||||||
Visible = False
|
Visible = False
|
||||||
end
|
end
|
||||||
|
|||||||
@ -74,6 +74,8 @@ begin
|
|||||||
Items[2] := lisCEOOnIdle;
|
Items[2] := lisCEOOnIdle;
|
||||||
end;
|
end;
|
||||||
FollowCursorCheckBox.Caption := lisCEFollowCursor;
|
FollowCursorCheckBox.Caption := lisCEFollowCursor;
|
||||||
|
FollowCursorCheckBox.Hint :=
|
||||||
|
lisWhenTheSourceEditorCursorMovesShowTheCurrentNodeIn;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCodeExplorerUpdateOptionsFrame.ReadSettings(
|
procedure TCodeExplorerUpdateOptionsFrame.ReadSettings(
|
||||||
|
|||||||
@ -4195,6 +4195,8 @@ resourcestring
|
|||||||
lisCEOWhenSwitchingFile = 'When switching file in source editor';
|
lisCEOWhenSwitchingFile = 'When switching file in source editor';
|
||||||
lisCEOOnIdle = 'On idle';
|
lisCEOOnIdle = 'On idle';
|
||||||
lisCEFollowCursor = 'Follow cursor';
|
lisCEFollowCursor = 'Follow cursor';
|
||||||
|
lisWhenTheSourceEditorCursorMovesShowTheCurrentNodeIn = 'When the source '
|
||||||
|
+'editor cursor moves, show the current node in the code explorer';
|
||||||
lisCECategories = 'Categories';
|
lisCECategories = 'Categories';
|
||||||
lisCEUses = 'Uses';
|
lisCEUses = 'Uses';
|
||||||
lisCEOnlyUsedInCategoryMode = 'Only used in category mode';
|
lisCEOnlyUsedInCategoryMode = 'Only used in category mode';
|
||||||
|
|||||||
14
ide/main.pp
14
ide/main.pp
@ -518,8 +518,6 @@ type
|
|||||||
const Filename: string);
|
const Filename: string);
|
||||||
|
|
||||||
// code explorer events
|
// code explorer events
|
||||||
procedure OnCodeExplorerGetCodeTree(Sender: TObject;
|
|
||||||
var ACodeTool: TCodeTool);
|
|
||||||
procedure OnCodeExplorerGetDirectivesTree(Sender: TObject;
|
procedure OnCodeExplorerGetDirectivesTree(Sender: TObject;
|
||||||
var ADirectivesTool: TDirectivesTool);
|
var ADirectivesTool: TDirectivesTool);
|
||||||
procedure OnCodeExplorerJumpToCode(Sender: TObject; const Filename: string;
|
procedure OnCodeExplorerJumpToCode(Sender: TObject; const Filename: string;
|
||||||
@ -8953,7 +8951,6 @@ begin
|
|||||||
if CodeExplorerView=nil then
|
if CodeExplorerView=nil then
|
||||||
begin
|
begin
|
||||||
CodeExplorerView:=TCodeExplorerView.Create(OwningComponent);
|
CodeExplorerView:=TCodeExplorerView.Create(OwningComponent);
|
||||||
CodeExplorerView.OnGetCodeTree:=@OnCodeExplorerGetCodeTree;
|
|
||||||
CodeExplorerView.OnGetDirectivesTree:=@OnCodeExplorerGetDirectivesTree;
|
CodeExplorerView.OnGetDirectivesTree:=@OnCodeExplorerGetDirectivesTree;
|
||||||
CodeExplorerView.OnJumpToCode:=@OnCodeExplorerJumpToCode;
|
CodeExplorerView.OnJumpToCode:=@OnCodeExplorerJumpToCode;
|
||||||
CodeExplorerView.OnShowOptions:=@OnCodeExplorerShowOptions;
|
CodeExplorerView.OnShowOptions:=@OnCodeExplorerShowOptions;
|
||||||
@ -13249,17 +13246,6 @@ begin
|
|||||||
DoOpenEditorFile(Filename,-1,-1,[]);
|
DoOpenEditorFile(Filename,-1,-1,[]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMainIDE.OnCodeExplorerGetCodeTree(Sender: TObject;
|
|
||||||
var ACodeTool: TCodeTool);
|
|
||||||
var
|
|
||||||
ActiveUnitInfo: TUnitInfo;
|
|
||||||
ActiveSrcEdit: TSourceEditor;
|
|
||||||
begin
|
|
||||||
ACodeTool:=nil;
|
|
||||||
if not BeginCodeTool(ActiveSrcEdit,ActiveUnitInfo,[]) then exit;
|
|
||||||
CodeToolBoss.Explore(ActiveUnitInfo.Source,ACodeTool,false);
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TMainIDE.OnCodeExplorerGetDirectivesTree(Sender: TObject;
|
procedure TMainIDE.OnCodeExplorerGetDirectivesTree(Sender: TObject;
|
||||||
var ADirectivesTool: TDirectivesTool);
|
var ADirectivesTool: TDirectivesTool);
|
||||||
var
|
var
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user