re-implement expanded view widgets

This commit is contained in:
Bradley Cicenas
2017-03-06 08:51:50 +00:00
parent f102e48cc9
commit 2ee0ae7fcb
7 changed files with 278 additions and 22 deletions

30
cwidgets/expanded/info.go Normal file
View File

@@ -0,0 +1,30 @@
package expanded
import (
ui "github.com/gizak/termui"
)
type Info struct {
*ui.Table
data map[string]string
}
func NewInfo(id string) *Info {
p := ui.NewTable()
p.Height = 4
p.Width = 50
p.FgColor = ui.ColorWhite
p.Seperator = false
i := &Info{p, make(map[string]string)}
i.Set("ID", id)
return i
}
func (w *Info) Set(k, v string) {
w.data[k] = v
// rebuild rows
w.Rows = [][]string{}
for k, v := range w.data {
w.Rows = append(w.Rows, []string{k, v})
}
}