Merge pull request #242 from lyricnz/feature/no-mouse

Add configuration for enable_mouse
pull/250/head
Miguel Mota 3 years ago committed by GitHub
commit 0a5ba717d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -92,6 +92,7 @@ type State struct {
tableCompactNotation bool tableCompactNotation bool
favoritesCompactNotation bool favoritesCompactNotation bool
portfolioCompactNotation bool portfolioCompactNotation bool
enableMouse bool
} }
// Cointop cointop // Cointop cointop
@ -187,6 +188,9 @@ var DefaultChartRange = "1Y"
// DefaultCompactNotation ... // DefaultCompactNotation ...
var DefaultCompactNotation = false var DefaultCompactNotation = false
// DefaultEnableMouse ...
var DefaultEnableMouse = true
// DefaultMaxChartWidth ... // DefaultMaxChartWidth ...
var DefaultMaxChartWidth = 175 var DefaultMaxChartWidth = 175
@ -296,6 +300,7 @@ func NewCointop(config *Config) (*Cointop, error) {
SoundEnabled: true, SoundEnabled: true,
}, },
compactNotation: DefaultCompactNotation, compactNotation: DefaultCompactNotation,
enableMouse: DefaultEnableMouse,
tableCompactNotation: DefaultCompactNotation, tableCompactNotation: DefaultCompactNotation,
favoritesCompactNotation: DefaultCompactNotation, favoritesCompactNotation: DefaultCompactNotation,
portfolioCompactNotation: DefaultCompactNotation, portfolioCompactNotation: DefaultCompactNotation,
@ -488,7 +493,7 @@ func (ct *Cointop) Run() error {
defer ui.Close() defer ui.Close()
ui.SetInputEsc(true) ui.SetInputEsc(true)
ui.SetMouse(true) ui.SetMouse(ct.State.enableMouse)
ui.SetHighlight(true) ui.SetHighlight(true)
ui.SetManagerFunc(ct.layout) ui.SetManagerFunc(ct.layout)
if err := ct.SetKeybindings(); err != nil { if err := ct.SetKeybindings(); err != nil {

@ -49,6 +49,7 @@ type ConfigFileConfig struct {
RefreshRate interface{} `toml:"refresh_rate"` RefreshRate interface{} `toml:"refresh_rate"`
CacheDir interface{} `toml:"cache_dir"` CacheDir interface{} `toml:"cache_dir"`
CompactNotation interface{} `toml:"compact_notation"` CompactNotation interface{} `toml:"compact_notation"`
EnableMouse interface{} `toml:"enable_mouse"`
Table map[string]interface{} `toml:"table"` Table map[string]interface{} `toml:"table"`
Chart map[string]interface{} `toml:"chart"` Chart map[string]interface{} `toml:"chart"`
} }
@ -72,6 +73,7 @@ func (ct *Cointop) SetupConfig() error {
ct.loadRefreshRateFromConfig, ct.loadRefreshRateFromConfig,
ct.loadCacheDirFromConfig, ct.loadCacheDirFromConfig,
ct.loadCompactNotationFromConfig, ct.loadCompactNotationFromConfig,
ct.loadEnableMouseFromConfig,
ct.loadPriceAlertsFromConfig, ct.loadPriceAlertsFromConfig,
ct.loadPortfolioFromConfig, ct.loadPortfolioFromConfig,
} }
@ -289,6 +291,7 @@ func (ct *Cointop) ConfigToToml() ([]byte, error) {
Table: tableMapIfc, Table: tableMapIfc,
Chart: chartMapIfc, Chart: chartMapIfc,
CompactNotation: ct.State.compactNotation, CompactNotation: ct.State.compactNotation,
EnableMouse: ct.State.enableMouse,
} }
var b bytes.Buffer var b bytes.Buffer
@ -506,6 +509,16 @@ func (ct *Cointop) loadCompactNotationFromConfig() error {
return nil return nil
} }
// loadCompactNotationFromConfig loads compact-notation setting from config file to struct
func (ct *Cointop) loadEnableMouseFromConfig() error {
log.Debug("loadEnableMouseFromConfig()")
if enableMouse, ok := ct.config.EnableMouse.(bool); ok {
ct.State.enableMouse = enableMouse
}
return nil
}
// LoadAPIChoiceFromConfig loads API choices from config file to struct // LoadAPIChoiceFromConfig loads API choices from config file to struct
func (ct *Cointop) loadAPIChoiceFromConfig() error { func (ct *Cointop) loadAPIChoiceFromConfig() error {
log.Debug("loadAPIKeysFromConfig()") log.Debug("loadAPIKeysFromConfig()")

@ -38,12 +38,12 @@ func (ui *UI) SetBgColor(bgColor gocui.Attribute) {
// SetInputEsc enables the escape key // SetInputEsc enables the escape key
func (ui *UI) SetInputEsc(enabled bool) { func (ui *UI) SetInputEsc(enabled bool) {
ui.g.InputEsc = true ui.g.InputEsc = enabled
} }
// SetMouse enables the mouse // SetMouse enables the mouse
func (ui *UI) SetMouse(enabled bool) { func (ui *UI) SetMouse(enabled bool) {
ui.g.Mouse = true ui.g.Mouse = enabled
} }
// SetCursor enables the input field cursor // SetCursor enables the input field cursor
@ -53,7 +53,7 @@ func (ui *UI) SetCursor(enabled bool) {
// SetHighlight enables the highlight active state // SetHighlight enables the highlight active state
func (ui *UI) SetHighlight(enabled bool) { func (ui *UI) SetHighlight(enabled bool) {
ui.g.Highlight = true ui.g.Highlight = enabled
} }
// SetManagerFunc sets the function to call for rendering UI // SetManagerFunc sets the function to call for rendering UI

Loading…
Cancel
Save