mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-29 15:10:22 +02:00
ide: implement Copy to Clipboard behavior in Search results dialog by Flávio Etrusco (issue #0015851)
git-svn-id: trunk@23809 -
This commit is contained in:
parent
a204eebb53
commit
eb52aebd64
@ -280,6 +280,9 @@ resourcestring
|
|||||||
lisCopyAllMessagesToClipboard = 'Copy all messages to clipboard';
|
lisCopyAllMessagesToClipboard = 'Copy all messages to clipboard';
|
||||||
lisCopyAllAndHiddenMessagesToClipboard = 'Copy all and hidden messages '
|
lisCopyAllAndHiddenMessagesToClipboard = 'Copy all and hidden messages '
|
||||||
+'to clipboard';
|
+'to clipboard';
|
||||||
|
lisCopyItemToClipboard = 'Copy item to clipboard';
|
||||||
|
lisCopySelectedItemToClipboard = 'Copy selected items to clipboard';
|
||||||
|
lisCopyAllItemsToClipboard = 'Copy all items to clipboard';
|
||||||
lisSaveAllMessagesToFile = 'Save all messages to file';
|
lisSaveAllMessagesToFile = 'Save all messages to file';
|
||||||
lisMVDocking = 'Docking';
|
lisMVDocking = 'Docking';
|
||||||
lisMenuViewSearchResults = 'Search Results';
|
lisMenuViewSearchResults = 'Search Results';
|
||||||
|
@ -254,4 +254,20 @@ object SearchResultsView: TSearchResultsView
|
|||||||
0000000000000000000000000000
|
0000000000000000000000000000
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
object popList: TPopupMenu
|
||||||
|
left = 190
|
||||||
|
top = 133
|
||||||
|
object mniCopyItem: TMenuItem
|
||||||
|
Caption = 'Copy Item'
|
||||||
|
OnClick = mniCopyItemClick
|
||||||
|
end
|
||||||
|
object mniCopyAll: TMenuItem
|
||||||
|
Caption = 'Copy All'
|
||||||
|
OnClick = mniCopyAllClick
|
||||||
|
end
|
||||||
|
object mniCopySelected: TMenuItem
|
||||||
|
Caption = 'Copy Selected'
|
||||||
|
OnClick = mniCopySelectedClick
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -38,9 +38,9 @@ interface
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, LCLProc, Forms, Controls, Graphics, Dialogs,
|
Classes, SysUtils, LCLProc, Forms, Controls, Graphics, Dialogs,
|
||||||
ComCtrls, ExtCtrls, StdCtrls, Buttons, LCLType, LCLIntf,
|
ComCtrls, ExtCtrls, StdCtrls, Buttons, LCLType, LCLIntf, Menus,
|
||||||
IDEOptionDefs, LazarusIDEStrConsts, EnvironmentOpts, EditorOptions, InputHistory,
|
IDEOptionDefs, LazarusIDEStrConsts, EnvironmentOpts, EditorOptions, InputHistory,
|
||||||
IDEProcs, FindInFilesDlg, Project, MainIntf;
|
IDEProcs, FindInFilesDlg, Project, MainIntf, Clipbrd;
|
||||||
|
|
||||||
type
|
type
|
||||||
{ TLazSearchMatchPos }
|
{ TLazSearchMatchPos }
|
||||||
@ -129,6 +129,10 @@ type
|
|||||||
{ TSearchResultsView }
|
{ TSearchResultsView }
|
||||||
|
|
||||||
TSearchResultsView = class(TForm)
|
TSearchResultsView = class(TForm)
|
||||||
|
mniCopySelected: TMenuItem;
|
||||||
|
mniCopyAll: TMenuItem;
|
||||||
|
mniCopyItem: TMenuItem;
|
||||||
|
popList: TPopupMenu;
|
||||||
SearchInListEdit: TEdit;
|
SearchInListEdit: TEdit;
|
||||||
ImageList: TImageList;
|
ImageList: TImageList;
|
||||||
ResultsNoteBook: TNotebook;
|
ResultsNoteBook: TNotebook;
|
||||||
@ -142,6 +146,9 @@ type
|
|||||||
procedure ClosePageButtonClick(Sender: TObject);
|
procedure ClosePageButtonClick(Sender: TObject);
|
||||||
procedure Form1Create(Sender: TObject);
|
procedure Form1Create(Sender: TObject);
|
||||||
procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
||||||
|
procedure mniCopyAllClick(Sender: TObject);
|
||||||
|
procedure mniCopyItemClick(Sender: TObject);
|
||||||
|
procedure mniCopySelectedClick(Sender: TObject);
|
||||||
procedure TreeViewKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
procedure TreeViewKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
||||||
procedure ResultsNoteBookClosetabclicked(Sender: TObject);
|
procedure ResultsNoteBookClosetabclicked(Sender: TObject);
|
||||||
procedure SearchAgainButtonClick(Sender: TObject);
|
procedure SearchAgainButtonClick(Sender: TObject);
|
||||||
@ -225,6 +232,22 @@ begin
|
|||||||
Result := True;
|
Result := True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function GetTreeSelectedItemsAsText(ATreeView: TCustomTreeView): string;
|
||||||
|
var
|
||||||
|
sl: TStringList;
|
||||||
|
node: TTreeNode;
|
||||||
|
begin
|
||||||
|
sl:=TStringList.Create;
|
||||||
|
node := ATreeView.GetFirstMultiSelected;
|
||||||
|
while assigned(node) do
|
||||||
|
begin
|
||||||
|
sl.Add(node.Text);
|
||||||
|
node := node.GetNextMultiSelected;
|
||||||
|
end;
|
||||||
|
Result:=sl.Text;
|
||||||
|
sl.Free;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TSearchResultsView.Form1Create(Sender: TObject);
|
procedure TSearchResultsView.Form1Create(Sender: TObject);
|
||||||
var
|
var
|
||||||
ALayout: TIDEWindowLayout;
|
ALayout: TIDEWindowLayout;
|
||||||
@ -251,6 +274,10 @@ begin
|
|||||||
fOnSelectionChanged:= nil;
|
fOnSelectionChanged:= nil;
|
||||||
ShowHint:= True;
|
ShowHint:= True;
|
||||||
fMouseOverIndex:= -1;
|
fMouseOverIndex:= -1;
|
||||||
|
|
||||||
|
mniCopyItem.Caption := lisCopyItemToClipboard;
|
||||||
|
mniCopySelected.Caption := lisCopySelectedItemToClipboard;
|
||||||
|
mniCopyAll.Caption := lisCopyAllItemsToClipboard;
|
||||||
end;//Create
|
end;//Create
|
||||||
|
|
||||||
procedure TSearchResultsView.FormKeyDown(Sender: TObject; var Key: Word;
|
procedure TSearchResultsView.FormKeyDown(Sender: TObject; var Key: Word;
|
||||||
@ -263,6 +290,32 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TSearchResultsView.mniCopyAllClick(Sender: TObject);
|
||||||
|
var
|
||||||
|
sl: TStrings;
|
||||||
|
begin
|
||||||
|
sl := (popList.PopupComponent as TLazSearchResultTV).ItemsAsStrings;
|
||||||
|
Clipboard.AsText := sl.Text;
|
||||||
|
sl.Free;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSearchResultsView.mniCopyItemClick(Sender: TObject);
|
||||||
|
var
|
||||||
|
tv: TCustomTreeView;
|
||||||
|
node: TTreeNode;
|
||||||
|
begin
|
||||||
|
tv := popList.PopupComponent as TCustomTreeView;
|
||||||
|
with tv.ScreenToClient(popList.PopupPoint) do
|
||||||
|
node := tv.GetNodeAt(X, Y);
|
||||||
|
if node <> nil then
|
||||||
|
Clipboard.AsText := node.Text;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSearchResultsView.mniCopySelectedClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
Clipboard.AsText := GetTreeSelectedItemsAsText(popList.PopupComponent as TCustomTreeView);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TSearchResultsView.ClosePageButtonClick(Sender: TObject);
|
procedure TSearchResultsView.ClosePageButtonClick(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
ClosePage(ResultsNoteBook.PageIndex);
|
ClosePage(ResultsNoteBook.PageIndex);
|
||||||
@ -770,6 +823,8 @@ begin
|
|||||||
OnMouseWheel:= @LazTVMouseWheel;
|
OnMouseWheel:= @LazTVMouseWheel;
|
||||||
ShowHint:= true;
|
ShowHint:= true;
|
||||||
RowSelect := True;
|
RowSelect := True;
|
||||||
|
Options := Options + [tvoAllowMultiselect];
|
||||||
|
PopupMenu := popList;
|
||||||
NewTreeView.Canvas.Brush.Color:= clWhite;
|
NewTreeView.Canvas.Brush.Color:= clWhite;
|
||||||
end;//with
|
end;//with
|
||||||
end;//if
|
end;//if
|
||||||
|
Loading…
Reference in New Issue
Block a user