70 lines
1.0 KiB
Go
70 lines
1.0 KiB
Go
package main
|
|
|
|
import (
|
|
"net/url"
|
|
"time"
|
|
|
|
"github.com/chzyer/readline"
|
|
)
|
|
|
|
type BrowserState struct {
|
|
*History
|
|
|
|
Modal []byte
|
|
|
|
Marks map[string]string
|
|
|
|
Identities Identities
|
|
|
|
NamedTours map[string]*Tour
|
|
DefaultTour Tour
|
|
CurrentTour *Tour
|
|
|
|
Quiet bool
|
|
Pager string
|
|
Timeout time.Duration
|
|
|
|
Readline *readline.Instance
|
|
}
|
|
|
|
type History struct {
|
|
Url *url.URL
|
|
|
|
Depth int
|
|
DocType string
|
|
Body []byte
|
|
Formatted string
|
|
Links []Link
|
|
|
|
Back *History
|
|
Forward *History
|
|
|
|
// Non-negative if we browsed here via a page link, else -1.
|
|
//
|
|
// The non-negative value is the index in the "back" page's
|
|
// list of links that got us here.
|
|
NavIndex int
|
|
}
|
|
|
|
type Link struct {
|
|
Text string
|
|
Target *url.URL
|
|
Prompt bool
|
|
}
|
|
|
|
func NewBrowserState(conf *Config) *BrowserState {
|
|
state := &BrowserState{
|
|
History: &History{
|
|
Url: nil,
|
|
Depth: 0,
|
|
NavIndex: -1,
|
|
},
|
|
|
|
Quiet: conf.Quiet,
|
|
Pager: conf.Pager,
|
|
Timeout: conf.Timeout.Duration,
|
|
}
|
|
state.CurrentTour = &state.DefaultTour
|
|
return state
|
|
}
|