mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-07 07:49:26 +01:00
IDE: code explorer: fixed check for updates, added menu item Rename
git-svn-id: trunk@22847 -
This commit is contained in:
parent
524cc9f759
commit
510e73913d
@ -156,6 +156,7 @@ object CodeExplorerView: TCodeExplorerView
|
|||||||
top = 64
|
top = 64
|
||||||
end
|
end
|
||||||
object TreePopupmenu: TPopupMenu
|
object TreePopupmenu: TPopupMenu
|
||||||
|
OnPopup = TreePopupmenuPopup
|
||||||
left = 64
|
left = 64
|
||||||
top = 128
|
top = 128
|
||||||
object MenuItem1: TMenuItem
|
object MenuItem1: TMenuItem
|
||||||
|
|||||||
@ -55,8 +55,9 @@ LazarusResources.Add('TCodeExplorerView','FORMDATA',[
|
|||||||
+'ons'#11#17'tvoAutoItemHeight'#16'tvoHideSelection'#21'tvoKeepCollapsedNodes'
|
+'ons'#11#17'tvoAutoItemHeight'#16'tvoHideSelection'#21'tvoKeepCollapsedNodes'
|
||||||
+#11'tvoReadOnly'#14'tvoShowButtons'#12'tvoShowLines'#11'tvoShowRoot'#11'tvoT'
|
+#11'tvoReadOnly'#14'tvoShowButtons'#12'tvoShowLines'#11'tvoShowRoot'#11'tvoT'
|
||||||
+'oolTips'#0#0#0#0#0#10'TImageList'#10'Imagelist1'#6'Height'#2#18#5'Width'#2
|
+'oolTips'#0#0#0#0#0#10'TImageList'#10'Imagelist1'#6'Height'#2#18#5'Width'#2
|
||||||
+#18#4'left'#2'@'#3'top'#2'@'#0#0#10'TPopupMenu'#13'TreePopupmenu'#4'left'#2
|
+#18#4'left'#2'@'#3'top'#2'@'#0#0#10'TPopupMenu'#13'TreePopupmenu'#7'OnPopup'
|
||||||
+'@'#3'top'#3#128#0#0#9'TMenuItem'#9'MenuItem1'#7'Caption'#6#9'New Item1'#7'V'
|
+#7#18'TreePopupmenuPopup'#4'left'#2'@'#3'top'#3#128#0#0#9'TMenuItem'#9'MenuI'
|
||||||
+'isible'#8#0#0#0#10'TIdleTimer'#10'IdleTimer1'#11'AutoEnabled'#9#8'Interval'
|
+'tem1'#7'Caption'#6#9'New Item1'#7'Visible'#8#0#0#0#10'TIdleTimer'#10'IdleTi'
|
||||||
+#3#244#1#7'OnTimer'#7#15'IdleTimer1Timer'#4'left'#2'@'#3'top'#3#192#0#0#0#0
|
+'mer1'#11'AutoEnabled'#9#8'Interval'#3#244#1#7'OnTimer'#7#15'IdleTimer1Timer'
|
||||||
|
+#4'left'#2'@'#3'top'#3#192#0#0#0#0
|
||||||
]);
|
]);
|
||||||
|
|||||||
@ -48,8 +48,8 @@ uses
|
|||||||
// IDE Intf
|
// IDE Intf
|
||||||
LazIDEIntf, IDECommands, MenuIntf, SrcEditorIntf,
|
LazIDEIntf, IDECommands, MenuIntf, SrcEditorIntf,
|
||||||
// IDE
|
// IDE
|
||||||
LazarusIDEStrConsts, EnvironmentOpts, IDEOptionDefs, InputHistory, IDEProcs,
|
KeyMapping, LazarusIDEStrConsts, EnvironmentOpts, IDEOptionDefs, InputHistory,
|
||||||
TodoList, CodeExplOpts;
|
IDEProcs, TodoList, CodeExplOpts;
|
||||||
|
|
||||||
type
|
type
|
||||||
TCodeExplorerView = class;
|
TCodeExplorerView = class;
|
||||||
@ -157,6 +157,8 @@ type
|
|||||||
procedure OptionsSpeedButtonClick(Sender: TObject);
|
procedure OptionsSpeedButtonClick(Sender: TObject);
|
||||||
procedure RefreshMenuitemClick(Sender: TObject);
|
procedure RefreshMenuitemClick(Sender: TObject);
|
||||||
procedure RefreshSpeedButtonClick(Sender: TObject);
|
procedure RefreshSpeedButtonClick(Sender: TObject);
|
||||||
|
procedure RenameMenuItemClick(Sender: TObject);
|
||||||
|
procedure TreePopupmenuPopup(Sender: TObject);
|
||||||
private
|
private
|
||||||
FCodeFilename: string;
|
FCodeFilename: string;
|
||||||
fCategoryNodes: array[TCodeExplorerCategory] of TTreeNode;
|
fCategoryNodes: array[TCodeExplorerCategory] of TTreeNode;
|
||||||
@ -239,7 +241,7 @@ type
|
|||||||
procedure RefreshCode(OnlyVisible: boolean);
|
procedure RefreshCode(OnlyVisible: boolean);
|
||||||
procedure RefreshDirectives(OnlyVisible: boolean);
|
procedure RefreshDirectives(OnlyVisible: boolean);
|
||||||
procedure ClearCTNodes(ATreeView: TTreeView);// remove temporary references
|
procedure ClearCTNodes(ATreeView: TTreeView);// remove temporary references
|
||||||
procedure JumpToSelection; // jump in source editor
|
function JumpToSelection: boolean; // jump in source editor
|
||||||
function SelectSourceEditorNode: boolean;
|
function SelectSourceEditorNode: boolean;
|
||||||
function SelectCodePosition(CodeBuf: TCodeBuffer; X, Y: integer): boolean; // select deepest node
|
function SelectCodePosition(CodeBuf: TCodeBuffer; X, Y: integer): boolean; // select deepest node
|
||||||
function FindCodeTVNodeAtCleanPos(CleanPos: integer): TTreeNode;
|
function FindCodeTVNodeAtCleanPos(CleanPos: integer): TTreeNode;
|
||||||
@ -402,6 +404,7 @@ begin
|
|||||||
CEJumpToIDEMenuCommand.OnClick:=@JumpToMenuitemCLICK;
|
CEJumpToIDEMenuCommand.OnClick:=@JumpToMenuitemCLICK;
|
||||||
CERefreshIDEMenuCommand.OnClick:=@RefreshMenuitemCLICK;
|
CERefreshIDEMenuCommand.OnClick:=@RefreshMenuitemCLICK;
|
||||||
CEDockingIDEMenuCommand.OnClick:=@DockingMenuItemClick;
|
CEDockingIDEMenuCommand.OnClick:=@DockingMenuItemClick;
|
||||||
|
CERenameIDEMenuCommand.OnClick:=@RenameMenuItemClick;
|
||||||
{$IFNDEF EnableIDEDocking}
|
{$IFNDEF EnableIDEDocking}
|
||||||
CEDockingIDEMenuCommand.Visible:=false;
|
CEDockingIDEMenuCommand.Visible:=false;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
@ -470,7 +473,7 @@ end;
|
|||||||
procedure TCodeExplorerView.IdleTimer1Timer(Sender: TObject);
|
procedure TCodeExplorerView.IdleTimer1Timer(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
if ((cevCheckOnIdle in FFlags) or (CodeExplorerOptions.Refresh=cerOnIdle))
|
if ((cevCheckOnIdle in FFlags) or (CodeExplorerOptions.Refresh=cerOnIdle))
|
||||||
and (not Active) then
|
and (not Active) and (not (fsModal in Screen.ActiveCustomForm.FormState)) then
|
||||||
Refresh(true);
|
Refresh(true);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -518,6 +521,48 @@ begin
|
|||||||
Refresh(true);
|
Refresh(true);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCodeExplorerView.RenameMenuItemClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if not JumpToSelection then begin
|
||||||
|
MessageDlg(lisCCOErrorCaption, lisTreeNeedsRefresh, mtError, [mbOk], 0);
|
||||||
|
Refresh(true);
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
ExecuteIDECommand(SourceEditorWindow,ecRenameIdentifier);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCodeExplorerView.TreePopupmenuPopup(Sender: TObject);
|
||||||
|
var
|
||||||
|
CurTreeView: TCustomTreeView;
|
||||||
|
CurItem: TTreeNode;
|
||||||
|
CanRename: boolean;
|
||||||
|
CurNode: TViewNodeData;
|
||||||
|
begin
|
||||||
|
CanRename:=false;
|
||||||
|
CurTreeView:=GetCurrentTreeView;
|
||||||
|
if CurTreeView<>nil then begin
|
||||||
|
if tvoAllowMultiselect in CurTreeView.Options then
|
||||||
|
CurItem:=CurTreeView.GetFirstMultiSelected
|
||||||
|
else
|
||||||
|
CurItem:=CurTreeView.Selected;
|
||||||
|
if CurItem<>nil then begin
|
||||||
|
CurNode:=TViewNodeData(CurItem.Data);
|
||||||
|
if CurNode.StartPos>0 then begin
|
||||||
|
case CurrentPage of
|
||||||
|
cepCode:
|
||||||
|
if (CurNode.Desc in AllIdentifierDefinitions)
|
||||||
|
and (CurItem.GetNextMultiSelected=nil) then
|
||||||
|
CanRename:=true;
|
||||||
|
cepDirectives:
|
||||||
|
;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
CERenameIDEMenuCommand.Visible:=CanRename;
|
||||||
|
DebugLn(['TCodeExplorerView.TreePopupmenuPopup ',CERenameIDEMenuCommand.Visible]);
|
||||||
|
end;
|
||||||
|
|
||||||
function TCodeExplorerView.GetCodeNodeDescription(ACodeTool: TCodeTool;
|
function TCodeExplorerView.GetCodeNodeDescription(ACodeTool: TCodeTool;
|
||||||
CodeNode: TCodeTreeNode): string;
|
CodeNode: TCodeTreeNode): string;
|
||||||
begin
|
begin
|
||||||
@ -1666,7 +1711,7 @@ begin
|
|||||||
and (ACodeTool.Scanner<>nil)
|
and (ACodeTool.Scanner<>nil)
|
||||||
and (ACodeTool.Scanner.ChangeStep=FLastCodeChangeStep)
|
and (ACodeTool.Scanner.ChangeStep=FLastCodeChangeStep)
|
||||||
and (Mode=FLastMode)
|
and (Mode=FLastMode)
|
||||||
and (FLastCodeChangeStep=CodeExplorerOptions.ChangeStep) then begin
|
and (fLastCodeOptionsChangeStep=CodeExplorerOptions.ChangeStep) then begin
|
||||||
// still the same source and options
|
// still the same source and options
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
@ -1814,7 +1859,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCodeExplorerView.JumpToSelection;
|
function TCodeExplorerView.JumpToSelection: boolean;
|
||||||
var
|
var
|
||||||
CurItem: TTreeNode;
|
CurItem: TTreeNode;
|
||||||
CurNode: TViewNodeData;
|
CurNode: TViewNodeData;
|
||||||
@ -1823,17 +1868,22 @@ var
|
|||||||
CodeBuffer: TCodeBuffer;
|
CodeBuffer: TCodeBuffer;
|
||||||
ACodeTool: TCodeTool;
|
ACodeTool: TCodeTool;
|
||||||
CurTreeView: TCustomTreeView;
|
CurTreeView: TCustomTreeView;
|
||||||
|
SrcEdit: TSourceEditorInterface;
|
||||||
begin
|
begin
|
||||||
|
Result:=false;
|
||||||
CurTreeView:=GetCurrentTreeView;
|
CurTreeView:=GetCurrentTreeView;
|
||||||
|
DebugLn(['TCodeExplorerView.JumpToSelection AAA1']);
|
||||||
if CurTreeView=nil then exit;
|
if CurTreeView=nil then exit;
|
||||||
|
DebugLn(['TCodeExplorerView.JumpToSelection AAA2']);
|
||||||
if tvoAllowMultiselect in CurTreeView.Options then
|
if tvoAllowMultiselect in CurTreeView.Options then
|
||||||
CurItem:=CurTreeView.GetFirstMultiSelected
|
CurItem:=CurTreeView.GetFirstMultiSelected
|
||||||
else
|
else
|
||||||
CurItem:=CurTreeView.Selected;
|
CurItem:=CurTreeView.Selected;
|
||||||
if CurItem=nil then exit;
|
if CurItem=nil then exit;
|
||||||
CurNode:=TViewNodeData(CurItem.Data);
|
CurNode:=TViewNodeData(CurItem.Data);
|
||||||
|
DebugLn(['TCodeExplorerView.JumpToSelection AAA3 ',CurNode.StartPos]);
|
||||||
if CurNode.StartPos<1 then exit;
|
if CurNode.StartPos<1 then exit;
|
||||||
|
CodeBuffer:=nil;
|
||||||
case CurrentPage of
|
case CurrentPage of
|
||||||
cepCode:
|
cepCode:
|
||||||
begin
|
begin
|
||||||
@ -1858,8 +1908,17 @@ begin
|
|||||||
else
|
else
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
DebugLn(['TCodeExplorerView.JumpToSelection AAA1']);
|
||||||
if Assigned(OnJumpToCode) then
|
if Assigned(OnJumpToCode) then
|
||||||
OnJumpToCode(Self,Caret.Code.Filename,Point(Caret.X,Caret.Y),NewTopLine);
|
OnJumpToCode(Self,Caret.Code.Filename,Point(Caret.X,Caret.Y),NewTopLine);
|
||||||
|
SrcEdit:=SourceEditorWindow.ActiveEditor;
|
||||||
|
DebugLn(['TCodeExplorerView.JumpToSelection AAA2 ',SrcEdit.FileName,' ',dbgs(SrcEdit.CursorTextXY),' X=',Caret.X,' Y=',Caret.Y]);
|
||||||
|
// check if jump was successful
|
||||||
|
if (SrcEdit.CodeToolsBuffer<>CodeBuffer)
|
||||||
|
or (SrcEdit.CursorTextXY.X<>Caret.X) or (SrcEdit.CursorTextXY.Y<>Caret.Y) then
|
||||||
|
exit;
|
||||||
|
DebugLn(['TCodeExplorerView.JumpToSelection AAA3']);
|
||||||
|
Result:=true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCodeExplorerView.SelectSourceEditorNode: boolean;
|
function TCodeExplorerView.SelectSourceEditorNode: boolean;
|
||||||
|
|||||||
@ -1693,6 +1693,7 @@ resourcestring
|
|||||||
dlgCCOTestMissingPPU = 'Test: Checking missing fpc ppu ...';
|
dlgCCOTestMissingPPU = 'Test: Checking missing fpc ppu ...';
|
||||||
dlgCCOTestCompilerDate = 'Test: Checking compiler date ...';
|
dlgCCOTestCompilerDate = 'Test: Checking compiler date ...';
|
||||||
lisCCOErrorCaption = 'Error';
|
lisCCOErrorCaption = 'Error';
|
||||||
|
lisTreeNeedsRefresh = 'Tree needs refresh';
|
||||||
lisEMDEmtpyMethods = 'Emtpy Methods';
|
lisEMDEmtpyMethods = 'Emtpy Methods';
|
||||||
lisEMDSearchInTheseClassSections = 'Search in these class sections:';
|
lisEMDSearchInTheseClassSections = 'Search in these class sections:';
|
||||||
lisUnableToLoadPackage = 'Unable to load package %s%s%s';
|
lisUnableToLoadPackage = 'Unable to load package %s%s%s';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user