fix q key press + add quit view action

pull/15/head
Miguel Mota 6 years ago
parent e623c10dfd
commit d4619b162f

@ -1,7 +1,9 @@
all: aul:
@echo "no default" @echo "no default"
run: run:
go run main.go
debug: debug:
DEBUG=1 go run main.go DEBUG=1 go run main.go

@ -145,7 +145,7 @@ Key|Action
<kbd>Home</kbd>|Go to first line of page <kbd>Home</kbd>|Go to first line of page
<kbd>End</kbd>|Go to last line of page <kbd>End</kbd>|Go to last line of page
<kbd>Enter</kbd>|Toggle [c]hart for highlighted coin <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>Space</kbd>|Toggle coin as favorite
<kbd>Ctrl</kbd>+<kbd>c</kbd>|Alias to quit <kbd>Ctrl</kbd>+<kbd>c</kbd>|Alias to quit
<kbd>Ctrl</kbd>+<kbd>d</kbd>|Jump page down (vim inspired) <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>t</kbd>|Sort table by *[t]otal supply*
<kbd>u</kbd>|Sort table by *last [u]pdated* <kbd>u</kbd>|Sort table by *last [u]pdated*
<kbd>v</kbd>|Sort table by *24 hour [v]olume* <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>|Go to last page (vim inspired)
<kbd>?</kbd>|Show help| <kbd>?</kbd>|Show help|
<kbd>/</kbd>|Search (vim inspired)| <kbd>/</kbd>|Search (vim inspired)|
@ -261,7 +261,7 @@ You can then configure the actions you want for each key:
p = "sort_column_price" p = "sort_column_price"
pagedown = "page_down" pagedown = "page_down"
pageup = "page_up" pageup = "page_up"
q = "quit" q = "quit_view"
r = "sort_column_rank" r = "sort_column_rank"
s = "sort_column_symbol" s = "sort_column_symbol"
space = "toggle_favorite" space = "toggle_favorite"
@ -298,6 +298,7 @@ Action|Description
`previous_chart_range`|Select previous chart date range (e.g. 7D -> 3D) `previous_chart_range`|Select previous chart date range (e.g. 7D -> 3D)
`previous_page`|Go to previous page `previous_page`|Go to previous page
`quit`|Quit application `quit`|Quit application
`quit_view`|Quit view
`refresh`|Do a manual refresh on the data `refresh`|Do a manual refresh on the data
`save`|Save config `save`|Save config
`show_currency_convert_menu`|Show currency convert menu `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. - 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 ## Development
### Go ### Go

@ -20,6 +20,7 @@ func actionsMap() map[string]bool {
"page_up": true, "page_up": true,
"previous_page": true, "previous_page": true,
"quit": true, "quit": true,
"quit_view": true,
"refresh": true, "refresh": true,
"sort_column_1h_change": true, "sort_column_1h_change": true,
"sort_column_24h_change": true, "sort_column_24h_change": true,

@ -184,15 +184,14 @@ func Run() {
} }
func (ct *Cointop) quit() error { func (ct *Cointop) quit() error {
if ct.helpvisible || ct.convertmenuvisible || ct.searchfieldvisible { return gocui.ErrQuit
return nil
}
return ct.forceQuit()
} }
func (ct *Cointop) forceQuit() error { func (ct *Cointop) quitView() error {
return gocui.ErrQuit if ct.activeViewName() == ct.tableviewname {
return ct.quit()
}
return nil
} }
// Exit safely exit application // Exit safely exit application

@ -293,6 +293,8 @@ func (ct *Cointop) keybindings(g *gocui.Gui) error {
case "quit": case "quit":
fn = ct.keyfn(ct.quit) fn = ct.keyfn(ct.quit)
view = "" view = ""
case "quit_view":
fn = ct.keyfn(ct.quitView)
case "next_chart_range": case "next_chart_range":
fn = ct.keyfn(ct.nextChartRange) fn = ct.keyfn(ct.nextChartRange)
case "previous_chart_range": case "previous_chart_range":
@ -318,8 +320,8 @@ func (ct *Cointop) keybindings(g *gocui.Gui) error {
} }
// keys to force quit // keys to force quit
ct.setKeybindingMod(gocui.KeyCtrlC, 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.forceQuit), "") ct.setKeybindingMod(gocui.KeyCtrlZ, gocui.ModNone, ct.keyfn(ct.quit), "")
// searchfield keys // searchfield keys
ct.setKeybindingMod(gocui.KeyEnter, gocui.ModNone, ct.keyfn(ct.doSearch), ct.searchfieldviewname) 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 // keys to quit help when open
ct.setKeybindingMod(gocui.KeyEsc, gocui.ModNone, ct.keyfn(ct.hideHelp), ct.helpviewname) 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('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 // keys to quit convert menu when open
ct.setKeybindingMod(gocui.KeyEsc, gocui.ModNone, ct.keyfn(ct.hideConvertMenu), ct.convertmenuviewname) 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('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 // character key press to select option
// TODO: use scrolling table // TODO: use scrolling table

@ -150,6 +150,10 @@ func (ct *Cointop) setActiveView(v string) error {
return nil return nil
} }
func (ct *Cointop) activeViewName() string {
return ct.g.CurrentView().Name()
}
func (ct *Cointop) setViewOnBottom(v string) error { func (ct *Cointop) setViewOnBottom(v string) error {
_, err := ct.g.SetViewOnBottom(v) _, err := ct.g.SetViewOnBottom(v)
return err return err

@ -11,7 +11,7 @@ func defaultShortcuts() map[string]string {
"home": "move_to_page_first_row", "home": "move_to_page_first_row",
"end": "move_to_page_last_row", "end": "move_to_page_last_row",
"enter": "toggle_row_chart", "enter": "toggle_row_chart",
"esc": "quit", "esc": "quit_view",
"space": "toggle_favorite", "space": "toggle_favorite",
"ctrl+c": "quit", "ctrl+c": "quit",
"ctrl+d": "page_down", "ctrl+d": "page_down",
@ -54,7 +54,7 @@ func defaultShortcuts() map[string]string {
"t": "sort_column_total_supply", "t": "sort_column_total_supply",
"u": "sort_column_last_updated", "u": "sort_column_last_updated",
"v": "sort_column_24h_volume", "v": "sort_column_24h_volume",
"q": "quit", "q": "quit_view",
"$": "last_page", "$": "last_page",
"?": "help", "?": "help",
"/": "open_search", "/": "open_search",

Loading…
Cancel
Save