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

Fix race conditions caused by writing to view

This commit is contained in:
Chris Cummer
2019-04-24 23:53:31 -07:00
parent 388851f02d
commit b7be868798
6 changed files with 32 additions and 37 deletions

View File

@@ -48,7 +48,10 @@ func NewBarGraph(app *tview.Application, name string, configKey string, focusabl
Config.UInt(fmt.Sprintf("wtf.mods.%s.position.height", configKey)),
)
widget.addView(app, configKey)
widget.View = widget.addView(configKey)
widget.View.SetChangedFunc(func() {
app.Draw()
})
return widget
}
@@ -109,7 +112,7 @@ func (widget *BarGraph) TextView() *tview.TextView {
/* -------------------- Unexported Functions -------------------- */
func (widget *BarGraph) addView(app *tview.Application, configKey string) {
func (widget *BarGraph) addView(configKey string) *tview.TextView {
view := tview.NewTextView()
view.SetBackgroundColor(ColorFor(Config.UString("wtf.colors.background", "black")))
@@ -125,15 +128,13 @@ func (widget *BarGraph) addView(app *tview.Application, configKey string) {
))
view.SetWrap(false)
widget.View = view
return view
}
// BuildBars will build a string of * to represent your data of [time][value]
// time should be passed as a int64
func (widget *BarGraph) BuildBars(data []Bar) {
widget.View.SetText(BuildStars(data, widget.maxStars, widget.starChar))
}
//BuildStars build the string to display