mirror of
https://github.com/bcicen/ctop.git
synced 2024-08-30 18:23:19 +00:00
f377dcaee2
The new column is disabled by default.
51 lines
971 B
Go
51 lines
971 B
Go
package compact
|
|
|
|
import (
|
|
"github.com/bcicen/ctop/config"
|
|
"github.com/bcicen/ctop/models"
|
|
|
|
ui "github.com/gizak/termui"
|
|
)
|
|
|
|
var (
|
|
allCols = map[string]NewCompactColFn{
|
|
"status": NewStatus,
|
|
"name": NewNameCol,
|
|
"id": NewCIDCol,
|
|
"cpu": NewCPUCol,
|
|
"cpus": NewCpuScaledCol,
|
|
"mem": NewMemCol,
|
|
"net": NewNetCol,
|
|
"io": NewIOCol,
|
|
"pids": NewPIDCol,
|
|
}
|
|
)
|
|
|
|
type NewCompactColFn func() CompactCol
|
|
|
|
func newRowWidgets() []CompactCol {
|
|
enabled := config.EnabledColumns()
|
|
cols := make([]CompactCol, len(enabled))
|
|
|
|
for n, name := range enabled {
|
|
wFn, ok := allCols[name]
|
|
if !ok {
|
|
panic("no such widget name: %s" + name)
|
|
}
|
|
cols[n] = wFn()
|
|
}
|
|
|
|
return cols
|
|
}
|
|
|
|
type CompactCol interface {
|
|
ui.GridBufferer
|
|
Reset()
|
|
Header() string // header text to display for column
|
|
FixedWidth() int // fixed width size. if == 0, width is automatically calculated
|
|
Highlight()
|
|
UnHighlight()
|
|
SetMeta(models.Meta)
|
|
SetMetrics(models.Metrics)
|
|
}
|