mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-21 12:15:00 +00:00
parent
5e898a809e
commit
269903503f
4 changed files with 62 additions and 15 deletions
|
@ -57,6 +57,11 @@ namespace SourceGit.ViewModels
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Models.Commit GetCommitInfo(string commitSHA)
|
||||||
|
{
|
||||||
|
return new Commands.QuerySingleCommit(_repo, commitSHA).Result();
|
||||||
|
}
|
||||||
|
|
||||||
private readonly string _repo;
|
private readonly string _repo;
|
||||||
private Models.BlameData _data = null;
|
private Models.BlameData _data = null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:m="using:SourceGit.Models"
|
||||||
xmlns:vm="using:SourceGit.ViewModels"
|
xmlns:vm="using:SourceGit.ViewModels"
|
||||||
xmlns:v="using:SourceGit.Views"
|
xmlns:v="using:SourceGit.Views"
|
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
|
@ -59,8 +60,22 @@
|
||||||
FontFamily="{DynamicResource Fonts.Monospace}"
|
FontFamily="{DynamicResource Fonts.Monospace}"
|
||||||
FontSize="{Binding Source={x:Static vm:Preferences.Instance}, Path=EditorFontSize}"
|
FontSize="{Binding Source={x:Static vm:Preferences.Instance}, Path=EditorFontSize}"
|
||||||
TabWidth="{Binding Source={x:Static vm:Preferences.Instance}, Path=EditorTabWidth}"
|
TabWidth="{Binding Source={x:Static vm:Preferences.Instance}, Path=EditorTabWidth}"
|
||||||
BlameData="{Binding Data}"/>
|
BlameData="{Binding Data}">
|
||||||
|
<v:BlameTextEditor.DataTemplates>
|
||||||
|
<DataTemplate DataType="m:Commit">
|
||||||
|
<StackPanel MinWidth="400" Orientation="Vertical">
|
||||||
|
<Grid ColumnDefinitions="Auto,*,Auto">
|
||||||
|
<v:Avatar Grid.Column="0" Width="16" Height="16" VerticalAlignment="Center" IsHitTestVisible="False" User="{Binding Author}"/>
|
||||||
|
<TextBlock Grid.Column="1" Classes="primary" Text="{Binding Author.Name}" Margin="8,0,0,0"/>
|
||||||
|
<TextBlock Grid.Column="2" Classes="primary" Text="{Binding CommitterTimeStr}" Foreground="{DynamicResource Brush.FG2}" Margin="8,0,0,0"/>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<TextBlock Classes="primary" Margin="0,8,0,0" Text="{Binding Subject}" TextWrapping="Wrap"/>
|
||||||
|
</StackPanel>
|
||||||
|
</DataTemplate>
|
||||||
|
</v:BlameTextEditor.DataTemplates>
|
||||||
|
</v:BlameTextEditor>
|
||||||
|
|
||||||
<!-- Not supported mask (for binary files) -->
|
<!-- Not supported mask (for binary files) -->
|
||||||
<StackPanel Orientation="Vertical"
|
<StackPanel Orientation="Vertical"
|
||||||
HorizontalAlignment="Center" VerticalAlignment="Center"
|
HorizontalAlignment="Center" VerticalAlignment="Center"
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Input;
|
using Avalonia.Input;
|
||||||
using Avalonia.Interactivity;
|
using Avalonia.Interactivity;
|
||||||
using Avalonia.Media;
|
using Avalonia.Media;
|
||||||
|
using Avalonia.Threading;
|
||||||
using AvaloniaEdit;
|
using AvaloniaEdit;
|
||||||
using AvaloniaEdit.Document;
|
using AvaloniaEdit.Document;
|
||||||
using AvaloniaEdit.Editing;
|
using AvaloniaEdit.Editing;
|
||||||
|
@ -162,7 +162,8 @@ namespace SourceGit.Views
|
||||||
break;
|
break;
|
||||||
|
|
||||||
var info = _editor.BlameData.LineInfos[lineNumber - 1];
|
var info = _editor.BlameData.LineInfos[lineNumber - 1];
|
||||||
var y = line.GetTextLineVisualYPosition(line.TextLines[0], VisualYPosition.TextTop) - view.VerticalOffset;
|
var y = line.GetTextLineVisualYPosition(line.TextLines[0], VisualYPosition.TextTop)
|
||||||
|
- view.VerticalOffset;
|
||||||
var shaLink = new FormattedText(
|
var shaLink = new FormattedText(
|
||||||
info.CommitSHA,
|
info.CommitSHA,
|
||||||
CultureInfo.CurrentCulture,
|
CultureInfo.CurrentCulture,
|
||||||
|
@ -175,12 +176,38 @@ namespace SourceGit.Views
|
||||||
if (rect.Contains(pos))
|
if (rect.Contains(pos))
|
||||||
{
|
{
|
||||||
Cursor = Cursor.Parse("Hand");
|
Cursor = Cursor.Parse("Hand");
|
||||||
|
|
||||||
|
// check if the tooltip is already set
|
||||||
|
var tooltip = ToolTip.GetTip(this);
|
||||||
|
if (tooltip is Models.Commit existedCommit && existedCommit.SHA == info.CommitSHA)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (DataContext is ViewModels.Blame blame)
|
||||||
|
{
|
||||||
|
Task.Run(() =>
|
||||||
|
{
|
||||||
|
var commit = blame.GetCommitInfo(info.CommitSHA);
|
||||||
|
if (commit == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Dispatcher.UIThread.Invoke(() =>
|
||||||
|
{
|
||||||
|
if (IsEffectivelyVisible && IsPointerOver)
|
||||||
|
{
|
||||||
|
ToolTip.SetTip(this, commit);
|
||||||
|
ToolTip.SetIsOpen(this, true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Cursor = Cursor.Default;
|
Cursor = Cursor.Default;
|
||||||
|
ToolTip.SetIsOpen(this, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnPointerPressed(PointerPressedEventArgs e)
|
protected override void OnPointerPressed(PointerPressedEventArgs e)
|
||||||
|
@ -230,9 +257,9 @@ namespace SourceGit.Views
|
||||||
private readonly BlameTextEditor _editor = null;
|
private readonly BlameTextEditor _editor = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class VerticalSeperatorMargin : AbstractMargin
|
public class VerticalSeparatorMargin : AbstractMargin
|
||||||
{
|
{
|
||||||
public VerticalSeperatorMargin(BlameTextEditor editor)
|
public VerticalSeparatorMargin(BlameTextEditor editor)
|
||||||
{
|
{
|
||||||
_editor = editor;
|
_editor = editor;
|
||||||
}
|
}
|
||||||
|
@ -284,9 +311,9 @@ namespace SourceGit.Views
|
||||||
_textMate = Models.TextMateHelper.CreateForEditor(this);
|
_textMate = Models.TextMateHelper.CreateForEditor(this);
|
||||||
|
|
||||||
TextArea.LeftMargins.Add(new LineNumberMargin() { Margin = new Thickness(8, 0) });
|
TextArea.LeftMargins.Add(new LineNumberMargin() { Margin = new Thickness(8, 0) });
|
||||||
TextArea.LeftMargins.Add(new VerticalSeperatorMargin(this));
|
TextArea.LeftMargins.Add(new VerticalSeparatorMargin(this));
|
||||||
TextArea.LeftMargins.Add(new CommitInfoMargin(this) { Margin = new Thickness(8, 0) });
|
TextArea.LeftMargins.Add(new CommitInfoMargin(this) { Margin = new Thickness(8, 0) });
|
||||||
TextArea.LeftMargins.Add(new VerticalSeperatorMargin(this));
|
TextArea.LeftMargins.Add(new VerticalSeparatorMargin(this));
|
||||||
TextArea.Caret.PositionChanged += OnTextAreaCaretPositionChanged;
|
TextArea.Caret.PositionChanged += OnTextAreaCaretPositionChanged;
|
||||||
TextArea.LayoutUpdated += OnTextAreaLayoutUpdated;
|
TextArea.LayoutUpdated += OnTextAreaLayoutUpdated;
|
||||||
TextArea.PointerWheelChanged += OnTextAreaPointerWheelChanged;
|
TextArea.PointerWheelChanged += OnTextAreaPointerWheelChanged;
|
||||||
|
|
|
@ -60,7 +60,7 @@ namespace SourceGit.Views
|
||||||
|
|
||||||
public class ThemedTextDiffPresenter : TextEditor
|
public class ThemedTextDiffPresenter : TextEditor
|
||||||
{
|
{
|
||||||
public class VerticalSeperatorMargin : AbstractMargin
|
public class VerticalSeparatorMargin : AbstractMargin
|
||||||
{
|
{
|
||||||
public override void Render(DrawingContext context)
|
public override void Render(DrawingContext context)
|
||||||
{
|
{
|
||||||
|
@ -1085,9 +1085,9 @@ namespace SourceGit.Views
|
||||||
public CombinedTextDiffPresenter() : base(new TextArea(), new TextDocument())
|
public CombinedTextDiffPresenter() : base(new TextArea(), new TextDocument())
|
||||||
{
|
{
|
||||||
TextArea.LeftMargins.Add(new LineNumberMargin(false, true));
|
TextArea.LeftMargins.Add(new LineNumberMargin(false, true));
|
||||||
TextArea.LeftMargins.Add(new VerticalSeperatorMargin());
|
TextArea.LeftMargins.Add(new VerticalSeparatorMargin());
|
||||||
TextArea.LeftMargins.Add(new LineNumberMargin(false, false));
|
TextArea.LeftMargins.Add(new LineNumberMargin(false, false));
|
||||||
TextArea.LeftMargins.Add(new VerticalSeperatorMargin());
|
TextArea.LeftMargins.Add(new VerticalSeparatorMargin());
|
||||||
TextArea.LeftMargins.Add(new LineModifyTypeMargin());
|
TextArea.LeftMargins.Add(new LineModifyTypeMargin());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1286,7 +1286,7 @@ namespace SourceGit.Views
|
||||||
public SingleSideTextDiffPresenter() : base(new TextArea(), new TextDocument())
|
public SingleSideTextDiffPresenter() : base(new TextArea(), new TextDocument())
|
||||||
{
|
{
|
||||||
TextArea.LeftMargins.Add(new LineNumberMargin(true, false));
|
TextArea.LeftMargins.Add(new LineNumberMargin(true, false));
|
||||||
TextArea.LeftMargins.Add(new VerticalSeperatorMargin());
|
TextArea.LeftMargins.Add(new VerticalSeparatorMargin());
|
||||||
TextArea.LeftMargins.Add(new LineModifyTypeMargin());
|
TextArea.LeftMargins.Add(new LineModifyTypeMargin());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue