diff --git a/components/codetools/ide/codyidentifiersdlg.lfm b/components/codetools/ide/codyidentifiersdlg.lfm index 5196bdc3ac..2b83e49b33 100644 --- a/components/codetools/ide/codyidentifiersdlg.lfm +++ b/components/codetools/ide/codyidentifiersdlg.lfm @@ -2,11 +2,12 @@ object CodyIdentifiersDlg: TCodyIdentifiersDlg Left = 250 Height = 300 Top = 250 - Width = 428 + Width = 521 ActiveControl = FilterEdit Caption = 'CodyIdentifiersDlg' ClientHeight = 300 - ClientWidth = 428 + ClientWidth = 521 + OnClose = FormClose OnCreate = FormCreate Position = poScreenCenter LCLVersion = '0.9.31' @@ -14,7 +15,7 @@ object CodyIdentifiersDlg: TCodyIdentifiersDlg Left = 6 Height = 42 Top = 252 - Width = 416 + Width = 509 OKButton.Name = 'OKButton' OKButton.DefaultCaption = True HelpButton.Name = 'HelpButton' @@ -44,13 +45,14 @@ object CodyIdentifiersDlg: TCodyIdentifiersDlg Left = 6 Height = 26 Top = 35 - Width = 416 + Width = 509 Anchors = [akTop, akLeft, akRight] BorderSpacing.Left = 6 BorderSpacing.Top = 10 BorderSpacing.Right = 6 OnChange = FilterEditChange OnExit = FilterEditExit + OnKeyDown = FilterEditKeyDown TabOrder = 1 Text = 'FilterEdit' end @@ -60,18 +62,44 @@ object CodyIdentifiersDlg: TCodyIdentifiersDlg AnchorSideTop.Side = asrBottom AnchorSideRight.Control = Owner AnchorSideRight.Side = asrBottom - AnchorSideBottom.Control = ButtonPanel1 + AnchorSideBottom.Control = UnitLabel Left = 6 - Height = 185 + Height = 149 Top = 61 - Width = 416 + Width = 509 Anchors = [akTop, akLeft, akRight, akBottom] BorderSpacing.Left = 6 BorderSpacing.Right = 6 - BorderSpacing.Bottom = 6 + BorderSpacing.Bottom = 1 ItemHeight = 0 - ScrollWidth = 414 + OnClick = ItemsListBoxClick + OnSelectionChange = ItemsListBoxSelectionChange + ScrollWidth = 507 TabOrder = 2 TopIndex = -1 end + object UnitLabel: TLabel + AnchorSideLeft.Control = InfoLabel + AnchorSideBottom.Control = PackageLabel + Left = 8 + Height = 17 + Top = 211 + Width = 59 + Anchors = [akLeft, akBottom] + BorderSpacing.Bottom = 1 + Caption = 'UnitLabel' + ParentColor = False + end + object PackageLabel: TLabel + AnchorSideLeft.Control = InfoLabel + AnchorSideBottom.Control = ButtonPanel1 + Left = 8 + Height = 17 + Top = 229 + Width = 84 + Anchors = [akLeft, akBottom] + BorderSpacing.Bottom = 1 + Caption = 'PackageLabel' + ParentColor = False + end end diff --git a/components/codetools/ide/codyidentifiersdlg.pas b/components/codetools/ide/codyidentifiersdlg.pas index 4a27e17b61..5861c75d04 100644 --- a/components/codetools/ide/codyidentifiersdlg.pas +++ b/components/codetools/ide/codyidentifiersdlg.pas @@ -48,7 +48,7 @@ interface uses Classes, SysUtils, FileProcs, LResources, LCLProc, avl_tree, Forms, Controls, - Graphics, Dialogs, ButtonPanel, StdCtrls, ExtCtrls, + Graphics, Dialogs, ButtonPanel, StdCtrls, ExtCtrls, LCLType, PackageIntf, LazIDEIntf, BasicCodeTools, CustomCodeTool, CodeToolManager, UnitDictionary, CodyStrConsts; @@ -113,21 +113,32 @@ type FilterEdit: TEdit; InfoLabel: TLabel; ItemsListBox: TListBox; + PackageLabel: TLabel; + UnitLabel: TLabel; procedure FileLabelClick(Sender: TObject); procedure FilterEditChange(Sender: TObject); procedure FilterEditExit(Sender: TObject); + procedure FilterEditKeyDown(Sender: TObject; var Key: Word; + {%H-}Shift: TShiftState); + procedure FormClose(Sender: TObject; var {%H-}CloseAction: TCloseAction); procedure FormCreate(Sender: TObject); + procedure ItemsListBoxClick(Sender: TObject); + procedure ItemsListBoxSelectionChange(Sender: TObject; {%H-}User: boolean); procedure OnIdle(Sender: TObject; var {%H-}Done: Boolean); private FLastFilter: string; FIdleConnected: boolean; FMaxItems: integer; FNoFilterText: string; + FItems: TStringList; procedure SetIdleConnected(AValue: boolean); procedure SetMaxItems(AValue: integer); + procedure UpdateGeneralInfo; procedure UpdateItemsList; - procedure UpdateInfo; + procedure UpdateIdentifierInfo; function GetFilterEditText: string; + function FindSelectedItem(out Identifier, UnitFilename, + GroupFilename: string): boolean; public procedure Init; property IdleConnected: boolean read FIdleConnected write SetIdleConnected; @@ -467,18 +478,56 @@ begin FilterEdit.Text:=FNoFilterText; end; +procedure TCodyIdentifiersDlg.FilterEditKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +var + i: Integer; +begin + i:=ItemsListBox.ItemIndex; + case Key of + VK_DOWN: + if i<0 then + ItemsListBox.ItemIndex:=0 + else if i0 then + ItemsListBox.ItemIndex:=i-1; + end; +end; + +procedure TCodyIdentifiersDlg.FormClose(Sender: TObject; + var CloseAction: TCloseAction); +begin + FreeAndNil(FItems); +end; + procedure TCodyIdentifiersDlg.FormCreate(Sender: TObject); begin Caption:=crsCodyIdentifierDictionary; FMaxItems:=20; FNoFilterText:=crsFilter; + FItems:=TStringList.Create; +end; + +procedure TCodyIdentifiersDlg.ItemsListBoxClick(Sender: TObject); +begin + +end; + +procedure TCodyIdentifiersDlg.ItemsListBoxSelectionChange(Sender: TObject; + User: boolean); +begin + UpdateIdentifierInfo; end; procedure TCodyIdentifiersDlg.OnIdle(Sender: TObject; var Done: Boolean); begin if not CodyUnitDictionary.Loaded then begin CodyUnitDictionary.Load; - UpdateInfo; + UpdateGeneralInfo; end; if FLastFilter<>GetFilterEditText then UpdateItemsList; @@ -517,6 +566,7 @@ var begin Filter:=GetFilterEditText; FilterP:=PChar(Filter); + FItems.Clear; sl:=TStringList.Create; try Found:=0; @@ -534,9 +584,10 @@ begin s:=Item.Name+' in '+Item.DUnit.Name; if Group.Name<>'' then s:=s+' of '+Group.Name; + FItems.Add(Item.Name+#10+Item.DUnit.Filename+#10+Group.Filename); + sl.Add(s); GroupNode:=Item.DUnit.UnitGroups.FindSuccessor(GroupNode); end; - sl.Add(s); end; end; Node:=CodyUnitDictionary.Identifiers.FindSuccessor(Node); @@ -546,12 +597,32 @@ begin sl.Add(Format(crsAndMoreIdentifiers, [IntToStr(Found-sl.Count)])); ItemsListBox.Items.Assign(sl); + if Found>0 then + ItemsListBox.ItemIndex:=0; + UpdateIdentifierInfo; finally sl.Free; end; end; -procedure TCodyIdentifiersDlg.UpdateInfo; +procedure TCodyIdentifiersDlg.UpdateIdentifierInfo; +var + Identifier: string; + UnitFilename: string; + GroupFilename: string; +begin + if FindSelectedItem(Identifier, UnitFilename, GroupFilename) then begin + if GroupFilename<>'' then + UnitFilename:=CreateRelativePath(UnitFilename,ExtractFilePath(GroupFilename)); + UnitLabel.Caption:='Unit: '+UnitFilename; + PackageLabel.Caption:='Package: '+GroupFilename; + end else begin + UnitLabel.Caption:='Unit: none selected'; + PackageLabel.Caption:='Package: none selected'; + end; +end; + +procedure TCodyIdentifiersDlg.UpdateGeneralInfo; var s: String; begin @@ -573,9 +644,37 @@ begin Result:=''; end; +function TCodyIdentifiersDlg.FindSelectedItem(out Identifier, UnitFilename, + GroupFilename: string): boolean; +var + i: Integer; + s: String; + p: SizeInt; +begin + Result:=false; + i:=ItemsListBox.ItemIndex; + if (i<0) or (i>=FItems.Count) then exit; + s:=FItems[i]; + p:=Pos(#10,s); + if p<1 then exit; + Identifier:=copy(s,1,p-1); + System.Delete(s,1,p); + p:=Pos(#10,s); + if p<1 then begin + UnitFilename:=s; + GroupFilename:=''; + end else begin + UnitFilename:=copy(s,1,p-1); + System.Delete(s,1,p); + GroupFilename:=s; + end; + //debugln(['TCodyIdentifiersDlg.FindSelectedItem ',Identifier,' Unit=',UnitFilename,' Pkg=',GroupFilename]); + Result:=true; +end; + procedure TCodyIdentifiersDlg.Init; begin - UpdateInfo; + UpdateGeneralInfo; FilterEdit.Text:=FNoFilterText; FLastFilter:='...'; // force one update IdleConnected:=true;