diff --git a/src/Views/Blame.axaml.cs b/src/Views/Blame.axaml.cs index 68e14de5..db4f8437 100644 --- a/src/Views/Blame.axaml.cs +++ b/src/Views/Blame.axaml.cs @@ -33,7 +33,7 @@ namespace SourceGit.Views return; var view = TextView; - if (view != null && view.VisualLinesValid) + if (view is { VisualLinesValid: true }) { var typeface = view.CreateTypeface(); var underlinePen = new Pen(Brushes.DarkOrange); @@ -142,12 +142,53 @@ namespace SourceGit.Views return new Size(maxWidth, 0); } + protected override void OnPointerMoved(PointerEventArgs e) + { + base.OnPointerMoved(e); + + var view = TextView; + if (!e.Handled && view is { VisualLinesValid: true }) + { + var pos = e.GetPosition(this); + var typeface = view.CreateTypeface(); + + foreach (var line in view.VisualLines) + { + if (line.IsDisposed || line.FirstDocumentLine == null || line.FirstDocumentLine.IsDeleted) + continue; + + var lineNumber = line.FirstDocumentLine.LineNumber; + if (lineNumber >= _editor.BlameData.LineInfos.Count) + break; + + var info = _editor.BlameData.LineInfos[lineNumber - 1]; + var y = line.GetTextLineVisualYPosition(line.TextLines[0], VisualYPosition.TextTop) - view.VerticalOffset; + var shaLink = new FormattedText( + info.CommitSHA, + CultureInfo.CurrentCulture, + FlowDirection.LeftToRight, + typeface, + _editor.FontSize, + Brushes.DarkOrange); + + var rect = new Rect(0, y, shaLink.Width, shaLink.Height); + if (rect.Contains(pos)) + { + Cursor = Cursor.Parse("Hand"); + return; + } + } + } + + Cursor = Cursor.Default; + } + protected override void OnPointerPressed(PointerPressedEventArgs e) { base.OnPointerPressed(e); var view = TextView; - if (!e.Handled && e.GetCurrentPoint(this).Properties.IsLeftButtonPressed && view != null && view.VisualLinesValid) + if (!e.Handled && e.GetCurrentPoint(this).Properties.IsLeftButtonPressed && view is { VisualLinesValid: true }) { var pos = e.GetPosition(this); var typeface = view.CreateTypeface(); diff --git a/src/Views/FileHistories.axaml b/src/Views/FileHistories.axaml index bdd4918b..bc048706 100644 --- a/src/Views/FileHistories.axaml +++ b/src/Views/FileHistories.axaml @@ -87,6 +87,7 @@