mirror of
https://github.com/bcicen/ctop.git
synced 2025-12-06 23:26:45 +08:00
move compactPar helper function into compact
This commit is contained in:
@@ -27,9 +27,9 @@ type Compact struct {
|
|||||||
|
|
||||||
func NewCompact(id string, name string) *Compact {
|
func NewCompact(id string, name string) *Compact {
|
||||||
return &Compact{
|
return &Compact{
|
||||||
Cid: compactPar(id),
|
Cid: slimPar(id),
|
||||||
Net: compactPar("-"),
|
Net: slimPar("-"),
|
||||||
Name: compactPar(name),
|
Name: slimPar(name),
|
||||||
Cpu: slimGauge(),
|
Cpu: slimGauge(),
|
||||||
Memory: slimGauge(),
|
Memory: slimGauge(),
|
||||||
}
|
}
|
||||||
@@ -83,6 +83,15 @@ func (w *Compact) SetMem(val int64, limit int64, percent int) {
|
|||||||
w.Memory.Percent = percent
|
w.Memory.Percent = percent
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func slimPar(s string) *ui.Par {
|
||||||
|
p := ui.NewPar(s)
|
||||||
|
p.Border = false
|
||||||
|
p.Height = 1
|
||||||
|
p.Width = 20
|
||||||
|
p.TextFgColor = ui.ColorWhite
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
|
||||||
func slimGauge() *ui.Gauge {
|
func slimGauge() *ui.Gauge {
|
||||||
g := ui.NewGauge()
|
g := ui.NewGauge()
|
||||||
g.Height = 1
|
g.Height = 1
|
||||||
|
|||||||
@@ -34,15 +34,6 @@ func byteFormat(n int64) string {
|
|||||||
return fmt.Sprintf("%sG", strconv.FormatInt(n, 10))
|
return fmt.Sprintf("%sG", strconv.FormatInt(n, 10))
|
||||||
}
|
}
|
||||||
|
|
||||||
func compactPar(s string) *ui.Par {
|
|
||||||
p := ui.NewPar(s)
|
|
||||||
p.Border = false
|
|
||||||
p.Height = 1
|
|
||||||
p.Width = 20
|
|
||||||
p.TextFgColor = ui.ColorWhite
|
|
||||||
return p
|
|
||||||
}
|
|
||||||
|
|
||||||
func colorScale(n int) ui.Attribute {
|
func colorScale(n int) ui.Attribute {
|
||||||
if n > 70 {
|
if n > 70 {
|
||||||
return ui.ColorRed
|
return ui.ColorRed
|
||||||
|
|||||||
Reference in New Issue
Block a user