From 4b78a13140a7fb6e54f4f6aa9516bfa848e87816 Mon Sep 17 00:00:00 2001 From: makeworld Date: Sat, 21 Nov 2020 12:45:54 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B8=20Support=20numpad=20enter=20key?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 3 +++ THANKS.md | 3 ++- display/display.go | 2 +- display/help.go | 2 +- display/tab.go | 4 ++-- display/util.go | 3 +++ 6 files changed, 12 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 97df23e..b0f10e2 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 +- Support numpad enter key (#123) + ### Changed - 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 diff --git a/THANKS.md b/THANKS.md index 0e093f4..bfe147c 100644 --- a/THANKS.md +++ b/THANKS.md @@ -10,4 +10,5 @@ Thank you to the following contributors, who have helped make Amfora great. FOSS - Timur Ismagilov (@bouncepaw) - Matt Caroll (@ohiolab) - Patryk Niedźwiedziński (@pniedzwiedzinski) -- Trevor Slocum (@tsclocum) \ No newline at end of file +- Trevor Slocum (@tsclocum) +- Cole Helbling (@cole-h) diff --git a/display/display.go b/display/display.go index d2b6921..4ccb5e4 100644 --- a/display/display.go +++ b/display/display.go @@ -115,7 +115,7 @@ func Init() { //nolint:exhaustive switch key { - case tcell.KeyEnter: + case tcell.KeyEnter, KeyNumpadEnter: // Figure out whether it's a URL, link number, or search // And send out a request diff --git a/display/help.go b/display/help.go index 1391a07..224adf2 100644 --- a/display/help.go +++ b/display/help.go @@ -63,7 +63,7 @@ func Help() { func helpInit() { // Populate help table 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)) App.SetFocus(tabs[curTab].view) App.Draw() diff --git a/display/tab.go b/display/tab.go index f192720..28d1d6c 100644 --- a/display/tab.go +++ b/display/tab.go @@ -76,7 +76,7 @@ func makeNewTab() *tab { currentSelection := tabs[tab].view.GetHighlights() 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 bottomBar.SetLabel("") linkN, _ := strconv.Atoi(currentSelection[0]) @@ -85,7 +85,7 @@ func makeNewTab() *tab { followLink(tabs[tab], tabs[tab].page.URL, tabs[tab].page.Links[linkN]) 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 tabs[tab].page.Mode = structs.ModeLinkSelect diff --git a/display/util.go b/display/util.go index 4ea8e91..3de9b16 100644 --- a/display/util.go +++ b/display/util.go @@ -5,12 +5,15 @@ import ( "net/url" "strings" + "github.com/gdamore/tcell" "github.com/spf13/viper" "gitlab.com/tslocum/cview" ) // 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. func escapeMeta(meta string) string { return cview.Escape(strings.ReplaceAll(meta, "\n", ""))