table toggle fullscreen shortcut

pull/42/head
Miguel Mota 5 years ago
parent 47b4b8461c
commit 29283b7d8e
No known key found for this signature in database
GPG Key ID: 67EC1161588A00F9

@ -348,6 +348,7 @@ Key|Action
<kbd>[</kbd>|Previous chart date range|
<kbd>}</kbd>|Last chart date range|
<kbd>{</kbd>|First chart date range|
<kbd>\\</kbd>|Toggle table fullscreen|
## Colorschemes
@ -413,6 +414,7 @@ refresh_rate = 60
"?" = "help"
"/" = "open_search"
"[" = "previous_chart_range"
"\\" = "toggle_table_fullscreen"
"]" = "next_chart_range"
"{" = "first_chart_range"
"}" = "last_chart_range"
@ -543,6 +545,7 @@ Action|Description
`toggle_portfolio`|Toggle portfolio view
`toggle_show_portfolio`|Toggle show portfolio view
`show_portfolio_edit_menu`|Show portfolio edit holdings menu
`toggle_table_fullscreen`|Toggle table fullscreen
## FAQ
@ -851,6 +854,10 @@ Frequently asked questions:
<img width="880" alt="table view only" src="https://user-images.githubusercontent.com/168240/60208658-b0387e80-980d-11e9-8819-8039fb11218f.png" />
- Q: How do I toggle the table to go fullscreen?
- A: Press <kbd>\\</kbd> to toggle the table fullscreen mode.
- Q: How can I hide the top marketbar?
- A: Run cointop with the `--hide-marketbar` flag.

@ -50,6 +50,10 @@ func (ct *Cointop) updateChart() error {
}
}
ct.update(func() {
if ct.chartview == nil {
return
}
fmt.Fprint(ct.chartview, ct.colorscheme.Chart(body))
})

@ -241,6 +241,11 @@ func NewCointop(config *Config) *Cointop {
log.Fatal(err)
}
ct.cache.Set("onlyTable", ct.onlyTable, cache.NoExpiration)
ct.cache.Set("hideMarketbar", ct.hideMarketbar, cache.NoExpiration)
ct.cache.Set("hideChart", ct.hideChart, cache.NoExpiration)
ct.cache.Set("hideStatusbar", ct.hideStatusbar, cache.NoExpiration)
if config.RefreshRate != nil {
ct.refreshRate = time.Duration(*config.RefreshRate) * time.Second
}

