feature: add +/- in line number to indicate type of change (#593)

This commit is contained in:
leo 2024-10-23 12:03:22 +08:00
parent 06fd49ba92
commit f6e1e65a53
No known key found for this signature in database

View file

@ -105,6 +105,32 @@ namespace SourceGit.Views
continue; continue;
var y = line.GetTextLineVisualYPosition(line.TextLines[0], VisualYPosition.LineMiddle) - view.VerticalOffset; var y = line.GetTextLineVisualYPosition(line.TextLines[0], VisualYPosition.LineMiddle) - view.VerticalOffset;
var prefix = null as FormattedText;
if (info.Type == Models.TextDiffLineType.Added)
{
prefix = new FormattedText(
"+",
CultureInfo.CurrentCulture,
FlowDirection.LeftToRight,
typeface,
presenter.FontSize,
Brushes.Green);
}
else if (info.Type == Models.TextDiffLineType.Deleted)
{
prefix = new FormattedText(
"-",
CultureInfo.CurrentCulture,
FlowDirection.LeftToRight,
typeface,
presenter.FontSize,
Brushes.Red);
}
if (prefix != null)
context.DrawText(prefix, new Point(0, y - prefix.Height * 0.5));
var txt = new FormattedText( var txt = new FormattedText(
lineNumber, lineNumber,
CultureInfo.CurrentCulture, CultureInfo.CurrentCulture,
@ -126,7 +152,7 @@ namespace SourceGit.Views
var maxLineNumber = presenter.GetMaxLineNumber(); var maxLineNumber = presenter.GetMaxLineNumber();
var typeface = TextView.CreateTypeface(); var typeface = TextView.CreateTypeface();
var test = new FormattedText( var test = new FormattedText(
$"{maxLineNumber}", $"- {maxLineNumber}",
CultureInfo.CurrentCulture, CultureInfo.CurrentCulture,
FlowDirection.LeftToRight, FlowDirection.LeftToRight,
typeface, typeface,