1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Bring BarGraph constructor up to parity with TextWidget

This commit is contained in:
Chris Cummer 2019-08-04 22:02:14 -07:00
parent dbc047516d
commit 98eb3c9013
2 changed files with 31 additions and 29 deletions

View File

@ -12,6 +12,8 @@ import (
//BarGraph lets make graphs //BarGraph lets make graphs
type BarGraph struct { type BarGraph struct {
app *tview.Application
bordered bool
commonSettings *cfg.Common commonSettings *cfg.Common
enabled bool enabled bool
focusable bool focusable bool
@ -20,9 +22,9 @@ type BarGraph struct {
name string name string
quitChan chan bool quitChan chan bool
refreshing bool refreshing bool
refreshInterval int
starChar string starChar string
RefreshInt int
View *tview.TextView View *tview.TextView
} }
@ -33,23 +35,23 @@ type Bar struct {
} }
// NewBarGraph initialize your fancy new graph // NewBarGraph initialize your fancy new graph
func NewBarGraph(app *tview.Application, name string, settings *cfg.Common, focusable bool) BarGraph { func NewBarGraph(app *tview.Application, name string, commonSettings *cfg.Common, focusable bool) BarGraph {
widget := BarGraph{ widget := BarGraph{
enabled: settings.Enabled, commonSettings: commonSettings,
focusable: focusable,
maxStars: settings.Config.UInt("graphStars", 20),
name: settings.Title,
quitChan: make(chan bool),
starChar: settings.Config.UString("graphIcon", "|"),
commonSettings: settings,
RefreshInt: settings.RefreshInterval, app: app,
bordered: commonSettings.Bordered,
enabled: commonSettings.Enabled,
focusable: focusable,
maxStars: commonSettings.Config.UInt("graphStars", 20),
name: commonSettings.Title,
quitChan: make(chan bool),
refreshInterval: commonSettings.RefreshInterval,
starChar: commonSettings.Config.UString("graphIcon", "|"),
} }
widget.View = widget.addView() widget.View = widget.addView()
widget.View.SetChangedFunc(func() { widget.View.SetBorder(widget.bordered)
app.Draw()
})
return widget return widget
} }
@ -105,7 +107,7 @@ func (widget *BarGraph) Refreshing() bool {
// RefreshInterval returns how often, in seconds, the widget will return its data // RefreshInterval returns how often, in seconds, the widget will return its data
func (widget *BarGraph) RefreshInterval() int { func (widget *BarGraph) RefreshInterval() int {
return widget.RefreshInt return widget.refreshInterval
} }
func (widget *BarGraph) SetFocusChar(char string) { func (widget *BarGraph) SetFocusChar(char string) {

View File

@ -10,16 +10,16 @@ import (
) )
type TextWidget struct { type TextWidget struct {
app *tview.Application
bordered bool bordered bool
commonSettings *cfg.Common commonSettings *cfg.Common
enabled bool enabled bool
focusable bool
focusChar string focusChar string
focusable bool
name string name string
quitChan chan bool quitChan chan bool
refreshing bool
refreshInterval int refreshInterval int
app *tview.Application refreshing bool
View *tview.TextView View *tview.TextView
} }
@ -31,12 +31,12 @@ func NewTextWidget(app *tview.Application, commonSettings *cfg.Common, focusable
app: app, app: app,
bordered: commonSettings.Bordered, bordered: commonSettings.Bordered,
enabled: commonSettings.Enabled, enabled: commonSettings.Enabled,
focusable: focusable,
focusChar: commonSettings.FocusChar(), focusChar: commonSettings.FocusChar(),
focusable: focusable,
name: commonSettings.Name, name: commonSettings.Name,
quitChan: make(chan bool), quitChan: make(chan bool),
refreshing: false,
refreshInterval: commonSettings.RefreshInterval, refreshInterval: commonSettings.RefreshInterval,
refreshing: false,
} }
widget.View = widget.addView() widget.View = widget.addView()