skipper/bindings.go

187 lines
3.3 KiB
Go
Raw Normal View History

2022-11-26 09:44:07 -07:00
package main
import "net/url"
2022-11-26 09:44:07 -07:00
import "git.tebibyte.media/sashakoshka/stone"
import "git.tebibyte.media/sashakoshka/skipper/bookmarks"
type bindingKey struct {
control bool
shift bool
alt bool
button stone.Button
}
var bindings = map[bindingKey] func () {
bindingKey {
button: stone.Button('`'),
}: func () { fetchStringUrl("about:skipper") },
bindingKey {
button: stone.Button('r'),
}: func () { go fetchNoTrace(page.currentUrl) },
bindingKey {
button: stone.Button('u'),
}: func () { go fetchSource(page.currentUrl) },
bindingKey {
button: stone.Button(' '),
}: func () { onUrlBarSelect("") },
bindingKey {
button: stone.Button(','),
}: func () { onUrlBarSelect(page.currentUrl.String()) },
bindingKey {
button: stone.Button('.'),
}: func () { onUrlBarSelect(".") },
bindingKey {
button: stone.Button('/'),
}: func () { onUrlBarSelect("?") },
bindingKey {
button: stone.Button('b'),
}: func () { fetchStringUrl("about:bookmarks") },
bindingKey {
shift: true,
button: stone.Button('B'),
}: func () {
bookmarks.Add (bookmarks.Bookmark {
Title: page.document.Title(),
Location: page.currentUrl,
})
},
bindingKey {
button: stone.Button('h'),
}: func () {
location, _ := url.Parse (
browserConfig.Parameters["homePage"].(string))
go fetch(location)
},
2022-11-26 09:44:07 -07:00
bindingKey {
button: stone.Button('0'),
}: func () { followLink(0) },
bindingKey {
button: stone.Button('1'),
}: func () { followLink(1) },
bindingKey {
button: stone.Button('2'),
}: func () { followLink(2) },
bindingKey {
button: stone.Button('3'),
}: func () { followLink(3) },
bindingKey {
button: stone.Button('4'),
}: func () { followLink(4) },
bindingKey {
button: stone.Button('5'),
}: func () { followLink(5) },
bindingKey {
button: stone.Button('6'),
}: func () { followLink(6) },
bindingKey {
button: stone.Button('7'),
}: func () { followLink(7) },
bindingKey {
button: stone.Button('8'),
}: func () { followLink(8) },
bindingKey {
button: stone.Button('9'),
}: func () { followLink(9) },
bindingKey {
button: stone.KeyLeft,
}: func () { fetchBackward() },
bindingKey {
button: stone.KeyRight,
}: func () { fetchForward() },
bindingKey {
button: stone.MouseButtonBack,
}: func () { fetchBackward() },
bindingKey {
button: stone.MouseButtonForward,
}: func () { fetchForward() },
bindingKey {
button: stone.KeyHome,
}: func () {
page.scroll = 0
constrainScroll()
redraw()
application.Draw()
},
bindingKey {
button: stone.KeyEnd,
}: func () {
page.scroll = page.height
constrainScroll()
redraw()
application.Draw()
},
bindingKey {
button: stone.KeyPageUp,
}: func () {
page.scroll -= page.viewHeight
constrainScroll()
redraw()
application.Draw()
},
bindingKey {
button: stone.KeyPageDown,
}: func () {
page.scroll += page.viewHeight
constrainScroll()
redraw()
application.Draw()
},
bindingKey {
button: stone.KeyUp,
}: func () {
page.scroll -= 1
constrainScroll()
redraw()
application.Draw()
},
bindingKey {
button: stone.KeyDown,
}: func () {
page.scroll += 1
constrainScroll()
redraw()
application.Draw()
},
bindingKey {
button: stone.MouseButtonBack,
}: func () {
fetchBackward()
},
bindingKey {
button: stone.MouseButtonForward,
}: func () {
fetchForward()
},
}