mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
BarGraph supports customizable titles in config
This commit is contained in:
parent
b6b695290c
commit
787d1a3ba9
@ -34,18 +34,13 @@ func NewBarGraph(app *tview.Application, name string, commonSettings *cfg.Common
|
||||
starChar: commonSettings.Config.UString("graphIcon", "|"),
|
||||
}
|
||||
|
||||
widget.View = widget.addView()
|
||||
widget.View.SetBorder(widget.bordered)
|
||||
widget.View = widget.addView(widget.bordered)
|
||||
|
||||
return widget
|
||||
}
|
||||
|
||||
/* -------------------- Exported Functions -------------------- */
|
||||
|
||||
func (widget *BarGraph) TextView() *tview.TextView {
|
||||
return widget.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) {
|
||||
@ -98,16 +93,20 @@ func BuildStars(data []Bar, maxStars int, starChar string) string {
|
||||
return buffer.String()
|
||||
}
|
||||
|
||||
func (widget *BarGraph) TextView() *tview.TextView {
|
||||
return widget.View
|
||||
}
|
||||
|
||||
/* -------------------- Unexported Functions -------------------- */
|
||||
|
||||
func (widget *BarGraph) addView() *tview.TextView {
|
||||
func (widget *BarGraph) addView(bordered bool) *tview.TextView {
|
||||
view := tview.NewTextView()
|
||||
|
||||
view.SetBackgroundColor(wtf.ColorFor(widget.commonSettings.Colors.Background))
|
||||
view.SetBorder(true)
|
||||
view.SetBorder(bordered)
|
||||
view.SetBorderColor(wtf.ColorFor(widget.BorderColor()))
|
||||
view.SetDynamicColors(true)
|
||||
view.SetTitle(widget.Name())
|
||||
view.SetTitle(widget.ContextualTitle(widget.CommonSettings().Title))
|
||||
view.SetTitleColor(wtf.ColorFor(widget.commonSettings.Colors.Title))
|
||||
view.SetWrap(false)
|
||||
|
||||
|
@ -16,8 +16,7 @@ func NewTextWidget(app *tview.Application, commonSettings *cfg.Common, focusable
|
||||
Base: NewBase(app, commonSettings, focusable),
|
||||
}
|
||||
|
||||
widget.View = widget.addView()
|
||||
widget.View.SetBorder(widget.bordered)
|
||||
widget.View = widget.addView(widget.bordered)
|
||||
|
||||
return widget
|
||||
}
|
||||
@ -39,16 +38,15 @@ func (widget *TextWidget) Redraw(title, text string, wrap bool) {
|
||||
|
||||
/* -------------------- Unexported Functions -------------------- */
|
||||
|
||||
func (widget *TextWidget) addView() *tview.TextView {
|
||||
func (widget *TextWidget) addView(bordered bool) *tview.TextView {
|
||||
view := tview.NewTextView()
|
||||
|
||||
view.SetBackgroundColor(wtf.ColorFor(widget.commonSettings.Colors.Background))
|
||||
view.SetBorder(bordered)
|
||||
view.SetBorderColor(wtf.ColorFor(widget.BorderColor()))
|
||||
view.SetDynamicColors(true)
|
||||
view.SetTextColor(wtf.ColorFor(widget.commonSettings.Colors.Text))
|
||||
view.SetTitleColor(wtf.ColorFor(widget.commonSettings.Colors.Title))
|
||||
|
||||
view.SetBorder(true)
|
||||
view.SetDynamicColors(true)
|
||||
view.SetWrap(false)
|
||||
|
||||
return view
|
||||
|
Loading…
x
Reference in New Issue
Block a user