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:
parent
dbc047516d
commit
98eb3c9013
@ -12,18 +12,20 @@ import (
|
|||||||
|
|
||||||
//BarGraph lets make graphs
|
//BarGraph lets make graphs
|
||||||
type BarGraph struct {
|
type BarGraph struct {
|
||||||
commonSettings *cfg.Common
|
app *tview.Application
|
||||||
enabled bool
|
bordered bool
|
||||||
focusable bool
|
commonSettings *cfg.Common
|
||||||
key string
|
enabled bool
|
||||||
maxStars int
|
focusable bool
|
||||||
name string
|
key string
|
||||||
quitChan chan bool
|
maxStars int
|
||||||
refreshing bool
|
name string
|
||||||
starChar string
|
quitChan chan bool
|
||||||
|
refreshing bool
|
||||||
|
refreshInterval int
|
||||||
|
starChar string
|
||||||
|
|
||||||
RefreshInt int
|
View *tview.TextView
|
||||||
View *tview.TextView
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Bar struct {
|
type Bar struct {
|
||||||
@ -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) {
|
||||||
|
@ -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()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user