mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-22 20:37:19 -08:00
feature: use Ctrl+C
to copy selected commits in histories (#321)
This commit is contained in:
parent
b059423391
commit
4ba7c879c5
2 changed files with 23 additions and 2 deletions
|
@ -27,10 +27,12 @@
|
|||
ColumnHeaderHeight="24"
|
||||
HorizontalScrollBarVisibility="Disabled"
|
||||
VerticalScrollBarVisibility="Auto"
|
||||
ClipboardCopyMode="None"
|
||||
LayoutUpdated="OnCommitDataGridLayoutUpdated"
|
||||
SelectionChanged="OnCommitDataGridSelectionChanged"
|
||||
ContextRequested="OnCommitDataGridContextRequested"
|
||||
DoubleTapped="OnCommitDataGridDoubleTapped">
|
||||
DoubleTapped="OnCommitDataGridDoubleTapped"
|
||||
KeyDown="OnCommitDataGridKeyDown">
|
||||
<DataGrid.Styles>
|
||||
<Style Selector="DataGridColumnHeader">
|
||||
<Setter Property="MinHeight" Value="24"/>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using System;
|
||||
|
||||
using System.Text;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Primitives;
|
||||
|
@ -419,5 +419,24 @@ namespace SourceGit.Views
|
|||
}
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void OnCommitDataGridKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (sender is DataGrid grid &&
|
||||
grid.SelectedItems is { Count: > 0 } selected &&
|
||||
e.Key == Key.C &&
|
||||
e.KeyModifiers.HasFlag(KeyModifiers.Control))
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
foreach (var item in selected)
|
||||
{
|
||||
if (item is Models.Commit commit)
|
||||
builder.AppendLine($"{commit.SHA.Substring(0, 10)} - {commit.Subject}");
|
||||
}
|
||||
|
||||
App.CopyText(builder.ToString());
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue