mirror of
https://github.com/bcicen/ctop.git
synced 2025-12-06 15:16:41 +08:00
add resize handlers, screen width error to expandedWidgets
This commit is contained in:
@@ -4,6 +4,8 @@ import (
|
||||
ui "github.com/gizak/termui"
|
||||
)
|
||||
|
||||
var displayInfo = []string{"id", "name", "image", "state"}
|
||||
|
||||
type Info struct {
|
||||
*ui.Table
|
||||
data map[string]string
|
||||
@@ -12,11 +14,11 @@ type Info struct {
|
||||
func NewInfo(id string) *Info {
|
||||
p := ui.NewTable()
|
||||
p.Height = 4
|
||||
p.Width = 50
|
||||
p.Width = colWidth[0]
|
||||
p.FgColor = ui.ColorWhite
|
||||
p.Seperator = false
|
||||
i := &Info{p, make(map[string]string)}
|
||||
i.Set("ID", id)
|
||||
i.Set("id", id)
|
||||
return i
|
||||
}
|
||||
|
||||
@@ -24,7 +26,10 @@ 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})
|
||||
for _, k := range displayInfo {
|
||||
if v, ok := w.data[k]; ok {
|
||||
w.Rows = append(w.Rows, []string{k, v})
|
||||
}
|
||||
}
|
||||
w.Height = len(w.Rows) + 2
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user