From 85c121d0aca8fb10be239a2ec685f438670ef26e Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Mon, 20 Jul 2020 11:00:17 -0400 Subject: [PATCH] Add Arabic pagination if the dot nav gets wider than the terminal width --- ui/stash.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ui/stash.go b/ui/stash.go index ccfb169..a177231 100644 --- a/ui/stash.go +++ b/ui/stash.go @@ -17,6 +17,7 @@ import ( "github.com/charmbracelet/charm/ui/common" "github.com/dustin/go-humanize" runewidth "github.com/mattn/go-runewidth" + "github.com/muesli/reflow/ansi" "github.com/muesli/reflow/wordwrap" te "github.com/muesli/termenv" ) @@ -492,6 +493,13 @@ func stashView(m stashModel) string { if m.paginator.TotalPages > 1 { pagination = paginator.View(m.paginator) + // If the dot pagination is wider than the width of the window + // switch to the arabic paginator. + if ansi.PrintableRuneWidth(pagination) > m.terminalWidth-stashViewHorizontalPadding { + m.paginator.Type = paginator.Arabic + pagination = common.Subtle(paginator.View(m.paginator)) + } + if !m.stashFullyLoaded { pagination += common.Subtle(" ยทยทยท") }