Update debuglog method names

pull/162/head
Miguel Mota 3 years ago
parent 1a789cb587
commit a86077e77e
No known key found for this signature in database
GPG Key ID: 67EC1161588A00F9

@ -132,7 +132,7 @@ func (ct *Cointop) ChartPoints(symbol string, name string) error {
if found {
// cache hit
data, _ = cached.([]float64)
ct.debuglog("ct.ChartPoints() soft cache hit")
ct.debuglog("ChartPoints() soft cache hit")
}
if len(data) == 0 {
@ -223,7 +223,7 @@ func (ct *Cointop) PortfolioChart() error {
if found {
// cache hit
graphData, _ = cached.([]float64)
ct.debuglog("soft cache hit")
ct.debuglog("PortfolioChart() soft cache hit")
} else {
if ct.filecache != nil {
ct.filecache.Get(cachekey, &graphData)
@ -390,8 +390,8 @@ func (ct *Cointop) ShowChartLoader() error {
// ChartWidth returns the width for chart
func (ct *Cointop) ChartWidth() int {
ct.debuglog("chartWidth()")
w := ct.width()
ct.debuglog("ChartWidth()")
w := ct.Width()
max := 175
if w > max {
return max

@ -60,7 +60,7 @@ func (ct *Cointop) GetCoinsTableHeaders() []string {
// GetCoinsTable returns the table for diplaying the coins
func (ct *Cointop) GetCoinsTable() *table.Table {
maxX := ct.width()
maxX := ct.Width()
t := table.NewTable().SetWidth(maxX)
var rows [][]*table.RowCell
headers := ct.GetCoinsTableHeaders()

@ -95,7 +95,7 @@ type Cointop struct {
apiKeys *APIKeys
cache *cache.Cache
colorsDir string
config config // toml config
config ConfigFileConfig
configFilepath string
api api.Interface
apiChoice string
@ -352,7 +352,7 @@ func NewCointop(config *Config) (*Cointop, error) {
ct.colorschemeName = config.Colorscheme
}
colors, err := ct.getColorschemeColors()
colors, err := ct.GetColorschemeColors()
if err != nil {
return nil, err
}
@ -470,7 +470,7 @@ func NewCointop(config *Config) (*Cointop, error) {
// Run runs cointop
func (ct *Cointop) Run() error {
ct.debuglog("run()")
ct.debuglog("Run()")
ui, err := ui.NewUI()
if err != nil {
return err
@ -574,7 +574,7 @@ func Reset(config *ResetConfig) error {
configDeleted := false
for _, configPath := range possibleConfigPaths {
for _, configPath := range PossibleConfigPaths {
normalizedPath := pathutil.NormalizePath(configPath)
if _, err := os.Stat(normalizedPath); !os.IsNotExist(err) {
if config.Log {

@ -12,23 +12,23 @@ import (
// TODO: fix hex color support
// colorschemeColors is a map of color string names to Attribute types
type colorschemeColors map[string]interface{}
// ColorschemeColors is a map of color string names to Attribute types
type ColorschemeColors map[string]interface{}
// ISprintf is a sprintf interface
type ISprintf func(...interface{}) string
// colorCache is a map of color string names to sprintf functions
type colorCache map[string]ISprintf
type ColorCache map[string]ISprintf
// Colorscheme is the struct for colorscheme
type Colorscheme struct {
colors colorschemeColors
cache colorCache
colors ColorschemeColors
cache ColorCache
cacheMutex sync.RWMutex
}
var fgcolorschemeColorsMap = map[string]fcolor.Attribute{
var FgColorschemeColorsMap = map[string]fcolor.Attribute{
"black": fcolor.FgBlack,
"blue": fcolor.FgBlue,
"cyan": fcolor.FgCyan,
@ -39,7 +39,7 @@ var fgcolorschemeColorsMap = map[string]fcolor.Attribute{
"yellow": fcolor.FgYellow,
}
var bgcolorschemeColorsMap = map[string]fcolor.Attribute{
var BgColorschemeColorsMap = map[string]fcolor.Attribute{
"black": fcolor.BgBlack,
"blue": fcolor.BgBlue,
"cyan": fcolor.BgCyan,
@ -50,7 +50,7 @@ var bgcolorschemeColorsMap = map[string]fcolor.Attribute{
"yellow": fcolor.BgYellow,
}
var gocuiColorschemeColorsMap = map[string]gocui.Attribute{
var GocuiColorschemeColorsMap = map[string]gocui.Attribute{
"black": gocui.ColorBlack,
"blue": gocui.ColorBlue,
"cyan": gocui.ColorCyan,
@ -62,175 +62,175 @@ var gocuiColorschemeColorsMap = map[string]gocui.Attribute{
}
// NewColorscheme ...
func NewColorscheme(colors colorschemeColors) *Colorscheme {
func NewColorscheme(colors ColorschemeColors) *Colorscheme {
return &Colorscheme{
colors: colors,
cache: make(colorCache),
cache: make(ColorCache),
cacheMutex: sync.RWMutex{},
}
}
// BaseFg ...
func (c *Colorscheme) BaseFg() gocui.Attribute {
return c.gocuiFgColor("base")
return c.GocuiFgColor("base")
}
// BaseBg ...
func (c *Colorscheme) BaseBg() gocui.Attribute {
return c.gocuiBgColor("base")
return c.GocuiBgColor("base")
}
// Chart ...
func (c *Colorscheme) Chart(a ...interface{}) string {
return c.color("chart", a...)
return c.Color("chart", a...)
}
// Marketbar ...
func (c *Colorscheme) Marketbar(a ...interface{}) string {
return c.color("marketbar", a...)
return c.Color("marketbar", a...)
}
// MarketbarSprintf ...
func (c *Colorscheme) MarketbarSprintf() ISprintf {
return c.toSprintf("marketbar")
return c.ToSprintf("marketbar")
}
// MarketbarChangeSprintf ...
func (c *Colorscheme) MarketbarChangeSprintf() ISprintf {
// NOTE: reusing table styles
return c.toSprintf("table_column_change")
return c.ToSprintf("table_column_change")
}
// MarketbarChangeDownSprintf ...
func (c *Colorscheme) MarketbarChangeDownSprintf() ISprintf {
// NOTE: reusing table styles
return c.toSprintf("table_column_change_down")
return c.ToSprintf("table_column_change_down")
}
// MarketbarChangeUpSprintf ...
func (c *Colorscheme) MarketbarChangeUpSprintf() ISprintf {
// NOTE: reusing table styles
return c.toSprintf("table_column_change_up")
return c.ToSprintf("table_column_change_up")
}
// MarketBarLabelActive ...
func (c *Colorscheme) MarketBarLabelActive(a ...interface{}) string {
return c.color("marketbar_label_active", a...)
return c.Color("marketbar_label_active", a...)
}
// Menu ...
func (c *Colorscheme) Menu(a ...interface{}) string {
return c.color("menu", a...)
return c.Color("menu", a...)
}
// MenuHeader ...
func (c *Colorscheme) MenuHeader(a ...interface{}) string {
return c.color("menu_header", a...)
return c.Color("menu_header", a...)
}
// MenuLabel ...
func (c *Colorscheme) MenuLabel(a ...interface{}) string {
return c.color("menu_label", a...)
return c.Color("menu_label", a...)
}
// MenuLabelActive ...
func (c *Colorscheme) MenuLabelActive(a ...interface{}) string {
return c.color("menu_label_active", a...)
return c.Color("menu_label_active", a...)
}
// Searchbar ...
func (c *Colorscheme) Searchbar(a ...interface{}) string {
return c.color("searchbar", a...)
return c.Color("searchbar", a...)
}
// Statusbar ...
func (c *Colorscheme) Statusbar(a ...interface{}) string {
return c.color("statusbar", a...)
return c.Color("statusbar", a...)
}
// TableColumnPrice ...
func (c *Colorscheme) TableColumnPrice(a ...interface{}) string {
return c.color("table_column_price", a...)
return c.Color("table_column_price", a...)
}
// TableColumnPriceSprintf ...
func (c *Colorscheme) TableColumnPriceSprintf() ISprintf {
return c.toSprintf("table_column_price")
return c.ToSprintf("table_column_price")
}
// TableColumnChange ...
func (c *Colorscheme) TableColumnChange(a ...interface{}) string {
return c.color("table_column_change", a...)
return c.Color("table_column_change", a...)
}
// TableColumnChangeSprintf ...
func (c *Colorscheme) TableColumnChangeSprintf() ISprintf {
return c.toSprintf("table_column_change")
return c.ToSprintf("table_column_change")
}
// TableColumnChangeDown ...
func (c *Colorscheme) TableColumnChangeDown(a ...interface{}) string {
return c.color("table_column_change_down", a...)
return c.Color("table_column_change_down", a...)
}
// TableColumnChangeDownSprintf ...
func (c *Colorscheme) TableColumnChangeDownSprintf() ISprintf {
return c.toSprintf("table_column_change_down")
return c.ToSprintf("table_column_change_down")
}
// TableColumnChangeUp ...
func (c *Colorscheme) TableColumnChangeUp(a ...interface{}) string {
return c.color("table_column_change_up", a...)
return c.Color("table_column_change_up", a...)
}
// TableColumnChangeUpSprintf ...
func (c *Colorscheme) TableColumnChangeUpSprintf() ISprintf {
return c.toSprintf("table_column_change_up")
return c.ToSprintf("table_column_change_up")
}
// TableHeader ...
func (c *Colorscheme) TableHeader(a ...interface{}) string {
return c.color("table_header", a...)
return c.Color("table_header", a...)
}
// TableHeaderSprintf ...
func (c *Colorscheme) TableHeaderSprintf() ISprintf {
return c.toSprintf("table_header")
return c.ToSprintf("table_header")
}
// TableHeaderColumnActive ...
func (c *Colorscheme) TableHeaderColumnActive(a ...interface{}) string {
return c.color("table_header_column_active", a...)
return c.Color("table_header_column_active", a...)
}
// TableHeaderColumnActiveSprintf ...
func (c *Colorscheme) TableHeaderColumnActiveSprintf() ISprintf {
return c.toSprintf("table_header_column_active")
return c.ToSprintf("table_header_column_active")
}
// TableRow ...
func (c *Colorscheme) TableRow(a ...interface{}) string {
return c.color("table_row", a...)
return c.Color("table_row", a...)
}
// TableRowSprintf ...
func (c *Colorscheme) TableRowSprintf() ISprintf {
return c.toSprintf("table_row")
return c.ToSprintf("table_row")
}
// TableRowActive ...
func (c *Colorscheme) TableRowActive(a ...interface{}) string {
return c.color("table_row_active", a...)
return c.Color("table_row_active", a...)
}
// TableRowFavorite ...
func (c *Colorscheme) TableRowFavorite(a ...interface{}) string {
return c.color("table_row_favorite", a...)
return c.Color("table_row_favorite", a...)
}
// TableRowFavoriteSprintf ...
func (c *Colorscheme) TableRowFavoriteSprintf() ISprintf {
return c.toSprintf("table_row_favorite")
return c.ToSprintf("table_row_favorite")
}
// Default ...
@ -238,7 +238,7 @@ func (c *Colorscheme) Default(a ...interface{}) string {
return fmt.Sprintf(a[0].(string), a[1:]...)
}
func (c *Colorscheme) toSprintf(name string) ISprintf {
func (c *Colorscheme) ToSprintf(name string) ISprintf {
c.cacheMutex.Lock()
defer c.cacheMutex.Unlock()
if cached, ok := c.cache[name]; ok {
@ -247,22 +247,22 @@ func (c *Colorscheme) toSprintf(name string) ISprintf {
var attrs []fcolor.Attribute
if v, ok := c.colors[name+"_fg"].(string); ok {
if fg, ok := c.toFgAttr(v); ok {
if fg, ok := c.ToFgAttr(v); ok {
attrs = append(attrs, fg)
}
}
if v, ok := c.colors[name+"_bg"].(string); ok {
if bg, ok := c.toBgAttr(v); ok {
if bg, ok := c.ToBgAttr(v); ok {
attrs = append(attrs, bg)
}
}
if v, ok := c.colors[name+"_bold"].(bool); ok {
if bold, ok := c.toBoldAttr(v); ok {
if bold, ok := c.ToBoldAttr(v); ok {
attrs = append(attrs, bold)
}
}
if v, ok := c.colors[name+"_underline"].(bool); ok {
if underline, ok := c.toUnderlineAttr(v); ok {
if underline, ok := c.ToUnderlineAttr(v); ok {
attrs = append(attrs, underline)
}
}
@ -271,14 +271,14 @@ func (c *Colorscheme) toSprintf(name string) ISprintf {
return c.cache[name]
}
func (c *Colorscheme) color(name string, a ...interface{}) string {
return c.toSprintf(name)(a...)
func (c *Colorscheme) Color(name string, a ...interface{}) string {
return c.ToSprintf(name)(a...)
}
func (c *Colorscheme) gocuiFgColor(name string) gocui.Attribute {
func (c *Colorscheme) GocuiFgColor(name string) gocui.Attribute {
var attrs []gocui.Attribute
if v, ok := c.colors[name+"_fg"].(string); ok {
if fg, ok := c.toGocuiAttr(v); ok {
if fg, ok := c.ToGocuiAttr(v); ok {
attrs = append(attrs, fg)
}
}
@ -303,9 +303,9 @@ func (c *Colorscheme) gocuiFgColor(name string) gocui.Attribute {
return gocui.ColorDefault
}
func (c *Colorscheme) gocuiBgColor(name string) gocui.Attribute {
func (c *Colorscheme) GocuiBgColor(name string) gocui.Attribute {
if v, ok := c.colors[name+"_bg"].(string); ok {
if bg, ok := c.toGocuiAttr(v); ok {
if bg, ok := c.ToGocuiAttr(v); ok {
return bg
}
}
@ -313,8 +313,8 @@ func (c *Colorscheme) gocuiBgColor(name string) gocui.Attribute {
return gocui.ColorDefault
}
func (c *Colorscheme) toFgAttr(v string) (fcolor.Attribute, bool) {
if attr, ok := fgcolorschemeColorsMap[v]; ok {
func (c *Colorscheme) ToFgAttr(v string) (fcolor.Attribute, bool) {
if attr, ok := FgColorschemeColorsMap[v]; ok {
return attr, true
}
@ -325,8 +325,8 @@ func (c *Colorscheme) toFgAttr(v string) (fcolor.Attribute, bool) {
return 0, false
}
func (c *Colorscheme) toBgAttr(v string) (fcolor.Attribute, bool) {
if attr, ok := bgcolorschemeColorsMap[v]; ok {
func (c *Colorscheme) ToBgAttr(v string) (fcolor.Attribute, bool) {
if attr, ok := BgColorschemeColorsMap[v]; ok {
return attr, true
}
@ -338,18 +338,18 @@ func (c *Colorscheme) toBgAttr(v string) (fcolor.Attribute, bool) {
}
// 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
}
// 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
}
// toGocuiAttr converts a color string name to a gocui Attribute type
func (c *Colorscheme) toGocuiAttr(v string) (gocui.Attribute, bool) {
if attr, ok := gocuiColorschemeColorsMap[v]; ok {
func (c *Colorscheme) ToGocuiAttr(v string) (gocui.Attribute, bool) {
if attr, ok := GocuiColorschemeColorsMap[v]; ok {
return attr, true
}

@ -16,13 +16,15 @@ import (
"github.com/miguelmota/cointop/pkg/toml"
)
var fileperm = os.FileMode(0644)
// FilePerm is the default file permissions
var FilePerm = os.FileMode(0644)
// ErrInvalidPriceAlert is error for invalid price alert value
var ErrInvalidPriceAlert = errors.New("invalid price alert value")
// PossibleConfigPaths are the the possible config file paths.
// NOTE: this is to support previous default config filepaths
var possibleConfigPaths = []string{
var PossibleConfigPaths = []string{
":PREFERRED_CONFIG_HOME:/cointop/config.toml",
":HOME:/.config/cointop/config.toml",
":HOME:/.config/cointop/config",
@ -30,7 +32,8 @@ var possibleConfigPaths = []string{
":HOME:/.cointop/config.toml",
}
type config struct {
// ConfigFileConfig is the config file structure
type ConfigFileConfig struct {
Shortcuts map[string]interface{} `toml:"shortcuts"`
Favorites map[string]interface{} `toml:"favorites"`
Portfolio map[string]interface{} `toml:"portfolio"`
@ -48,11 +51,11 @@ type config struct {
// SetupConfig loads config file
func (ct *Cointop) SetupConfig() error {
ct.debuglog("setupConfig()")
ct.debuglog("SetupConfig()")
if err := ct.CreateConfigIfNotExists(); err != nil {
return err
}
if err := ct.parseConfig(); err != nil {
if err := ct.ParseConfig(); err != nil {
return err
}
if err := ct.loadTableConfig(); err != nil {
@ -100,13 +103,13 @@ func (ct *Cointop) SetupConfig() error {
// CreateConfigIfNotExists creates config file if it doesn't exist
func (ct *Cointop) CreateConfigIfNotExists() error {
ct.debuglog("createConfigIfNotExists()")
ct.debuglog("CreateConfigIfNotExists()")
ct.configFilepath = pathutil.NormalizePath(ct.configFilepath)
// check if config file exists in one of th default paths
if ct.configFilepath == DefaultConfigFilepath {
for _, configPath := range possibleConfigPaths {
for _, configPath := range PossibleConfigPaths {
normalizedPath := pathutil.NormalizePath(configPath)
if _, err := os.Stat(normalizedPath); err == nil {
ct.configFilepath = normalizedPath
@ -115,12 +118,12 @@ func (ct *Cointop) CreateConfigIfNotExists() error {
}
}
err := ct.makeConfigDir()
err := ct.MakeConfigDir()
if err != nil {
return err
}
err = ct.makeConfigFile()
err = ct.MakeConfigFile()
if err != nil {
return err
}
@ -130,7 +133,7 @@ func (ct *Cointop) CreateConfigIfNotExists() error {
// ConfigDirPath returns the config directory path
func (ct *Cointop) ConfigDirPath() string {
ct.debuglog("configDirPath()")
ct.debuglog("ConfigDirPath()")
path := pathutil.NormalizePath(ct.configFilepath)
separator := string(filepath.Separator)
parts := strings.Split(path, separator)
@ -139,13 +142,13 @@ func (ct *Cointop) ConfigDirPath() string {
// ConfigFilePath return the config file path
func (ct *Cointop) ConfigFilePath() string {
ct.debuglog("configFilePath()")
ct.debuglog("ConfigFilePath()")
return pathutil.NormalizePath(ct.configFilepath)
}
// ConfigPath return the config file path
func (ct *Cointop) makeConfigDir() error {
ct.debuglog("makeConfigDir()")
func (ct *Cointop) MakeConfigDir() error {
ct.debuglog("MakeConfigDir()")
path := ct.ConfigDirPath()
if _, err := os.Stat(path); os.IsNotExist(err) {
return os.MkdirAll(path, os.ModePerm)
@ -155,8 +158,8 @@ func (ct *Cointop) makeConfigDir() error {
}
// MakeConfigFile creates a new config file
func (ct *Cointop) makeConfigFile() error {
ct.debuglog("makeConfigFile()")
func (ct *Cointop) MakeConfigFile() error {
ct.debuglog("MakeConfigFile()")
path := ct.ConfigFilePath()
if _, err := os.Stat(path); os.IsNotExist(err) {
fo, err := os.Create(path)
@ -164,7 +167,7 @@ func (ct *Cointop) makeConfigFile() error {
return err
}
defer fo.Close()
b, err := ct.configToToml()
b, err := ct.ConfigToToml()
if err != nil {
return err
}
@ -177,16 +180,16 @@ func (ct *Cointop) makeConfigFile() error {
// SaveConfig writes settings to the config file
func (ct *Cointop) SaveConfig() error {
ct.debuglog("saveConfig()")
ct.debuglog("SaveConfig()")
ct.saveMux.Lock()
defer ct.saveMux.Unlock()
path := ct.ConfigFilePath()
if _, err := os.Stat(path); err == nil {
b, err := ct.configToToml()
b, err := ct.ConfigToToml()
if err != nil {
return err
}
err = ioutil.WriteFile(path, b, fileperm)
err = ioutil.WriteFile(path, b, FilePerm)
if err != nil {
return err
}
@ -195,9 +198,9 @@ func (ct *Cointop) SaveConfig() error {
}
// ParseConfig decodes the toml config file
func (ct *Cointop) parseConfig() error {
ct.debuglog("parseConfig()")
var conf config
func (ct *Cointop) ParseConfig() error {
ct.debuglog("ParseConfig()")
var conf ConfigFileConfig
path := ct.configFilepath
if _, err := toml.DecodeFile(path, &conf); err != nil {
return err
@ -208,8 +211,8 @@ func (ct *Cointop) parseConfig() error {
}
// ConfigToToml encodes config struct to TOML
func (ct *Cointop) configToToml() ([]byte, error) {
ct.debuglog("configToToml()")
func (ct *Cointop) ConfigToToml() ([]byte, error) {
ct.debuglog("ConfigToToml()")
shortcutsIfcs := map[string]interface{}{}
for k, v := range ct.State.shortcutKeys {
var i interface{} = v
@ -293,7 +296,7 @@ func (ct *Cointop) configToToml() ([]byte, error) {
var keepRowFocusOnSortIfc interface{} = ct.State.keepRowFocusOnSort
tableMapIfc["keep_row_focus_on_sort"] = keepRowFocusOnSortIfc
var inputs = &config{
var inputs = &ConfigFileConfig{
API: apiChoiceIfc,
Colorscheme: colorschemeIfc,
CoinMarketCap: cmcIfc,
@ -321,6 +324,7 @@ func (ct *Cointop) configToToml() ([]byte, error) {
// LoadTableConfig loads table config from toml config into state struct
func (ct *Cointop) loadTableConfig() error {
ct.debuglog("loadTableConfig()")
err := ct.loadTableColumnsFromConfig()
if err != nil {
return err
@ -462,43 +466,6 @@ func (ct *Cointop) loadCacheDirFromConfig() error {
return nil
}
// GetColorschemeColors loads colors from colorsheme file to struct
func (ct *Cointop) getColorschemeColors() (map[string]interface{}, error) {
ct.debuglog("getColorschemeColors()")
var colors map[string]interface{}
if ct.colorschemeName == "" {
ct.colorschemeName = DefaultColorscheme
if _, err := toml.Decode(DefaultColors, &colors); err != nil {
return nil, err
}
} else {
colorsDir := fmt.Sprintf("%s/colors", ct.ConfigDirPath())
if ct.colorsDir != "" {
colorsDir = pathutil.NormalizePath(ct.colorsDir)
}
path := fmt.Sprintf("%s/%s.toml", colorsDir, ct.colorschemeName)
if _, err := os.Stat(path); os.IsNotExist(err) {
// NOTE: case for when cointop is set as the theme but the colorscheme file doesn't exist
if ct.colorschemeName == "cointop" {
if _, err := toml.Decode(DefaultColors, &colors); err != nil {
return nil, err
}
return colors, nil
}
return nil, fmt.Errorf("the colorscheme file %q was not found.\n%s", path, ColorschemeHelpString())
}
if _, err := toml.DecodeFile(path, &colors); err != nil {
return nil, err
}
}
return colors, nil
}
// LoadAPIChoiceFromConfig loads API choices from config file to struct
func (ct *Cointop) loadAPIChoiceFromConfig() error {
ct.debuglog("loadAPIKeysFromConfig()")
@ -677,6 +644,43 @@ func (ct *Cointop) loadPriceAlertsFromConfig() error {
return nil
}
// GetColorschemeColors loads colors from colorsheme file to struct
func (ct *Cointop) GetColorschemeColors() (map[string]interface{}, error) {
ct.debuglog("GetColorschemeColors()")
var colors map[string]interface{}
if ct.colorschemeName == "" {
ct.colorschemeName = DefaultColorscheme
if _, err := toml.Decode(DefaultColors, &colors); err != nil {
return nil, err
}
} else {
colorsDir := fmt.Sprintf("%s/colors", ct.ConfigDirPath())
if ct.colorsDir != "" {
colorsDir = pathutil.NormalizePath(ct.colorsDir)
}
path := fmt.Sprintf("%s/%s.toml", colorsDir, ct.colorschemeName)
if _, err := os.Stat(path); os.IsNotExist(err) {
// NOTE: case for when cointop is set as the theme but the colorscheme file doesn't exist
if ct.colorschemeName == "cointop" {
if _, err := toml.Decode(DefaultColors, &colors); err != nil {
return nil, err
}
return colors, nil
}
return nil, fmt.Errorf("the colorscheme file %q was not found.\n%s", path, ColorschemeHelpString())
}
if _, err := toml.DecodeFile(path, &colors); err != nil {
return nil, err
}
}
return colors, nil
}
// InterfaceToFloat64 attempts to convert interface to float64
func (ct *Cointop) InterfaceToFloat64(value interface{}) (float64, error) {
var num float64

@ -151,8 +151,8 @@ func (ct *Cointop) SortedSupportedCurrencyConversions() []string {
// UpdateConvertMenu updates the convert menu
func (ct *Cointop) UpdateConvertMenu() error {
ct.debuglog("updateConvertMenu()")
header := ct.colorscheme.MenuHeader(fmt.Sprintf(" Currency Conversion %s\n\n", pad.Left("[q] close ", ct.width()-24, " ")))
ct.debuglog("UpdateConvertMenu()")
header := ct.colorscheme.MenuHeader(fmt.Sprintf(" Currency Conversion %s\n\n", pad.Left("[q] close ", ct.Width()-24, " ")))
helpline := " Press the corresponding key to select currency for conversion\n\n"
cnt := 0
h := ct.Views.Menu.Height()
@ -226,7 +226,7 @@ func (ct *Cointop) SetCurrencyConverstion(convert string) error {
// SetCurrencyConverstionFn sets the currency conversion function
func (ct *Cointop) SetCurrencyConverstionFn(convert string) func() error {
ct.debuglog("setCurrencyConverstionFn()")
ct.debuglog("SetCurrencyConverstionFn()")
return func() error {
ct.HideConvertMenu()
@ -245,13 +245,13 @@ func (ct *Cointop) SetCurrencyConverstionFn(convert string) func() error {
// CurrencySymbol returns the symbol for the currency conversion
func (ct *Cointop) CurrencySymbol() string {
ct.debuglog("currencySymbol()")
ct.debuglog("CurrencySymbol()")
return CurrencySymbol(ct.State.currencyConversion)
}
// ShowConvertMenu shows the convert menu view
func (ct *Cointop) ShowConvertMenu() error {
ct.debuglog("showConvertMenu()")
ct.debuglog("ShowConvertMenu()")
ct.State.convertMenuVisible = true
ct.UpdateConvertMenu()
ct.SetActiveView(ct.Views.Menu.Name())
@ -260,7 +260,7 @@ func (ct *Cointop) ShowConvertMenu() error {
// HideConvertMenu hides the convert menu view
func (ct *Cointop) HideConvertMenu() error {
ct.debuglog("hideConvertMenu()")
ct.debuglog("HideConvertMenu()")
ct.State.convertMenuVisible = false
ct.ui.SetViewOnBottom(ct.Views.Menu)
ct.SetActiveView(ct.Views.Table.Name())
@ -273,7 +273,7 @@ func (ct *Cointop) HideConvertMenu() error {
// ToggleConvertMenu toggles the convert menu view
func (ct *Cointop) ToggleConvertMenu() error {
ct.debuglog("toggleConvertMenu()")
ct.debuglog("ToggleConvertMenu()")
ct.State.convertMenuVisible = !ct.State.convertMenuVisible
if ct.State.convertMenuVisible {
return ct.ShowConvertMenu()

@ -11,7 +11,7 @@ func (ct *Cointop) GetFavoritesTableHeaders() []string {
// ToggleFavorite toggles coin as favorite
func (ct *Cointop) ToggleFavorite() error {
ct.debuglog("toggleFavorite()")
ct.debuglog("ToggleFavorite()")
coin := ct.HighlightedRowCoin()
if coin == nil {
return nil
@ -37,7 +37,7 @@ func (ct *Cointop) ToggleFavorite() error {
// ToggleFavorites toggles the favorites view
func (ct *Cointop) ToggleFavorites() error {
ct.debuglog("toggleFavorites()")
ct.debuglog("ToggleFavorites()")
ct.ToggleSelectedView(FavoritesView)
go ct.UpdateTable()
return nil
@ -45,7 +45,7 @@ func (ct *Cointop) ToggleFavorites() error {
// ToggleShowFavorites shows the favorites view
func (ct *Cointop) ToggleShowFavorites() error {
ct.debuglog("toggleShowFavorites()")
ct.debuglog("ToggleShowFavorites()")
ct.ToggleSelectedView(FavoritesView)
go ct.UpdateTable()
return nil
@ -53,7 +53,7 @@ func (ct *Cointop) ToggleShowFavorites() error {
// GetFavoritesSlice returns coin favorites as slice
func (ct *Cointop) GetFavoritesSlice() []*Coin {
ct.debuglog("getFavoritesSlice()")
ct.debuglog("GetFavoritesSlice()")
sliced := []*Coin{}
for i := range ct.State.allCoins {
coin := ct.State.allCoins[i]

@ -9,14 +9,14 @@ import (
// UpdateHelp updates the help views
func (ct *Cointop) UpdateHelp() {
ct.debuglog("updateHelp()")
ct.debuglog("UpdateHelp()")
keys := make([]string, 0, len(ct.State.shortcutKeys))
for k := range ct.State.shortcutKeys {
keys = append(keys, k)
}
sort.Strings(keys)
header := ct.colorscheme.MenuHeader(fmt.Sprintf(" Help %s\n\n", pad.Left("[q] close ", ct.width()-9, " ")))
header := ct.colorscheme.MenuHeader(fmt.Sprintf(" Help %s\n\n", pad.Left("[q] close ", ct.Width()-9, " ")))
cnt := 0
h := ct.Views.Menu.Height()
percol := h - 11
@ -58,7 +58,7 @@ func (ct *Cointop) UpdateHelp() {
// ShowHelp shows the help view
func (ct *Cointop) ShowHelp() error {
ct.debuglog("showHelp()")
ct.debuglog("ShowHelp()")
ct.State.helpVisible = true
ct.UpdateHelp()
ct.SetActiveView(ct.Views.Menu.Name())
@ -67,7 +67,7 @@ func (ct *Cointop) ShowHelp() error {
// HideHelp hides the help view
func (ct *Cointop) HideHelp() error {
ct.debuglog("hideHelp()")
ct.debuglog("HideHelp()")
ct.State.helpVisible = false
ct.ui.SetViewOnBottom(ct.Views.Menu)
ct.SetActiveView(ct.Views.Table.Name())
@ -80,7 +80,7 @@ func (ct *Cointop) HideHelp() error {
// ToggleHelp toggles the help view
func (ct *Cointop) ToggleHelp() error {
ct.debuglog("toggleHelp()")
ct.debuglog("ToggleHelp()")
ct.State.helpVisible = !ct.State.helpVisible
if ct.State.helpVisible {
return ct.ShowHelp()

@ -265,7 +265,7 @@ func (ct *Cointop) SetKeybindingAction(shortcutKey string, action string) error
case "last_page":
fn = ct.Keyfn(ct.LastPage)
case "open_search":
fn = ct.Keyfn(ct.openSearch)
fn = ct.Keyfn(ct.OpenSearch)
view = ""
case "toggle_price_alerts":
fn = ct.Keyfn(ct.TogglePriceAlerts)

@ -11,9 +11,9 @@ var lastWidth int
// layout sets initial layout
func (ct *Cointop) layout() error {
ct.debuglog("layout()")
maxY := ct.height()
maxX := ct.width()
ct.debuglog("Layout()")
maxY := ct.Height()
maxX := ct.Width()
topOffset := 0
headerHeight := 1
@ -59,8 +59,8 @@ func (ct *Cointop) layout() error {
} else {
if err := ct.ui.SetView(ct.Views.Marketbar, 0, topOffset-1, maxX, marketbarHeight+1); err != nil {
ct.Views.Marketbar.SetFrame(false)
ct.Views.Marketbar.SetFgColor(ct.colorscheme.gocuiFgColor(ct.Views.Marketbar.Name()))
ct.Views.Marketbar.SetBgColor(ct.colorscheme.gocuiBgColor(ct.Views.Marketbar.Name()))
ct.Views.Marketbar.SetFgColor(ct.colorscheme.GocuiFgColor(ct.Views.Marketbar.Name()))
ct.Views.Marketbar.SetBgColor(ct.colorscheme.GocuiBgColor(ct.Views.Marketbar.Name()))
go func() {
ct.UpdateMarketbar()
_, found := ct.cache.Get(ct.Views.Marketbar.Name())
@ -93,8 +93,8 @@ func (ct *Cointop) layout() error {
if err := ct.ui.SetView(ct.Views.Chart, 0, chartTopOffset, maxX, topOffset+chartHeight); err != nil {
ct.Views.Chart.Clear()
ct.Views.Chart.SetFrame(false)
ct.Views.Chart.SetFgColor(ct.colorscheme.gocuiFgColor(ct.Views.Chart.Name()))
ct.Views.Chart.SetBgColor(ct.colorscheme.gocuiBgColor(ct.Views.Chart.Name()))
ct.Views.Chart.SetFgColor(ct.colorscheme.GocuiFgColor(ct.Views.Chart.Name()))
ct.Views.Chart.SetBgColor(ct.colorscheme.GocuiBgColor(ct.Views.Chart.Name()))
go func() {
ct.UpdateChart()
cachekey := strings.ToLower(fmt.Sprintf("%s_%s", "globaldata", strings.Replace(ct.State.selectedChartRange, " ", "", -1)))
@ -125,8 +125,8 @@ func (ct *Cointop) layout() error {
topOffset = topOffset + chartHeight
if err := ct.ui.SetView(ct.Views.TableHeader, tableOffsetX, topOffset-1, maxX, topOffset+1); err != nil {
ct.Views.TableHeader.SetFrame(false)
ct.Views.TableHeader.SetFgColor(ct.colorscheme.gocuiFgColor(ct.Views.TableHeader.Name()))
ct.Views.TableHeader.SetBgColor(ct.colorscheme.gocuiBgColor(ct.Views.TableHeader.Name()))
ct.Views.TableHeader.SetFgColor(ct.colorscheme.GocuiFgColor(ct.Views.TableHeader.Name()))
ct.Views.TableHeader.SetBgColor(ct.colorscheme.GocuiBgColor(ct.Views.TableHeader.Name()))
go ct.UpdateTableHeader()
}
@ -134,8 +134,8 @@ func (ct *Cointop) layout() error {
if err := ct.ui.SetView(ct.Views.Table, tableOffsetX, topOffset-1, maxX, maxY-statusbarHeight); err != nil {
ct.Views.Table.SetFrame(false)
ct.Views.Table.SetHighlight(true)
ct.Views.Table.SetSelFgColor(ct.colorscheme.gocuiFgColor("table_row_active"))
ct.Views.Table.SetSelBgColor(ct.colorscheme.gocuiBgColor("table_row_active"))
ct.Views.Table.SetSelFgColor(ct.colorscheme.GocuiFgColor("table_row_active"))
ct.Views.Table.SetSelBgColor(ct.colorscheme.GocuiBgColor("table_row_active"))
_, found := ct.cache.Get("allCoinsSlugMap")
if found {
ct.cache.Delete("allCoinsSlugMap")
@ -150,8 +150,8 @@ func (ct *Cointop) layout() error {
if !ct.State.hideStatusbar {
if err := ct.ui.SetView(ct.Views.Statusbar, 0, maxY-statusbarHeight-1, maxX, maxY); err != nil {
ct.Views.Statusbar.SetFrame(false)
ct.Views.Statusbar.SetFgColor(ct.colorscheme.gocuiFgColor(ct.Views.Statusbar.Name()))
ct.Views.Statusbar.SetBgColor(ct.colorscheme.gocuiBgColor(ct.Views.Statusbar.Name()))
ct.Views.Statusbar.SetFgColor(ct.colorscheme.GocuiFgColor(ct.Views.Statusbar.Name()))
ct.Views.Statusbar.SetBgColor(ct.colorscheme.GocuiBgColor(ct.Views.Statusbar.Name()))
go ct.UpdateStatusbar("")
}
} else {
@ -167,22 +167,22 @@ func (ct *Cointop) layout() error {
ct.Views.SearchField.SetEditable(true)
ct.Views.SearchField.SetWrap(true)
ct.Views.SearchField.SetFrame(false)
ct.Views.SearchField.SetFgColor(ct.colorscheme.gocuiFgColor("searchbar"))
ct.Views.SearchField.SetBgColor(ct.colorscheme.gocuiBgColor("searchbar"))
ct.Views.SearchField.SetFgColor(ct.colorscheme.GocuiFgColor("searchbar"))
ct.Views.SearchField.SetBgColor(ct.colorscheme.GocuiBgColor("searchbar"))
}
if err := ct.ui.SetView(ct.Views.Menu, 1, 1, maxX-1, maxY-1); err != nil {
ct.Views.Menu.SetFrame(false)
ct.Views.Menu.SetFgColor(ct.colorscheme.gocuiFgColor("menu"))
ct.Views.Menu.SetBgColor(ct.colorscheme.gocuiBgColor("menu"))
ct.Views.Menu.SetFgColor(ct.colorscheme.GocuiFgColor("menu"))
ct.Views.Menu.SetBgColor(ct.colorscheme.GocuiBgColor("menu"))
}
if err := ct.ui.SetView(ct.Views.Input, 3, 6, 30, 8); err != nil {
ct.Views.Input.SetFrame(true)
ct.Views.Input.SetEditable(true)
ct.Views.Input.SetWrap(true)
ct.Views.Input.SetFgColor(ct.colorscheme.gocuiFgColor("menu"))
ct.Views.Input.SetBgColor(ct.colorscheme.gocuiBgColor("menu"))
ct.Views.Input.SetFgColor(ct.colorscheme.GocuiFgColor("menu"))
ct.Views.Input.SetBgColor(ct.colorscheme.GocuiBgColor("menu"))
// run only once on init.
// this bit of code should be at the bottom

@ -12,7 +12,7 @@ var updatecoinsmux sync.Mutex
// UpdateCoins updates coins view
func (ct *Cointop) UpdateCoins() error {
ct.debuglog("updateCoins()")
ct.debuglog("UpdateCoins()")
coinslock.Lock()
defer coinslock.Unlock()
cachekey := ct.CacheKey("allCoinsSlugMap")
@ -23,12 +23,12 @@ func (ct *Cointop) UpdateCoins() error {
if found {
// cache hit
allCoinsSlugMap, _ = cached.(map[string]types.Coin)
ct.debuglog("soft cache hit")
ct.debuglog("UpdateCoins() soft cache hit")
}
// cache miss
if allCoinsSlugMap == nil {
ct.debuglog("cache miss")
ct.debuglog("UpdateCoins() cache miss")
ch := make(chan []types.Coin)
err = ct.api.GetAllCoinData(ct.State.currencyConversion, ch)
if err != nil {
@ -47,7 +47,7 @@ func (ct *Cointop) UpdateCoins() error {
// ProcessCoinsMap processes coins map
func (ct *Cointop) processCoinsMap(coinsMap map[string]types.Coin) {
ct.debuglog("processCoinsMap()")
ct.debuglog("ProcessCoinsMap()")
var coins []types.Coin
for _, v := range coinsMap {
@ -59,7 +59,7 @@ func (ct *Cointop) processCoinsMap(coinsMap map[string]types.Coin) {
// ProcessCoins processes coins list
func (ct *Cointop) processCoins(coins []types.Coin) {
ct.debuglog("processCoins()")
ct.debuglog("ProcessCoins()")
updatecoinsmux.Lock()
defer updatecoinsmux.Unlock()
@ -160,7 +160,7 @@ func (ct *Cointop) processCoins(coins []types.Coin) {
// GetListCount returns count of coins list
func (ct *Cointop) GetListCount() int {
ct.debuglog("getListCount()")
ct.debuglog("GetListCount()")
if ct.IsFavoritesVisible() {
return len(ct.State.favorites)
} else if ct.IsPortfolioVisible() {

@ -24,8 +24,8 @@ func NewMarketbarView() *MarketbarView {
// UpdateMarketbar updates the market bar view
func (ct *Cointop) UpdateMarketbar() error {
ct.debuglog("updateMarketbar()")
maxX := ct.width()
ct.debuglog("UpdateMarketbar()")
maxX := ct.Width()
logo := "cointop"
if ct.colorschemeName == "cointop" {
logo = fmt.Sprintf("%s%s%s%s", color.Green(""), color.Cyan(""), color.Green(""), color.Cyan("cointop"))
@ -88,7 +88,7 @@ func (ct *Cointop) UpdateMarketbar() error {
)
} else {
ct.State.marketBarHeight = 1
if ct.width() < 125 {
if ct.Width() < 125 {
ct.State.marketBarHeight = 2
}
@ -102,7 +102,7 @@ func (ct *Cointop) UpdateMarketbar() error {
var ok bool
market, ok = cached.(types.GlobalMarketData)
if ok {
ct.debuglog("soft cache hit")
ct.debuglog("UpdateMarketbar() soft cache hit")
}
}
@ -140,9 +140,9 @@ func (ct *Cointop) UpdateMarketbar() error {
separator1 := "•"
separator2 := "•"
offset := strings.Repeat(" ", 12)
if ct.width() < 105 {
if ct.Width() < 105 {
separator1 = "\n" + offset
} else if ct.width() < 125 {
} else if ct.Width() < 125 {
separator2 = "\n" + offset
}

@ -13,6 +13,6 @@ func NewMenuView() *MenuView {
// HideMenu hides the menu view
func (ct *Cointop) HideMenu() error {
ct.debuglog("hideMenu()")
ct.debuglog("HideMenu()")
return nil
}

@ -6,25 +6,25 @@ import (
// CurrentPage returns the current page
func (ct *Cointop) CurrentPage() int {
ct.debuglog("currentPage()")
ct.debuglog("CurrentPage()")
return ct.State.page + 1
}
// CurrentDisplayPage returns the current page in human readable format
func (ct *Cointop) CurrentDisplayPage() int {
ct.debuglog("currentDisplayPage()")
ct.debuglog("CurrentDisplayPage()")
return ct.State.page + 1
}
// TotalPages returns the number of total pages
func (ct *Cointop) TotalPages() int {
ct.debuglog("totalPages()")
ct.debuglog("TotalPages()")
return ct.GetListCount() / ct.State.perPage
}
// TotalPagesDisplay returns the number of total pages in human readable format
func (ct *Cointop) TotalPagesDisplay() int {
ct.debuglog("totalPagesDisplay()")
ct.debuglog("TotalPagesDisplay()")
return ct.TotalPages() + 1
}
@ -35,7 +35,7 @@ func (ct *Cointop) TotalPerPage() int {
// SetPage navigates to the selected page
func (ct *Cointop) SetPage(page int) int {
ct.debuglog("setPage()")
ct.debuglog("SetPage()")
if (page*ct.State.perPage) < ct.GetListCount() && page >= 0 {
ct.State.page = page
}
@ -44,7 +44,7 @@ func (ct *Cointop) SetPage(page int) int {
// CursorDown moves the cursor one row down
func (ct *Cointop) CursorDown() error {
ct.debuglog("cursorDown()")
ct.debuglog("CursorDown()")
// return if already at the bottom
if ct.IsLastRow() {
return nil
@ -69,7 +69,7 @@ func (ct *Cointop) CursorDown() error {
// CursorUp moves the cursor one row up
func (ct *Cointop) CursorUp() error {
ct.debuglog("cursorUp()")
ct.debuglog("CursorUp()")
// return if already at the top
if ct.IsFirstRow() {
return nil
@ -94,7 +94,7 @@ func (ct *Cointop) CursorUp() error {
// PageDown moves the cursor one page down
func (ct *Cointop) PageDown() error {
ct.debuglog("pageDown()")
ct.debuglog("PageDown()")
// return if already at the bottom
if ct.IsLastRow() {
return nil
@ -131,7 +131,7 @@ func (ct *Cointop) PageDown() error {
// PageUp moves the cursor one page up
func (ct *Cointop) PageUp() error {
ct.debuglog("pageUp()")
ct.debuglog("PageUp()")
// return if already at the top
if ct.IsFirstRow() {
return nil
@ -159,7 +159,7 @@ func (ct *Cointop) PageUp() error {
// NavigateFirstLine moves the cursor to the first row of the table
func (ct *Cointop) NavigateFirstLine() error {
ct.debuglog("navigateFirstLine()")
ct.debuglog("NavigateFirstLine()")
// return if already at the top
if ct.IsFirstRow() {
return nil
@ -180,7 +180,7 @@ func (ct *Cointop) NavigateFirstLine() error {
// NavigateLastLine moves the cursor to the last row of the table
func (ct *Cointop) NavigateLastLine() error {
ct.debuglog("navigateLastLine()")
ct.debuglog("NavigateLastLine()")
// return if already at the bottom
if ct.IsLastRow() {
return nil
@ -209,7 +209,7 @@ func (ct *Cointop) NavigateLastLine() error {
// NavigatePageFirstLine moves the cursor to the visible first row of the table
func (ct *Cointop) NavigatePageFirstLine() error {
ct.debuglog("navigatePageFirstLine()")
ct.debuglog("NavigatePageFirstLine()")
// return if already at the correct line
if ct.IsPageFirstLine() {
return nil
@ -225,7 +225,7 @@ func (ct *Cointop) NavigatePageFirstLine() error {
// NavigatePageMiddleLine moves the cursor to the visible middle row of the table
func (ct *Cointop) NavigatePageMiddleLine() error {
ct.debuglog("navigatePageMiddleLine()")
ct.debuglog("NavigatePageMiddleLine()")
// return if already at the correct line
if ct.IsPageMiddleLine() {
return nil
@ -242,7 +242,7 @@ func (ct *Cointop) NavigatePageMiddleLine() error {
// NavigatePageLastLine moves the cursor to the visible last row of the table
func (ct *Cointop) navigatePageLastLine() error {
ct.debuglog("navigatePageLastLine()")
ct.debuglog("NavigatePageLastLine()")
// return if already at the correct line
if ct.IsPageLastLine() {
return nil
@ -259,7 +259,7 @@ func (ct *Cointop) navigatePageLastLine() error {
// NextPage navigates to the next page
func (ct *Cointop) NextPage() error {
ct.debuglog("nextPage()")
ct.debuglog("NextPage()")
// return if already at the last page
if ct.IsLastPage() {
@ -274,7 +274,7 @@ func (ct *Cointop) NextPage() error {
// PrevPage navigates to the previous page
func (ct *Cointop) PrevPage() error {
ct.debuglog("prevPage()")
ct.debuglog("PrevPage()")
// return if already at the first page
if ct.IsFirstPage() {
@ -289,7 +289,7 @@ func (ct *Cointop) PrevPage() error {
// NextPageTop navigates to the first row of the next page
func (ct *Cointop) nextPageTop() error {
ct.debuglog("nextPageTop()")
ct.debuglog("NextPageTop()")
ct.NextPage()
ct.NavigateFirstLine()
@ -299,7 +299,7 @@ func (ct *Cointop) nextPageTop() error {
// PrevPageTop navigates to the first row of the previous page
func (ct *Cointop) PrevPageTop() error {
ct.debuglog("prevtPageTop()")
ct.debuglog("PrevtPageTop()")
ct.PrevPage()
ct.NavigateLastLine()
@ -309,7 +309,7 @@ func (ct *Cointop) PrevPageTop() error {
// FirstPage navigates to the first page
func (ct *Cointop) FirstPage() error {
ct.debuglog("firstPage()")
ct.debuglog("FirstPage()")
// return if already at the first page
if ct.IsFirstPage() {
@ -324,7 +324,7 @@ func (ct *Cointop) FirstPage() error {
// LastPage navigates to the last page
func (ct *Cointop) LastPage() error {
ct.debuglog("lastPage()")
ct.debuglog("LastPage()")
// return if already at the last page
if ct.IsLastPage() {
@ -339,7 +339,7 @@ func (ct *Cointop) LastPage() error {
// IsFirstRow returns true if cursor is on first row
func (ct *Cointop) IsFirstRow() bool {
ct.debuglog("isFirstRow()")
ct.debuglog("IsFirstRow()")
oy := ct.Views.Table.OriginY()
cy := ct.Views.Table.CursorY()
return (cy + oy) == 0
@ -347,7 +347,7 @@ func (ct *Cointop) IsFirstRow() bool {
// IsLastRow returns true if cursor is on last row
func (ct *Cointop) IsLastRow() bool {
ct.debuglog("isLastRow()")
ct.debuglog("IsLastRow()")
oy := ct.Views.Table.OriginY()
cy := ct.Views.Table.CursorY()
numRows := ct.TableRowsLen() - 1
@ -356,19 +356,19 @@ func (ct *Cointop) IsLastRow() bool {
// IsFirstPage returns true if cursor is on the first page
func (ct *Cointop) IsFirstPage() bool {
ct.debuglog("isFirstPage()")
ct.debuglog("IsFirstPage()")
return ct.State.page == 0
}
// IsLastPage returns true if cursor is on the last page
func (ct *Cointop) IsLastPage() bool {
ct.debuglog("isLastPage()")
ct.debuglog("IsLastPage()")
return ct.State.page == ct.TotalPages()-1
}
// IsPageFirstLine returns true if the cursor is on the visible first row
func (ct *Cointop) IsPageFirstLine() bool {
ct.debuglog("isPageFirstLine()")
ct.debuglog("IsPageFirstLine()")
cy := ct.Views.Table.CursorY()
return cy == 0
@ -376,7 +376,7 @@ func (ct *Cointop) IsPageFirstLine() bool {
// IsPageMiddleLine returns true if the cursor is on the visible middle row
func (ct *Cointop) IsPageMiddleLine() bool {
ct.debuglog("isPageMiddleLine()")
ct.debuglog("IsPageMiddleLine()")
cy := ct.Views.Table.CursorY()
sy := ct.Views.Table.Height()
return (sy/2)-1 == cy
@ -384,7 +384,7 @@ func (ct *Cointop) IsPageMiddleLine() bool {
// IsPageLastLine returns true if the cursor is on the visible last row
func (ct *Cointop) IsPageLastLine() bool {
ct.debuglog("isPageLastLine()")
ct.debuglog("IsPageLastLine()")
cy := ct.Views.Table.CursorY()
sy := ct.Views.Table.Height()
@ -393,7 +393,7 @@ func (ct *Cointop) IsPageLastLine() bool {
// GoToPageRowIndex navigates to the selected row index of the page
func (ct *Cointop) GoToPageRowIndex(idx int) error {
ct.debuglog("goToPageRowIndex()")
ct.debuglog("GoToPageRowIndex()")
if idx < 0 {
idx = 0
}
@ -407,7 +407,7 @@ func (ct *Cointop) GoToPageRowIndex(idx int) error {
// GoToGlobalIndex navigates to the selected row index of all page rows
func (ct *Cointop) GoToGlobalIndex(idx int) error {
ct.debuglog("goToGlobalIndex()")
ct.debuglog("GoToGlobalIndex()")
l := ct.TableRowsLen()
atpage := idx / l
ct.SetPage(atpage)
@ -422,7 +422,7 @@ func (ct *Cointop) HighlightRow(pageRowIndex int) error {
if pageRowIndex < 0 {
pageRowIndex = 0
}
ct.debuglog("highlightRow()")
ct.debuglog("HighlightRow()")
ct.Views.Table.SetOrigin(0, 0)
ct.Views.Table.SetCursor(0, 0)
ox := ct.Views.Table.OriginX()
@ -441,7 +441,7 @@ func (ct *Cointop) HighlightRow(pageRowIndex int) error {
cy = h - (l - pageRowIndex)
}
}
ct.debuglog("highlightRow idx:%v h:%v cy:%v oy:%v", pageRowIndex, h, cy, oy)
ct.debuglog("HighlightRow idx:%v h:%v cy:%v oy:%v", pageRowIndex, h, cy, oy)
ct.Views.Table.SetOrigin(ox, oy)
ct.Views.Table.SetCursor(cx, cy)
return nil
@ -449,7 +449,7 @@ func (ct *Cointop) HighlightRow(pageRowIndex int) error {
// GoToCoinRow navigates to the row of the matched coin
func (ct *Cointop) GoToCoinRow(coin *Coin) error {
ct.debuglog("goToCoinRow()")
ct.debuglog("GoToCoinRow()")
if coin == nil {
return nil
}
@ -538,7 +538,7 @@ func (ct *Cointop) TableScrollLeft() error {
// TableScrollRight scrolls the the table to the right
func (ct *Cointop) TableScrollRight() error {
ct.State.tableOffsetX--
maxX := int(math.Min(float64(1-(ct.maxTableWidth-ct.width())), 0))
maxX := int(math.Min(float64(1-(ct.maxTableWidth-ct.Width())), 0))
if ct.State.tableOffsetX <= maxX {
ct.State.tableOffsetX = maxX
}

@ -70,7 +70,7 @@ func (ct *Cointop) GetPortfolioTableHeaders() []string {
// GetPortfolioTable returns the table for displaying portfolio holdings
func (ct *Cointop) GetPortfolioTable() *table.Table {
total := ct.GetPortfolioTotal()
maxX := ct.width()
maxX := ct.Width()
t := table.NewTable().SetWidth(maxX)
var rows [][]*table.RowCell
headers := ct.GetPortfolioTableHeaders()
@ -306,7 +306,7 @@ func (ct *Cointop) GetPortfolioTable() *table.Table {
// TogglePortfolio toggles the portfolio view
func (ct *Cointop) TogglePortfolio() error {
ct.debuglog("togglePortfolio()")
ct.debuglog("TogglePortfolio()")
ct.ToggleSelectedView(PortfolioView)
go ct.UpdateChart()
go ct.UpdateTable()
@ -315,7 +315,7 @@ func (ct *Cointop) TogglePortfolio() error {
// ToggleShowPortfolio shows the portfolio view
func (ct *Cointop) ToggleShowPortfolio() error {
ct.debuglog("toggleShowPortfolio()")
ct.debuglog("ToggleShowPortfolio()")
ct.SetSelectedView(PortfolioView)
go ct.UpdateChart()
go ct.UpdateTable()
@ -324,7 +324,7 @@ func (ct *Cointop) ToggleShowPortfolio() error {
// TogglePortfolioUpdateMenu toggles the portfolio update menu
func (ct *Cointop) TogglePortfolioUpdateMenu() error {
ct.debuglog("togglePortfolioUpdateMenu()")
ct.debuglog("TogglePortfolioUpdateMenu()")
if ct.IsPriceAlertsVisible() {
return ct.ShowPriceAlertsUpdateMenu()
}
@ -344,11 +344,11 @@ func (ct *Cointop) CoinHoldings(coin *Coin) float64 {
// UpdatePortfolioUpdateMenu updates the portfolio update menu view
func (ct *Cointop) UpdatePortfolioUpdateMenu() error {
ct.debuglog("updatePortfolioUpdateMenu()")
ct.debuglog("UpdatePortfolioUpdateMenu()")
coin := ct.HighlightedRowCoin()
exists := ct.PortfolioEntryExists(coin)
value := strconv.FormatFloat(ct.CoinHoldings(coin), 'f', -1, 64)
ct.debuglog("holdings %v", value)
ct.debuglog("UpdatePortfolioUpdateMenu() holdings %v", value)
var mode string
var current string
var submitText string
@ -360,7 +360,7 @@ func (ct *Cointop) UpdatePortfolioUpdateMenu() error {
mode = "Add"
submitText = "Add"
}
header := ct.colorscheme.MenuHeader(fmt.Sprintf(" %s Portfolio Entry %s\n\n", mode, pad.Left("[q] close ", ct.width()-25, " ")))
header := ct.colorscheme.MenuHeader(fmt.Sprintf(" %s Portfolio Entry %s\n\n", mode, pad.Left("[q] close ", ct.Width()-25, " ")))
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)
@ -376,7 +376,7 @@ func (ct *Cointop) UpdatePortfolioUpdateMenu() error {
// ShowPortfolioUpdateMenu shows the portfolio update menu
func (ct *Cointop) ShowPortfolioUpdateMenu() error {
ct.debuglog("showPortfolioUpdateMenu()")
ct.debuglog("ShowPortfolioUpdateMenu()")
// TODO: separation of concerns
if ct.IsPriceAlertsVisible() {
@ -400,7 +400,7 @@ func (ct *Cointop) ShowPortfolioUpdateMenu() error {
// HidePortfolioUpdateMenu hides the portfolio update menu
func (ct *Cointop) HidePortfolioUpdateMenu() error {
ct.debuglog("hidePortfolioUpdateMenu()")
ct.debuglog("HidePortfolioUpdateMenu()")
ct.State.portfolioUpdateMenuVisible = false
ct.ui.SetViewOnBottom(ct.Views.Menu)
ct.ui.SetViewOnBottom(ct.Views.Input)
@ -418,7 +418,7 @@ func (ct *Cointop) HidePortfolioUpdateMenu() error {
// SetPortfolioHoldings sets portfolio entry holdings from inputed value
func (ct *Cointop) SetPortfolioHoldings() error {
ct.debuglog("setPortfolioHoldings()")
ct.debuglog("SetPortfolioHoldings()")
defer ct.HidePortfolioUpdateMenu()
coin := ct.HighlightedRowCoin()
if coin == nil {
@ -469,7 +469,7 @@ func (ct *Cointop) SetPortfolioHoldings() error {
// PortfolioEntry returns a portfolio entry
func (ct *Cointop) PortfolioEntry(c *Coin) (*PortfolioEntry, bool) {
//ct.debuglog("portfolioEntry()") // too many
//ct.debuglog("PortfolioEntry()") // too many
if c == nil {
return &PortfolioEntry{}, true
}
@ -495,7 +495,7 @@ func (ct *Cointop) PortfolioEntry(c *Coin) (*PortfolioEntry, bool) {
// SetPortfolioEntry sets a portfolio entry
func (ct *Cointop) SetPortfolioEntry(coin string, holdings float64) error {
ct.debuglog("setPortfolioEntry()")
ct.debuglog("SetPortfolioEntry()")
ic, _ := ct.State.allCoinsSlugMap.Load(strings.ToLower(coin))
c, _ := ic.(*Coin)
p, isNew := ct.PortfolioEntry(c)
@ -518,7 +518,7 @@ func (ct *Cointop) SetPortfolioEntry(coin string, holdings float64) error {
// RemovePortfolioEntry removes a portfolio entry
func (ct *Cointop) RemovePortfolioEntry(coin string) error {
ct.debuglog("removePortfolioEntry()")
ct.debuglog("RemovePortfolioEntry()")
delete(ct.State.portfolio.Entries, strings.ToLower(coin))
if err := ct.Save(); err != nil {
return err
@ -528,20 +528,20 @@ func (ct *Cointop) RemovePortfolioEntry(coin string) error {
// PortfolioEntryExists returns true if portfolio entry exists
func (ct *Cointop) PortfolioEntryExists(c *Coin) bool {
ct.debuglog("portfolioEntryExists()")
ct.debuglog("PortfolioEntryExists()")
_, isNew := ct.PortfolioEntry(c)
return !isNew
}
// PortfolioEntriesCount returns the count of portfolio entries
func (ct *Cointop) PortfolioEntriesCount() int {
ct.debuglog("portfolioEntriesCount()")
ct.debuglog("PortfolioEntriesCount()")
return len(ct.State.portfolio.Entries)
}
// GetPortfolioSlice returns portfolio entries as a slice
func (ct *Cointop) GetPortfolioSlice() []*Coin {
ct.debuglog("getPortfolioSlice()")
ct.debuglog("GetPortfolioSlice()")
sliced := []*Coin{}
if ct.PortfolioEntriesCount() == 0 {
return sliced
@ -595,7 +595,7 @@ OUTER:
// GetPortfolioTotal returns the total balance of portfolio entries
func (ct *Cointop) GetPortfolioTotal() float64 {
ct.debuglog("getPortfolioTotal()")
ct.debuglog("GetPortfolioTotal()")
portfolio := ct.GetPortfolioSlice()
var total float64
for _, p := range portfolio {
@ -606,7 +606,7 @@ func (ct *Cointop) GetPortfolioTotal() float64 {
// RefreshPortfolioCoins refreshes portfolio entry coin data
func (ct *Cointop) RefreshPortfolioCoins() error {
ct.debuglog("refreshPortfolioCoins()")
ct.debuglog("RefreshPortfolioCoins()")
holdings := ct.GetPortfolioSlice()
holdingCoins := make([]string, len(holdings))
for i, entry := range holdings {
@ -654,7 +654,7 @@ var portfolioColumns = map[string]bool{
// PrintHoldingsTable prints the holdings in an ASCII table
func (ct *Cointop) PrintHoldingsTable(options *TablePrintOptions) error {
ct.debuglog("printHoldingsTable()")
ct.debuglog("PrintHoldingsTable()")
if options == nil {
options = &TablePrintOptions{}
}

@ -42,8 +42,8 @@ var PriceAlertFrequencyMap = map[string]bool{
// GetPriceAlertsTable returns the table for displaying alerts
func (ct *Cointop) GetPriceAlertsTable() *table.Table {
ct.debuglog("getPriceAlertsTable()")
maxX := ct.width()
ct.debuglog("GetPriceAlertsTable()")
maxX := ct.Width()
t := table.NewTable().SetWidth(maxX)
var rows [][]*table.RowCell
headers := ct.GetPriceAlertsTableHeaders()
@ -145,7 +145,7 @@ func (ct *Cointop) GetPriceAlertsTable() *table.Table {
// TogglePriceAlerts toggles the price alerts view
func (ct *Cointop) TogglePriceAlerts() error {
ct.debuglog("togglePriceAlerts()")
ct.debuglog("TogglePriceAlerts()")
ct.ToggleSelectedView(PriceAlertsView)
ct.NavigateFirstLine()
go ct.UpdateTable()
@ -159,7 +159,7 @@ func (ct *Cointop) IsPriceAlertsVisible() bool {
// PriceAlertWatcher starts the price alert watcher
func (ct *Cointop) PriceAlertWatcher() error {
ct.debuglog("priceAlertWatcher()")
ct.debuglog("PriceAlertWatcher()")
alerts := ct.State.priceAlerts.Entries
ticker := time.NewTicker(5 * time.Second)
for range ticker.C {
@ -175,7 +175,7 @@ func (ct *Cointop) PriceAlertWatcher() error {
// CheckPriceAlert checks the price alert
func (ct *Cointop) CheckPriceAlert(alert *PriceAlert) error {
ct.debuglog("checkPriceAlert()")
ct.debuglog("CheckPriceAlert()")
if alert.Expired {
return nil
}
@ -227,7 +227,7 @@ func (ct *Cointop) CheckPriceAlert(alert *PriceAlert) error {
// UpdatePriceAlertsUpdateMenu updates the alerts update menu view
func (ct *Cointop) UpdatePriceAlertsUpdateMenu(isNew bool, coin *Coin) error {
ct.debuglog("updatePriceAlertsUpdateMenu()")
ct.debuglog("UpdatePriceAlertsUpdateMenu()")
isEdit := false
var value string
@ -266,7 +266,7 @@ func (ct *Cointop) UpdatePriceAlertsUpdateMenu(isNew bool, coin *Coin) error {
mode = "Edit"
current = fmt.Sprintf("(current %s%s)", ct.CurrencySymbol(), currentPrice)
submitText = "Set"
offset = ct.width() - 21
offset = ct.Width() - 21
} else {
if coin == nil {
coin = ct.HighlightedRowCoin()
@ -275,7 +275,7 @@ func (ct *Cointop) UpdatePriceAlertsUpdateMenu(isNew bool, coin *Coin) error {
value = fmt.Sprintf("> %s", currentPrice)
mode = "Create"
submitText = "Create"
offset = ct.width() - 23
offset = ct.Width() - 23
}
header := ct.colorscheme.MenuHeader(fmt.Sprintf(" %s Alert Entry %s\n\n", mode, pad.Left("[q] close ", offset, " ")))
label := fmt.Sprintf(" Enter target price for %s %s", ct.colorscheme.MenuLabel(coin.Name), current)
@ -293,7 +293,7 @@ func (ct *Cointop) UpdatePriceAlertsUpdateMenu(isNew bool, coin *Coin) error {
// ShowPriceAlertsAddMenu shows the alert add menu
func (ct *Cointop) ShowPriceAlertsAddMenu() error {
ct.debuglog("showPriceAlertsAddMenu()")
ct.debuglog("ShowPriceAlertsAddMenu()")
coin := ct.HighlightedRowCoin()
ct.SetSelectedView(PriceAlertsView)
ct.UpdatePriceAlertsUpdateMenu(true, coin)
@ -306,7 +306,7 @@ func (ct *Cointop) ShowPriceAlertsAddMenu() error {
// ShowPriceAlertsUpdateMenu shows the alerts update menu
func (ct *Cointop) ShowPriceAlertsUpdateMenu() error {
ct.debuglog("showPriceAlertsUpdateMenu()")
ct.debuglog("ShowPriceAlertsUpdateMenu()")
coin := ct.HighlightedRowCoin()
ct.SetSelectedView(PriceAlertsView)
ct.UpdatePriceAlertsUpdateMenu(false, coin)
@ -319,7 +319,7 @@ func (ct *Cointop) ShowPriceAlertsUpdateMenu() error {
// HidePriceAlertsUpdateMenu hides the alerts update menu
func (ct *Cointop) HidePriceAlertsUpdateMenu() error {
ct.debuglog("hidePriceAlertsUpdateMenu()")
ct.debuglog("HidePriceAlertsUpdateMenu()")
ct.ui.SetViewOnBottom(ct.Views.Menu)
ct.ui.SetViewOnBottom(ct.Views.Input)
ct.ui.SetCursor(false)
@ -345,7 +345,7 @@ func (ct *Cointop) EnterKeyPressHandler() error {
// CreatePriceAlert sets price from inputed value
func (ct *Cointop) CreatePriceAlert() error {
ct.debuglog("createPriceAlert()")
ct.debuglog("CreatePriceAlert()")
defer ct.HidePriceAlertsUpdateMenu()
isNew := ct.State.priceAlertNewID != ""
@ -436,7 +436,7 @@ func (ct *Cointop) ParsePriceAlertInput(value string) (string, float64, error) {
// SetPriceAlert sets a price alert
func (ct *Cointop) SetPriceAlert(coinName string, operator string, targetPrice float64) error {
ct.debuglog("setPriceAlert()")
ct.debuglog("SetPriceAlert()")
if operator == "" {
operator = "="
@ -474,7 +474,7 @@ func (ct *Cointop) SetPriceAlert(coinName string, operator string, targetPrice f
// RemovePriceAlert removes a price alert entry
func (ct *Cointop) RemovePriceAlert(id string) error {
ct.debuglog("removePriceAlert()")
ct.debuglog("RemovePriceAlert()")
for i, entry := range ct.State.priceAlerts.Entries {
if entry.ID == ct.State.priceAlertEditID {
ct.State.priceAlerts.Entries = append(ct.State.priceAlerts.Entries[:i], ct.State.priceAlerts.Entries[i+1:]...)

@ -14,7 +14,7 @@ func (ct *Cointop) Quit() error {
// QuitView exists the current view
func (ct *Cointop) QuitView() error {
ct.debuglog("quitView()")
ct.debuglog("QuitView()")
if ct.State.selectedView != CoinsView {
ct.SetSelectedView(CoinsView)
return ct.UpdateTable()
@ -28,7 +28,7 @@ func (ct *Cointop) QuitView() error {
// Exit safely exits the program
func (ct *Cointop) Exit() {
ct.debuglog("exit()")
ct.debuglog("Exit()")
ct.logfile.Close()
if ct.g != nil {
ct.g.Close()

@ -7,7 +7,7 @@ import (
// Refresh triggers a force refresh of coin data
func (ct *Cointop) Refresh() error {
ct.debuglog("refresh()")
ct.debuglog("Refresh()")
go func() {
<-ct.limiter
ct.forceRefresh <- true
@ -17,7 +17,7 @@ func (ct *Cointop) Refresh() error {
// RefreshAll triggers a force refresh of all data
func (ct *Cointop) RefreshAll() error {
ct.debuglog("refreshAll()")
ct.debuglog("RefreshAll()")
ct.refreshMux.Lock()
defer ct.refreshMux.Unlock()
ct.setRefreshStatus()

@ -27,8 +27,8 @@ func NewInputView() *InputView {
}
// OpenSearch opens the search field
func (ct *Cointop) openSearch() error {
ct.debuglog("openSearch()")
func (ct *Cointop) OpenSearch() error {
ct.debuglog("OpenSearch()")
if ct.ui.ActiveViewName() != ct.Views.Table.Name() {
return nil
}
@ -40,7 +40,7 @@ func (ct *Cointop) openSearch() error {
// CancelSearch closes the search field
func (ct *Cointop) CancelSearch() error {
ct.debuglog("cancelSearch()")
ct.debuglog("CancelSearch()")
ct.State.searchFieldVisible = false
ct.ui.SetCursor(false)
ct.SetActiveView(ct.Views.Table.Name())
@ -49,7 +49,7 @@ func (ct *Cointop) CancelSearch() error {
// DoSearch triggers the search and sets views
func (ct *Cointop) DoSearch() error {
ct.debuglog("doSearch()")
ct.debuglog("DoSearch()")
ct.Views.SearchField.Rewind()
b := make([]byte, 100)
n, err := ct.Views.SearchField.Read(b)
@ -79,7 +79,7 @@ func (ct *Cointop) DoSearch() error {
// Search performs the search and filtering
func (ct *Cointop) Search(q string) error {
ct.debuglog("search()")
ct.debuglog("Search()")
q = strings.TrimSpace(strings.ToLower(q))
idx := -1
min := -1

@ -2,7 +2,7 @@ package cointop
// SelectedCoinName returns the selected coin name
func (ct *Cointop) SelectedCoinName() string {
ct.debuglog("selectedCoinName()")
ct.debuglog("SelectedCoinName()")
coin := ct.State.selectedCoin
if coin != nil {
return coin.Name
@ -13,7 +13,7 @@ func (ct *Cointop) SelectedCoinName() string {
// SelectedCoinSymbol returns the selected coin symbol
func (ct *Cointop) SelectedCoinSymbol() string {
ct.debuglog("selectedCoinSymbol()")
ct.debuglog("SelectedCoinSymbol()")
coin := ct.State.selectedCoin
if coin != nil {
return coin.Symbol

@ -1,8 +1,8 @@
package cointop
// Size returns window width and height
func (ct *Cointop) size() (int, int) {
ct.debuglog("size()")
func (ct *Cointop) Size() (int, int) {
ct.debuglog("Size()")
if ct.g == nil {
return 0, 0
}
@ -11,22 +11,22 @@ func (ct *Cointop) size() (int, int) {
}
// Width returns window width
func (ct *Cointop) width() int {
ct.debuglog("width()")
w, _ := ct.size()
func (ct *Cointop) Width() int {
ct.debuglog("Width()")
w, _ := ct.Size()
return w
}
// Height returns window height
func (ct *Cointop) height() int {
ct.debuglog("height()")
_, h := ct.size()
func (ct *Cointop) Height() int {
ct.debuglog("Height()")
_, h := ct.Size()
return h
}
// ViewWidth returns view width
func (ct *Cointop) ViewWidth(view string) int {
ct.debuglog("viewWidth()")
ct.debuglog("ViewWidth()")
v, err := ct.g.View(view)
if err != nil {
return 0
@ -37,8 +37,8 @@ func (ct *Cointop) ViewWidth(view string) int {
// ClampedWidth returns the clamped width
func (ct *Cointop) ClampedWidth() int {
ct.debuglog("clampedWidth()")
w := ct.width()
ct.debuglog("ClampedWidth()")
w := ct.Width()
if w > ct.maxTableWidth {
return ct.maxTableWidth
}

@ -11,7 +11,7 @@ var sortlock sync.Mutex
// Sort sorts the list of coins
func (ct *Cointop) Sort(sortBy string, desc bool, list []*Coin, renderHeaders bool) {
ct.debuglog("sort()")
ct.debuglog("Sort()")
sortlock.Lock()
defer sortlock.Unlock()
ct.State.sortBy = sortBy
@ -79,7 +79,7 @@ func (ct *Cointop) Sort(sortBy string, desc bool, list []*Coin, renderHeaders bo
// SortAsc sorts list of coins in ascending order
func (ct *Cointop) SortAsc() error {
ct.debuglog("sortAsc()")
ct.debuglog("SortAsc()")
ct.State.sortDesc = false
ct.UpdateTable()
return nil
@ -87,7 +87,7 @@ func (ct *Cointop) SortAsc() error {
// SortDesc sorts list of coins in descending order
func (ct *Cointop) SortDesc() error {
ct.debuglog("sortDesc()")
ct.debuglog("SortDesc()")
ct.State.sortDesc = true
ct.UpdateTable()
return nil
@ -95,7 +95,7 @@ func (ct *Cointop) SortDesc() error {
// SortPrevCol sorts the previous column
func (ct *Cointop) SortPrevCol() error {
ct.debuglog("sortPrevCol()")
ct.debuglog("SortPrevCol()")
cols := ct.GetActiveTableHeaders()
i := ct.GetSortColIndex()
k := i - 1
@ -110,7 +110,7 @@ func (ct *Cointop) SortPrevCol() error {
// SortNextCol sorts the next column
func (ct *Cointop) SortNextCol() error {
ct.debuglog("sortNextCol()")
ct.debuglog("SortNextCol()")
cols := ct.GetActiveTableHeaders()
l := len(cols)
i := ct.GetSortColIndex()
@ -126,7 +126,7 @@ func (ct *Cointop) SortNextCol() error {
// SortToggle toggles the sort order
func (ct *Cointop) SortToggle(sortBy string, desc bool) error {
ct.debuglog("sortToggle()")
ct.debuglog("SortToggle()")
if ct.State.sortBy == sortBy {
desc = !ct.State.sortDesc
}
@ -138,7 +138,7 @@ func (ct *Cointop) SortToggle(sortBy string, desc bool) error {
// Sortfn returns the sort function as a wrapped gocui keybinding function
func (ct *Cointop) Sortfn(sortBy string, desc bool) func(g *gocui.Gui, v *gocui.View) error {
ct.debuglog("sortfn()")
ct.debuglog("Sortfn()")
return func(g *gocui.Gui, v *gocui.View) error {
coin := ct.HighlightedRowCoin()
err := ct.SortToggle(sortBy, desc)
@ -157,7 +157,7 @@ func (ct *Cointop) Sortfn(sortBy string, desc bool) func(g *gocui.Gui, v *gocui.
// GetSortColIndex gets the sort column index
func (ct *Cointop) GetSortColIndex() int {
ct.debuglog("getSortColIndex()")
ct.debuglog("GetSortColIndex()")
cols := ct.GetActiveTableHeaders()
for i, col := range cols {
if ct.State.sortBy == col {

@ -52,7 +52,7 @@ func (ct *Cointop) UpdateStatusbar(s string) error {
content = fmt.Sprintf("%s %s[+]Add", helpStr, editStr)
} else {
base := fmt.Sprintf("%s %sChart %sRange %sSearch %sConvert %s %s", helpStr, "[Enter]", "[[ ]]", "[/]", "[C]", favoritesText, portfolioText)
str := pad.Right(fmt.Sprintf("%v %sPage %v/%v %s", base, "[← →]", currpage, totalpages, s), ct.width(), " ")
str := pad.Right(fmt.Sprintf("%v %sPage %v/%v %s", base, "[← →]", currpage, totalpages, s), ct.Width(), " ")
v := ct.Version()
size := utf8.RuneCountInString(str)
end := size - utf8.RuneCountInString(v) + 2

@ -21,7 +21,7 @@ const dots = "..."
// RefreshTable refreshes the table
func (ct *Cointop) RefreshTable() error {
ct.debuglog("refreshTable()")
ct.debuglog("RefreshTable()")
statusText := ""
switch ct.State.selectedView {

@ -13,7 +13,7 @@ import (
// OpenLink opens the url in a browser
func (ct *Cointop) OpenLink() error {
ct.debuglog("openLink()")
ct.debuglog("OpenLink()")
open.URL(ct.RowLink())
return nil
}

Loading…
Cancel
Save