forked from Mirrors/bubbletea
Fix pager footer positioning
This commit is contained in:
parent
2a297fabad
commit
9cf57efe5f
|
@ -22,6 +22,7 @@ func main() {
|
||||||
|
|
||||||
// Load some text to render
|
// Load some text to render
|
||||||
content, err := ioutil.ReadFile("artichoke.md")
|
content, err := ioutil.ReadFile("artichoke.md")
|
||||||
|
//content, err := ioutil.ReadFile("menagerie.txt")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("could not load file:", err)
|
fmt.Println("could not load file:", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
@ -130,18 +131,13 @@ func view(mdl tea.Model) string {
|
||||||
header := fmt.Sprintf("%s\n%s\n%s", headerTop, headerMid, headerBot)
|
header := fmt.Sprintf("%s\n%s\n%s", headerTop, headerMid, headerBot)
|
||||||
|
|
||||||
footerTop := "╭──────╮"
|
footerTop := "╭──────╮"
|
||||||
footerMid := "┤ %3.f%% │"
|
footerMid := fmt.Sprintf("┤ %3.f%% │", m.viewport.ScrollPercent()*100)
|
||||||
footerBot := "╰──────╯"
|
footerBot := "╰──────╯"
|
||||||
space := m.viewport.Width - runewidth.StringWidth(footerMid)
|
gapSize := m.viewport.Width - runewidth.StringWidth(footerMid)
|
||||||
footerTop = strings.Repeat(" ", space) + footerTop
|
footerTop = strings.Repeat(" ", gapSize) + footerTop
|
||||||
footerMid = strings.Repeat("─", space) + footerMid
|
footerMid = strings.Repeat("─", gapSize) + footerMid
|
||||||
footerBot = strings.Repeat(" ", space) + footerBot
|
footerBot = strings.Repeat(" ", gapSize) + footerBot
|
||||||
footer := footerTop + "\n" + footerMid + "\n" + footerBot
|
footer := footerTop + "\n" + footerMid + "\n" + footerBot
|
||||||
|
|
||||||
return fmt.Sprintf(
|
return fmt.Sprintf("%s\n%s\n%s", header, viewport.View(m.viewport), footer)
|
||||||
"%s\n%s\n%s",
|
|
||||||
header,
|
|
||||||
viewport.View(m.viewport),
|
|
||||||
fmt.Sprintf(footer, m.viewport.ScrollPercent()*100),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue