summaryrefslogtreecommitdiff
path: root/state.go
diff options
context:
space:
mode:
authortjp <tjp@ctrl-c.club>2024-01-03 08:29:40 -0700
committertjp <tjp@ctrl-c.club>2024-01-03 08:29:40 -0700
commit6c9558c0d2201d933b1d396febeb6e70ceaad058 (patch)
tree565b8b048fc3e63b6c2eb6892a6f356f0c3c15aa /state.go
parent4b3dd896fb0c157e0d727f39ccb6d940a75d1cce (diff)
working basic navigation and marks
Diffstat (limited to 'state.go')
-rw-r--r--state.go49
1 files changed, 49 insertions, 0 deletions
diff --git a/state.go b/state.go
new file mode 100644
index 0000000..5838fcd
--- /dev/null
+++ b/state.go
@@ -0,0 +1,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,
+ },
+ }
+}