mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
* WTF-730 Fix missing color key config error Signed-off-by: Chris Cummer <chriscummer@me.com> * WTF-730 Add Subheading color formatting to modules Users can now set a `subheading` color in their config to change the color of subheadings in widget display. Defaults to `red`. Signed-off-by: Chris Cummer <chriscummer@me.com> * WTF-730 Fix oustanding color issues Clean up missing color config changes not addressed in earlier commits. Signed-off-by: Chris Cummer <chriscummer@me.com> * Remove unused dependency Signed-off-by: Chris Cummer <chriscummer@me.com> * WTF-730 Base cleanup Signed-off-by: Chris Cummer <chriscummer@me.com> * WTF-730 Fix a few bugs related to color config changes Signed-off-by: Chris Cummer <chriscummer@me.com> * WTF-730 Fix issues with PagerDuty subheading display Signed-off-by: Chris Cummer <chriscummer@me.com> * WTF-730 Fix bug with Todo list colour rendering Signed-off-by: Chris Cummer <chriscummer@me.com>
68 lines
1.4 KiB
Go
68 lines
1.4 KiB
Go
package app
|
|
|
|
import (
|
|
"github.com/olebedev/config"
|
|
"github.com/rivo/tview"
|
|
"github.com/wtfutil/wtf/utils"
|
|
"github.com/wtfutil/wtf/wtf"
|
|
)
|
|
|
|
// Display is the container for the onscreen representation of a WtfApp
|
|
type Display struct {
|
|
Grid *tview.Grid
|
|
config *config.Config
|
|
}
|
|
|
|
// NewDisplay creates and returns a Display
|
|
func NewDisplay(widgets []wtf.Wtfable, config *config.Config) *Display {
|
|
display := Display{
|
|
Grid: tview.NewGrid(),
|
|
config: config,
|
|
}
|
|
|
|
firstWidget := widgets[0]
|
|
display.Grid.SetBackgroundColor(
|
|
wtf.ColorFor(
|
|
firstWidget.CommonSettings().Colors.WidgetTheme.Background,
|
|
),
|
|
)
|
|
|
|
display.build(widgets)
|
|
|
|
return &display
|
|
}
|
|
|
|
/* -------------------- Unexported Functions -------------------- */
|
|
|
|
func (display *Display) add(widget wtf.Wtfable) {
|
|
if widget.Disabled() {
|
|
return
|
|
}
|
|
|
|
display.Grid.AddItem(
|
|
widget.TextView(),
|
|
widget.CommonSettings().Top,
|
|
widget.CommonSettings().Left,
|
|
widget.CommonSettings().Height,
|
|
widget.CommonSettings().Width,
|
|
0,
|
|
0,
|
|
false,
|
|
)
|
|
}
|
|
|
|
func (display *Display) build(widgets []wtf.Wtfable) *tview.Grid {
|
|
cols := utils.ToInts(display.config.UList("wtf.grid.columns"))
|
|
rows := utils.ToInts(display.config.UList("wtf.grid.rows"))
|
|
|
|
display.Grid.SetColumns(cols...)
|
|
display.Grid.SetRows(rows...)
|
|
display.Grid.SetBorder(false)
|
|
|
|
for _, widget := range widgets {
|
|
display.add(widget)
|
|
}
|
|
|
|
return display.Grid
|
|
}
|