mirror of
https://github.com/bcicen/ctop.git
synced 2025-12-06 15:16:41 +08:00
re-implement expanded view widgets
This commit is contained in:
30
cwidgets/expanded/info.go
Normal file
30
cwidgets/expanded/info.go
Normal 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})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user