Skip to content

Commit 3b09ea4

Browse files
committed
feature: add change minimap for text diff view
Signed-off-by: leo <[email protected]>
1 parent b7abf2e commit 3b09ea4

File tree

3 files changed

+216
-66
lines changed

3 files changed

+216
-66
lines changed

src/Views/CommitRefsPresenter.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public double FontSize
3838
}
3939

4040
public static readonly StyledProperty<IBrush> BackgroundProperty =
41-
AvaloniaProperty.Register<CommitRefsPresenter, IBrush>(nameof(Background), null);
41+
AvaloniaProperty.Register<CommitRefsPresenter, IBrush>(nameof(Background), Brushes.Transparent);
4242

4343
public IBrush Background
4444
{
@@ -56,7 +56,7 @@ public IBrush Foreground
5656
}
5757

5858
public static readonly StyledProperty<bool> UseGraphColorProperty =
59-
AvaloniaProperty.Register<CommitRefsPresenter, bool>(nameof(UseGraphColor), false);
59+
AvaloniaProperty.Register<CommitRefsPresenter, bool>(nameof(UseGraphColor));
6060

6161
public bool UseGraphColor
6262
{
@@ -96,7 +96,6 @@ public override void Render(DrawingContext context)
9696
var x = 1.0;
9797
foreach (var item in _items)
9898
{
99-
var iconRect = new RoundedRect(new Rect(x, 0, 16, 16), new CornerRadius(2, 0, 0, 2));
10099
var entireRect = new RoundedRect(new Rect(x, 0, item.Width, 16), new CornerRadius(2));
101100

102101
if (item.IsHead)

src/Views/TextDiffView.axaml

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,39 @@
1313
<ContentControl x:Name="Editor">
1414
<ContentControl.DataTemplates>
1515
<DataTemplate DataType="m:TextDiff">
16-
<v:CombinedTextDiffPresenter FileName="{Binding File}"
17-
Foreground="{DynamicResource Brush.FG1}"
18-
LineBrush="{DynamicResource Brush.Border2}"
19-
EmptyContentBackground="{DynamicResource Brush.Diff.EmptyBG}"
20-
AddedContentBackground="{DynamicResource Brush.Diff.AddedBG}"
21-
DeletedContentBackground="{DynamicResource Brush.Diff.DeletedBG}"
22-
AddedHighlightBrush="{DynamicResource Brush.Diff.AddedHighlight}"
23-
DeletedHighlightBrush="{DynamicResource Brush.Diff.DeletedHighlight}"
24-
IndicatorForeground="{DynamicResource Brush.FG2}"
25-
FontFamily="{DynamicResource Fonts.Monospace}"
26-
FontSize="{Binding Source={x:Static vm:Preference.Instance}, Path=EditorFontSize}"
27-
UseSyntaxHighlighting="{Binding Source={x:Static vm:Preference.Instance}, Path=UseSyntaxHighlighting}"
28-
WordWrap="{Binding Source={x:Static vm:Preference.Instance}, Path=EnableDiffViewWordWrap}"
29-
ShowHiddenSymbols="{Binding Source={x:Static vm:Preference.Instance}, Path=ShowHiddenSymbolsInDiffView}"
30-
EnableChunkSelection="{Binding #ThisControl.EnableChunkSelection}"
31-
SelectedChunk="{Binding #ThisControl.SelectedChunk, Mode=TwoWay}"/>
16+
<Grid ColumnDefinitions="*,1,8">
17+
<v:CombinedTextDiffPresenter Grid.Column="0"
18+
x:Name="CombinedPresenter"
19+
FileName="{Binding File}"
20+
Foreground="{DynamicResource Brush.FG1}"
21+
LineBrush="{DynamicResource Brush.Border2}"
22+
EmptyContentBackground="{DynamicResource Brush.Diff.EmptyBG}"
23+
AddedContentBackground="{DynamicResource Brush.Diff.AddedBG}"
24+
DeletedContentBackground="{DynamicResource Brush.Diff.DeletedBG}"
25+
AddedHighlightBrush="{DynamicResource Brush.Diff.AddedHighlight}"
26+
DeletedHighlightBrush="{DynamicResource Brush.Diff.DeletedHighlight}"
27+
IndicatorForeground="{DynamicResource Brush.FG2}"
28+
FontFamily="{DynamicResource Fonts.Monospace}"
29+
FontSize="{Binding Source={x:Static vm:Preference.Instance}, Path=EditorFontSize}"
30+
UseSyntaxHighlighting="{Binding Source={x:Static vm:Preference.Instance}, Path=UseSyntaxHighlighting}"
31+
WordWrap="{Binding Source={x:Static vm:Preference.Instance}, Path=EnableDiffViewWordWrap}"
32+
ShowHiddenSymbols="{Binding Source={x:Static vm:Preference.Instance}, Path=ShowHiddenSymbolsInDiffView}"
33+
EnableChunkSelection="{Binding #ThisControl.EnableChunkSelection}"
34+
SelectedChunk="{Binding #ThisControl.SelectedChunk, Mode=TwoWay}"/>
35+
36+
<Rectangle Grid.Column="1" Fill="{DynamicResource Brush.Border2}" Width="1" HorizontalAlignment="Center" VerticalAlignment="Stretch"/>
37+
38+
<v:TextDiffViewMinimap Grid.Column="2"
39+
DisplayRange="{Binding #CombinedPresenter.DisplayRange}"
40+
AddedLineBrush="{DynamicResource Brush.Diff.AddedBG}"
41+
DeletedLineBrush="{DynamicResource Brush.Diff.DeletedBG}"/>
42+
</Grid>
3243
</DataTemplate>
3344

3445
<DataTemplate DataType="vm:TwoSideTextDiff">
35-
<Grid ColumnDefinitions="*,1,*">
46+
<Grid ColumnDefinitions="*,1,*,1,12">
3647
<v:SingleSideTextDiffPresenter Grid.Column="0"
48+
x:Name="LeftSidePresenter"
3749
IsOld="True"
3850
FileName="{Binding File}"
3951
Foreground="{DynamicResource Brush.FG1}"
@@ -72,6 +84,13 @@
7284
ShowHiddenSymbols="{Binding Source={x:Static vm:Preference.Instance}, Path=ShowHiddenSymbolsInDiffView}"
7385
EnableChunkSelection="{Binding #ThisControl.EnableChunkSelection}"
7486
SelectedChunk="{Binding #ThisControl.SelectedChunk, Mode=TwoWay}"/>
87+
88+
<Rectangle Grid.Column="3" Fill="{DynamicResource Brush.Border2}" Width="1" HorizontalAlignment="Center" VerticalAlignment="Stretch"/>
89+
90+
<v:TextDiffViewMinimap Grid.Column="4"
91+
DisplayRange="{Binding #LeftSidePresenter.DisplayRange}"
92+
AddedLineBrush="{DynamicResource Brush.Diff.AddedBG}"
93+
DeletedLineBrush="{DynamicResource Brush.Diff.DeletedBG}"/>
7594
</Grid>
7695
</DataTemplate>
7796
</ContentControl.DataTemplates>

0 commit comments

Comments
 (0)