enhance: add first/last buttons for block-nav, no wrapping (#1015) (#1016)

Added 2 new buttons (only visible in block-nav mode), with new icons and new (en_US) strings (First/Last Difference).
Implemented these new buttons, and disabled the automatic wrap-around for the prev/next buttons in block-nav mode.
This commit is contained in:
Göran W 2025-02-24 02:32:19 +01:00 committed by GitHub
parent 9ab602788a
commit fa4caa2186
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 127 additions and 3 deletions

View file

@ -543,6 +543,21 @@ namespace SourceGit.Views
{
}
public void GotoFirstChange()
{
var blockNavigation = BlockNavigation;
if (blockNavigation != null)
{
var prev = blockNavigation.GotoFirst();
if (prev != null)
{
TextArea.Caret.Line = prev.Start;
ScrollToLine(prev.Start);
}
}
// NOTE: Not implemented (button hidden) for non-block navigation.
}
public void GotoPrevChange()
{
var blockNavigation = BlockNavigation;
@ -641,6 +656,21 @@ namespace SourceGit.Views
}
}
public void GotoLastChange()
{
var blockNavigation = BlockNavigation;
if (blockNavigation != null)
{
var next = blockNavigation.GotoLast();
if (next != null)
{
TextArea.Caret.Line = next.Start;
ScrollToLine(next.Start);
}
}
// NOTE: Not implemented (button hidden) for non-block navigation.
}
public override void Render(DrawingContext context)
{
base.Render(context);
@ -1682,6 +1712,19 @@ namespace SourceGit.Views
InitializeComponent();
}
public void GotoFirstChange()
{
var presenter = this.FindDescendantOfType<ThemedTextDiffPresenter>();
if (presenter == null)
return;
presenter.GotoFirstChange();
if (presenter is SingleSideTextDiffPresenter singleSide)
singleSide.ForceSyncScrollOffset();
BlockNavigationIndicator = BlockNavigation?.Indicator ?? string.Empty;
}
public void GotoPrevChange()
{
var presenter = this.FindDescendantOfType<ThemedTextDiffPresenter>();
@ -1708,6 +1751,19 @@ namespace SourceGit.Views
BlockNavigationIndicator = BlockNavigation?.Indicator ?? string.Empty;
}
public void GotoLastChange()
{
var presenter = this.FindDescendantOfType<ThemedTextDiffPresenter>();
if (presenter == null)
return;
presenter.GotoLastChange();
if (presenter is SingleSideTextDiffPresenter singleSide)
singleSide.ForceSyncScrollOffset();
BlockNavigationIndicator = BlockNavigation?.Indicator ?? string.Empty;
}
protected override void OnDataContextChanged(EventArgs e)
{
base.OnDataContextChanged(e);