mirror of
https://github.com/makew0rld/amfora.git
synced 2024-12-04 14:46:29 -05:00
🔧 Use shift_numbers - #64
This commit is contained in:
parent
5fbef1e517
commit
70438cfdb5
@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
### Added
|
### Added
|
||||||
- Emoji favicons can now be seen if `emoji_favicons` is enabled in the config (#62)
|
- Emoji favicons can now be seen if `emoji_favicons` is enabled in the config (#62)
|
||||||
|
- The `shift_numbers` key in the config was added, so that non US keyboard users can navigate tabs (#64)
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
@ -95,10 +95,10 @@ Features in *italics* are in the master branch, but not in the latest release.
|
|||||||
- [x] Bookmarks
|
- [x] Bookmarks
|
||||||
- [x] Download pages and arbitrary data
|
- [x] Download pages and arbitrary data
|
||||||
- [x] Theming
|
- [x] Theming
|
||||||
- [ ] Subscribe to RSS and Atom feeds and display them
|
|
||||||
- Subscribing to page changes, similar to how Spacewalk works, will also be supported
|
|
||||||
- [x] *Emoji favicons*
|
- [x] *Emoji favicons*
|
||||||
- See `gemini://mozz.us/files/rfc_gemini_favicon.gmi` for details
|
- See `gemini://mozz.us/files/rfc_gemini_favicon.gmi` for details
|
||||||
|
- [ ] Subscribe to RSS and Atom feeds and display them
|
||||||
|
- Subscribing to page changes, similar to how Spacewalk works, will also be supported
|
||||||
- [ ] Stream support
|
- [ ] Stream support
|
||||||
- [ ] Full client certificate UX within the client
|
- [ ] Full client certificate UX within the client
|
||||||
- Create transient and permanent certs within the client, per domain
|
- Create transient and permanent certs within the client, per domain
|
||||||
|
@ -154,6 +154,7 @@ func Init() error {
|
|||||||
viper.SetDefault("a-general.page_max_size", 2097152)
|
viper.SetDefault("a-general.page_max_size", 2097152)
|
||||||
viper.SetDefault("a-general.page_max_time", 10)
|
viper.SetDefault("a-general.page_max_time", 10)
|
||||||
viper.SetDefault("a-general.emoji_favicons", false)
|
viper.SetDefault("a-general.emoji_favicons", false)
|
||||||
|
viper.SetDefault("keybindings.shift_numbers", "!@#$%^&*()")
|
||||||
viper.SetDefault("cache.max_size", 0)
|
viper.SetDefault("cache.max_size", 0)
|
||||||
viper.SetDefault("cache.max_pages", 20)
|
viper.SetDefault("cache.max_pages", 20)
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ var defaultConf = []byte(`# This is the default config file.
|
|||||||
# example.com
|
# example.com
|
||||||
# example.com:123
|
# example.com:123
|
||||||
|
|
||||||
|
|
||||||
[a-general]
|
[a-general]
|
||||||
# Press Ctrl-H to access it
|
# Press Ctrl-H to access it
|
||||||
home = "gemini://gemini.circumlunar.space"
|
home = "gemini://gemini.circumlunar.space"
|
||||||
@ -49,10 +50,18 @@ page_max_time = 10
|
|||||||
# Whether to replace tab numbers with emoji favicons, which are cached.
|
# Whether to replace tab numbers with emoji favicons, which are cached.
|
||||||
emoji_favicons = false
|
emoji_favicons = false
|
||||||
|
|
||||||
|
[keybindings]
|
||||||
|
# In the future there will be more settings here.
|
||||||
|
|
||||||
|
# Hold down shift and press the numbers on your keyboard (1,2,3,4,5,6,7,8,9,0) to set this up.
|
||||||
|
# It is default set to be accurate for US keyboards.
|
||||||
|
shift_numbers = "!@#$%^&*()"
|
||||||
|
|
||||||
|
|
||||||
|
[cache]
|
||||||
# Options for page cache - which is only for text/gemini pages
|
# Options for page cache - which is only for text/gemini pages
|
||||||
# Increase the cache size to speed up browsing at the expense of memory
|
# Increase the cache size to speed up browsing at the expense of memory
|
||||||
[cache]
|
|
||||||
# Zero values mean there is no limit
|
# Zero values mean there is no limit
|
||||||
max_size = 0 # Size in bytes
|
max_size = 0 # Size in bytes
|
||||||
max_pages = 30 # The maximum number of pages the cache will store
|
max_pages = 30 # The maximum number of pages the cache will store
|
||||||
|
24
config/keybindings.go
Normal file
24
config/keybindings.go
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
package config
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
|
||||||
|
"github.com/spf13/viper"
|
||||||
|
)
|
||||||
|
|
||||||
|
// KeyToNum returns the number on the user's keyboard they pressed,
|
||||||
|
// using the rune returned when when they press Shift+Num.
|
||||||
|
// The error is not nil if the provided key is invalid.
|
||||||
|
func KeyToNum(key rune) (int, error) {
|
||||||
|
runes := []rune(viper.GetString("keybindings.shift_numbers"))
|
||||||
|
for i := range runes {
|
||||||
|
if key == runes[i] {
|
||||||
|
if i == len(runes)-1 {
|
||||||
|
// Last key is 0, not 10
|
||||||
|
return 0, nil
|
||||||
|
}
|
||||||
|
return i + 1, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1, errors.New("provided key is invalid")
|
||||||
|
}
|
@ -8,6 +8,7 @@
|
|||||||
# example.com
|
# example.com
|
||||||
# example.com:123
|
# example.com:123
|
||||||
|
|
||||||
|
|
||||||
[a-general]
|
[a-general]
|
||||||
# Press Ctrl-H to access it
|
# Press Ctrl-H to access it
|
||||||
home = "gemini://gemini.circumlunar.space"
|
home = "gemini://gemini.circumlunar.space"
|
||||||
@ -46,10 +47,18 @@ page_max_time = 10
|
|||||||
# Whether to replace tab numbers with emoji favicons, which are cached.
|
# Whether to replace tab numbers with emoji favicons, which are cached.
|
||||||
emoji_favicons = false
|
emoji_favicons = false
|
||||||
|
|
||||||
|
[keybindings]
|
||||||
|
# In the future there will be more settings here.
|
||||||
|
|
||||||
|
# Hold down shift and press the numbers on your keyboard (1,2,3,4,5,6,7,8,9,0) to set this up.
|
||||||
|
# It is default set to be accurate for US keyboards.
|
||||||
|
shift_numbers = "!@#$%^&*()"
|
||||||
|
|
||||||
|
|
||||||
|
[cache]
|
||||||
# Options for page cache - which is only for text/gemini pages
|
# Options for page cache - which is only for text/gemini pages
|
||||||
# Increase the cache size to speed up browsing at the expense of memory
|
# Increase the cache size to speed up browsing at the expense of memory
|
||||||
[cache]
|
|
||||||
# Zero values mean there is no limit
|
# Zero values mean there is no limit
|
||||||
max_size = 0 # Size in bytes
|
max_size = 0 # Size in bytes
|
||||||
max_pages = 30 # The maximum number of pages the cache will store
|
max_pages = 30 # The maximum number of pages the cache will store
|
||||||
|
@ -354,6 +354,18 @@ func Init() {
|
|||||||
return nil
|
return nil
|
||||||
case tcell.KeyRune:
|
case tcell.KeyRune:
|
||||||
// Regular key was sent
|
// Regular key was sent
|
||||||
|
|
||||||
|
if num, err := config.KeyToNum(event.Rune()); err == nil {
|
||||||
|
// It's a Shift+Num key
|
||||||
|
if num == 0 {
|
||||||
|
// Zero key goes to the last tab
|
||||||
|
SwitchTab(NumTabs() - 1)
|
||||||
|
} else {
|
||||||
|
SwitchTab(num - 1)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
switch string(event.Rune()) {
|
switch string(event.Rune()) {
|
||||||
case "q":
|
case "q":
|
||||||
Stop()
|
Stop()
|
||||||
@ -361,38 +373,6 @@ func Init() {
|
|||||||
case "?":
|
case "?":
|
||||||
Help()
|
Help()
|
||||||
return nil
|
return nil
|
||||||
|
|
||||||
// Shift+NUMBER keys, for switching to a specific tab
|
|
||||||
case "!":
|
|
||||||
SwitchTab(0)
|
|
||||||
return nil
|
|
||||||
case "@":
|
|
||||||
SwitchTab(1)
|
|
||||||
return nil
|
|
||||||
case "#":
|
|
||||||
SwitchTab(2)
|
|
||||||
return nil
|
|
||||||
case "$":
|
|
||||||
SwitchTab(3)
|
|
||||||
return nil
|
|
||||||
case "%":
|
|
||||||
SwitchTab(4)
|
|
||||||
return nil
|
|
||||||
case "^":
|
|
||||||
SwitchTab(5)
|
|
||||||
return nil
|
|
||||||
case "&":
|
|
||||||
SwitchTab(6)
|
|
||||||
return nil
|
|
||||||
case "*":
|
|
||||||
SwitchTab(7)
|
|
||||||
return nil
|
|
||||||
case "(":
|
|
||||||
SwitchTab(8)
|
|
||||||
return nil
|
|
||||||
case ")": // Zero key goes to the last tab
|
|
||||||
SwitchTab(NumTabs() - 1)
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user