mirror of
https://github.com/makeworld-the-better-one/amfora.git
synced 2024-09-11 14:55:51 +03:00
✨ Display selected URL and support Esc - fixes #24
This commit is contained in:
parent
3e807ab5b8
commit
8cfff2296f
@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- You can type `..` in the bottom bar to go up a directory in the URL (#21)
|
||||
- Error popup for when input string would result in a too long out-of-spec URL (#25)
|
||||
- Paging, using <kbd>d</kbd> and <kbd>u</kbd>, as well as <kbd>Page Up</kbd> and <kbd>Page Down</kbd> (#19)
|
||||
- <kbd>Esc</kbd> can exit link highlighting mode (#24)
|
||||
- Selected link URL is displayed in the bottom bar (#24)
|
||||
|
||||
### Changed
|
||||
- Bottom bar now says `URL/Num./Search: ` when space is pressed
|
||||
|
@ -355,18 +355,32 @@ func NewTab() {
|
||||
// Altered from: https://gitlab.com/tslocum/cview/-/blob/master/demos/textview/main.go
|
||||
// Handles being able to select and "click" links with the enter and tab keys
|
||||
|
||||
if key == tcell.KeyEsc {
|
||||
// Stop highlighting
|
||||
tabViews[curTab].Highlight("")
|
||||
bottomBar.SetLabel("")
|
||||
bottomBar.SetText(tabMap[curTab].Url)
|
||||
}
|
||||
|
||||
currentSelection := tabViews[curTab].GetHighlights()
|
||||
numSelections := len(tabMap[curTab].Links)
|
||||
|
||||
if key == tcell.KeyEnter {
|
||||
if len(currentSelection) > 0 && len(tabMap[curTab].Links) > 0 {
|
||||
// A link was selected, "click" it and load the page it's for
|
||||
bottomBar.SetLabel("")
|
||||
linkN, _ := strconv.Atoi(currentSelection[0])
|
||||
followLink(tabMap[curTab].Url, tabMap[curTab].Links[linkN])
|
||||
return
|
||||
} else {
|
||||
tabViews[curTab].Highlight("0").ScrollToHighlight()
|
||||
// Display link URL in bottomBar
|
||||
bottomBar.SetLabel("[::b]Link: [::-]")
|
||||
bottomBar.SetText(tabMap[curTab].Links[0])
|
||||
}
|
||||
} else if len(currentSelection) > 0 {
|
||||
// There's still a selection, but a different key was pressed, not Enter
|
||||
|
||||
index, _ := strconv.Atoi(currentSelection[0])
|
||||
if key == tcell.KeyTab {
|
||||
index = (index + 1) % numSelections
|
||||
@ -376,6 +390,9 @@ func NewTab() {
|
||||
return
|
||||
}
|
||||
tabViews[curTab].Highlight(strconv.Itoa(index)).ScrollToHighlight()
|
||||
// Display link URL in bottomBar
|
||||
bottomBar.SetLabel("[::b]Link: [::-]")
|
||||
bottomBar.SetText(tabMap[curTab].Links[index])
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -18,7 +18,7 @@ f, Alt-Right|Go forward a page
|
||||
g|Go to top of document
|
||||
G|Go to bottom of document
|
||||
spacebar|Open bar at the bottom - type a URL, link number, or search term. You can also type two dots (..) to go up a directory in the URL.
|
||||
Enter|On a page this will start link highlighting. Press Tab and Shift-Tab to pick different links. Press enter again to go to one.
|
||||
Enter|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.
|
||||
Shift-0, )|Go to the last tab.
|
||||
Ctrl-H|Go home
|
||||
|
Loading…
Reference in New Issue
Block a user