Cody/Dictionary: Ability to temporarily show more identifiers in the list

This commit is contained in:
n7800 2025-07-08 01:06:40 +05:00
parent bdef51f335
commit 69aa026bac
3 changed files with 44 additions and 3 deletions

View File

@ -68,9 +68,12 @@ object CodyIdentifiersDlg: TCodyIdentifiersDlg
BorderSpacing.Left = 6
BorderSpacing.Right = 6
BorderSpacing.Bottom = 1
ClickOnSelChange = False
ItemHeight = 0
OnClick = ItemsListBoxClick
OnContextPopup = ItemsListBoxContextPopup
OnDblClick = ItemsListBoxDblClick
OnKeyDown = ItemsListBoxKeyDown
OnSelectionChange = ItemsListBoxSelectionChange
PopupMenu = PopupMenu1
TabOrder = 2

View File

@ -172,6 +172,9 @@ type
procedure FormClose(Sender: TObject; var {%H-}CloseAction: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure HideOtherProjectsCheckBoxChange(Sender: TObject);
procedure ItemsListBoxKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure ItemsListBoxClick(Sender: TObject);
procedure ItemsListBoxDblClick(Sender: TObject);
procedure ItemsListBoxSelectionChange(Sender: TObject; {%H-}User: boolean);
procedure OnIdle(Sender: TObject; var {%H-}Done: Boolean);
@ -956,6 +959,9 @@ begin
ItemsListBox.ItemIndex:=i-1;
Key := 0;
end;
if Key <> 0 then
ItemsListBoxKeyDown(Sender, Key, Shift);
end;
procedure TCodyIdentifiersDlg.FormDestroy(Sender: TObject);
@ -1014,6 +1020,32 @@ begin
IdleConnected:=true;
end;
procedure TCodyIdentifiersDlg.ItemsListBoxKeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
begin
if (Key = VK_RETURN) and (Shift = []) then
begin
if FindSelectedIdentifier = nil then
begin
MaxItems := MaxItems + CodyOptions.UDMaxListItems;
Key := 0;
end;
end;
end;
procedure TCodyIdentifiersDlg.ItemsListBoxClick(Sender: TObject);
var
lClickPos: TPoint;
begin
// ignore clicks in empty area
lClickPos := ItemsListBox.ScreenToClient(Mouse.CursorPos);
if ItemsListBox.ItemAtPos(lClickPos, true) < 0 then exit;
// if a special item "show more" is clicked
if (ItemsListBox.ItemIndex >= 0) and (FindSelectedIdentifier = nil) then
MaxItems := MaxItems + CodyOptions.UDMaxListItems;
end;
procedure TCodyIdentifiersDlg.ItemsListBoxDblClick(Sender: TObject);
var
lClickPos: TPoint;
@ -1243,8 +1275,13 @@ begin
end;
sl.Add(s);
end;
if Found>sl.Count then
sl.Add(Format(crsAndMoreIdentifiers, [IntToStr(Found-sl.Count)]));
if Found > sl.Count then
begin
if Found - sl.Count > CodyOptions.UDMaxListItems then
sl.Add(Format(crsShowMoreIdentifiers, [CodyOptions.UDMaxListItems, Found - sl.Count]))
else
sl.Add(Format(crsShowRemainingIdentifiers, [Found - sl.Count]));
end;
ItemsListBox.Items.Assign(sl);
if Found>0 then

View File

@ -182,7 +182,8 @@ resourcestring
crsShowOnlyIdentifiersContainingFilterText = 'Show only identifiers '
+'containing filter text';
crsUseIdentifier = '&Use identifier';
crsAndMoreIdentifiers = '... and %s more identifiers';
crsShowMoreIdentifiers = '... click to show %d more (up to %d left)';
crsShowRemainingIdentifiers = '... click to show remaining (up to %d left)';
crsContextUseIdentifier = 'Use "%s"';
crsContextJumpTo = 'Jump to "%s"';
crsContextDeleteUnit = 'Delete unit "%s"';