summaryrefslogtreecommitdiff
path: root/state.go
blob: 5838fcd894466cfd06927ad255d4f4360744e10f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package main

import (
	"net/url"

	"github.com/chzyer/readline"
)

type BrowserState struct {
	*History

	Modal    []byte
	Marks    map[string]string
	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
}

func NewBrowserState() *BrowserState {
	return &BrowserState{
		History: &History{
			Url:      nil,
			Depth:    0,
			NavIndex: -1,
		},
	}
}