Update method descriptions

pull/49/head 1.4.1
Miguel Mota 5 years ago
parent 6f286490be
commit b61e2fdd84

@ -4,9 +4,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [1.4.1] - 2019-11-17
### Fixed
- Fix version ldflags
## [1.4.0] - 2019-11-17 ## [1.4.0] - 2019-11-17
### Added ### Added
- Keyboard shortcuts to enlarge and shorten chart. - Keyboard shortcuts to enlarge and shorten chart
## [1.3.6] - 2019-09-15 ## [1.3.6] - 2019-09-15
### Fixed ### Fixed

@ -1,6 +1,7 @@
package cointop package cointop
func actionsMap() map[string]bool { // ActionsMap returns a map of all the available actions
func ActionsMap() map[string]bool {
return map[string]bool{ return map[string]bool{
"first_page": true, "first_page": true,
"help": true, "help": true,
@ -58,5 +59,5 @@ func actionsMap() map[string]bool {
// ActionExists returns true if action exists // ActionExists returns true if action exists
func (ct *Cointop) ActionExists(action string) bool { func (ct *Cointop) ActionExists(action string) bool {
return ct.actionsMap[action] return ct.ActionsMap[action]
} }

@ -8,13 +8,15 @@ import (
"github.com/miguelmota/cointop/cointop/common/filecache" "github.com/miguelmota/cointop/cointop/common/filecache"
) )
func (ct *Cointop) cacheKey(key string) string { // CacheKey returns cached value given key
ct.debuglog("cacheKey()") func (ct *Cointop) CacheKey(key string) string {
ct.debuglog("CacheKey()")
return strings.ToLower(fmt.Sprintf("%s_%s", ct.apiChoice, key)) return strings.ToLower(fmt.Sprintf("%s_%s", ct.apiChoice, key))
} }
func (ct *Cointop) cacheAllCoinsSlugMap() { // CacheAllCoinsSlugMap writes the coins map to the memory and disk cache
ct.debuglog("cacheAllCoinsSlugMap()") func (ct *Cointop) CacheAllCoinsSlugMap() {
ct.debuglog("CacheAllCoinsSlugMap()")
allCoinsSlugMap := make(map[string]*Coin) allCoinsSlugMap := make(map[string]*Coin)
ct.State.allCoinsSlugMap.Range(func(key, value interface{}) bool { ct.State.allCoinsSlugMap.Range(func(key, value interface{}) bool {
allCoinsSlugMap[key.(string)] = value.(*Coin) allCoinsSlugMap[key.(string)] = value.(*Coin)
@ -23,7 +25,7 @@ func (ct *Cointop) cacheAllCoinsSlugMap() {
// NOTE: do not override with empty data on startup // NOTE: do not override with empty data on startup
if len(allCoinsSlugMap) != 0 { if len(allCoinsSlugMap) != 0 {
cachekey := ct.cacheKey("allCoinsSlugMap") cachekey := ct.CacheKey("allCoinsSlugMap")
ct.cache.Set(cachekey, allCoinsSlugMap, 10*time.Second) ct.cache.Set(cachekey, allCoinsSlugMap, 10*time.Second)
filecache.Set(cachekey, allCoinsSlugMap, 24*time.Hour) filecache.Set(cachekey, allCoinsSlugMap, 24*time.Hour)
} }

@ -58,7 +58,7 @@ func chartRangesMap() map[string]time.Duration {
// UpdateChart updates the chart view // UpdateChart updates the chart view
func (ct *Cointop) UpdateChart() error { func (ct *Cointop) UpdateChart() error {
ct.debuglog("updateChart()") ct.debuglog("UpdateChart()")
if ct.Views.Chart.Backing() == nil { if ct.Views.Chart.Backing() == nil {
return nil return nil
} }
@ -94,7 +94,7 @@ func (ct *Cointop) UpdateChart() error {
} }
} }
ct.update(func() { ct.Update(func() {
if ct.Views.Chart.Backing() == nil { if ct.Views.Chart.Backing() == nil {
return return
} }
@ -107,7 +107,7 @@ func (ct *Cointop) UpdateChart() error {
// ChartPoints calculates the the chart points // ChartPoints calculates the the chart points
func (ct *Cointop) ChartPoints(symbol string, name string) error { func (ct *Cointop) ChartPoints(symbol string, name string) error {
ct.debuglog("chartPoints()") ct.debuglog("ChartPoints()")
maxX := ct.ClampedWidth() maxX := ct.ClampedWidth()
chartPointsLock.Lock() chartPointsLock.Lock()
@ -140,7 +140,7 @@ func (ct *Cointop) ChartPoints(symbol string, name string) error {
if keyname == "" { if keyname == "" {
keyname = "globaldata" keyname = "globaldata"
} }
cachekey := ct.cacheKey(fmt.Sprintf("%s_%s", keyname, strings.Replace(ct.State.selectedChartRange, " ", "", -1))) cachekey := ct.CacheKey(fmt.Sprintf("%s_%s", keyname, strings.Replace(ct.State.selectedChartRange, " ", "", -1)))
cached, found := ct.cache.Get(cachekey) cached, found := ct.cache.Get(cachekey)
if found { if found {
@ -211,7 +211,7 @@ func (ct *Cointop) ChartPoints(symbol string, name string) error {
// PortfolioChart renders the portfolio chart // PortfolioChart renders the portfolio chart
func (ct *Cointop) PortfolioChart() error { func (ct *Cointop) PortfolioChart() error {
ct.debuglog("portfolioChart()") ct.debuglog("PortfolioChart()")
maxX := ct.ClampedWidth() maxX := ct.ClampedWidth()
chartPointsLock.Lock() chartPointsLock.Lock()
defer chartPointsLock.Unlock() defer chartPointsLock.Unlock()
@ -348,7 +348,7 @@ func (ct *Cointop) EnlargeChart() error {
// NextChartRange sets the chart to the next range option // NextChartRange sets the chart to the next range option
func (ct *Cointop) NextChartRange() error { func (ct *Cointop) NextChartRange() error {
ct.debuglog("nextChartRange()") ct.debuglog("NextChartRange()")
sel := 0 sel := 0
max := len(ct.chartRanges) max := len(ct.chartRanges)
for i, k := range ct.chartRanges { for i, k := range ct.chartRanges {
@ -369,7 +369,7 @@ func (ct *Cointop) NextChartRange() error {
// PrevChartRange sets the chart to the prevous range option // PrevChartRange sets the chart to the prevous range option
func (ct *Cointop) PrevChartRange() error { func (ct *Cointop) PrevChartRange() error {
ct.debuglog("prevChartRange()") ct.debuglog("PrevChartRange()")
sel := 0 sel := 0
for i, k := range ct.chartRanges { for i, k := range ct.chartRanges {
if k == ct.State.selectedChartRange { if k == ct.State.selectedChartRange {
@ -388,7 +388,7 @@ func (ct *Cointop) PrevChartRange() error {
// FirstChartRange sets the chart to the first range option // FirstChartRange sets the chart to the first range option
func (ct *Cointop) FirstChartRange() error { func (ct *Cointop) FirstChartRange() error {
ct.debuglog("firstChartRange()") ct.debuglog("FirstChartRange()")
ct.State.selectedChartRange = ct.chartRanges[0] ct.State.selectedChartRange = ct.chartRanges[0]
go ct.UpdateChart() go ct.UpdateChart()
return nil return nil
@ -396,7 +396,7 @@ func (ct *Cointop) FirstChartRange() error {
// LastChartRange sets the chart to the last range option // LastChartRange sets the chart to the last range option
func (ct *Cointop) LastChartRange() error { func (ct *Cointop) LastChartRange() error {
ct.debuglog("lastChartRange()") ct.debuglog("LastChartRange()")
ct.State.selectedChartRange = ct.chartRanges[len(ct.chartRanges)-1] ct.State.selectedChartRange = ct.chartRanges[len(ct.chartRanges)-1]
go ct.UpdateChart() go ct.UpdateChart()
return nil return nil
@ -404,7 +404,7 @@ func (ct *Cointop) LastChartRange() error {
// ToggleCoinChart toggles between the global chart and the coin chart // ToggleCoinChart toggles between the global chart and the coin chart
func (ct *Cointop) ToggleCoinChart() error { func (ct *Cointop) ToggleCoinChart() error {
ct.debuglog("toggleCoinChart()") ct.debuglog("ToggleCoinChart()")
highlightedcoin := ct.HighlightedRowCoin() highlightedcoin := ct.HighlightedRowCoin()
if ct.State.selectedCoin == highlightedcoin { if ct.State.selectedCoin == highlightedcoin {
ct.State.selectedCoin = nil ct.State.selectedCoin = nil
@ -420,8 +420,8 @@ func (ct *Cointop) ToggleCoinChart() error {
// ShowChartLoader shows chart loading indicator // ShowChartLoader shows chart loading indicator
func (ct *Cointop) ShowChartLoader() error { func (ct *Cointop) ShowChartLoader() error {
ct.debuglog("showChartLoader()") ct.debuglog("ShowChartLoader()")
ct.update(func() { ct.Update(func() {
if ct.Views.Chart.Backing() == nil { if ct.Views.Chart.Backing() == nil {
return return
} }

@ -23,8 +23,9 @@ type Coin struct {
Balance float64 Balance float64
} }
func (ct *Cointop) allCoins() []*Coin { // AllCoins returns a slice of all the coins
ct.debuglog("allCoins()") func (ct *Cointop) AllCoins() []*Coin {
ct.debuglog("AllCoins()")
if ct.State.filterByFavorites { if ct.State.filterByFavorites {
var list []*Coin var list []*Coin
for i := range ct.State.allCoins { for i := range ct.State.allCoins {
@ -50,8 +51,9 @@ func (ct *Cointop) allCoins() []*Coin {
return ct.State.allCoins return ct.State.allCoins
} }
func (ct *Cointop) coinBySymbol(symbol string) *Coin { // CoinBySymbol returns the coin struct given the symbol
ct.debuglog("coinBySymbol()") func (ct *Cointop) CoinBySymbol(symbol string) *Coin {
ct.debuglog("CoinBySymbol()")
for i := range ct.State.allCoins { for i := range ct.State.allCoins {
coin := ct.State.allCoins[i] coin := ct.State.allCoins[i]
if coin.Symbol == symbol { if coin.Symbol == symbol {

@ -77,7 +77,7 @@ type State struct {
// Cointop cointop // Cointop cointop
type Cointop struct { type Cointop struct {
g *gocui.Gui g *gocui.Gui
actionsMap map[string]bool ActionsMap map[string]bool
apiKeys *APIKeys apiKeys *APIKeys
cache *cache.Cache cache *cache.Cache
config config // toml config config config // toml config
@ -97,7 +97,7 @@ type Cointop struct {
saveMux sync.Mutex saveMux sync.Mutex
State *State State *State
table *table.Table table *table.Table
tableColumnOrder []string TableColumnOrder []string
Views *Views Views *Views
} }
@ -159,7 +159,7 @@ func NewCointop(config *Config) (*Cointop, error) {
apiKeys: new(APIKeys), apiKeys: new(APIKeys),
forceRefresh: make(chan bool), forceRefresh: make(chan bool),
maxTableWidth: 175, maxTableWidth: 175,
actionsMap: actionsMap(), ActionsMap: ActionsMap(),
cache: cache.New(1*time.Minute, 2*time.Minute), cache: cache.New(1*time.Minute, 2*time.Minute),
configFilepath: configFilepath, configFilepath: configFilepath,
chartRanges: chartRanges(), chartRanges: chartRanges(),
@ -178,7 +178,7 @@ func NewCointop(config *Config) (*Cointop, error) {
onlyTable: config.OnlyTable, onlyTable: config.OnlyTable,
refreshRate: 60 * time.Second, refreshRate: 60 * time.Second,
selectedChartRange: "7D", selectedChartRange: "7D",
shortcutKeys: defaultShortcuts(), shortcutKeys: DefaultShortcuts(),
sortBy: "rank", sortBy: "rank",
page: 0, page: 0,
perPage: 100, perPage: 100,
@ -187,7 +187,7 @@ func NewCointop(config *Config) (*Cointop, error) {
}, },
chartHeight: 10, chartHeight: 10,
}, },
tableColumnOrder: tableColumnOrder(), TableColumnOrder: TableColumnOrder(),
Views: &Views{ Views: &Views{
Chart: NewChartView(), Chart: NewChartView(),
Table: NewTableView(), Table: NewTableView(),
@ -252,7 +252,7 @@ func NewCointop(config *Config) (*Cointop, error) {
apiKey := os.Getenv("CMC_PRO_API_KEY") apiKey := os.Getenv("CMC_PRO_API_KEY")
if apiKey == "" { if apiKey == "" {
if !config.NoPrompts { if !config.NoPrompts {
ct.apiKeys.cmc = ct.readAPIKeyFromStdin("CoinMarketCap Pro") ct.apiKeys.cmc = ct.ReadAPIKeyFromStdin("CoinMarketCap Pro")
} }
} else { } else {
ct.apiKeys.cmc = apiKey ct.apiKeys.cmc = apiKey
@ -275,7 +275,7 @@ func NewCointop(config *Config) (*Cointop, error) {
} }
allCoinsSlugMap := make(map[string]*Coin) allCoinsSlugMap := make(map[string]*Coin)
coinscachekey := ct.cacheKey("allCoinsSlugMap") coinscachekey := ct.CacheKey("allCoinsSlugMap")
filecache.Get(coinscachekey, &allCoinsSlugMap) filecache.Get(coinscachekey, &allCoinsSlugMap)
for k, v := range allCoinsSlugMap { for k, v := range allCoinsSlugMap {
@ -314,12 +314,12 @@ func NewCointop(config *Config) (*Cointop, error) {
}) })
var globaldata []float64 var globaldata []float64
chartcachekey := ct.cacheKey(fmt.Sprintf("%s_%s", "globaldata", strings.Replace(ct.State.selectedChartRange, " ", "", -1))) chartcachekey := ct.CacheKey(fmt.Sprintf("%s_%s", "globaldata", strings.Replace(ct.State.selectedChartRange, " ", "", -1)))
filecache.Get(chartcachekey, &globaldata) filecache.Get(chartcachekey, &globaldata)
ct.cache.Set(chartcachekey, globaldata, 10*time.Second) ct.cache.Set(chartcachekey, globaldata, 10*time.Second)
var market types.GlobalMarketData var market types.GlobalMarketData
marketcachekey := ct.cacheKey("market") marketcachekey := ct.CacheKey("market")
filecache.Get(marketcachekey, &market) filecache.Get(marketcachekey, &market)
ct.cache.Set(marketcachekey, market, 10*time.Second) ct.cache.Set(marketcachekey, market, 10*time.Second)

@ -4,6 +4,7 @@ import (
"testing" "testing"
) )
// TestRun tests that cointop runs
func TestRun(t *testing.T) { func TestRun(t *testing.T) {
// Run() // Run()
} }

@ -10,16 +10,16 @@ import (
// TODO: fix hex color support // TODO: fix hex color support
// colorschemeColors .. // colorschemeColors is a map of color string names to Attribute types
type colorschemeColors map[string]interface{} type colorschemeColors map[string]interface{}
// ISprintf ... // ISprintf is a sprintf interface
type ISprintf func(...interface{}) string type ISprintf func(...interface{}) string
// colorCache .. // colorCache is a map of color string names to sprintf functions
type colorCache map[string]ISprintf type colorCache map[string]ISprintf
// Colorscheme ... // Colorscheme is the struct for colorscheme
type Colorscheme struct { type Colorscheme struct {
colors colorschemeColors colors colorschemeColors
cache colorCache cache colorCache
@ -320,14 +320,17 @@ func (c *Colorscheme) toBgAttr(v string) (fcolor.Attribute, bool) {
return 0, false return 0, false
} }
// toBoldAttr converts a boolean to an Attribute type
func (c *Colorscheme) toBoldAttr(v bool) (fcolor.Attribute, bool) { func (c *Colorscheme) toBoldAttr(v bool) (fcolor.Attribute, bool) {
return fcolor.Bold, v return fcolor.Bold, v
} }
// toUnderlineAttr converts a boolean to an Attribute type
func (c *Colorscheme) toUnderlineAttr(v bool) (fcolor.Attribute, bool) { func (c *Colorscheme) toUnderlineAttr(v bool) (fcolor.Attribute, bool) {
return fcolor.Underline, v return fcolor.Underline, v
} }
// toGocuiAttr converts a color string name to a gocui Attribute type
func (c *Colorscheme) toGocuiAttr(v string) (gocui.Attribute, bool) { func (c *Colorscheme) toGocuiAttr(v string) (gocui.Attribute, bool) {
if attr, ok := gocuiColorschemeColorsMap[v]; ok { if attr, ok := gocuiColorschemeColorsMap[v]; ok {
return attr, true return attr, true
@ -340,6 +343,7 @@ func (c *Colorscheme) toGocuiAttr(v string) (gocui.Attribute, bool) {
return 0, false return 0, false
} }
// hexToAnsi converts a hex color string to a uint8 ansi code
func hexToAnsi(h string) (uint8, bool) { func hexToAnsi(h string) (uint8, bool) {
if h == "" { if h == "" {
return 0, false return 0, false

@ -174,7 +174,7 @@ func (ct *Cointop) updateConvertMenu() {
} }
content := fmt.Sprintf("%s%s%s", header, helpline, body) content := fmt.Sprintf("%s%s%s", header, helpline, body)
ct.update(func() { ct.Update(func() {
if ct.Views.ConvertMenu.Backing() == nil { if ct.Views.ConvertMenu.Backing() == nil {
return return
} }
@ -197,7 +197,7 @@ func (ct *Cointop) setCurrencyConverstionFn(convert string) func() error {
ct.State.currencyConversion = convert ct.State.currencyConversion = convert
if err := ct.save(); err != nil { if err := ct.Save(); err != nil {
return err return err
} }
@ -230,7 +230,7 @@ func (ct *Cointop) hideConvertMenu() error {
ct.State.convertMenuVisible = false ct.State.convertMenuVisible = false
ct.SetViewOnBottom(ct.Views.ConvertMenu.Name()) ct.SetViewOnBottom(ct.Views.ConvertMenu.Name())
ct.SetActiveView(ct.Views.Table.Name()) ct.SetActiveView(ct.Views.Table.Name())
ct.update(func() { ct.Update(func() {
if ct.Views.ConvertMenu.Backing() == nil { if ct.Views.ConvertMenu.Backing() == nil {
return return
} }

@ -8,6 +8,7 @@ import (
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
) )
// debuglog writs a debug log to stdout
func (ct *Cointop) debuglog(msg string) { func (ct *Cointop) debuglog(msg string) {
if !ct.debug { if !ct.debug {
return return

@ -1,6 +1,6 @@
package cointop package cointop
// DefaultColors ... // DefaultColors is the default color scheme
var DefaultColors = ` var DefaultColors = `
colorscheme = "cointop" colorscheme = "cointop"

@ -1,7 +1,7 @@
package cointop package cointop
// RowChanged is called when the row is updated // RowChanged is called when the row is updated
func (ct *Cointop) rowChanged() { func (ct *Cointop) RowChanged() {
ct.debuglog("rowChanged()") ct.debuglog("RowChanged()")
ct.RefreshRowLink() ct.RefreshRowLink()
} }

@ -18,11 +18,11 @@ func (ct *Cointop) toggleFavorite() error {
coin.Favorite = true coin.Favorite = true
} }
if err := ct.save(); err != nil { if err := ct.Save(); err != nil {
return err return err
} }
go ct.updateTable() go ct.UpdateTable()
return nil return nil
} }
@ -31,7 +31,7 @@ func (ct *Cointop) toggleShowFavorites() error {
ct.debuglog("toggleShowFavorites()") ct.debuglog("toggleShowFavorites()")
ct.State.portfolioVisible = false ct.State.portfolioVisible = false
ct.State.filterByFavorites = !ct.State.filterByFavorites ct.State.filterByFavorites = !ct.State.filterByFavorites
go ct.updateTable() go ct.UpdateTable()
return nil return nil
} }

@ -58,7 +58,7 @@ func (ct *Cointop) updateHelp() {
versionline := pad.Left(fmt.Sprintf("v%s", ct.Version()), ct.maxTableWidth-5, " ") versionline := pad.Left(fmt.Sprintf("v%s", ct.Version()), ct.maxTableWidth-5, " ")
content := header + infoline + body + versionline content := header + infoline + body + versionline
ct.update(func() { ct.Update(func() {
if ct.Views.Help.Backing() == nil { if ct.Views.Help.Backing() == nil {
return return
} }
@ -82,7 +82,7 @@ func (ct *Cointop) hideHelp() error {
ct.State.helpVisible = false ct.State.helpVisible = false
ct.SetViewOnBottom(ct.Views.Help.Name()) ct.SetViewOnBottom(ct.Views.Help.Name())
ct.SetActiveView(ct.Views.Table.Name()) ct.SetActiveView(ct.Views.Table.Name())
ct.update(func() { ct.Update(func() {
if ct.Views.Help.Backing() == nil { if ct.Views.Help.Backing() == nil {
return return
} }

@ -303,7 +303,7 @@ func (ct *Cointop) keybindings(g *gocui.Gui) error {
case "toggle_show_favorites": case "toggle_show_favorites":
fn = ct.keyfn(ct.toggleShowFavorites) fn = ct.keyfn(ct.toggleShowFavorites)
case "save": case "save":
fn = ct.keyfn(ct.save) fn = ct.keyfn(ct.Save)
case "quit": case "quit":
fn = ct.keyfn(ct.Quit) fn = ct.keyfn(ct.Quit)
view = "" view = ""

@ -106,7 +106,7 @@ func (ct *Cointop) layout(g *gocui.Gui) error {
ct.Views.TableHeader.SetBacking(v) ct.Views.TableHeader.SetBacking(v)
ct.Views.TableHeader.Backing().Frame = false ct.Views.TableHeader.Backing().Frame = false
ct.colorscheme.SetViewColor(ct.Views.TableHeader.Backing(), "table_header") ct.colorscheme.SetViewColor(ct.Views.TableHeader.Backing(), "table_header")
go ct.updateTableHeader() go ct.UpdateTableHeader()
} }
topOffset = topOffset + headerHeight topOffset = topOffset + headerHeight
@ -124,7 +124,7 @@ func (ct *Cointop) layout(g *gocui.Gui) error {
} }
go func() { go func() {
ct.updateCoins() ct.updateCoins()
ct.updateTable() ct.UpdateTable()
}() }()
} }
@ -136,7 +136,7 @@ func (ct *Cointop) layout(g *gocui.Gui) error {
ct.Views.Statusbar.SetBacking(v) ct.Views.Statusbar.SetBacking(v)
ct.Views.Statusbar.Backing().Frame = false ct.Views.Statusbar.Backing().Frame = false
ct.colorscheme.SetViewColor(ct.Views.Statusbar.Backing(), "statusbar") ct.colorscheme.SetViewColor(ct.Views.Statusbar.Backing(), "statusbar")
go ct.updateStatusbar("") go ct.UpdateStatusbar("")
} }
} else { } else {
if ct.Views.Statusbar.Backing() != nil { if ct.Views.Statusbar.Backing() != nil {

@ -14,7 +14,7 @@ func (ct *Cointop) updateCoins() error {
ct.debuglog("updateCoins()") ct.debuglog("updateCoins()")
coinslock.Lock() coinslock.Lock()
defer coinslock.Unlock() defer coinslock.Unlock()
cachekey := ct.cacheKey("allCoinsSlugMap") cachekey := ct.CacheKey("allCoinsSlugMap")
var err error var err error
var allCoinsSlugMap map[string]types.Coin var allCoinsSlugMap map[string]types.Coin
@ -60,7 +60,7 @@ func (ct *Cointop) processCoins(coins []types.Coin) {
updatecoinsmux.Lock() updatecoinsmux.Lock()
defer updatecoinsmux.Unlock() defer updatecoinsmux.Unlock()
ct.cacheAllCoinsSlugMap() ct.CacheAllCoinsSlugMap()
for _, v := range coins { for _, v := range coins {
k := v.Name k := v.Name
@ -138,7 +138,7 @@ func (ct *Cointop) processCoins(coins []types.Coin) {
time.AfterFunc(10*time.Millisecond, func() { time.AfterFunc(10*time.Millisecond, func() {
ct.sort(ct.State.sortBy, ct.State.sortDesc, ct.State.coins, true) ct.sort(ct.State.sortBy, ct.State.sortDesc, ct.State.coins, true)
ct.updateTable() ct.UpdateTable()
}) })
} }

@ -91,7 +91,7 @@ func (ct *Cointop) updateMarketbar() error {
} else { } else {
var market types.GlobalMarketData var market types.GlobalMarketData
var err error var err error
cachekey := ct.cacheKey("market") cachekey := ct.CacheKey("market")
cached, found := ct.cache.Get(cachekey) cached, found := ct.cache.Get(cachekey)
if found { if found {
@ -143,7 +143,7 @@ func (ct *Cointop) updateMarketbar() error {
content = pad.Right(content, maxX, " ") content = pad.Right(content, maxX, " ")
content = ct.colorscheme.Marketbar(content) content = ct.colorscheme.Marketbar(content)
ct.update(func() { ct.Update(func() {
if ct.Views.Marketbar.Backing() == nil { if ct.Views.Marketbar.Backing() == nil {
return return
} }

@ -52,7 +52,7 @@ func (ct *Cointop) cursorDown() error {
return err return err
} }
} }
ct.rowChanged() ct.RowChanged()
return nil return nil
} }
@ -76,7 +76,7 @@ func (ct *Cointop) cursorUp() error {
return err return err
} }
} }
ct.rowChanged() ct.RowChanged()
return nil return nil
} }
@ -115,7 +115,7 @@ func (ct *Cointop) pageDown() error {
return err return err
} }
} }
ct.rowChanged() ct.RowChanged()
return nil return nil
} }
@ -146,7 +146,7 @@ func (ct *Cointop) pageUp() error {
return err return err
} }
} }
ct.rowChanged() ct.RowChanged()
return nil return nil
} }
@ -169,7 +169,7 @@ func (ct *Cointop) navigateFirstLine() error {
if err := ct.Views.Table.Backing().SetCursor(cx, 0); err != nil { if err := ct.Views.Table.Backing().SetCursor(cx, 0); err != nil {
return err return err
} }
ct.rowChanged() ct.RowChanged()
return nil return nil
} }
@ -195,7 +195,7 @@ func (ct *Cointop) navigateLastLine() error {
if err := ct.Views.Table.Backing().SetCursor(cx, sy-1); err != nil { if err := ct.Views.Table.Backing().SetCursor(cx, sy-1); err != nil {
return err return err
} }
ct.rowChanged() ct.RowChanged()
return nil return nil
} }
@ -214,7 +214,7 @@ func (ct *Cointop) navigatePageFirstLine() error {
if err := ct.Views.Table.Backing().SetCursor(cx, 0); err != nil { if err := ct.Views.Table.Backing().SetCursor(cx, 0); err != nil {
return err return err
} }
ct.rowChanged() ct.RowChanged()
return nil return nil
} }
@ -234,7 +234,7 @@ func (ct *Cointop) navigatePageMiddleLine() error {
if err := ct.Views.Table.Backing().SetCursor(cx, (sy/2)-1); err != nil { if err := ct.Views.Table.Backing().SetCursor(cx, (sy/2)-1); err != nil {
return err return err
} }
ct.rowChanged() ct.RowChanged()
return nil return nil
} }
@ -254,7 +254,7 @@ func (ct *Cointop) navigatePageLastLine() error {
if err := ct.Views.Table.Backing().SetCursor(cx, sy-1); err != nil { if err := ct.Views.Table.Backing().SetCursor(cx, sy-1); err != nil {
return err return err
} }
ct.rowChanged() ct.RowChanged()
return nil return nil
} }
@ -267,8 +267,8 @@ func (ct *Cointop) prevPage() error {
} }
ct.setPage(ct.State.page - 1) ct.setPage(ct.State.page - 1)
ct.updateTable() ct.UpdateTable()
ct.rowChanged() ct.RowChanged()
return nil return nil
} }
@ -281,8 +281,8 @@ func (ct *Cointop) nextPage() error {
} }
ct.setPage(ct.State.page + 1) ct.setPage(ct.State.page + 1)
ct.updateTable() ct.UpdateTable()
ct.rowChanged() ct.RowChanged()
return nil return nil
} }
@ -295,8 +295,8 @@ func (ct *Cointop) firstPage() error {
} }
ct.State.page = 0 ct.State.page = 0
ct.updateTable() ct.UpdateTable()
ct.rowChanged() ct.RowChanged()
return nil return nil
} }
@ -361,8 +361,8 @@ func (ct *Cointop) lastPage() error {
} }
ct.State.page = ct.getListCount() / ct.State.perPage ct.State.page = ct.getListCount() / ct.State.perPage
ct.updateTable() ct.UpdateTable()
ct.rowChanged() ct.RowChanged()
return nil return nil
} }
@ -375,7 +375,7 @@ func (ct *Cointop) goToPageRowIndex(idx int) error {
if err := ct.Views.Table.Backing().SetCursor(cx, idx); err != nil { if err := ct.Views.Table.Backing().SetCursor(cx, idx); err != nil {
return err return err
} }
ct.rowChanged() ct.RowChanged()
return nil return nil
} }
@ -386,7 +386,7 @@ func (ct *Cointop) goToGlobalIndex(idx int) error {
ct.setPage(atpage) ct.setPage(atpage)
rowIndex := (idx % perpage) rowIndex := (idx % perpage)
ct.highlightRow(rowIndex) ct.highlightRow(rowIndex)
ct.updateTable() ct.UpdateTable()
return nil return nil
} }

@ -33,7 +33,7 @@ func (ct *Cointop) togglePortfolio() error {
ct.State.portfolioVisible = !ct.State.portfolioVisible ct.State.portfolioVisible = !ct.State.portfolioVisible
go ct.UpdateChart() go ct.UpdateChart()
go ct.updateTable() go ct.UpdateTable()
return nil return nil
} }
@ -42,7 +42,7 @@ func (ct *Cointop) toggleShowPortfolio() error {
ct.State.filterByFavorites = false ct.State.filterByFavorites = false
ct.State.portfolioVisible = true ct.State.portfolioVisible = true
go ct.UpdateChart() go ct.UpdateChart()
go ct.updateTable() go ct.UpdateTable()
return nil return nil
} }
@ -82,7 +82,7 @@ func (ct *Cointop) updatePortfolioUpdateMenu() {
label := fmt.Sprintf(" Enter holdings for %s %s", ct.colorscheme.MenuLabel(coin.Name), current) label := fmt.Sprintf(" Enter holdings for %s %s", ct.colorscheme.MenuLabel(coin.Name), current)
content := fmt.Sprintf("%s\n%s\n\n%s%s\n\n\n [Enter] %s [ESC] Cancel", header, label, strings.Repeat(" ", 29), coin.Symbol, submitText) content := fmt.Sprintf("%s\n%s\n\n%s%s\n\n\n [Enter] %s [ESC] Cancel", header, label, strings.Repeat(" ", 29), coin.Symbol, submitText)
ct.update(func() { ct.Update(func() {
ct.Views.PortfolioUpdateMenu.Backing().Clear() ct.Views.PortfolioUpdateMenu.Backing().Clear()
ct.Views.PortfolioUpdateMenu.Backing().Frame = true ct.Views.PortfolioUpdateMenu.Backing().Frame = true
fmt.Fprintln(ct.Views.PortfolioUpdateMenu.Backing(), content) fmt.Fprintln(ct.Views.PortfolioUpdateMenu.Backing(), content)
@ -112,7 +112,7 @@ func (ct *Cointop) hidePortfolioUpdateMenu() error {
ct.SetViewOnBottom(ct.Views.PortfolioUpdateMenu.Name()) ct.SetViewOnBottom(ct.Views.PortfolioUpdateMenu.Name())
ct.SetViewOnBottom(ct.Views.Input.Name()) ct.SetViewOnBottom(ct.Views.Input.Name())
ct.SetActiveView(ct.Views.Table.Name()) ct.SetActiveView(ct.Views.Table.Name())
ct.update(func() { ct.Update(func() {
if ct.Views.PortfolioUpdateMenu.Backing() == nil { if ct.Views.PortfolioUpdateMenu.Backing() == nil {
return return
} }
@ -158,9 +158,9 @@ func (ct *Cointop) setPortfolioHoldings() error {
if shouldDelete { if shouldDelete {
ct.removePortfolioEntry(coin.Name) ct.removePortfolioEntry(coin.Name)
ct.updateTable() ct.UpdateTable()
} else { } else {
ct.updateTable() ct.UpdateTable()
ct.goToPageRowIndex(ct.State.lastSelectedRowIndex) ct.goToPageRowIndex(ct.State.lastSelectedRowIndex)
} }
@ -208,7 +208,7 @@ func (ct *Cointop) setPortfolioEntry(coin string, holdings float64) {
p.Holdings = holdings p.Holdings = holdings
} }
if err := ct.save(); err != nil { if err := ct.Save(); err != nil {
log.Fatal(err) log.Fatal(err)
} }
} }

@ -16,11 +16,11 @@ func (ct *Cointop) QuitView() error {
ct.debuglog("quitView()") ct.debuglog("quitView()")
if ct.State.portfolioVisible { if ct.State.portfolioVisible {
ct.State.portfolioVisible = false ct.State.portfolioVisible = false
return ct.updateTable() return ct.UpdateTable()
} }
if ct.State.filterByFavorites { if ct.State.filterByFavorites {
ct.State.filterByFavorites = false ct.State.filterByFavorites = false
return ct.updateTable() return ct.UpdateTable()
} }
if ct.ActiveViewName() == ct.Views.Table.Name() { if ct.ActiveViewName() == ct.Views.Table.Name() {
return ct.Quit() return ct.Quit()

@ -23,7 +23,7 @@ func (ct *Cointop) refreshAll() error {
ct.cache.Delete("market") ct.cache.Delete("market")
go func() { go func() {
ct.updateCoins() ct.updateCoins()
ct.updateTable() ct.UpdateTable()
ct.UpdateChart() ct.UpdateChart()
}() }()
return nil return nil
@ -33,7 +33,7 @@ func (ct *Cointop) setRefreshStatus() {
ct.debuglog("setRefreshStatus()") ct.debuglog("setRefreshStatus()")
go func() { go func() {
ct.loadingTicks("refreshing", 900) ct.loadingTicks("refreshing", 900)
ct.rowChanged() ct.RowChanged()
}() }()
} }
@ -42,7 +42,7 @@ func (ct *Cointop) loadingTicks(s string, t int) {
interval := 150 interval := 150
k := 0 k := 0
for i := 0; i < (t / interval); i++ { for i := 0; i < (t / interval); i++ {
ct.updateStatusbar(s + strings.Repeat(".", k)) ct.UpdateStatusbar(s + strings.Repeat(".", k))
time.Sleep(time.Duration(i*interval) * time.Millisecond) time.Sleep(time.Duration(i*interval) * time.Millisecond)
k = k + 1 k = k + 1
if k > 3 { if k > 3 {

@ -2,27 +2,29 @@ package cointop
import "log" import "log"
func (ct *Cointop) save() error { // Save saves the cointop settings to the config file
ct.debuglog("save()") func (ct *Cointop) Save() error {
ct.setSavingStatus() ct.debuglog("Save()")
ct.SetSavingStatus()
if err := ct.saveConfig(); err != nil { if err := ct.saveConfig(); err != nil {
log.Fatal(err) log.Fatal(err)
} }
ct.cacheAllCoinsSlugMap() ct.CacheAllCoinsSlugMap()
return nil return nil
} }
func (ct *Cointop) setSavingStatus() { // SetSavingStatus sets the saving indicator in the statusbar
ct.debuglog("setSavingStatus()") func (ct *Cointop) SetSavingStatus() {
ct.debuglog("SetSavingStatus()")
if ct.g == nil { if ct.g == nil {
return return
} }
go func() { go func() {
ct.loadingTicks("saving", 590) ct.loadingTicks("saving", 590)
ct.updateStatusbar("") ct.UpdateStatusbar("")
ct.rowChanged() ct.RowChanged()
}() }()
} }

@ -1,6 +1,7 @@
package cointop package cointop
func defaultShortcuts() map[string]string { // DefaultShortcuts is a map of the default shortcuts
func DefaultShortcuts() map[string]string {
return map[string]string{"up": "move_up", return map[string]string{"up": "move_up",
"down": "move_down", "down": "move_down",
"left": "previous_page", "left": "previous_page",

@ -68,52 +68,52 @@ func (ct *Cointop) sort(sortBy string, desc bool, list []*Coin, renderHeaders bo
}) })
if renderHeaders { if renderHeaders {
ct.updateTableHeader() ct.UpdateTableHeader()
} }
} }
func (ct *Cointop) sortAsc() error { func (ct *Cointop) sortAsc() error {
ct.debuglog("sortAsc()") ct.debuglog("sortAsc()")
ct.State.sortDesc = false ct.State.sortDesc = false
ct.updateTable() ct.UpdateTable()
return nil return nil
} }
func (ct *Cointop) sortDesc() error { func (ct *Cointop) sortDesc() error {
ct.debuglog("sortDesc()") ct.debuglog("sortDesc()")
ct.State.sortDesc = true ct.State.sortDesc = true
ct.updateTable() ct.UpdateTable()
return nil return nil
} }
func (ct *Cointop) sortPrevCol() error { func (ct *Cointop) sortPrevCol() error {
ct.debuglog("sortPrevCol()") ct.debuglog("sortPrevCol()")
nextsortBy := ct.tableColumnOrder[0] nextsortBy := ct.TableColumnOrder[0]
i := ct.getSortColIndex() i := ct.getSortColIndex()
k := i - 1 k := i - 1
if k < 0 { if k < 0 {
k = 0 k = 0
} }
nextsortBy = ct.tableColumnOrder[k] nextsortBy = ct.TableColumnOrder[k]
ct.sort(nextsortBy, ct.State.sortDesc, ct.State.coins, true) ct.sort(nextsortBy, ct.State.sortDesc, ct.State.coins, true)
ct.updateTable() ct.UpdateTable()
return nil return nil
} }
func (ct *Cointop) sortNextCol() error { func (ct *Cointop) sortNextCol() error {
ct.debuglog("sortNextCol()") ct.debuglog("sortNextCol()")
nextsortBy := ct.tableColumnOrder[0] nextsortBy := ct.TableColumnOrder[0]
l := len(ct.tableColumnOrder) l := len(ct.TableColumnOrder)
i := ct.getSortColIndex() i := ct.getSortColIndex()
k := i + 1 k := i + 1
if k > l-1 { if k > l-1 {
k = l - 1 k = l - 1
} }
nextsortBy = ct.tableColumnOrder[k] nextsortBy = ct.TableColumnOrder[k]
ct.sort(nextsortBy, ct.State.sortDesc, ct.State.coins, true) ct.sort(nextsortBy, ct.State.sortDesc, ct.State.coins, true)
ct.updateTable() ct.UpdateTable()
return nil return nil
} }
@ -124,7 +124,7 @@ func (ct *Cointop) sortToggle(sortBy string, desc bool) error {
} }
ct.sort(sortBy, desc, ct.State.coins, true) ct.sort(sortBy, desc, ct.State.coins, true)
ct.updateTable() ct.UpdateTable()
return nil return nil
} }
@ -137,7 +137,7 @@ func (ct *Cointop) sortfn(sortBy string, desc bool) func(g *gocui.Gui, v *gocui.
func (ct *Cointop) getSortColIndex() int { func (ct *Cointop) getSortColIndex() int {
ct.debuglog("getSortColIndex()") ct.debuglog("getSortColIndex()")
for i, col := range ct.tableColumnOrder { for i, col := range ct.TableColumnOrder {
if ct.State.sortBy == col { if ct.State.sortBy == col {
return i return i
} }

@ -29,9 +29,9 @@ func (statusbar *StatusbarView) Update(str string) error {
return nil return nil
} }
// updateStatusbar updates the statusbar view // UpdateStatusbar updates the statusbar view
func (ct *Cointop) updateStatusbar(s string) error { func (ct *Cointop) UpdateStatusbar(s string) error {
ct.debuglog("updateStatusbar()") ct.debuglog("UpdateStatusbar()")
currpage := ct.currentDisplayPage() currpage := ct.currentDisplayPage()
totalpages := ct.totalPagesDisplay() totalpages := ct.totalPagesDisplay()
var quitText string var quitText string
@ -63,7 +63,7 @@ func (ct *Cointop) updateStatusbar(s string) error {
str = str[:end] + v str = str[:end] + v
ct.update(func() { ct.Update(func() {
ct.Views.Statusbar.Update(str) ct.Views.Statusbar.Update(str)
}) })
@ -72,14 +72,14 @@ func (ct *Cointop) updateStatusbar(s string) error {
// RefreshRowLink updates the row link in the statusbar // RefreshRowLink updates the row link in the statusbar
func (ct *Cointop) RefreshRowLink() error { func (ct *Cointop) RefreshRowLink() error {
ct.debuglog("refreshRowLink()") ct.debuglog("RefreshRowLink()")
var shortcut string var shortcut string
if !open.CommandExists() { if !open.CommandExists() {
shortcut = "[O]Open " shortcut = "[O]Open "
} }
url := ct.RowLinkShort() url := ct.RowLinkShort()
ct.updateStatusbar(fmt.Sprintf("%s%s", shortcut, url)) ct.UpdateStatusbar(fmt.Sprintf("%s%s", shortcut, url))
return nil return nil
} }

@ -9,9 +9,9 @@ import (
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
) )
// readAPIKeyFromStdin reads the user inputed API from the stdin prompt // ReadAPIKeyFromStdin reads the user inputed API from the stdin prompt
func (ct *Cointop) readAPIKeyFromStdin(name string) string { func (ct *Cointop) ReadAPIKeyFromStdin(name string) string {
ct.debuglog("readAPIKeyFromStdin()") ct.debuglog("ReadAPIKeyFromStdin()")
reader := bufio.NewReader(os.Stdin) reader := bufio.NewReader(os.Stdin)
fmt.Printf("Enter %s API Key: ", name) fmt.Printf("Enter %s API Key: ", name)
text, err := reader.ReadString('\n') text, err := reader.ReadString('\n')

@ -24,7 +24,7 @@ func NewTableView() *TableView {
} }
// TableColumnOrder returns the default order of the table columns // TableColumnOrder returns the default order of the table columns
func tableColumnOrder() []string { func TableColumnOrder() []string {
return []string{ return []string{
"rank", "rank",
"name", "name",
@ -193,15 +193,15 @@ func (ct *Cointop) RefreshTable() error {
ct.highlightRow(currentrow) ct.highlightRow(currentrow)
} }
ct.update(func() { ct.Update(func() {
if ct.Views.Table.Backing() == nil { if ct.Views.Table.Backing() == nil {
return return
} }
ct.Views.Table.Backing().Clear() ct.Views.Table.Backing().Clear()
ct.table.Format().Fprint(ct.Views.Table.Backing()) ct.table.Format().Fprint(ct.Views.Table.Backing())
go ct.rowChanged() go ct.RowChanged()
go ct.updateTableHeader() go ct.UpdateTableHeader()
go ct.updateMarketbar() go ct.updateMarketbar()
go ct.UpdateChart() go ct.UpdateChart()
}) })
@ -209,9 +209,9 @@ func (ct *Cointop) RefreshTable() error {
return nil return nil
} }
// updateTable updates the table // UpdateTable updates the table
func (ct *Cointop) updateTable() error { func (ct *Cointop) UpdateTable() error {
ct.debuglog("updateTable()") ct.debuglog("UpdateTable()")
ct.State.allCoinsSlugMap.Range(func(key, value interface{}) bool { ct.State.allCoinsSlugMap.Range(func(key, value interface{}) bool {
k := key.(string) k := key.(string)
if v, ok := value.(*Coin); ok { if v, ok := value.(*Coin); ok {
@ -233,7 +233,7 @@ func (ct *Cointop) updateTable() error {
ct.State.sortDesc = false ct.State.sortDesc = false
} }
ct.State.coins = ct.getTableCoinsSlice() ct.State.coins = ct.GetTableCoinsSlice()
} }
ct.sort(ct.State.sortBy, ct.State.sortDesc, ct.State.coins, true) ct.sort(ct.State.sortBy, ct.State.sortDesc, ct.State.coins, true)
@ -241,13 +241,13 @@ func (ct *Cointop) updateTable() error {
return nil return nil
} }
// getTableCoinsSlice ... // GetTableCoinsSlice returns a slice of the table rows
func (ct *Cointop) getTableCoinsSlice() []*Coin { func (ct *Cointop) GetTableCoinsSlice() []*Coin {
ct.debuglog("getTableCoinsSlice()") ct.debuglog("GetTableCoinsSlice()")
sliced := []*Coin{} sliced := []*Coin{}
start := ct.State.page * ct.State.perPage start := ct.State.page * ct.State.perPage
end := start + ct.State.perPage end := start + ct.State.perPage
allCoins := ct.allCoins() allCoins := ct.AllCoins()
size := len(allCoins) size := len(allCoins)
if start < 0 { if start < 0 {
start = 0 start = 0
@ -286,7 +286,7 @@ func (ct *Cointop) getTableCoinsSlice() []*Coin {
// HighlightedRowIndex returns the index of the highlighted row // HighlightedRowIndex returns the index of the highlighted row
func (ct *Cointop) HighlightedRowIndex() int { func (ct *Cointop) HighlightedRowIndex() int {
ct.debuglog("highlightedRowIndex()") ct.debuglog("HighlightedRowIndex()")
_, y := ct.Views.Table.Backing().Origin() _, y := ct.Views.Table.Backing().Origin()
_, cy := ct.Views.Table.Backing().Cursor() _, cy := ct.Views.Table.Backing().Cursor()
idx := y + cy idx := y + cy
@ -301,7 +301,7 @@ func (ct *Cointop) HighlightedRowIndex() int {
// HighlightedRowCoin returns the coin at the index of the highlighted row // HighlightedRowCoin returns the coin at the index of the highlighted row
func (ct *Cointop) HighlightedRowCoin() *Coin { func (ct *Cointop) HighlightedRowCoin() *Coin {
ct.debuglog("highlightedRowCoin()") ct.debuglog("HighlightedRowCoin()")
idx := ct.HighlightedRowIndex() idx := ct.HighlightedRowIndex()
if len(ct.State.coins) == 0 { if len(ct.State.coins) == 0 {
return nil return nil
@ -311,7 +311,7 @@ func (ct *Cointop) HighlightedRowCoin() *Coin {
// HighlightedPageRowIndex returns the index of page row of the highlighted row // HighlightedPageRowIndex returns the index of page row of the highlighted row
func (ct *Cointop) HighlightedPageRowIndex() int { func (ct *Cointop) HighlightedPageRowIndex() int {
ct.debuglog("highlightedPageRowIndex()") ct.debuglog("HighlightedPageRowIndex()")
_, cy := ct.Views.Table.Backing().Cursor() _, cy := ct.Views.Table.Backing().Cursor()
idx := cy idx := cy
if idx < 0 { if idx < 0 {
@ -323,7 +323,7 @@ func (ct *Cointop) HighlightedPageRowIndex() int {
// RowLink returns the row url link // RowLink returns the row url link
func (ct *Cointop) RowLink() string { func (ct *Cointop) RowLink() string {
ct.debuglog("rowLink()") ct.debuglog("RowLink()")
coin := ct.HighlightedRowCoin() coin := ct.HighlightedRowCoin()
if coin == nil { if coin == nil {
return "" return ""
@ -334,7 +334,7 @@ func (ct *Cointop) RowLink() string {
// RowLinkShort returns a shortened version of the row url link // RowLinkShort returns a shortened version of the row url link
func (ct *Cointop) RowLinkShort() string { func (ct *Cointop) RowLinkShort() string {
ct.debuglog("rowLinkShort()") ct.debuglog("RowLinkShort()")
link := ct.RowLink() link := ct.RowLink()
if link != "" { if link != "" {
u, err := url.Parse(link) u, err := url.Parse(link)
@ -358,7 +358,7 @@ func (ct *Cointop) RowLinkShort() string {
// ToggleTableFullscreen toggles the table fullscreen mode // ToggleTableFullscreen toggles the table fullscreen mode
func (ct *Cointop) ToggleTableFullscreen() error { func (ct *Cointop) ToggleTableFullscreen() error {
ct.debuglog("toggleTableFullscreen()") ct.debuglog("ToggleTableFullscreen()")
ct.State.onlyTable = !ct.State.onlyTable ct.State.onlyTable = !ct.State.onlyTable
if ct.State.onlyTable { if ct.State.onlyTable {
} else { } else {

@ -15,9 +15,9 @@ func NewTableHeaderView() *TableHeaderView {
return &TableHeaderView{NewView("header")} return &TableHeaderView{NewView("header")}
} }
// updateTableHeader renders the table header // UpdateTableHeader renders the table header
func (ct *Cointop) updateTableHeader() { func (ct *Cointop) UpdateTableHeader() {
ct.debuglog("updateTableHeader()") ct.debuglog("UpdateTableHeader()")
var cols []string var cols []string
type t struct { type t struct {
@ -89,7 +89,7 @@ func (ct *Cointop) updateTableHeader() {
headers = append(headers, str) headers = append(headers, str)
} }
ct.update(func() { ct.Update(func() {
if ct.Views.TableHeader.Backing() == nil { if ct.Views.TableHeader.Backing() == nil {
return return
} }

@ -7,9 +7,9 @@ import (
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
) )
// update takes a callback which updates the view // Update takes a callback which updates the view
func (ct *Cointop) update(f func()) { func (ct *Cointop) Update(f func()) {
ct.debuglog(fmt.Sprintf("update()")) ct.debuglog(fmt.Sprintf("Update()"))
if ct.g == nil { if ct.g == nil {
log.Fatal("gocui is not initialized") log.Fatal("gocui is not initialized")

Loading…
Cancel
Save