Add Arabic pagination if the dot nav gets wider than the terminal width

This commit is contained in:
Christian Rocha 2020-07-20 11:00:17 -04:00 committed by Christian Muehlhaeuser
commit 85c121d0ac

View file

@ -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(" ···")
}