2020-06-18 16:54:48 -04:00
|
|
|
package display
|
|
|
|
|
2020-07-07 21:13:45 -04:00
|
|
|
// applyHist is a history.go internal function, to load a URL in the history.
|
|
|
|
func applyHist(t *tab) {
|
2020-08-27 18:55:42 -04:00
|
|
|
handleURL(t, t.history.urls[t.history.pos], 0) // Load that position in history
|
2021-12-26 16:22:29 -05:00
|
|
|
|
|
|
|
// Set page's scroll and link info from history cache, in case it didn't have it in the page already
|
|
|
|
// Like for non-cached pages like about: pages
|
|
|
|
// This fixes #122
|
|
|
|
pg := t.history.pageCache[t.history.pos]
|
|
|
|
p := t.page
|
|
|
|
p.Row = pg.row
|
|
|
|
p.Column = pg.column
|
|
|
|
p.Selected = pg.selected
|
|
|
|
p.SelectedID = pg.selectedID
|
|
|
|
p.Mode = pg.mode
|
|
|
|
|
2020-07-07 21:13:45 -04:00
|
|
|
t.applyAll()
|
2020-06-18 16:54:48 -04:00
|
|
|
}
|
|
|
|
|
2020-07-07 21:13:45 -04:00
|
|
|
func histForward(t *tab) {
|
|
|
|
if t.history.pos >= len(t.history.urls)-1 {
|
2020-06-18 16:54:48 -04:00
|
|
|
// Already on the most recent URL in the history
|
|
|
|
return
|
|
|
|
}
|
2021-12-26 16:22:29 -05:00
|
|
|
|
|
|
|
// Update page cache in history for #122
|
|
|
|
t.historyCachePage()
|
|
|
|
|
2020-07-07 21:13:45 -04:00
|
|
|
t.history.pos++
|
|
|
|
go applyHist(t)
|
2020-06-18 16:54:48 -04:00
|
|
|
}
|
|
|
|
|
2020-07-07 21:13:45 -04:00
|
|
|
func histBack(t *tab) {
|
|
|
|
if t.history.pos <= 0 {
|
2020-06-18 16:54:48 -04:00
|
|
|
// First tab in history
|
|
|
|
return
|
|
|
|
}
|
2021-12-26 16:22:29 -05:00
|
|
|
|
|
|
|
// Update page cache in history for #122
|
|
|
|
t.historyCachePage()
|
|
|
|
|
2020-07-07 21:13:45 -04:00
|
|
|
t.history.pos--
|
|
|
|
go applyHist(t)
|
2020-06-18 16:54:48 -04:00
|
|
|
}
|