Added String var kind

This commit is contained in:
Ivan Daniluk 2015-05-02 21:43:32 +03:00
parent 57d82c5544
commit 191559f45e
3 changed files with 8 additions and 0 deletions

2
ui.go
View File

@ -160,6 +160,8 @@ func colorByKind(kind VarKind) termui.Attribute {
return termui.ColorRed | termui.AttrBold return termui.ColorRed | termui.AttrBold
case KindDuration: case KindDuration:
return termui.ColorYellow | termui.AttrBold return termui.ColorYellow | termui.AttrBold
case KindString:
return termui.ColorGreen | termui.AttrBold
default: default:
return termui.ColorBlue | termui.AttrBold return termui.ColorBlue | termui.AttrBold
} }

View File

@ -88,6 +88,9 @@ func (t *TermUISingle) Update(data UIData) {
// Sparklines // Sparklines
for i, name := range data.Vars { for i, name := range data.Vars {
if name.Kind() == KindString {
continue
}
spl := &t.Sparkline.Lines[i] spl := &t.Sparkline.Lines[i]
spl.Title = fmt.Sprintf("%s: %v", name.Long(), service.Value(name)) spl.Title = fmt.Sprintf("%s: %v", name.Long(), service.Value(name))
spl.TitleColor = colorByKind(name.Kind()) spl.TitleColor = colorByKind(name.Kind())

3
var.go
View File

@ -16,6 +16,7 @@ const (
KindDefault VarKind = iota KindDefault VarKind = iota
KindMemory KindMemory
KindDuration KindDuration
KindString
) )
// ToSlice converts "dot-separated" notation into the "slice of strings". // ToSlice converts "dot-separated" notation into the "slice of strings".
@ -62,6 +63,8 @@ func (v VarName) Kind() VarKind {
return KindMemory return KindMemory
case "duration": case "duration":
return KindDuration return KindDuration
case "str":
return KindString
} }
return KindDefault return KindDefault
} }