mirror of
https://github.com/bcicen/ctop.git
synced 2025-12-06 15:16:41 +08:00
commit missing compact column, row files
This commit is contained in:
49
cwidgets/compact/column.go
Normal file
49
cwidgets/compact/column.go
Normal file
@@ -0,0 +1,49 @@
|
||||
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,
|
||||
"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)
|
||||
}
|
||||
Reference in New Issue
Block a user