Skip to content
Myr

Fix pager footer positioning

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Christian Rocha · committed by Christian Rocha · parent 2a297fa · Browse files · 1 file+7 added−11 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+7 added−11 removed

  • other:+7 added−11 removed

1 file+7 added−11 removed

modified:examples/pager/main.go+7 added-11 removed
20 unmodified lines
21func main() {2223 // Load some text to render24 content, err := ioutil.ReadFile("artichoke.md")25 //content, err := ioutil.ReadFile("menagerie.txt")26 if err != nil {27 fmt.Println("could not load file:", err)28 os.Exit(1)29 }
100 unmodified lines
130 headerMid += strings.Repeat("─", m.viewport.Width-runewidth.StringWidth(headerMid))131 header := fmt.Sprintf("%s\n%s\n%s", headerTop, headerMid, headerBot)132133 footerTop := "╭──────╮"133 footerMid := "┤ %3.f%% │"134 footerMid := fmt.Sprintf("┤ %3.f%% │", m.viewport.ScrollPercent()*100)135 footerBot := "╰──────╯"135 space := m.viewport.Width - runewidth.StringWidth(footerMid)136 footerTop = strings.Repeat(" ", space) + footerTop137 footerMid = strings.Repeat("─", space) + footerMid138 footerBot = strings.Repeat(" ", space) + footerBot136 gapSize := m.viewport.Width - runewidth.StringWidth(footerMid)137 footerTop = strings.Repeat(" ", gapSize) + footerTop138 footerMid = strings.Repeat("─", gapSize) + footerMid139 footerBot = strings.Repeat(" ", gapSize) + footerBot140 footer := footerTop + "\n" + footerMid + "\n" + footerBot141141 return fmt.Sprintf(142 "%s\n%s\n%s",143 header,144 viewport.View(m.viewport),145 fmt.Sprintf(footer, m.viewport.ScrollPercent()*100),146 )142 return fmt.Sprintf("%s\n%s\n%s", header, viewport.View(m.viewport), footer)143}