aboutsummaryrefslogtreecommitdiffstats
path: root/Godeps/_workspace/src/github.com/gizak/termui/theme.go
diff options
context:
space:
mode:
Diffstat (limited to 'Godeps/_workspace/src/github.com/gizak/termui/theme.go')
-rw-r--r--Godeps/_workspace/src/github.com/gizak/termui/theme.go58
1 files changed, 57 insertions, 1 deletions
diff --git a/Godeps/_workspace/src/github.com/gizak/termui/theme.go b/Godeps/_workspace/src/github.com/gizak/termui/theme.go
index c8ad94756..c3ccda559 100644
--- a/Godeps/_workspace/src/github.com/gizak/termui/theme.go
+++ b/Godeps/_workspace/src/github.com/gizak/termui/theme.go
@@ -1,9 +1,12 @@
-// Copyright 2015 Zack Guo <gizak@icloud.com>. All rights reserved.
+// Copyright 2016 Zack Guo <gizak@icloud.com>. All rights reserved.
// Use of this source code is governed by a MIT license that can
// be found in the LICENSE file.
package termui
+import "strings"
+
+/*
// A ColorScheme represents the current look-and-feel of the dashboard.
type ColorScheme struct {
BodyBg Attribute
@@ -29,6 +32,7 @@ type ColorScheme struct {
MBarChartBar Attribute
MBarChartText Attribute
MBarChartNum Attribute
+ TabActiveBg Attribute
}
// default color scheme depends on the user's terminal setting.
@@ -58,6 +62,7 @@ var themeHelloWorld = ColorScheme{
MBarChartBar: ColorRed,
MBarChartNum: ColorWhite,
MBarChartText: ColorCyan,
+ TabActiveBg: ColorMagenta,
}
var theme = themeDefault // global dep
@@ -82,3 +87,54 @@ func UseTheme(th string) {
theme = themeDefault
}
}
+*/
+
+var ColorMap = map[string]Attribute{
+ "fg": ColorWhite,
+ "bg": ColorDefault,
+ "border.fg": ColorWhite,
+ "label.fg": ColorGreen,
+ "par.fg": ColorYellow,
+ "par.label.bg": ColorWhite,
+}
+
+func ThemeAttr(name string) Attribute {
+ return lookUpAttr(ColorMap, name)
+}
+
+func lookUpAttr(clrmap map[string]Attribute, name string) Attribute {
+
+ a, ok := clrmap[name]
+ if ok {
+ return a
+ }
+
+ ns := strings.Split(name, ".")
+ for i := range ns {
+ nn := strings.Join(ns[i:len(ns)], ".")
+ a, ok = ColorMap[nn]
+ if ok {
+ break
+ }
+ }
+
+ return a
+}
+
+// 0<=r,g,b <= 5
+func ColorRGB(r, g, b int) Attribute {
+ within := func(n int) int {
+ if n < 0 {
+ return 0
+ }
+
+ if n > 5 {
+ return 5
+ }
+
+ return n
+ }
+
+ r, b, g = within(r), within(b), within(g)
+ return Attribute(0x0f + 36*r + 6*g + b)
+}