mirror of
https://github.com/bcicen/ctop.git
synced 2025-12-06 15:16:41 +08:00
restructure compact widgets
This commit is contained in:
@@ -1,17 +1,9 @@
|
||||
package compact
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
ui "github.com/gizak/termui"
|
||||
)
|
||||
|
||||
const (
|
||||
mark = string('\u25C9')
|
||||
vBar = string('\u25AE')
|
||||
statusWidth = 3
|
||||
)
|
||||
|
||||
type TextCol struct {
|
||||
*ui.Par
|
||||
}
|
||||
@@ -41,33 +33,3 @@ func (w *TextCol) Reset() {
|
||||
func (w *TextCol) Set(s string) {
|
||||
w.Text = s
|
||||
}
|
||||
|
||||
type Status struct {
|
||||
*ui.Par
|
||||
}
|
||||
|
||||
func NewStatus() *Status {
|
||||
p := ui.NewPar(mark)
|
||||
p.Border = false
|
||||
p.Height = 1
|
||||
p.Width = statusWidth
|
||||
return &Status{p}
|
||||
}
|
||||
|
||||
func (s *Status) Set(val string) {
|
||||
// defaults
|
||||
text := mark
|
||||
color := ui.ColorDefault
|
||||
|
||||
switch val {
|
||||
case "running":
|
||||
color = ui.ColorGreen
|
||||
case "exited":
|
||||
color = ui.ColorRed
|
||||
case "paused":
|
||||
text = fmt.Sprintf("%s%s", vBar, vBar)
|
||||
}
|
||||
|
||||
s.Text = text
|
||||
s.TextFgColor = color
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user