From aa4edc4344a83891fe763b1e8370d30089fc257f Mon Sep 17 00:00:00 2001 From: makeworld Date: Sun, 19 Jul 2020 11:09:33 -0400 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Tab=20can=20enter=20link=20selectin?= =?UTF-8?q?g=20mode=20-=20fixes=20#48?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 3 +++ README.md | 3 ++- amfora.go | 2 +- display/help.go | 2 +- display/tab.go | 43 ++++++++++++++++++++++--------------------- 5 files changed, 29 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e9e540c..5e3f121 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Added +- Tab now also enters link selecting mode, like Enter (#48) + ### Fixed - You can't change link selection while the page is loading diff --git a/README.md b/README.md index 7b287e3..2da8fae 100644 --- a/README.md +++ b/README.md @@ -80,11 +80,12 @@ Features in *italics* are in the master branch, but not in the latest release. - [ ] Full mouse support - [ ] Table of contents for pages - [ ] Full client certificate UX within the client - - *I will be waiting for some spec changes/recommendations to happen before implementing this* - Create transient and permanent certs within the client, per domain - Manage and browse them + - Similar to [Kristall](https://github.com/MasterQ32/kristall) - https://lists.orbitalfox.eu/archives/gemini/2020/001400.html - [ ] Subscribe to RSS and Atom feeds and display them + - Subscribing to page changes, similar to how Spacewalk works, will also be supported - [ ] Support Markdown rendering - [ ] History browser diff --git a/amfora.go b/amfora.go index 63a7cc2..0139fbf 100644 --- a/amfora.go +++ b/amfora.go @@ -8,7 +8,7 @@ import ( "github.com/makeworld-the-better-one/amfora/display" ) -var version = "1.3.0" +var version = "1.4.0-unreleased" func main() { // err := logger.Init() diff --git a/display/help.go b/display/help.go index 3481016..c4e9a30 100644 --- a/display/help.go +++ b/display/help.go @@ -22,7 +22,7 @@ spacebar|Open bar at the bottom - type a URL, link number, search term. |You can also type two dots (..) to go up a directory in the URL. |Typing new:N will open link number N in a new tab |instead of the current one. -Enter|On a page this will start link highlighting. +Enter, Tab|On a page this will start link highlighting. |Press Tab and Shift-Tab to pick different links. |Press Enter again to go to one, or Esc to stop. Shift-NUMBER|Go to a specific tab. diff --git a/display/tab.go b/display/tab.go index 977a6ca..d69495f 100644 --- a/display/tab.go +++ b/display/tab.go @@ -76,28 +76,29 @@ func makeNewTab() *tab { currentSelection := tabs[tab].view.GetHighlights() numSelections := len(tabs[tab].page.Links) - if key == tcell.KeyEnter { - if len(currentSelection) > 0 { - // A link was selected, "click" it and load the page it's for - bottomBar.SetLabel("") - linkN, _ := strconv.Atoi(currentSelection[0]) - tabs[tab].page.Selected = tabs[tab].page.Links[linkN] - tabs[tab].page.SelectedID = currentSelection[0] - followLink(tabs[tab], tabs[tab].page.Url, tabs[tab].page.Links[linkN]) - return - } else { - // They've started link highlighting - tabs[tab].page.Mode = structs.ModeLinkSelect + if key == tcell.KeyEnter && len(currentSelection) > 0 { + // A link is selected and enter was pressed: "click" it and load the page it's for + bottomBar.SetLabel("") + linkN, _ := strconv.Atoi(currentSelection[0]) + tabs[tab].page.Selected = tabs[tab].page.Links[linkN] + tabs[tab].page.SelectedID = currentSelection[0] + followLink(tabs[tab], tabs[tab].page.Url, tabs[tab].page.Links[linkN]) + return + } + if len(currentSelection) <= 0 && (key == tcell.KeyEnter || key == tcell.KeyTab) { + // They've started link highlighting + tabs[tab].page.Mode = structs.ModeLinkSelect - tabs[tab].view.Highlight("0").ScrollToHighlight() - // Display link URL in bottomBar - bottomBar.SetLabel("[::b]Link: [::-]") - bottomBar.SetText(tabs[tab].page.Links[0]) - tabs[tab].saveBottomBar() - tabs[tab].page.Selected = tabs[tab].page.Links[0] - tabs[tab].page.SelectedID = "0" - } - } else if len(currentSelection) > 0 { + tabs[tab].view.Highlight("0").ScrollToHighlight() + // Display link URL in bottomBar + bottomBar.SetLabel("[::b]Link: [::-]") + bottomBar.SetText(tabs[tab].page.Links[0]) + tabs[tab].saveBottomBar() + tabs[tab].page.Selected = tabs[tab].page.Links[0] + tabs[tab].page.SelectedID = "0" + } + + if len(currentSelection) > 0 { // There's still a selection, but a different key was pressed, not Enter index, _ := strconv.Atoi(currentSelection[0])