mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-26 21:17:20 -08:00
Added Preference and ToggleButton for diff navigation style
This commit is contained in:
parent
2f2579772f
commit
908b982170
5 changed files with 79 additions and 22 deletions
|
@ -133,6 +133,14 @@ namespace SourceGit.ViewModels
|
|||
LoadDiffContent();
|
||||
}
|
||||
|
||||
public void ToggleHighlightedDiffNavigation()
|
||||
{
|
||||
Preference.Instance.EnableChangeBlocks = !Preference.Instance.EnableChangeBlocks;
|
||||
if (_content is Models.TextDiff textDiff)
|
||||
textDiff.CurrentChangeBlockIdx = -1;
|
||||
RefreshChangeBlockIndicator();
|
||||
}
|
||||
|
||||
public void IncrUnified()
|
||||
{
|
||||
UnifiedLines = _unifiedLines + 1;
|
||||
|
@ -145,6 +153,12 @@ namespace SourceGit.ViewModels
|
|||
LoadDiffContent();
|
||||
}
|
||||
|
||||
public void ToggleTwoSideDiff()
|
||||
{
|
||||
Preference.Instance.UseSideBySideDiff = !Preference.Instance.UseSideBySideDiff;
|
||||
RefreshChangeBlockIndicator();
|
||||
}
|
||||
|
||||
public void OpenExternalMergeTool()
|
||||
{
|
||||
var toolType = Preference.Instance.ExternalMergeToolType;
|
||||
|
|
|
@ -206,6 +206,12 @@ namespace SourceGit.ViewModels
|
|||
set => SetProperty(ref _useFullTextDiff, value);
|
||||
}
|
||||
|
||||
public bool EnableChangeBlocks
|
||||
{
|
||||
get => _enableChangeBlocks;
|
||||
set => SetProperty(ref _enableChangeBlocks, value);
|
||||
}
|
||||
|
||||
public Models.ChangeViewMode UnstagedChangeViewMode
|
||||
{
|
||||
get => _unstagedChangeViewMode;
|
||||
|
@ -614,6 +620,7 @@ namespace SourceGit.ViewModels
|
|||
private bool _enableDiffViewWordWrap = false;
|
||||
private bool _showHiddenSymbolsInDiffView = false;
|
||||
private bool _useFullTextDiff = false;
|
||||
private bool _enableChangeBlocks = false;
|
||||
|
||||
private Models.ChangeViewMode _unstagedChangeViewMode = Models.ChangeViewMode.List;
|
||||
private Models.ChangeViewMode _stagedChangeViewMode = Models.ChangeViewMode.List;
|
||||
|
|
|
@ -34,6 +34,15 @@
|
|||
|
||||
<!-- Toolbar Buttons -->
|
||||
<StackPanel Grid.Column="3" Margin="8,0,0,0" Orientation="Horizontal" VerticalAlignment="Center">
|
||||
<ToggleButton Classes="line_path"
|
||||
Width="28"
|
||||
Command="{Binding ToggleHighlightedDiffNavigation}"
|
||||
IsChecked="{Binding Source={x:Static vm:Preference.Instance}, Path=EnableChangeBlocks, Mode=OneWay}"
|
||||
IsVisible="{Binding IsTextDiff}"
|
||||
ToolTip.Tip="{DynamicResource Text.Diff.HighlightedDiffNavigation}">
|
||||
<Path Width="13" Height="13" Data="{StaticResource Icons.Highlight}" Margin="0,3,0,0"/>
|
||||
</ToggleButton>
|
||||
|
||||
<Button Classes="icon_button"
|
||||
Width="28"
|
||||
Click="OnGotoPrevChange"
|
||||
|
@ -45,9 +54,14 @@
|
|||
<TextBlock Classes="primary"
|
||||
Margin="0,0,0,0"
|
||||
Text="{Binding ChangeBlockIndicator}"
|
||||
FontSize="11"
|
||||
TextTrimming="CharacterEllipsis"
|
||||
IsVisible="{Binding IsTextDiff}"/>
|
||||
FontSize="11">
|
||||
<TextBlock.IsVisible>
|
||||
<MultiBinding Converter="{x:Static BoolConverters.And}">
|
||||
<Binding Path="IsTextDiff"/>
|
||||
<Binding Source="{x:Static vm:Preference.Instance}" Path="EnableChangeBlocks" Mode="OneWay"/>
|
||||
</MultiBinding>
|
||||
</TextBlock.IsVisible>
|
||||
</TextBlock>
|
||||
|
||||
<Button Classes="icon_button"
|
||||
Width="28"
|
||||
|
@ -131,7 +145,8 @@
|
|||
|
||||
<ToggleButton Classes="line_path"
|
||||
Width="28" Height="18"
|
||||
IsChecked="{Binding Source={x:Static vm:Preference.Instance}, Path=UseSideBySideDiff, Mode=TwoWay}"
|
||||
Command="{Binding ToggleTwoSideDiff}"
|
||||
IsChecked="{Binding Source={x:Static vm:Preference.Instance}, Path=UseSideBySideDiff, Mode=OneWay}"
|
||||
IsVisible="{Binding IsTextDiff}"
|
||||
ToolTip.Tip="{DynamicResource Text.Diff.SideBySide}">
|
||||
<Path Width="12" Height="12" Data="{StaticResource Icons.LayoutHorizontal}" Margin="0,2,0,0"/>
|
||||
|
|
|
@ -12,6 +12,13 @@ namespace SourceGit.Views
|
|||
}
|
||||
|
||||
private void OnGotoPrevChange(object _, RoutedEventArgs e)
|
||||
{
|
||||
if (ViewModels.Preference.Instance.EnableChangeBlocks)
|
||||
{
|
||||
if (DataContext is ViewModels.DiffContext diffCtx)
|
||||
diffCtx.PrevChange();
|
||||
}
|
||||
else
|
||||
{
|
||||
var textDiff = this.FindDescendantOfType<ThemedTextDiffPresenter>();
|
||||
if (textDiff == null)
|
||||
|
@ -23,8 +30,16 @@ namespace SourceGit.Views
|
|||
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnGotoNextChange(object _, RoutedEventArgs e)
|
||||
{
|
||||
if (ViewModels.Preference.Instance.EnableChangeBlocks)
|
||||
{
|
||||
if (DataContext is ViewModels.DiffContext diffCtx)
|
||||
diffCtx.NextChange();
|
||||
}
|
||||
else
|
||||
{
|
||||
var textDiff = this.FindDescendantOfType<ThemedTextDiffPresenter>();
|
||||
if (textDiff == null)
|
||||
|
@ -37,4 +52,5 @@ namespace SourceGit.Views
|
|||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -635,6 +635,7 @@ namespace SourceGit.Views
|
|||
//TextArea.Caret.BringCaretToView(); // NOTE: Brings caret line (barely) into view.
|
||||
ScrollToLine(changeBlock.StartLine); // NOTE: Brings specified line into center of view.
|
||||
}
|
||||
TextArea.TextView.Redraw();
|
||||
}
|
||||
|
||||
public override void Render(DrawingContext context)
|
||||
|
@ -712,6 +713,10 @@ namespace SourceGit.Views
|
|||
{
|
||||
InvalidateVisual();
|
||||
}
|
||||
else if (change.Property == CurrentChangeBlockIdxProperty)
|
||||
{
|
||||
InvalidateVisual();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTextViewContextRequested(object sender, ContextRequestedEventArgs e)
|
||||
|
@ -1587,7 +1592,7 @@ namespace SourceGit.Views
|
|||
|
||||
CurrentChangeBlockIdxProperty.Changed.AddClassHandler<TextDiffView>((v, e) =>
|
||||
{
|
||||
if ((int)e.NewValue >= 0 && v.Editor.Presenter != null)
|
||||
if (v.Editor.Presenter != null)
|
||||
{
|
||||
foreach (var p in v.Editor.Presenter.GetVisualDescendants().OfType<ThemedTextDiffPresenter>())
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue