gdb com, add ctxt menu item to copy as a markdown table

This commit is contained in:
Basile Burg 2017-03-04 10:30:55 +01:00
parent 46d5ad7e20
commit 6726fe176e
No known key found for this signature in database
GPG Key ID: 1868039F415CB8CF
1 changed files with 28 additions and 0 deletions

View File

@ -146,6 +146,7 @@ type
procedure copyColumn(sender: TObject); procedure copyColumn(sender: TObject);
procedure copyAll(sender: TObject); procedure copyAll(sender: TObject);
procedure copyAllAsList(sender: TObject); procedure copyAllAsList(sender: TObject);
procedure copyAllAsMarkdown(sender: TObject);
public public
constructor create(aOwner: TComponent); override; constructor create(aOwner: TComponent); override;
end; end;
@ -668,6 +669,11 @@ begin
itm.Caption := 'copy all as list'; itm.Caption := 'copy all as list';
itm.OnClick := @copyAllAsList; itm.OnClick := @copyAllAsList;
items.Add(itm); items.Add(itm);
itm := TMenuItem.Create(self);
itm.Caption := 'copy all as markdown table';
itm.OnClick := @copyAllAsMarkdown;
items.Add(itm);
end; end;
function TCEListViewCopyMenu.getColumnIndex: integer; function TCEListViewCopyMenu.getColumnIndex: integer;
@ -813,5 +819,27 @@ begin
clipboard.AsText := s; clipboard.AsText := s;
end; end;
procedure TCEListViewCopyMenu.copyAllAsMarkdown(sender: TObject);
var
s: string = '';
c: integer;
i: integer;
begin
c := fList.Items.Count - 1;
for i:= 0 to fList.ColumnCount-1 do
s += '| ' + fList.Column[i].Caption;
s += LineEnding;
for i:= 0 to fList.ColumnCount-1 do
s += '| ---';
s += LineEnding;
for i := 0 to c do
begin
s += getLine(fList.Items[i]);
if i <> c then
s += LineEnding;
end;
clipboard.AsText := s;
end;
end. end.