mirror of
https://github.com/bcicen/ctop.git
synced 2025-12-06 15:16:41 +08:00
integrate widget order, toggling into global config and compact grid
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
|
||||
"github.com/bcicen/ctop/cwidgets"
|
||||
"github.com/bcicen/ctop/models"
|
||||
|
||||
ui "github.com/gizak/termui"
|
||||
)
|
||||
|
||||
|
||||
@@ -17,11 +17,7 @@ type CompactGrid struct {
|
||||
|
||||
func NewCompactGrid() *CompactGrid {
|
||||
cg := &CompactGrid{header: NewCompactHeader()}
|
||||
for _, wFn := range allCols {
|
||||
w := wFn()
|
||||
cg.cols = append(cg.cols, w)
|
||||
cg.header.addFieldPar(w.Header())
|
||||
}
|
||||
cg.RebuildHeader()
|
||||
return cg
|
||||
}
|
||||
|
||||
@@ -41,6 +37,14 @@ func (cg *CompactGrid) Align() {
|
||||
}
|
||||
}
|
||||
|
||||
func (cg *CompactGrid) RebuildHeader() {
|
||||
cg.cols = newRowWidgets()
|
||||
cg.header.clearFieldPars()
|
||||
for _, col := range cg.cols {
|
||||
cg.header.addFieldPar(col.Header())
|
||||
}
|
||||
}
|
||||
|
||||
func (cg *CompactGrid) Clear() { cg.Rows = []RowBufferer{} }
|
||||
func (cg *CompactGrid) GetHeight() int { return len(cg.Rows) + cg.header.Height }
|
||||
func (cg *CompactGrid) SetX(x int) { cg.X = x }
|
||||
|
||||
@@ -51,6 +51,10 @@ func (row *CompactHeader) Buffer() ui.Buffer {
|
||||
return buf
|
||||
}
|
||||
|
||||
func (row *CompactHeader) clearFieldPars() {
|
||||
row.pars = []*ui.Par{}
|
||||
}
|
||||
|
||||
func (row *CompactHeader) addFieldPar(s string) {
|
||||
p := ui.NewPar(s)
|
||||
p.Height = row.Height
|
||||
|
||||
@@ -2,6 +2,7 @@ package compact
|
||||
|
||||
import (
|
||||
"github.com/bcicen/ctop/models"
|
||||
|
||||
ui "github.com/gizak/termui"
|
||||
)
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
|
||||
"github.com/bcicen/ctop/cwidgets"
|
||||
"github.com/bcicen/ctop/models"
|
||||
|
||||
ui "github.com/gizak/termui"
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user