summaryrefslogtreecommitdiffstats
path: root/termui
diff options
context:
space:
mode:
authorCaleb Bassi <calebjbassi@gmail.com>2018-02-21 02:24:36 -0800
committerCaleb Bassi <calebjbassi@gmail.com>2018-02-21 02:28:17 -0800
commitbcc1d35b558145fb6ea5bd965643a914a88f576e (patch)
tree07ebfc1239a18ba0ecf0cde2217f56e190b7e332 /termui
parent6a92c31be6666c0f3dc9554d78bac46417a963b6 (diff)
Added colorscheme support
Diffstat (limited to 'termui')
-rw-r--r--termui/block.go2
-rw-r--r--termui/colors.go10
-rw-r--r--termui/gauge.go12
-rw-r--r--termui/list.go8
-rw-r--r--termui/sparkline.go2
5 files changed, 19 insertions, 15 deletions
diff --git a/termui/block.go b/termui/block.go
index 5b65f15..6d8602a 100644
--- a/termui/block.go
+++ b/termui/block.go
@@ -18,8 +18,8 @@ type Block struct {
BorderBg Color
LabelFg Color
LabelBg Color
- Bg Color
Fg Color
+ Bg Color
}
// NewBlock returns a *Block which inherits styles from current theme.
diff --git a/termui/colors.go b/termui/colors.go
index 53fdae8..469fd15 100644
--- a/termui/colors.go
+++ b/termui/colors.go
@@ -21,9 +21,12 @@ var DefaultTheme = Colorscheme{
BorderFg: 6,
BorderBg: -1,
- SparkLine: 4,
+ Sparkline: 4,
LineGraph: -1,
TableCursor: 4,
+ BarColor: 7,
+ TempLow: 2,
+ TempHigh: 1,
}
// A ColorScheme represents the current look-and-feel of the dashboard.
@@ -36,7 +39,10 @@ type Colorscheme struct {
BorderFg Color
BorderBg Color
- SparkLine Color
+ Sparkline Color
LineGraph Color
TableCursor Color
+ BarColor Color
+ TempLow Color
+ TempHigh Color
}
diff --git a/termui/gauge.go b/termui/gauge.go
index 6525498..7e6ab7e 100644
--- a/termui/gauge.go
+++ b/termui/gauge.go
@@ -18,7 +18,7 @@ func NewGauge() *Gauge {
return &Gauge{
Block: NewBlock(),
PercentColor: Theme.Fg,
- BarColor: Theme.Bg,
+ BarColor: Theme.BarColor,
}
}
@@ -30,11 +30,7 @@ func (g *Gauge) Buffer() *Buffer {
width := g.Percent * g.X / 100
for y := 1; y <= g.Y; y++ {
for x := 1; x <= width; x++ {
- bg := g.BarColor
- if bg == ColorDefault {
- bg |= AttrReverse
- }
- buf.SetCell(x, y, Cell{' ', ColorDefault, bg})
+ buf.SetCell(x, y, Cell{' ', g.BarColor, g.BarColor})
}
}
@@ -46,10 +42,12 @@ func (g *Gauge) Buffer() *Buffer {
for i, char := range s {
bg := g.Bg
+ fg := g.Fg
if x+i < width {
+ fg = g.BarColor
bg = AttrReverse
}
- buf.SetCell(1+x+i, y, Cell{char, g.PercentColor, bg})
+ buf.SetCell(1+x+i, y, Cell{char, fg, bg})
}
return buf
diff --git a/termui/list.go b/termui/list.go
index 0d82afb..27c0380 100644
--- a/termui/list.go
+++ b/termui/list.go
@@ -29,13 +29,13 @@ func (bc *List) Buffer() *Buffer {
if y+1 > bc.Y {
break
}
- bg := Color(2)
+ bg := Theme.TempLow
if bc.Data[y] >= bc.Threshold {
- bg = Color(1)
+ bg = Theme.TempHigh
}
r := MaxString(text, (bc.X - 4))
- buf.SetString(1, y+1, r, Color(7), ColorDefault)
- buf.SetString(bc.X-2, y+1, fmt.Sprintf("%dC", bc.Data[y]), bg, ColorDefault)
+ buf.SetString(1, y+1, r, Color(7), bc.Bg)
+ buf.SetString(bc.X-2, y+1, fmt.Sprintf("%dC", bc.Data[y]), bg, bc.Bg)
}
return buf
diff --git a/termui/sparkline.go b/termui/sparkline.go
index f71d5c8..9f3b9ee 100644
--- a/termui/sparkline.go
+++ b/termui/sparkline.go
@@ -27,7 +27,7 @@ func (s *Sparklines) Add(sl Sparkline) {
func NewSparkline() *Sparkline {
return &Sparkline{
TitleColor: Theme.Fg,
- LineColor: Theme.SparkLine,
+ LineColor: Theme.Sparkline,
}
}