Fixes issue where percent read was incorrect when moving through history

This commit is contained in:
sloumdrone 2019-09-19 21:29:52 -07:00
parent fdaf6312ab
commit 8c42748432
1 changed files with 15 additions and 1 deletions

View File

@ -101,6 +101,7 @@ func (c *client) Draw() {
} else {
screen.WriteString(fmt.Sprintf("%-*.*s", contentWidth, contentWidth, " "))
}
screen.WriteString("\033[500C\033[39D")
}
if c.Options["theme"] == "inverse" && !c.BookMarks.IsFocused {
@ -125,7 +126,7 @@ func (c *client) Draw() {
screen.WriteString(fmt.Sprintf("%-*.*s", c.Width, c.Width, pageContent[i]))
screen.WriteString("\n")
} else {
screen.WriteString(fmt.Sprintf("%*s", c.Width, " "))
screen.WriteString(fmt.Sprintf("%*.*s", c.Width, c.Width, " "))
screen.WriteString("\n")
}
}
@ -182,6 +183,7 @@ func (c *client) TakeControlInput() {
c.DrawMessage()
} else {
c.SetHeaderUrl()
c.SetPercentRead()
c.Draw()
}
case 'B':
@ -197,6 +199,7 @@ func (c *client) TakeControlInput() {
c.DrawMessage()
} else {
c.SetHeaderUrl()
c.SetPercentRead()
c.Draw()
}
case '\t':
@ -610,6 +613,17 @@ func (c *client) Scroll(amount int) {
}
}
func (c *client) SetPercentRead() {
page := c.PageState.History[c.PageState.Position]
var percentRead int
if len(page.WrappedContent) < c.Height - 3 {
percentRead = 100
} else {
percentRead = int(float32(page.ScrollPosition + c.Height - 3) / float32(len(page.WrappedContent)) * 100.0)
}
c.FootBar.SetPercentRead(percentRead)
}
func (c *client) displayConfigValue(setting string) {
if val, ok := c.Options[setting]; ok {
c.SetMessage(fmt.Sprintf("%s is set to: %q", setting, val), false)