2015-03-12 04:15:59 +08:00
|
|
|
package termui
|
|
|
|
|
2015-03-20 17:35:09 +08:00
|
|
|
// A ColorScheme represents the current look-and-feel of the dashboard.
|
|
|
|
type ColorScheme struct {
|
2015-03-12 04:15:59 +08:00
|
|
|
BodyBg Attribute
|
|
|
|
BlockBg Attribute
|
|
|
|
HasBorder bool
|
|
|
|
BorderFg Attribute
|
|
|
|
BorderBg Attribute
|
|
|
|
BorderLabelTextFg Attribute
|
|
|
|
BorderLabelTextBg Attribute
|
|
|
|
ParTextFg Attribute
|
|
|
|
ParTextBg Attribute
|
|
|
|
SparklineLine Attribute
|
|
|
|
SparklineTitle Attribute
|
|
|
|
GaugeBar Attribute
|
|
|
|
GaugePercent Attribute
|
|
|
|
LineChartLine Attribute
|
|
|
|
LineChartAxes Attribute
|
|
|
|
ListItemFg Attribute
|
|
|
|
ListItemBg Attribute
|
|
|
|
BarChartBar Attribute
|
|
|
|
BarChartText Attribute
|
|
|
|
BarChartNum Attribute
|
|
|
|
}
|
|
|
|
|
|
|
|
// default color scheme depends on the user's terminal setting.
|
2015-03-20 17:35:09 +08:00
|
|
|
var themeDefault = ColorScheme{HasBorder: true}
|
2015-03-12 04:15:59 +08:00
|
|
|
|
2015-03-20 17:35:09 +08:00
|
|
|
var themeHelloWorld = ColorScheme{
|
2015-03-12 04:15:59 +08:00
|
|
|
BodyBg: ColorBlack,
|
|
|
|
BlockBg: ColorBlack,
|
|
|
|
HasBorder: true,
|
|
|
|
BorderFg: ColorWhite,
|
|
|
|
BorderBg: ColorBlack,
|
|
|
|
BorderLabelTextBg: ColorBlack,
|
|
|
|
BorderLabelTextFg: ColorGreen,
|
|
|
|
ParTextBg: ColorBlack,
|
|
|
|
ParTextFg: ColorWhite,
|
|
|
|
SparklineLine: ColorMagenta,
|
|
|
|
SparklineTitle: ColorWhite,
|
|
|
|
GaugeBar: ColorRed,
|
|
|
|
GaugePercent: ColorWhite,
|
|
|
|
LineChartLine: ColorYellow | AttrBold,
|
|
|
|
LineChartAxes: ColorWhite,
|
|
|
|
ListItemBg: ColorBlack,
|
|
|
|
ListItemFg: ColorYellow,
|
|
|
|
BarChartBar: ColorRed,
|
|
|
|
BarChartNum: ColorWhite,
|
|
|
|
BarChartText: ColorCyan,
|
|
|
|
}
|
|
|
|
|
|
|
|
var theme = themeDefault // global dep
|
|
|
|
|
2015-03-20 17:35:09 +08:00
|
|
|
// Theme returns the currently used theme.
|
|
|
|
func Theme() ColorScheme {
|
|
|
|
return theme
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetTheme sets a new, custom theme.
|
|
|
|
func SetTheme(newTheme ColorScheme) {
|
|
|
|
theme = newTheme
|
|
|
|
}
|
|
|
|
|
|
|
|
// UseTheme sets a predefined scheme. Currently available: "hello-world" and
|
|
|
|
// "black-and-white".
|
2015-03-12 04:15:59 +08:00
|
|
|
func UseTheme(th string) {
|
|
|
|
switch th {
|
|
|
|
case "helloworld":
|
|
|
|
theme = themeHelloWorld
|
|
|
|
default:
|
|
|
|
theme = themeDefault
|
|
|
|
}
|
|
|
|
}
|