mirror of
https://github.com/miguelmota/cointop
synced 2024-11-05 00:00:14 +00:00
fix q key press + add quit view action
This commit is contained in:
parent
e623c10dfd
commit
d4619b162f
4
Makefile
4
Makefile
@ -1,7 +1,9 @@
|
||||
all:
|
||||
aul:
|
||||
@echo "no default"
|
||||
|
||||
run:
|
||||
go run main.go
|
||||
|
||||
debug:
|
||||
DEBUG=1 go run main.go
|
||||
|
||||
|
11
README.md
11
README.md
@ -145,7 +145,7 @@ Key|Action
|
||||
<kbd>Home</kbd>|Go to first line of page
|
||||
<kbd>End</kbd>|Go to last line of page
|
||||
<kbd>Enter</kbd>|Toggle [c]hart for highlighted coin
|
||||
<kbd>Esc</kbd>|Quit
|
||||
<kbd>Esc</kbd>|Quit view
|
||||
<kbd>Space</kbd>|Toggle coin as favorite
|
||||
<kbd>Ctrl</kbd>+<kbd>c</kbd>|Alias to quit
|
||||
<kbd>Ctrl</kbd>+<kbd>d</kbd>|Jump page down (vim inspired)
|
||||
@ -187,7 +187,7 @@ Key|Action
|
||||
<kbd>t</kbd>|Sort table by *[t]otal supply*
|
||||
<kbd>u</kbd>|Sort table by *last [u]pdated*
|
||||
<kbd>v</kbd>|Sort table by *24 hour [v]olume*
|
||||
<kbd>q</kbd>|[q]uit
|
||||
<kbd>q</kbd>|[q]uit view
|
||||
<kbd>$</kbd>|Go to last page (vim inspired)
|
||||
<kbd>?</kbd>|Show help|
|
||||
<kbd>/</kbd>|Search (vim inspired)|
|
||||
@ -261,7 +261,7 @@ You can then configure the actions you want for each key:
|
||||
p = "sort_column_price"
|
||||
pagedown = "page_down"
|
||||
pageup = "page_up"
|
||||
q = "quit"
|
||||
q = "quit_view"
|
||||
r = "sort_column_rank"
|
||||
s = "sort_column_symbol"
|
||||
space = "toggle_favorite"
|
||||
@ -298,6 +298,7 @@ Action|Description
|
||||
`previous_chart_range`|Select previous chart date range (e.g. 7D -> 3D)
|
||||
`previous_page`|Go to previous page
|
||||
`quit`|Quit application
|
||||
`quit_view`|Quit view
|
||||
`refresh`|Do a manual refresh on the data
|
||||
`save`|Save config
|
||||
`show_currency_convert_menu`|Show currency convert menu
|
||||
@ -445,6 +446,10 @@ Action|Description
|
||||
|
||||
- A: The CoinMarketCap API has rate limits, so make sure to keep manual refreshes to a minimum. If you've hit the rate limit then wait about half an hour to be able to fetch the data again. Keep in mind the oinMarketCap updates prices every 5 minutes constant refreshes aren't necessary.
|
||||
|
||||
- Q: How do I quit the application?
|
||||
|
||||
- A: Press <kbd>ctrl</kbd>+<kbd>c</kbd> to quit the application.
|
||||
|
||||
## Development
|
||||
|
||||
### Go
|
||||
|
@ -20,6 +20,7 @@ func actionsMap() map[string]bool {
|
||||
"page_up": true,
|
||||
"previous_page": true,
|
||||
"quit": true,
|
||||
"quit_view": true,
|
||||
"refresh": true,
|
||||
"sort_column_1h_change": true,
|
||||
"sort_column_24h_change": true,
|
||||
|
@ -184,15 +184,14 @@ func Run() {
|
||||
}
|
||||
|
||||
func (ct *Cointop) quit() error {
|
||||
if ct.helpvisible || ct.convertmenuvisible || ct.searchfieldvisible {
|
||||
return nil
|
||||
}
|
||||
|
||||
return ct.forceQuit()
|
||||
return gocui.ErrQuit
|
||||
}
|
||||
|
||||
func (ct *Cointop) forceQuit() error {
|
||||
return gocui.ErrQuit
|
||||
func (ct *Cointop) quitView() error {
|
||||
if ct.activeViewName() == ct.tableviewname {
|
||||
return ct.quit()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Exit safely exit application
|
||||
|
@ -293,6 +293,8 @@ func (ct *Cointop) keybindings(g *gocui.Gui) error {
|
||||
case "quit":
|
||||
fn = ct.keyfn(ct.quit)
|
||||
view = ""
|
||||
case "quit_view":
|
||||
fn = ct.keyfn(ct.quitView)
|
||||
case "next_chart_range":
|
||||
fn = ct.keyfn(ct.nextChartRange)
|
||||
case "previous_chart_range":
|
||||
@ -318,8 +320,8 @@ func (ct *Cointop) keybindings(g *gocui.Gui) error {
|
||||
}
|
||||
|
||||
// keys to force quit
|
||||
ct.setKeybindingMod(gocui.KeyCtrlC, gocui.ModNone, ct.keyfn(ct.forceQuit), "")
|
||||
ct.setKeybindingMod(gocui.KeyCtrlZ, gocui.ModNone, ct.keyfn(ct.forceQuit), "")
|
||||
ct.setKeybindingMod(gocui.KeyCtrlC, gocui.ModNone, ct.keyfn(ct.quit), "")
|
||||
ct.setKeybindingMod(gocui.KeyCtrlZ, gocui.ModNone, ct.keyfn(ct.quit), "")
|
||||
|
||||
// searchfield keys
|
||||
ct.setKeybindingMod(gocui.KeyEnter, gocui.ModNone, ct.keyfn(ct.doSearch), ct.searchfieldviewname)
|
||||
@ -328,13 +330,10 @@ func (ct *Cointop) keybindings(g *gocui.Gui) error {
|
||||
// keys to quit help when open
|
||||
ct.setKeybindingMod(gocui.KeyEsc, gocui.ModNone, ct.keyfn(ct.hideHelp), ct.helpviewname)
|
||||
ct.setKeybindingMod('q', gocui.ModNone, ct.keyfn(ct.hideHelp), ct.helpviewname)
|
||||
ct.setKeybindingMod('x', gocui.ModNone, ct.keyfn(ct.hideHelp), ct.helpviewname)
|
||||
ct.setKeybindingMod('c', gocui.ModNone, ct.keyfn(ct.hideHelp), ct.helpviewname)
|
||||
|
||||
// keys to quit convert menu when open
|
||||
ct.setKeybindingMod(gocui.KeyEsc, gocui.ModNone, ct.keyfn(ct.hideConvertMenu), ct.convertmenuviewname)
|
||||
ct.setKeybindingMod('q', gocui.ModNone, ct.keyfn(ct.hideConvertMenu), ct.convertmenuviewname)
|
||||
ct.setKeybindingMod('x', gocui.ModNone, ct.keyfn(ct.hideConvertMenu), ct.convertmenuviewname)
|
||||
|
||||
// character key press to select option
|
||||
// TODO: use scrolling table
|
||||
|
@ -150,6 +150,10 @@ func (ct *Cointop) setActiveView(v string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ct *Cointop) activeViewName() string {
|
||||
return ct.g.CurrentView().Name()
|
||||
}
|
||||
|
||||
func (ct *Cointop) setViewOnBottom(v string) error {
|
||||
_, err := ct.g.SetViewOnBottom(v)
|
||||
return err
|
||||
|
@ -11,7 +11,7 @@ func defaultShortcuts() map[string]string {
|
||||
"home": "move_to_page_first_row",
|
||||
"end": "move_to_page_last_row",
|
||||
"enter": "toggle_row_chart",
|
||||
"esc": "quit",
|
||||
"esc": "quit_view",
|
||||
"space": "toggle_favorite",
|
||||
"ctrl+c": "quit",
|
||||
"ctrl+d": "page_down",
|
||||
@ -54,7 +54,7 @@ func defaultShortcuts() map[string]string {
|
||||
"t": "sort_column_total_supply",
|
||||
"u": "sort_column_last_updated",
|
||||
"v": "sort_column_24h_volume",
|
||||
"q": "quit",
|
||||
"q": "quit_view",
|
||||
"$": "last_page",
|
||||
"?": "help",
|
||||
"/": "open_search",
|
||||
|
Loading…
Reference in New Issue
Block a user