mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-10-31 13:03:20 -07:00
enhance: save last visual line numbers in diff view (#207)
This commit is contained in:
parent
d43f88da03
commit
faabfd6b80
7 changed files with 53 additions and 23 deletions
|
@ -333,6 +333,7 @@
|
|||
<x:String x:Key="Text.Preference.General.RestoreTabs" xml:space="preserve">Restore windows</x:String>
|
||||
<x:String x:Key="Text.Preference.General.SubjectGuideLength" xml:space="preserve">Subject Guide Length</x:String>
|
||||
<x:String x:Key="Text.Preference.General.UseFixedTabWidth" xml:space="preserve">Use fixed tab width in titlebar</x:String>
|
||||
<x:String x:Key="Text.Preference.General.VisibleDiffContextLines" xml:space="preserve">Visible Diff Context Lines</x:String>
|
||||
<x:String x:Key="Text.Preference.Git" xml:space="preserve">GIT</x:String>
|
||||
<x:String x:Key="Text.Preference.Git.AutoFetch" xml:space="preserve">Fetch remotes automatically</x:String>
|
||||
<x:String x:Key="Text.Preference.Git.AutoFetchInterval" xml:space="preserve">Auto Fetch Interval</x:String>
|
||||
|
|
|
@ -336,6 +336,7 @@
|
|||
<x:String x:Key="Text.Preference.General.RestoreTabs" xml:space="preserve">启动时恢复上次打开的仓库</x:String>
|
||||
<x:String x:Key="Text.Preference.General.SubjectGuideLength" xml:space="preserve">SUBJECT字数检测</x:String>
|
||||
<x:String x:Key="Text.Preference.General.UseFixedTabWidth" xml:space="preserve">使用固定宽度的标题栏标签</x:String>
|
||||
<x:String x:Key="Text.Preference.General.VisibleDiffContextLines" xml:space="preserve">DIFF上下文行数</x:String>
|
||||
<x:String x:Key="Text.Preference.Git" xml:space="preserve">GIT配置</x:String>
|
||||
<x:String x:Key="Text.Preference.Git.AutoFetch" xml:space="preserve">启用定时自动拉取远程更新</x:String>
|
||||
<x:String x:Key="Text.Preference.Git.AutoFetchInterval" xml:space="preserve">自动拉取间隔</x:String>
|
||||
|
|
|
@ -336,6 +336,7 @@
|
|||
<x:String x:Key="Text.Preference.General.RestoreTabs" xml:space="preserve">啟動時恢復上次開啟的倉庫</x:String>
|
||||
<x:String x:Key="Text.Preference.General.SubjectGuideLength" xml:space="preserve">SUBJECT字數檢測</x:String>
|
||||
<x:String x:Key="Text.Preference.General.UseFixedTabWidth" xml:space="preserve">使用固定寬度的標題欄標籤</x:String>
|
||||
<x:String x:Key="Text.Preference.General.VisibleDiffContextLines" xml:space="preserve">DIFF上下文行數</x:String>
|
||||
<x:String x:Key="Text.Preference.Git" xml:space="preserve">GIT配置</x:String>
|
||||
<x:String x:Key="Text.Preference.Git.AutoFetch" xml:space="preserve">啟用定時自動拉取遠端更新</x:String>
|
||||
<x:String x:Key="Text.Preference.Git.AutoFetchInterval" xml:space="preserve">自動拉取間隔</x:String>
|
||||
|
|
|
@ -57,16 +57,6 @@ namespace SourceGit.ViewModels
|
|||
private set => SetProperty(ref _content, value);
|
||||
}
|
||||
|
||||
public int Unified
|
||||
{
|
||||
get => _unified;
|
||||
set
|
||||
{
|
||||
if (SetProperty(ref _unified, value))
|
||||
LoadDiffContent();
|
||||
}
|
||||
}
|
||||
|
||||
public DiffContext(string repo, Models.DiffOption option, DiffContext previous = null)
|
||||
{
|
||||
_repo = repo;
|
||||
|
@ -88,12 +78,20 @@ namespace SourceGit.ViewModels
|
|||
|
||||
public void IncrUnified()
|
||||
{
|
||||
Unified = _unified + 1;
|
||||
var pref = Preference.Instance;
|
||||
pref.DiffViewVisualLineNumbers = pref.DiffViewVisualLineNumbers + 1;
|
||||
LoadDiffContent();
|
||||
}
|
||||
|
||||
public void DecrUnified()
|
||||
{
|
||||
Unified = Math.Max(4, _unified - 1);
|
||||
var pref = Preference.Instance;
|
||||
var unified = pref.DiffViewVisualLineNumbers - 1;
|
||||
if (pref.DiffViewVisualLineNumbers != unified)
|
||||
{
|
||||
pref.DiffViewVisualLineNumbers = unified;
|
||||
LoadDiffContent();
|
||||
}
|
||||
}
|
||||
|
||||
public void OpenExternalMergeTool()
|
||||
|
@ -105,9 +103,10 @@ namespace SourceGit.ViewModels
|
|||
|
||||
private void LoadDiffContent()
|
||||
{
|
||||
var unified = Preference.Instance.DiffViewVisualLineNumbers;
|
||||
Task.Run(() =>
|
||||
{
|
||||
var latest = new Commands.Diff(_repo, _option, _unified).Result();
|
||||
var latest = new Commands.Diff(_repo, _option, unified).Result();
|
||||
var rs = null as object;
|
||||
|
||||
if (latest.TextDiff != null)
|
||||
|
@ -238,6 +237,5 @@ namespace SourceGit.ViewModels
|
|||
private bool _isLoading = true;
|
||||
private bool _isTextDiff = false;
|
||||
private object _content = null;
|
||||
private int _unified = 4;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -194,6 +194,12 @@ namespace SourceGit.ViewModels
|
|||
set => SetProperty(ref _showHiddenSymbolsInDiffView, value);
|
||||
}
|
||||
|
||||
public int DiffViewVisualLineNumbers
|
||||
{
|
||||
get => _diffViewVisualLineNumbers;
|
||||
set => SetProperty(ref _diffViewVisualLineNumbers, value);
|
||||
}
|
||||
|
||||
public Models.ChangeViewMode UnstagedChangeViewMode
|
||||
{
|
||||
get => _unstagedChangeViewMode;
|
||||
|
@ -550,6 +556,7 @@ namespace SourceGit.ViewModels
|
|||
private bool _useSyntaxHighlighting = false;
|
||||
private bool _enableDiffViewWordWrap = false;
|
||||
private bool _showHiddenSymbolsInDiffView = false;
|
||||
private int _diffViewVisualLineNumbers = 4;
|
||||
|
||||
private Models.ChangeViewMode _unstagedChangeViewMode = Models.ChangeViewMode.List;
|
||||
private Models.ChangeViewMode _stagedChangeViewMode = Models.ChangeViewMode.List;
|
||||
|
|
|
@ -34,11 +34,20 @@
|
|||
|
||||
<!-- Toolbar Buttons -->
|
||||
<StackPanel Grid.Column="3" Margin="8,0,0,0" Orientation="Horizontal" VerticalAlignment="Center">
|
||||
<Button Classes="icon_button" Width="32" Command="{Binding IncrUnified}" IsVisible="{Binding IsTextDiff}" ToolTip.Tip="{DynamicResource Text.Diff.VisualLines.Incr}">
|
||||
<Button Classes="icon_button"
|
||||
Width="32"
|
||||
Command="{Binding IncrUnified}"
|
||||
IsVisible="{Binding IsTextDiff}"
|
||||
ToolTip.Tip="{DynamicResource Text.Diff.VisualLines.Incr}">
|
||||
<Path Width="12" Height="12" Stretch="Uniform" Margin="0,6,0,0" Data="{StaticResource Icons.Lines.Incr}"/>
|
||||
</Button>
|
||||
|
||||
<Button Classes="icon_button" Width="32" Command="{Binding DecrUnified}" IsVisible="{Binding IsTextDiff}" ToolTip.Tip="{DynamicResource Text.Diff.VisualLines.Decr}" IsEnabled="{Binding Unified, Converter={x:Static c:IntConverters.IsGreaterThanFour}}">
|
||||
<Button Classes="icon_button"
|
||||
Width="32"
|
||||
Command="{Binding DecrUnified}"
|
||||
IsVisible="{Binding IsTextDiff}"
|
||||
ToolTip.Tip="{DynamicResource Text.Diff.VisualLines.Decr}"
|
||||
IsEnabled="{Binding Source={x:Static vm:Preference.Instance}, Path=DiffViewVisualLineNumbers, Converter={x:Static c:IntConverters.IsGreaterThanFour}}">
|
||||
<Path Width="12" Height="12" Stretch="Uniform" Margin="0,6,0,0" Data="{StaticResource Icons.Lines.Decr}"/>
|
||||
</Button>
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@
|
|||
<TabItem.Header>
|
||||
<TextBlock Classes="tab_header" Text="{DynamicResource Text.Preference.General}"/>
|
||||
</TabItem.Header>
|
||||
<Grid Margin="8" RowDefinitions="32,32,32,32,32,32,32" ColumnDefinitions="Auto,*">
|
||||
<Grid Margin="8" RowDefinitions="32,32,32,32,32,32,32,32" ColumnDefinitions="Auto,*">
|
||||
<TextBlock Grid.Row="0" Grid.Column="0"
|
||||
Text="{DynamicResource Text.Preference.General.Locale}"
|
||||
HorizontalAlignment="Right"
|
||||
|
@ -87,10 +87,23 @@
|
|||
</ComboBox>
|
||||
|
||||
<TextBlock Grid.Row="2" Grid.Column="0"
|
||||
Text="{DynamicResource Text.Preference.General.SubjectGuideLength}"
|
||||
Text="{DynamicResource Text.Preference.General.VisibleDiffContextLines}"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0,0,16,0"/>
|
||||
<NumericUpDown Grid.Row="2" Grid.Column="1"
|
||||
Minimum="4" Maximum="10000" Increment="1"
|
||||
Height="28"
|
||||
Padding="4"
|
||||
ShowButtonSpinner="False"
|
||||
BorderThickness="1" BorderBrush="{DynamicResource Brush.Border1}"
|
||||
CornerRadius="3"
|
||||
Value="{Binding DiffViewVisualLineNumbers, Mode=TwoWay}"/>
|
||||
|
||||
<TextBlock Grid.Row="3" Grid.Column="0"
|
||||
Text="{DynamicResource Text.Preference.General.SubjectGuideLength}"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0,0,16,0"/>
|
||||
<NumericUpDown Grid.Row="3" Grid.Column="1"
|
||||
Minimum="50" Maximum="1000" Increment="1"
|
||||
Height="28"
|
||||
Padding="4"
|
||||
|
@ -99,11 +112,11 @@
|
|||
CornerRadius="3"
|
||||
Value="{Binding SubjectGuideLength, Mode=TwoWay}"/>
|
||||
|
||||
<TextBlock Grid.Row="3" Grid.Column="0"
|
||||
<TextBlock Grid.Row="4" Grid.Column="0"
|
||||
Text="{DynamicResource Text.Preference.General.MaxHistoryCommits}"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0,0,16,0"/>
|
||||
<Grid Grid.Row="3" Grid.Column="1" ColumnDefinitions="*,64">
|
||||
<Grid Grid.Row="4" Grid.Column="1" ColumnDefinitions="*,64">
|
||||
<Slider Grid.Column="0"
|
||||
Minimum="20000" Maximum="100000"
|
||||
TickPlacement="BottomRight" TickFrequency="5000"
|
||||
|
@ -127,16 +140,16 @@
|
|||
Text="{Binding MaxHistoryCommits}"/>
|
||||
</Grid>
|
||||
|
||||
<CheckBox Grid.Row="4" Grid.Column="1"
|
||||
<CheckBox Grid.Row="5" Grid.Column="1"
|
||||
Content="{DynamicResource Text.Preference.General.RestoreTabs}"
|
||||
IsChecked="{Binding RestoreTabs, Mode=TwoWay}"/>
|
||||
|
||||
<CheckBox Grid.Row="5" Grid.Column="1"
|
||||
<CheckBox Grid.Row="6" Grid.Column="1"
|
||||
Height="32"
|
||||
Content="{DynamicResource Text.Preference.General.UseFixedTabWidth}"
|
||||
IsChecked="{Binding Source={x:Static vm:Preference.Instance}, Path=UseFixedTabWidth, Mode=TwoWay}"/>
|
||||
|
||||
<CheckBox Grid.Row="6" Grid.Column="1"
|
||||
<CheckBox Grid.Row="7" Grid.Column="1"
|
||||
Height="32"
|
||||
Content="{DynamicResource Text.Preference.General.Check4UpdatesOnStartup}"
|
||||
IsChecked="{Binding Source={x:Static vm:Preference.Instance}, Path=Check4UpdatesOnStartup, Mode=TwoWay}"/>
|
||||
|
|
Loading…
Reference in a new issue