@ -171,6 +171,10 @@ func (ct *Cointop) updateConvertMenu() {
content := fmt.Sprintf("%s%s%s", header, helpline, body)
ct.update(func() {
if ct.convertmenuview == nil {
return
}
ct.convertmenuview.Clear()
ct.convertmenuview.Frame = true
fmt.Fprintln(ct.convertmenuview, content)
@ -189,6 +193,10 @@ func (ct *Cointop) hideConvertMenu() error {
ct.setViewOnBottom(ct.convertmenuviewname)
ct.setActiveView(ct.tableviewname)
ct.update(func() {
if ct.convertmenuview == nil {
return
}
ct.convertmenuview.Clear()
ct.convertmenuview.Frame = false
fmt.Fprintln(ct.convertmenuview, "")

@ -78,6 +78,10 @@ func (ct *Cointop) updateHeaders() {
}
ct.update(func() {
if ct.headersview == nil {
return
}
ct.headersview.Clear()
fmt.Fprintln(ct.headersview, strings.Join(headers, ""))
})

@ -56,6 +56,10 @@ func (ct *Cointop) updateHelp() {
content := header + infoline + body + versionline
ct.update(func() {
if ct.helpview == nil {
return
}
ct.helpview.Clear()
ct.helpview.Frame = true
fmt.Fprintln(ct.helpview, content)
@ -74,6 +78,10 @@ func (ct *Cointop) hideHelp() error {
ct.setViewOnBottom(ct.helpviewname)
ct.setActiveView(ct.tableviewname)
ct.update(func() {
if ct.helpview == nil {
return
}
ct.helpview.Clear()
ct.helpview.Frame = false
fmt.Fprintln(ct.helpview, "")

@ -18,8 +18,10 @@ func (ct *Cointop) parseKeys(s string) (interface{}, gocui.Modifier) {
s = k
} else if m == "ctrl" {
switch k {
case "0": // not supported?
case "1": // not supported?
case "0":
key = '0'
case "1":
key = '1'
case "2":
key = gocui.KeyCtrl2
case "3":
@ -34,7 +36,8 @@ func (ct *Cointop) parseKeys(s string) (interface{}, gocui.Modifier) {
key = gocui.KeyCtrl7
case "8":
key = gocui.KeyCtrl8
case "9": // not supported?
case "9":
key = '9'
case "a":
key = gocui.KeyCtrlA
case "b":
@ -111,6 +114,8 @@ func (ct *Cointop) parseKeys(s string) (interface{}, gocui.Modifier) {
key = gocui.KeyCtrlBackslash
case "underscore":
key = gocui.KeyCtrlUnderscore
case "\\\\":
key = '\\'
}
return key, mod
}
@ -194,6 +199,8 @@ func (ct *Cointop) parseKeys(s string) (interface{}, gocui.Modifier) {
key = gocui.KeyHome
case "end":
key = gocui.KeyEnd
case "\\\\":
key = '\\'
}
return key, mod
@ -323,6 +330,9 @@ func (ct *Cointop) keybindings(g *gocui.Gui) error {
fn = ct.keyfn(ct.toggleShowPortfolio)
case "show_portfolio_edit_menu":
fn = ct.keyfn(ct.togglePortfolioUpdateMenu)
case "toggle_table_fullscreen":
fn = ct.keyfn(ct.toggleTableFullscreen)
view = ""
default:
fn = ct.keyfn(ct.noop)
}

@ -52,6 +52,13 @@ func (ct *Cointop) layout(g *gocui.Gui) error {
}
}()
}
} else {
if ct.marketbarview != nil {
if err := g.DeleteView(ct.marketbarviewname); err != nil {
return err
}
ct.marketbarview = nil
}
}
topOffset = topOffset + marketbarHeight
@ -74,6 +81,13 @@ func (ct *Cointop) layout(g *gocui.Gui) error {
}
}()
}
} else {
if ct.chartview != nil {
if err := g.DeleteView(ct.chartviewname); err != nil {
return err
}
ct.chartview = nil
}
}
topOffset = topOffset + chartHeight
@ -107,7 +121,7 @@ func (ct *Cointop) layout(g *gocui.Gui) error {
}
if !ct.hideStatusbar {
if v, err := g.SetView(ct.statusbarviewname, 0, maxY-2, ct.maxtablewidth, maxY); err != nil {
if v, err := g.SetView(ct.statusbarviewname, 0, maxY-statusbarHeight-1, ct.maxtablewidth, maxY); err != nil {
if err != gocui.ErrUnknownView {
return err
}
@ -116,6 +130,13 @@ func (ct *Cointop) layout(g *gocui.Gui) error {
ct.colorscheme.SetViewColor(ct.statusbarview, "statusbar")
go ct.updateStatusbar("")
}
} else {
if ct.statusbarview != nil {
if err := g.DeleteView(ct.statusbarviewname); err != nil {
return err
}
ct.statusbarview = nil
}
}
if v, err := g.SetView(ct.searchfieldviewname, 0, maxY-2, ct.maxtablewidth, maxY); err != nil {

@ -133,6 +133,10 @@ func (ct *Cointop) updateMarketbar() error {
content = ct.colorscheme.Marketbar(content)
ct.update(func() {
if ct.marketbarview == nil {
return
}
ct.marketbarview.Clear()
fmt.Fprintln(ct.marketbarview, content)
})

@ -79,6 +79,10 @@ func (ct *Cointop) hidePortfolioUpdateMenu() error {
ct.setViewOnBottom(ct.inputviewname)
ct.setActiveView(ct.tableviewname)
ct.update(func() {
if ct.portfolioupdatemenuview == nil {
return
}
ct.portfolioupdatemenuview.Clear()
ct.portfolioupdatemenuview.Frame = false
fmt.Fprintln(ct.portfolioupdatemenuview, "")

@ -1,8 +1,7 @@
package cointop
func defaultShortcuts() map[string]string {
return map[string]string{
"up": "move_up",
return map[string]string{"up": "move_up",
"down": "move_down",
"left": "previous_page",
"right": "next_page",
@ -71,5 +70,6 @@ func defaultShortcuts() map[string]string {
"[": "previous_chart_range",
"}": "last_chart_range",
"{": "first_chart_range",
"\\\\": "toggle_table_fullscreen",
}
}

@ -34,6 +34,10 @@ func (ct *Cointop) updateStatusbar(s string) error {
}
ct.update(func() {
if ct.statusbarview == nil {
return
}
ct.statusbarview.Clear()
base := fmt.Sprintf("%s%s %sHelp %sChart %sRange %sSearch %sConvert %s %s %sSave", "[Q]", quitText, "[?]", "[Enter]", "[[ ]]", "[/]", "[C]", favoritesText, portfolioText, "[CTRL-S]")
str := pad.Right(fmt.Sprintf("%v %sPage %v/%v %s", base, "[← →]", currpage, totalpages, s), ct.maxtablewidth, " ")

@ -153,6 +153,10 @@ func (ct *Cointop) refreshTable() error {
}
ct.update(func() {
if ct.tableview == nil {
return
}
ct.tableview.Clear()
ct.table.Format().Fprint(ct.tableview)
go ct.rowChanged()
@ -314,3 +318,30 @@ func (ct *Cointop) coinBySymbol(symbol string) *Coin {
return nil
}
func (ct *Cointop) toggleTableFullscreen() error {
ct.onlyTable = !ct.onlyTable
if ct.onlyTable {
} else {
// NOTE: cached values are initial config settings.
// If the only-table config was set then toggle
// all other initial hidden views.
onlyTable, _ := ct.cache.Get("onlyTable")
if onlyTable.(bool) {
ct.hideMarketbar = false
ct.hideChart = false
ct.hideStatusbar = false
} else {
// NOTE: cached values store initial hidden views preferences.
hideMarketbar, _ := ct.cache.Get("hideMarketbar")
ct.hideMarketbar = hideMarketbar.(bool)
hideChart, _ := ct.cache.Get("hideChart")
ct.hideChart = hideChart.(bool)
hideStatusbar, _ := ct.cache.Get("hideStatusbar")
ct.hideStatusbar = hideStatusbar.(bool)
}
}
return nil
}

Loading…
Cancel
Save