Allow configurable max_chart_width (default 175, if 0 use full width)

Start working on MaxTableWidth
pull/189/head
Simon Roberts 3 years ago
parent 562c5fd3f4
commit 9a270d4b19
No known key found for this signature in database
GPG Key ID: 0F30F99E6B771FD4

@ -453,8 +453,8 @@ func (ct *Cointop) ShowChartLoader() error {
func (ct *Cointop) ChartWidth() int { func (ct *Cointop) ChartWidth() int {
log.Debug("ChartWidth()") log.Debug("ChartWidth()")
w := ct.Width() w := ct.Width()
max := 175 max := int(ct.config.MaxChartWidth.(int64))
if w > max { if max > 0 && w > max {
return max return max
} }

@ -110,6 +110,7 @@ type Cointop struct {
forceRefresh chan bool forceRefresh chan bool
limiter <-chan time.Time limiter <-chan time.Time
maxTableWidth int maxTableWidth int
maxChartWidth int
refreshMux sync.Mutex refreshMux sync.Mutex
refreshTicker *time.Ticker refreshTicker *time.Ticker
saveMux sync.Mutex saveMux sync.Mutex
@ -179,6 +180,12 @@ var DefaultCurrency = "USD"
// DefaultChartRange ... // DefaultChartRange ...
var DefaultChartRange = "1Y" var DefaultChartRange = "1Y"
// DefaultMaxTableWidth ...
var DefaultMaxTableWidth int = 175
// DefaultMaxChartWidth ...
var DefaultMaxChartWidth int = 175
// DefaultSortBy ... // DefaultSortBy ...
var DefaultSortBy = "rank" var DefaultSortBy = "rank"
@ -230,7 +237,8 @@ func NewCointop(config *Config) (*Cointop, error) {
apiChoice: CoinGecko, apiChoice: CoinGecko,
apiKeys: new(APIKeys), apiKeys: new(APIKeys),
forceRefresh: make(chan bool), forceRefresh: make(chan bool),
maxTableWidth: 175, maxTableWidth: DefaultMaxTableWidth,
maxChartWidth: DefaultMaxChartWidth,
ActionsMap: ActionsMap(), ActionsMap: ActionsMap(),
cache: cache.New(1*time.Minute, 2*time.Minute), cache: cache.New(1*time.Minute, 2*time.Minute),
colorsDir: config.ColorsDir, colorsDir: config.ColorsDir,

@ -42,6 +42,8 @@ type ConfigFileConfig struct {
Currency interface{} `toml:"currency"` Currency interface{} `toml:"currency"`
DefaultView interface{} `toml:"default_view"` DefaultView interface{} `toml:"default_view"`
DefaultChartRange interface{} `toml:"default_chart_range"` DefaultChartRange interface{} `toml:"default_chart_range"`
MaxTableWidth interface{} `toml:"max_table_width"`
MaxChartWidth interface{} `toml:"max_chart_width"`
CoinMarketCap map[string]interface{} `toml:"coinmarketcap"` CoinMarketCap map[string]interface{} `toml:"coinmarketcap"`
API interface{} `toml:"api"` API interface{} `toml:"api"`
Colorscheme interface{} `toml:"colorscheme"` Colorscheme interface{} `toml:"colorscheme"`
@ -264,6 +266,8 @@ func (ct *Cointop) ConfigToToml() ([]byte, error) {
var currencyIfc interface{} = ct.State.currencyConversion var currencyIfc interface{} = ct.State.currencyConversion
var defaultViewIfc interface{} = ct.State.defaultView var defaultViewIfc interface{} = ct.State.defaultView
var defaultChartRangeIfc interface{} = ct.State.defaultChartRange var defaultChartRangeIfc interface{} = ct.State.defaultChartRange
var maxTableWidth interface{} = ct.maxChartWidth
var maxChartWidth interface{} = ct.maxChartWidth
var colorschemeIfc interface{} = ct.colorschemeName var colorschemeIfc interface{} = ct.colorschemeName
var refreshRateIfc interface{} = uint(ct.State.refreshRate.Seconds()) var refreshRateIfc interface{} = uint(ct.State.refreshRate.Seconds())
var cacheDirIfc interface{} = ct.State.cacheDir var cacheDirIfc interface{} = ct.State.cacheDir
@ -304,6 +308,8 @@ func (ct *Cointop) ConfigToToml() ([]byte, error) {
Currency: currencyIfc, Currency: currencyIfc,
DefaultView: defaultViewIfc, DefaultView: defaultViewIfc,
DefaultChartRange: defaultChartRangeIfc, DefaultChartRange: defaultChartRangeIfc,
MaxTableWidth: maxTableWidth,
MaxChartWidth: maxChartWidth,
Favorites: favoritesMapIfc, Favorites: favoritesMapIfc,
RefreshRate: refreshRateIfc, RefreshRate: refreshRateIfc,
Shortcuts: shortcutsIfcs, Shortcuts: shortcutsIfcs,

Loading…
Cancel
Save