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

Rename addView() to createView()

This commit is contained in:
Chris Cummer 2019-08-04 23:21:46 -07:00
parent 787d1a3ba9
commit d372e1029f
2 changed files with 9 additions and 9 deletions

View File

@ -10,7 +10,7 @@ import (
"github.com/wtfutil/wtf/wtf"
)
//BarGraph lets make graphs
//BarGraph defines the data required to make a bar graph
type BarGraph struct {
maxStars int
starChar string
@ -19,13 +19,14 @@ type BarGraph struct {
View *tview.TextView
}
// Bar defines a single row in the bar graph
type Bar struct {
Label string
Percent int
ValueLabel string
}
// NewBarGraph initialize your fancy new graph
// NewBarGraph creates and returns an instance of BarGraph
func NewBarGraph(app *tview.Application, name string, commonSettings *cfg.Common, focusable bool) BarGraph {
widget := BarGraph{
Base: NewBase(app, commonSettings, focusable),
@ -34,7 +35,7 @@ func NewBarGraph(app *tview.Application, name string, commonSettings *cfg.Common
starChar: commonSettings.Config.UString("graphIcon", "|"),
}
widget.View = widget.addView(widget.bordered)
widget.View = widget.createView(widget.bordered)
return widget
}
@ -56,11 +57,9 @@ func BuildStars(data []Bar, maxStars int, starChar string) string {
//just getting min and max values
for _, bar := range data {
if len(bar.Label) > longestLabel {
longestLabel = len(bar.Label)
}
}
// each number = how many stars?
@ -68,7 +67,6 @@ func BuildStars(data []Bar, maxStars int, starChar string) string {
//build the stars
for _, bar := range data {
//how many stars for this one?
var starCount = int(float64(bar.Percent) * starRatio)
@ -99,7 +97,7 @@ func (widget *BarGraph) TextView() *tview.TextView {
/* -------------------- Unexported Functions -------------------- */
func (widget *BarGraph) addView(bordered bool) *tview.TextView {
func (widget *BarGraph) createView(bordered bool) *tview.TextView {
view := tview.NewTextView()
view.SetBackgroundColor(wtf.ColorFor(widget.commonSettings.Colors.Background))

View File

@ -6,17 +6,19 @@ import (
"github.com/wtfutil/wtf/wtf"
)
// TextWidget defines the data necessary to make a text widget
type TextWidget struct {
Base
View *tview.TextView
}
// NewTextWidget creates and returns an instance of TextWidget
func NewTextWidget(app *tview.Application, commonSettings *cfg.Common, focusable bool) TextWidget {
widget := TextWidget{
Base: NewBase(app, commonSettings, focusable),
}
widget.View = widget.addView(widget.bordered)
widget.View = widget.createView(widget.bordered)
return widget
}
@ -38,7 +40,7 @@ func (widget *TextWidget) Redraw(title, text string, wrap bool) {
/* -------------------- Unexported Functions -------------------- */
func (widget *TextWidget) addView(bordered bool) *tview.TextView {
func (widget *TextWidget) createView(bordered bool) *tview.TextView {
view := tview.NewTextView()
view.SetBackgroundColor(wtf.ColorFor(widget.commonSettings.Colors.Background))