1
0
mirror of https://github.com/makew0rld/amfora.git synced 2024-09-25 22:55:55 -04:00

🚸 Support numpad enter key

This commit is contained in:
makeworld 2020-11-21 12:45:54 -05:00
parent 73bd071753
commit 4b78a13140
6 changed files with 12 additions and 5 deletions

View File

@ -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). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased] ## [Unreleased]
### Added
- Support numpad enter key (#123)
### Changed ### Changed
- Updated [go-gemini](https://github.com/makeworld-the-better-one/go-gemini) to v0.9.1 to support CN-only wildcard certs - Updated [go-gemini](https://github.com/makeworld-the-better-one/go-gemini) to v0.9.1 to support CN-only wildcard certs
- Preformatted text is now light yellow by default - Preformatted text is now light yellow by default

View File

@ -10,4 +10,5 @@ Thank you to the following contributors, who have helped make Amfora great. FOSS
- Timur Ismagilov (@bouncepaw) - Timur Ismagilov (@bouncepaw)
- Matt Caroll (@ohiolab) - Matt Caroll (@ohiolab)
- Patryk Niedźwiedziński (@pniedzwiedzinski) - Patryk Niedźwiedziński (@pniedzwiedzinski)
- Trevor Slocum (@tsclocum) - Trevor Slocum (@tsclocum)
- Cole Helbling (@cole-h)

View File

@ -115,7 +115,7 @@ func Init() {
//nolint:exhaustive //nolint:exhaustive
switch key { switch key {
case tcell.KeyEnter: case tcell.KeyEnter, KeyNumpadEnter:
// Figure out whether it's a URL, link number, or search // Figure out whether it's a URL, link number, or search
// And send out a request // And send out a request

View File

@ -63,7 +63,7 @@ func Help() {
func helpInit() { func helpInit() {
// Populate help table // Populate help table
helpTable.SetDoneFunc(func(key tcell.Key) { helpTable.SetDoneFunc(func(key tcell.Key) {
if key == tcell.KeyEsc || key == tcell.KeyEnter { if key == tcell.KeyEsc || key == tcell.KeyEnter || key == KeyNumpadEnter {
tabPages.SwitchToPage(strconv.Itoa(curTab)) tabPages.SwitchToPage(strconv.Itoa(curTab))
App.SetFocus(tabs[curTab].view) App.SetFocus(tabs[curTab].view)
App.Draw() App.Draw()

View File

@ -76,7 +76,7 @@ func makeNewTab() *tab {
currentSelection := tabs[tab].view.GetHighlights() currentSelection := tabs[tab].view.GetHighlights()
numSelections := len(tabs[tab].page.Links) numSelections := len(tabs[tab].page.Links)
if key == tcell.KeyEnter && len(currentSelection) > 0 { if (key == tcell.KeyEnter || key == KeyNumpadEnter) && len(currentSelection) > 0 {
// A link is selected and enter was pressed: "click" it and load the page it's for // A link is selected and enter was pressed: "click" it and load the page it's for
bottomBar.SetLabel("") bottomBar.SetLabel("")
linkN, _ := strconv.Atoi(currentSelection[0]) linkN, _ := strconv.Atoi(currentSelection[0])
@ -85,7 +85,7 @@ func makeNewTab() *tab {
followLink(tabs[tab], tabs[tab].page.URL, tabs[tab].page.Links[linkN]) followLink(tabs[tab], tabs[tab].page.URL, tabs[tab].page.Links[linkN])
return return
} }
if len(currentSelection) == 0 && (key == tcell.KeyEnter || key == tcell.KeyTab) { if len(currentSelection) == 0 && (key == tcell.KeyEnter || key == KeyNumpadEnter || key == tcell.KeyTab) {
// They've started link highlighting // They've started link highlighting
tabs[tab].page.Mode = structs.ModeLinkSelect tabs[tab].page.Mode = structs.ModeLinkSelect

View File

@ -5,12 +5,15 @@ import (
"net/url" "net/url"
"strings" "strings"
"github.com/gdamore/tcell"
"github.com/spf13/viper" "github.com/spf13/viper"
"gitlab.com/tslocum/cview" "gitlab.com/tslocum/cview"
) )
// This file contains funcs that are small, self-contained utilities. // This file contains funcs that are small, self-contained utilities.
const KeyNumpadEnter = tcell.KeyCtrlJ
// escapeMeta santizes a META string for use within a cview modal. // escapeMeta santizes a META string for use within a cview modal.
func escapeMeta(meta string) string { func escapeMeta(meta string) string {
return cview.Escape(strings.ReplaceAll(meta, "\n", "")) return cview.Escape(strings.ReplaceAll(meta, "\n", ""))