mirror of
https://github.com/charmbracelet/glow
synced 2024-11-13 23:47:06 +00:00
Also keep the scroll percentage at 0% or higher
This commit is contained in:
parent
f43a0271d2
commit
3ab3b8fcb4
1 changed files with 2 additions and 6 deletions
8
ui/ui.go
8
ui/ui.go
|
@ -3,6 +3,7 @@ package ui
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"math"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
@ -310,12 +311,7 @@ func statusBarView(m model) string {
|
||||||
logo := glowLogoView(logoText)
|
logo := glowLogoView(logoText)
|
||||||
|
|
||||||
// Scroll percent
|
// Scroll percent
|
||||||
scrollPercent := m.pager.ScrollPercent()
|
scrollPercent := math.Max(0.0, math.Min(1.0, m.pager.ScrollPercent()))
|
||||||
if scrollPercent > 1.0 {
|
|
||||||
// Don't let read more than 100%, which could happen if we resize and
|
|
||||||
// the bottom of the page ends up in the middle of the window.
|
|
||||||
scrollPercent = 1.0
|
|
||||||
}
|
|
||||||
percentText := fmt.Sprintf(" %3.f%% ", scrollPercent*100)
|
percentText := fmt.Sprintf(" %3.f%% ", scrollPercent*100)
|
||||||
percent := te.String(percentText).
|
percent := te.String(percentText).
|
||||||
Foreground(statusBarFg.Color()).
|
Foreground(statusBarFg.Color()).
|
||||||
|
|
Loading…
Reference in a new issue