|
|
|
@ -38,80 +38,80 @@ func (ct *Cointop) layout(g *gocui.Gui) error {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if !ct.State.hideMarketbar {
|
|
|
|
|
if v, err := g.SetView(ct.Views.Marketbar.Name, 0, topOffset, maxX, 2); err != nil {
|
|
|
|
|
if v, err := g.SetView(ct.Views.Marketbar.Name(), 0, topOffset, maxX, 2); err != nil {
|
|
|
|
|
if err != gocui.ErrUnknownView {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
ct.Views.Marketbar.Backing = v
|
|
|
|
|
ct.Views.Marketbar.Backing.Frame = false
|
|
|
|
|
ct.colorscheme.SetViewColor(ct.Views.Marketbar.Backing, "marketbar")
|
|
|
|
|
ct.Views.Marketbar.SetBacking(v)
|
|
|
|
|
ct.Views.Marketbar.Backing().Frame = false
|
|
|
|
|
ct.colorscheme.SetViewColor(ct.Views.Marketbar.Backing(), "marketbar")
|
|
|
|
|
go func() {
|
|
|
|
|
ct.updateMarketbar()
|
|
|
|
|
_, found := ct.cache.Get(ct.Views.Marketbar.Name)
|
|
|
|
|
_, found := ct.cache.Get(ct.Views.Marketbar.Name())
|
|
|
|
|
if found {
|
|
|
|
|
ct.cache.Delete(ct.Views.Marketbar.Name)
|
|
|
|
|
ct.cache.Delete(ct.Views.Marketbar.Name())
|
|
|
|
|
ct.updateMarketbar()
|
|
|
|
|
}
|
|
|
|
|
}()
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if ct.Views.Marketbar.Backing != nil {
|
|
|
|
|
if err := g.DeleteView(ct.Views.Marketbar.Name); err != nil {
|
|
|
|
|
if ct.Views.Marketbar.Backing() != nil {
|
|
|
|
|
if err := g.DeleteView(ct.Views.Marketbar.Name()); err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
ct.Views.Marketbar.Backing = nil
|
|
|
|
|
ct.Views.Marketbar.SetBacking(nil)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
topOffset = topOffset + marketbarHeight
|
|
|
|
|
|
|
|
|
|
if !ct.State.hideChart {
|
|
|
|
|
if v, err := g.SetView(ct.Views.Chart.Name, 0, topOffset, maxX, topOffset+chartHeight+marketbarHeight); err != nil {
|
|
|
|
|
if v, err := g.SetView(ct.Views.Chart.Name(), 0, topOffset, maxX, topOffset+chartHeight+marketbarHeight); err != nil {
|
|
|
|
|
if err != gocui.ErrUnknownView {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
ct.Views.Chart.Backing = v
|
|
|
|
|
ct.Views.Chart.Backing.Frame = false
|
|
|
|
|
ct.colorscheme.SetViewColor(ct.Views.Chart.Backing, "chart")
|
|
|
|
|
ct.Views.Chart.SetBacking(v)
|
|
|
|
|
ct.Views.Chart.Backing().Frame = false
|
|
|
|
|
ct.colorscheme.SetViewColor(ct.Views.Chart.Backing(), "chart")
|
|
|
|
|
go func() {
|
|
|
|
|
ct.updateChart()
|
|
|
|
|
ct.UpdateChart()
|
|
|
|
|
cachekey := strings.ToLower(fmt.Sprintf("%s_%s", "globaldata", strings.Replace(ct.State.selectedChartRange, " ", "", -1)))
|
|
|
|
|
_, found := ct.cache.Get(cachekey)
|
|
|
|
|
if found {
|
|
|
|
|
ct.cache.Delete(cachekey)
|
|
|
|
|
ct.updateChart()
|
|
|
|
|
ct.UpdateChart()
|
|
|
|
|
}
|
|
|
|
|
}()
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if ct.Views.Chart.Backing != nil {
|
|
|
|
|
if err := g.DeleteView(ct.Views.Chart.Name); err != nil {
|
|
|
|
|
if ct.Views.Chart.Backing() != nil {
|
|
|
|
|
if err := g.DeleteView(ct.Views.Chart.Name()); err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
ct.Views.Chart.Backing = nil
|
|
|
|
|
ct.Views.Chart.SetBacking(nil)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
topOffset = topOffset + chartHeight
|
|
|
|
|
if v, err := g.SetView(ct.Views.Header.Name, 0, topOffset, ct.maxTableWidth, topOffset+2); err != nil {
|
|
|
|
|
if v, err := g.SetView(ct.Views.TableHeader.Name(), 0, topOffset, ct.maxTableWidth, topOffset+2); err != nil {
|
|
|
|
|
if err != gocui.ErrUnknownView {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
ct.Views.Header.Backing = v
|
|
|
|
|
ct.Views.Header.Backing.Frame = false
|
|
|
|
|
ct.colorscheme.SetViewColor(ct.Views.Header.Backing, "table_header")
|
|
|
|
|
go ct.updateHeaders()
|
|
|
|
|
ct.Views.TableHeader.SetBacking(v)
|
|
|
|
|
ct.Views.TableHeader.Backing().Frame = false
|
|
|
|
|
ct.colorscheme.SetViewColor(ct.Views.TableHeader.Backing(), "table_header")
|
|
|
|
|
go ct.updateTableHeader()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
topOffset = topOffset + headerHeight
|
|
|
|
|
if v, err := g.SetView(ct.Views.Table.Name, 0, topOffset, ct.maxTableWidth, maxY-statusbarHeight); err != nil {
|
|
|
|
|
if v, err := g.SetView(ct.Views.Table.Name(), 0, topOffset, ct.maxTableWidth, maxY-statusbarHeight); err != nil {
|
|
|
|
|
if err != gocui.ErrUnknownView {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
ct.Views.Table.Backing = v
|
|
|
|
|
ct.Views.Table.Backing.Frame = false
|
|
|
|
|
ct.Views.Table.Backing.Highlight = true
|
|
|
|
|
ct.colorscheme.SetViewActiveColor(ct.Views.Table.Backing, "table_row_active")
|
|
|
|
|
ct.Views.Table.SetBacking(v)
|
|
|
|
|
ct.Views.Table.Backing().Frame = false
|
|
|
|
|
ct.Views.Table.Backing().Highlight = true
|
|
|
|
|
ct.colorscheme.SetViewActiveColor(ct.Views.Table.Backing(), "table_row_active")
|
|
|
|
|
_, found := ct.cache.Get("allCoinsSlugMap")
|
|
|
|
|
if found {
|
|
|
|
|
ct.cache.Delete("allCoinsSlugMap")
|
|
|
|
@ -123,81 +123,81 @@ func (ct *Cointop) layout(g *gocui.Gui) error {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if !ct.State.hideStatusbar {
|
|
|
|
|
if v, err := g.SetView(ct.Views.Statusbar.Name, 0, maxY-statusbarHeight-1, ct.maxTableWidth, maxY); err != nil {
|
|
|
|
|
if v, err := g.SetView(ct.Views.Statusbar.Name(), 0, maxY-statusbarHeight-1, ct.maxTableWidth, maxY); err != nil {
|
|
|
|
|
if err != gocui.ErrUnknownView {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
ct.Views.Statusbar.Backing = v
|
|
|
|
|
ct.Views.Statusbar.Backing.Frame = false
|
|
|
|
|
ct.colorscheme.SetViewColor(ct.Views.Statusbar.Backing, "statusbar")
|
|
|
|
|
ct.Views.Statusbar.SetBacking(v)
|
|
|
|
|
ct.Views.Statusbar.Backing().Frame = false
|
|
|
|
|
ct.colorscheme.SetViewColor(ct.Views.Statusbar.Backing(), "statusbar")
|
|
|
|
|
go ct.updateStatusbar("")
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if ct.Views.Statusbar.Backing != nil {
|
|
|
|
|
if err := g.DeleteView(ct.Views.Statusbar.Name); err != nil {
|
|
|
|
|
if ct.Views.Statusbar.Backing() != nil {
|
|
|
|
|
if err := g.DeleteView(ct.Views.Statusbar.Name()); err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
ct.Views.Statusbar.Backing = nil
|
|
|
|
|
ct.Views.Statusbar.SetBacking(nil)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if v, err := g.SetView(ct.Views.SearchField.Name, 0, maxY-2, ct.maxTableWidth, maxY); err != nil {
|
|
|
|
|
if v, err := g.SetView(ct.Views.SearchField.Name(), 0, maxY-2, ct.maxTableWidth, maxY); err != nil {
|
|
|
|
|
if err != gocui.ErrUnknownView {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
ct.Views.SearchField.Backing = v
|
|
|
|
|
ct.Views.SearchField.Backing.Editable = true
|
|
|
|
|
ct.Views.SearchField.Backing.Wrap = true
|
|
|
|
|
ct.Views.SearchField.Backing.Frame = false
|
|
|
|
|
ct.colorscheme.SetViewColor(ct.Views.SearchField.Backing, "searchbar")
|
|
|
|
|
ct.Views.SearchField.SetBacking(v)
|
|
|
|
|
ct.Views.SearchField.Backing().Editable = true
|
|
|
|
|
ct.Views.SearchField.Backing().Wrap = true
|
|
|
|
|
ct.Views.SearchField.Backing().Frame = false
|
|
|
|
|
ct.colorscheme.SetViewColor(ct.Views.SearchField.Backing(), "searchbar")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if v, err := g.SetView(ct.Views.Help.Name, 1, 1, ct.maxTableWidth-1, maxY-1); err != nil {
|
|
|
|
|
if v, err := g.SetView(ct.Views.Help.Name(), 1, 1, ct.maxTableWidth-1, maxY-1); err != nil {
|
|
|
|
|
if err != gocui.ErrUnknownView {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
ct.Views.Help.Backing = v
|
|
|
|
|
ct.Views.Help.Backing.Frame = false
|
|
|
|
|
ct.colorscheme.SetViewColor(ct.Views.Help.Backing, "menu")
|
|
|
|
|
ct.Views.Help.SetBacking(v)
|
|
|
|
|
ct.Views.Help.Backing().Frame = false
|
|
|
|
|
ct.colorscheme.SetViewColor(ct.Views.Help.Backing(), "menu")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if v, err := g.SetView(ct.Views.PortfolioUpdateMenu.Name, 1, 1, ct.maxTableWidth-1, maxY-1); err != nil {
|
|
|
|
|
if v, err := g.SetView(ct.Views.PortfolioUpdateMenu.Name(), 1, 1, ct.maxTableWidth-1, maxY-1); err != nil {
|
|
|
|
|
if err != gocui.ErrUnknownView {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
ct.Views.PortfolioUpdateMenu.Backing = v
|
|
|
|
|
ct.Views.PortfolioUpdateMenu.Backing.Frame = false
|
|
|
|
|
ct.colorscheme.SetViewColor(ct.Views.PortfolioUpdateMenu.Backing, "menu")
|
|
|
|
|
ct.Views.PortfolioUpdateMenu.SetBacking(v)
|
|
|
|
|
ct.Views.PortfolioUpdateMenu.Backing().Frame = false
|
|
|
|
|
ct.colorscheme.SetViewColor(ct.Views.PortfolioUpdateMenu.Backing(), "menu")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if v, err := g.SetView(ct.Views.Input.Name, 3, 6, 30, 8); err != nil {
|
|
|
|
|
if v, err := g.SetView(ct.Views.Input.Name(), 3, 6, 30, 8); err != nil {
|
|
|
|
|
if err != gocui.ErrUnknownView {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
ct.Views.Input.Backing = v
|
|
|
|
|
ct.Views.Input.Backing.Frame = true
|
|
|
|
|
ct.Views.Input.Backing.Editable = true
|
|
|
|
|
ct.Views.Input.Backing.Wrap = true
|
|
|
|
|
ct.colorscheme.SetViewColor(ct.Views.Input.Backing, "menu")
|
|
|
|
|
ct.Views.Input.SetBacking(v)
|
|
|
|
|
ct.Views.Input.Backing().Frame = true
|
|
|
|
|
ct.Views.Input.Backing().Editable = true
|
|
|
|
|
ct.Views.Input.Backing().Wrap = true
|
|
|
|
|
ct.colorscheme.SetViewColor(ct.Views.Input.Backing(), "menu")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if v, err := g.SetView(ct.Views.ConvertMenu.Name, 1, 1, ct.maxTableWidth-1, maxY-1); err != nil {
|
|
|
|
|
if v, err := g.SetView(ct.Views.ConvertMenu.Name(), 1, 1, ct.maxTableWidth-1, maxY-1); err != nil {
|
|
|
|
|
if err != gocui.ErrUnknownView {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
ct.Views.ConvertMenu.Backing = v
|
|
|
|
|
ct.Views.ConvertMenu.Backing.Frame = false
|
|
|
|
|
ct.colorscheme.SetViewColor(ct.Views.ConvertMenu.Backing, "menu")
|
|
|
|
|
ct.Views.ConvertMenu.SetBacking(v)
|
|
|
|
|
ct.Views.ConvertMenu.Backing().Frame = false
|
|
|
|
|
ct.colorscheme.SetViewColor(ct.Views.ConvertMenu.Backing(), "menu")
|
|
|
|
|
|
|
|
|
|
// run only once on init.
|
|
|
|
|
// this bit of code should be at the bottom
|
|
|
|
|
ct.g = g
|
|
|
|
|
g.SetViewOnBottom(ct.Views.SearchField.Name) // hide
|
|
|
|
|
g.SetViewOnBottom(ct.Views.Help.Name) // hide
|
|
|
|
|
g.SetViewOnBottom(ct.Views.ConvertMenu.Name) // hide
|
|
|
|
|
g.SetViewOnBottom(ct.Views.PortfolioUpdateMenu.Name) // hide
|
|
|
|
|
g.SetViewOnBottom(ct.Views.Input.Name) // hide
|
|
|
|
|
ct.setActiveView(ct.Views.Table.Name)
|
|
|
|
|
g.SetViewOnBottom(ct.Views.SearchField.Name()) // hide
|
|
|
|
|
g.SetViewOnBottom(ct.Views.Help.Name()) // hide
|
|
|
|
|
g.SetViewOnBottom(ct.Views.ConvertMenu.Name()) // hide
|
|
|
|
|
g.SetViewOnBottom(ct.Views.PortfolioUpdateMenu.Name()) // hide
|
|
|
|
|
g.SetViewOnBottom(ct.Views.Input.Name()) // hide
|
|
|
|
|
ct.SetActiveView(ct.Views.Table.Name())
|
|
|
|
|
ct.intervalFetchData()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|