mirror of
https://github.com/bcicen/ctop.git
synced 2025-11-12 22:25:40 +01:00
refactor cpu gauge into standalone widget
This commit is contained in:
26
widgets/util.go
Normal file
26
widgets/util.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package widgets
|
||||
|
||||
import (
|
||||
ui "github.com/gizak/termui"
|
||||
)
|
||||
|
||||
func mkGauge() *ui.Gauge {
|
||||
g := ui.NewGauge()
|
||||
g.Height = 1
|
||||
g.Border = false
|
||||
g.Percent = 0
|
||||
g.PaddingBottom = 0
|
||||
g.BarColor = ui.ColorGreen
|
||||
g.Label = "-"
|
||||
return g
|
||||
}
|
||||
|
||||
func colorScale(n int) ui.Attribute {
|
||||
if n > 70 {
|
||||
return ui.ColorRed
|
||||
}
|
||||
if n > 30 {
|
||||
return ui.ColorYellow
|
||||
}
|
||||
return ui.ColorGreen
|
||||
}
|
||||
Reference in New Issue
Block a user