mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-23 20:47:25 -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"
|
ColumnHeaderHeight="24"
|
||||||
HorizontalScrollBarVisibility="Disabled"
|
HorizontalScrollBarVisibility="Disabled"
|
||||||
VerticalScrollBarVisibility="Auto"
|
VerticalScrollBarVisibility="Auto"
|
||||||
|
ClipboardCopyMode="None"
|
||||||
LayoutUpdated="OnCommitDataGridLayoutUpdated"
|
LayoutUpdated="OnCommitDataGridLayoutUpdated"
|
||||||
SelectionChanged="OnCommitDataGridSelectionChanged"
|
SelectionChanged="OnCommitDataGridSelectionChanged"
|
||||||
ContextRequested="OnCommitDataGridContextRequested"
|
ContextRequested="OnCommitDataGridContextRequested"
|
||||||
DoubleTapped="OnCommitDataGridDoubleTapped">
|
DoubleTapped="OnCommitDataGridDoubleTapped"
|
||||||
|
KeyDown="OnCommitDataGridKeyDown">
|
||||||
<DataGrid.Styles>
|
<DataGrid.Styles>
|
||||||
<Style Selector="DataGridColumnHeader">
|
<Style Selector="DataGridColumnHeader">
|
||||||
<Setter Property="MinHeight" Value="24"/>
|
<Setter Property="MinHeight" Value="24"/>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Text;
|
||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Controls.Primitives;
|
using Avalonia.Controls.Primitives;
|
||||||
|
@ -419,5 +419,24 @@ namespace SourceGit.Views
|
||||||
}
|
}
|
||||||
e.Handled = true;
|
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