mirror of
https://github.com/makew0rld/amfora.git
synced 2024-12-04 14:46:29 -05:00
parent
1aa13f2408
commit
33bf9603b5
@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- [Client certificates](https://github.com/makeworld-the-better-one/amfora/wiki/Client-Certificates) can be restricted to certain paths of a host (#115)
|
||||
- `header` config option in `[subscriptions]` to allow disabling the header text on the subscriptions page (#191)
|
||||
- Selected link and scroll position stays for non-cached pages (#122)
|
||||
- Keybinding to open URL with URL handler instead of configured proxy (#143)
|
||||
|
||||
### Changed
|
||||
- Center text automatically, removing `left_margin` from the config (#233)
|
||||
|
@ -255,6 +255,7 @@ func Init() error {
|
||||
viper.SetDefault("keybindings.bind_beginning", []string{"Home", "g"})
|
||||
viper.SetDefault("keybindings.bind_end", []string{"End", "G"})
|
||||
viper.SetDefault("keybindings.shift_numbers", "")
|
||||
viper.SetDefault("keybindings.bind_url_handler_open", "Ctrl-U")
|
||||
viper.SetDefault("url-handlers.other", "default")
|
||||
viper.SetDefault("cache.max_size", 0)
|
||||
viper.SetDefault("cache.max_pages", 20)
|
||||
|
@ -188,6 +188,7 @@ underline = true
|
||||
# bind_copy_target_url
|
||||
# bind_beginning: moving to beginning of page (top left)
|
||||
# bind_end: same but the for the end (bottom left)
|
||||
# bind_url_handler_open: Open highlighted URL with URL handler (#143)
|
||||
|
||||
[url-handlers]
|
||||
# Allows setting the commands to run for various URL schemes.
|
||||
|
@ -61,6 +61,7 @@ const (
|
||||
CmdCopyTargetURL
|
||||
CmdBeginning
|
||||
CmdEnd
|
||||
CmdURLHandlerOpen // See #143
|
||||
)
|
||||
|
||||
type keyBinding struct {
|
||||
@ -161,43 +162,44 @@ func parseBinding(cmd Command, binding string) {
|
||||
// Called by config.Init()
|
||||
func KeyInit() {
|
||||
configBindings := map[Command]string{
|
||||
CmdLink1: "keybindings.bind_link1",
|
||||
CmdLink2: "keybindings.bind_link2",
|
||||
CmdLink3: "keybindings.bind_link3",
|
||||
CmdLink4: "keybindings.bind_link4",
|
||||
CmdLink5: "keybindings.bind_link5",
|
||||
CmdLink6: "keybindings.bind_link6",
|
||||
CmdLink7: "keybindings.bind_link7",
|
||||
CmdLink8: "keybindings.bind_link8",
|
||||
CmdLink9: "keybindings.bind_link9",
|
||||
CmdLink0: "keybindings.bind_link0",
|
||||
CmdBottom: "keybindings.bind_bottom",
|
||||
CmdEdit: "keybindings.bind_edit",
|
||||
CmdHome: "keybindings.bind_home",
|
||||
CmdBookmarks: "keybindings.bind_bookmarks",
|
||||
CmdAddBookmark: "keybindings.bind_add_bookmark",
|
||||
CmdSave: "keybindings.bind_save",
|
||||
CmdReload: "keybindings.bind_reload",
|
||||
CmdBack: "keybindings.bind_back",
|
||||
CmdForward: "keybindings.bind_forward",
|
||||
CmdMoveUp: "keybindings.bind_moveup",
|
||||
CmdMoveDown: "keybindings.bind_movedown",
|
||||
CmdMoveLeft: "keybindings.bind_moveleft",
|
||||
CmdMoveRight: "keybindings.bind_moveright",
|
||||
CmdPgup: "keybindings.bind_pgup",
|
||||
CmdPgdn: "keybindings.bind_pgdn",
|
||||
CmdNewTab: "keybindings.bind_new_tab",
|
||||
CmdCloseTab: "keybindings.bind_close_tab",
|
||||
CmdNextTab: "keybindings.bind_next_tab",
|
||||
CmdPrevTab: "keybindings.bind_prev_tab",
|
||||
CmdQuit: "keybindings.bind_quit",
|
||||
CmdHelp: "keybindings.bind_help",
|
||||
CmdSub: "keybindings.bind_sub",
|
||||
CmdAddSub: "keybindings.bind_add_sub",
|
||||
CmdCopyPageURL: "keybindings.bind_copy_page_url",
|
||||
CmdCopyTargetURL: "keybindings.bind_copy_target_url",
|
||||
CmdBeginning: "keybindings.bind_beginning",
|
||||
CmdEnd: "keybindings.bind_end",
|
||||
CmdLink1: "keybindings.bind_link1",
|
||||
CmdLink2: "keybindings.bind_link2",
|
||||
CmdLink3: "keybindings.bind_link3",
|
||||
CmdLink4: "keybindings.bind_link4",
|
||||
CmdLink5: "keybindings.bind_link5",
|
||||
CmdLink6: "keybindings.bind_link6",
|
||||
CmdLink7: "keybindings.bind_link7",
|
||||
CmdLink8: "keybindings.bind_link8",
|
||||
CmdLink9: "keybindings.bind_link9",
|
||||
CmdLink0: "keybindings.bind_link0",
|
||||
CmdBottom: "keybindings.bind_bottom",
|
||||
CmdEdit: "keybindings.bind_edit",
|
||||
CmdHome: "keybindings.bind_home",
|
||||
CmdBookmarks: "keybindings.bind_bookmarks",
|
||||
CmdAddBookmark: "keybindings.bind_add_bookmark",
|
||||
CmdSave: "keybindings.bind_save",
|
||||
CmdReload: "keybindings.bind_reload",
|
||||
CmdBack: "keybindings.bind_back",
|
||||
CmdForward: "keybindings.bind_forward",
|
||||
CmdMoveUp: "keybindings.bind_moveup",
|
||||
CmdMoveDown: "keybindings.bind_movedown",
|
||||
CmdMoveLeft: "keybindings.bind_moveleft",
|
||||
CmdMoveRight: "keybindings.bind_moveright",
|
||||
CmdPgup: "keybindings.bind_pgup",
|
||||
CmdPgdn: "keybindings.bind_pgdn",
|
||||
CmdNewTab: "keybindings.bind_new_tab",
|
||||
CmdCloseTab: "keybindings.bind_close_tab",
|
||||
CmdNextTab: "keybindings.bind_next_tab",
|
||||
CmdPrevTab: "keybindings.bind_prev_tab",
|
||||
CmdQuit: "keybindings.bind_quit",
|
||||
CmdHelp: "keybindings.bind_help",
|
||||
CmdSub: "keybindings.bind_sub",
|
||||
CmdAddSub: "keybindings.bind_add_sub",
|
||||
CmdCopyPageURL: "keybindings.bind_copy_page_url",
|
||||
CmdCopyTargetURL: "keybindings.bind_copy_target_url",
|
||||
CmdBeginning: "keybindings.bind_beginning",
|
||||
CmdEnd: "keybindings.bind_end",
|
||||
CmdURLHandlerOpen: "keybindings.bind_url_handler_open",
|
||||
}
|
||||
// This is split off to allow shift_numbers to override bind_tab[1-90]
|
||||
// (This is needed for older configs so that the default bind_tab values
|
||||
|
@ -185,6 +185,7 @@ underline = true
|
||||
# bind_copy_target_url
|
||||
# bind_beginning: moving to beginning of page (top left)
|
||||
# bind_end: same but the for the end (bottom left)
|
||||
# bind_url_handler_open: Open highlighted URL with URL handler (#143)
|
||||
|
||||
[url-handlers]
|
||||
# Allows setting the commands to run for various URL schemes.
|
||||
|
@ -216,6 +216,8 @@ func handleURL(t *tab, u string, numRedirects int) (string, bool) {
|
||||
}
|
||||
t.mode = tabModeDone
|
||||
|
||||
t.preferURLHandler = false
|
||||
|
||||
go func(p *structs.Page) {
|
||||
if b && t.hasContent() && !t.isAnAboutPage() && viper.GetBool("subscriptions.popup") {
|
||||
// The current page might be an untracked feed, and the user wants
|
||||
@ -261,7 +263,7 @@ func handleURL(t *tab, u string, numRedirects int) (string, bool) {
|
||||
}
|
||||
|
||||
if strings.HasPrefix(u, "http") {
|
||||
if proxy == "" || proxy == "off" {
|
||||
if proxy == "" || proxy == "off" || t.preferURLHandler {
|
||||
// No proxy available
|
||||
handleHTTP(u, true)
|
||||
return ret("", false)
|
||||
@ -280,7 +282,7 @@ func handleURL(t *tab, u string, numRedirects int) (string, bool) {
|
||||
|
||||
if !strings.HasPrefix(u, "http") && !strings.HasPrefix(u, "gemini") && !strings.HasPrefix(u, "file") {
|
||||
// Not a Gemini URL
|
||||
if proxy == "" || proxy == "off" {
|
||||
if proxy == "" || proxy == "off" || t.preferURLHandler {
|
||||
// No proxy available
|
||||
handleOther(u)
|
||||
return ret("", false)
|
||||
|
@ -33,6 +33,7 @@ var helpCells = strings.TrimSpace(
|
||||
"Enter, Tab\tOn a page this will start link highlighting.\n" +
|
||||
"\tPress Tab and Shift-Tab to pick different links.\n" +
|
||||
"\tPress Enter again to go to one, or Esc to stop.\n" +
|
||||
"%s\tOpen the highlighted URL with a URL handler instead of the configured proxy\n" +
|
||||
"%s\tGo to a specific tab. (Default: Shift-NUMBER)\n" +
|
||||
"%s\tGo to the last tab.\n" +
|
||||
"%s\tPrevious tab\n" +
|
||||
@ -95,6 +96,7 @@ func helpInit() {
|
||||
config.GetKeyBinding(config.CmdEdit),
|
||||
config.GetKeyBinding(config.CmdCopyPageURL),
|
||||
config.GetKeyBinding(config.CmdCopyTargetURL),
|
||||
config.GetKeyBinding(config.CmdURLHandlerOpen),
|
||||
tabKeys,
|
||||
config.GetKeyBinding(config.CmdTab0),
|
||||
config.GetKeyBinding(config.CmdPrevTab),
|
||||
|
@ -39,12 +39,13 @@ type tabHistory struct {
|
||||
|
||||
// tab hold the information needed for each browser tab.
|
||||
type tab struct {
|
||||
page *structs.Page
|
||||
view *cview.TextView
|
||||
history *tabHistory
|
||||
mode tabMode
|
||||
barLabel string // The bottomBar label for the tab
|
||||
barText string // The bottomBar text for the tab
|
||||
page *structs.Page
|
||||
view *cview.TextView
|
||||
history *tabHistory
|
||||
mode tabMode
|
||||
barLabel string // The bottomBar label for the tab
|
||||
barText string // The bottomBar text for the tab
|
||||
preferURLHandler bool // For #143, use URL handler over proxy
|
||||
}
|
||||
|
||||
// makeNewTab initializes an tab struct with no content.
|
||||
@ -98,6 +99,7 @@ func makeNewTab() *tab {
|
||||
linkN, _ := strconv.Atoi(currentSelection[0])
|
||||
tabs[tab].page.Selected = tabs[tab].page.Links[linkN]
|
||||
tabs[tab].page.SelectedID = currentSelection[0]
|
||||
tabs[tab].preferURLHandler = false // Reset in case
|
||||
go followLink(tabs[tab], tabs[tab].page.URL, tabs[tab].page.Links[linkN])
|
||||
return
|
||||
}
|
||||
@ -216,11 +218,24 @@ func makeNewTab() *tab {
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
case config.CmdURLHandlerOpen:
|
||||
currentSelection := t.view.GetHighlights()
|
||||
t.preferURLHandler = true
|
||||
// Copied code from when enter key is pressed
|
||||
if len(currentSelection) > 0 {
|
||||
bottomBar.SetLabel("")
|
||||
linkN, _ := strconv.Atoi(currentSelection[0])
|
||||
t.page.Selected = t.page.Links[linkN]
|
||||
t.page.SelectedID = currentSelection[0]
|
||||
go followLink(&t, t.page.URL, t.page.Links[linkN])
|
||||
}
|
||||
return nil
|
||||
}
|
||||
// Number key: 1-9, 0, LINK1-LINK10
|
||||
if cmd >= config.CmdLink1 && cmd <= config.CmdLink0 {
|
||||
if int(cmd) <= len(t.page.Links) {
|
||||
// It's a valid link number
|
||||
t.preferURLHandler = false // Reset in case
|
||||
go followLink(&t, t.page.URL, t.page.Links[cmd-1])
|
||||
return nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user