mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-11-01 13:13:21 -07:00
feature<DiffViewer, CommitViewer>: override default behaviour while using Ctrl+C to copy selected lines in DataGrid
This commit is contained in:
parent
b81cf63b6f
commit
d1f64b1d12
2 changed files with 32 additions and 0 deletions
|
@ -446,6 +446,21 @@ namespace SourceGit.UI {
|
||||||
grid.FrozenColumnCount = 1;
|
grid.FrozenColumnCount = 1;
|
||||||
grid.ContextMenuOpening += OnPreviewContextMenuOpening;
|
grid.ContextMenuOpening += OnPreviewContextMenuOpening;
|
||||||
grid.RowStyle = FindResource("Style.DataGridRow.NoBringIntoView") as Style;
|
grid.RowStyle = FindResource("Style.DataGridRow.NoBringIntoView") as Style;
|
||||||
|
grid.CommandBindings.Add(new CommandBinding(ApplicationCommands.Copy, (o, e) => {
|
||||||
|
var items = (o as DataGrid).SelectedItems;
|
||||||
|
if (items.Count == 0) return;
|
||||||
|
|
||||||
|
var builder = new StringBuilder();
|
||||||
|
foreach (var item in items) {
|
||||||
|
var line = item as Git.Commit.Line;
|
||||||
|
if (line == null) continue;
|
||||||
|
|
||||||
|
builder.Append(line.Content);
|
||||||
|
builder.AppendLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
Clipboard.SetText(builder.ToString());
|
||||||
|
}));
|
||||||
|
|
||||||
var colLineNumber = new DataGridTextColumn();
|
var colLineNumber = new DataGridTextColumn();
|
||||||
colLineNumber.IsReadOnly = true;
|
colLineNumber.IsReadOnly = true;
|
||||||
|
|
|
@ -6,6 +6,7 @@ using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Data;
|
using System.Windows.Data;
|
||||||
|
using System.Windows.Input;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Shapes;
|
using System.Windows.Shapes;
|
||||||
using System.Windows.Threading;
|
using System.Windows.Threading;
|
||||||
|
@ -425,6 +426,22 @@ namespace SourceGit.UI {
|
||||||
grid.FrozenColumnCount = lineNumbers.Length;
|
grid.FrozenColumnCount = lineNumbers.Length;
|
||||||
grid.ContextMenuOpening += OnTextChangeContextMenuOpening;
|
grid.ContextMenuOpening += OnTextChangeContextMenuOpening;
|
||||||
grid.RowStyle = FindResource("Style.DataGridRow.NoBringIntoView") as Style;
|
grid.RowStyle = FindResource("Style.DataGridRow.NoBringIntoView") as Style;
|
||||||
|
grid.CommandBindings.Add(new CommandBinding(ApplicationCommands.Copy, (o, e) => {
|
||||||
|
var items = (o as DataGrid).SelectedItems;
|
||||||
|
if (items.Count == 0) return;
|
||||||
|
|
||||||
|
var builder = new StringBuilder();
|
||||||
|
foreach (var item in items) {
|
||||||
|
var block = item as ChangeBlock;
|
||||||
|
if (block == null) continue;
|
||||||
|
if (!block.IsContent) continue;
|
||||||
|
|
||||||
|
builder.Append(block.Content);
|
||||||
|
builder.AppendLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
Clipboard.SetText(builder.ToString());
|
||||||
|
}));
|
||||||
|
|
||||||
foreach (var number in lineNumbers) {
|
foreach (var number in lineNumbers) {
|
||||||
var colLineNumber = new DataGridTextColumn();
|
var colLineNumber = new DataGridTextColumn();
|
||||||
|
|
Loading…
Reference in a new issue