Added refresh feature

This commit is contained in:
sloumdrone 2019-10-05 17:55:15 -07:00
parent ee9fc8332c
commit b5fc017978
1 changed files with 24 additions and 0 deletions

View File

@ -187,6 +187,15 @@ func (c *client) TakeControlInput() {
c.SetPercentRead()
c.Draw()
}
case 'R':
c.ClearMessage()
err := c.ReloadPage()
if err != nil {
c.SetMessage(err.Error(), false)
c.DrawMessage()
} else {
c.Draw()
}
case 'B':
// open the bookmarks browser
c.BookMarks.ToggleOpen()
@ -987,6 +996,21 @@ func (c *client) Visit(url string) {
}
}
func (c *client) ReloadPage() error {
if c.PageState.Length < 1 {
return fmt.Errorf("There is no page to reload")
}
url := c.PageState.History[c.PageState.Position].Location.Full
err := c.PageState.NavigateHistory(-1)
if err != nil {
return err
}
length := c.PageState.Length
c.Visit(url)
c.PageState.Length = length
return nil
}
//------------------------------------------------\\
// + + + F U N C T I O N S + + + \\