mirror of
https://github.com/bcicen/ctop.git
synced 2024-08-30 18:23:19 +00:00
fix reset method for compact widgets
This commit is contained in:
parent
bb682677f5
commit
2329f93e5f
@ -5,12 +5,9 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/bcicen/ctop/cwidgets"
|
"github.com/bcicen/ctop/cwidgets"
|
||||||
"github.com/bcicen/ctop/logging"
|
|
||||||
ui "github.com/gizak/termui"
|
ui "github.com/gizak/termui"
|
||||||
)
|
)
|
||||||
|
|
||||||
var log = logging.Init()
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
mark = string('\u25C9')
|
mark = string('\u25C9')
|
||||||
vBar = string('\u25AE')
|
vBar = string('\u25AE')
|
||||||
@ -20,11 +17,11 @@ const (
|
|||||||
|
|
||||||
type Compact struct {
|
type Compact struct {
|
||||||
Status *ui.Par
|
Status *ui.Par
|
||||||
Cid *ui.Par
|
|
||||||
Net *ui.Par
|
|
||||||
Name *ui.Par
|
Name *ui.Par
|
||||||
|
Cid *ui.Par
|
||||||
Cpu *ui.Gauge
|
Cpu *ui.Gauge
|
||||||
Memory *ui.Gauge
|
Memory *ui.Gauge
|
||||||
|
Net *ui.Par
|
||||||
X, Y int
|
X, Y int
|
||||||
Width int
|
Width int
|
||||||
Height int
|
Height int
|
||||||
@ -33,8 +30,11 @@ type Compact struct {
|
|||||||
func NewCompact(id, name, status string) *Compact {
|
func NewCompact(id, name, status string) *Compact {
|
||||||
row := &Compact{
|
row := &Compact{
|
||||||
Status: slimPar(mark),
|
Status: slimPar(mark),
|
||||||
Cid: slimPar(id),
|
|
||||||
Name: slimPar(name),
|
Name: slimPar(name),
|
||||||
|
Cid: slimPar(id),
|
||||||
|
Cpu: slimGauge(),
|
||||||
|
Memory: slimGauge(),
|
||||||
|
Net: slimPar("-"),
|
||||||
Height: 1,
|
Height: 1,
|
||||||
}
|
}
|
||||||
row.Reset()
|
row.Reset()
|
||||||
@ -44,9 +44,11 @@ func NewCompact(id, name, status string) *Compact {
|
|||||||
|
|
||||||
// Set gauges, counters to default unread values
|
// Set gauges, counters to default unread values
|
||||||
func (row *Compact) Reset() {
|
func (row *Compact) Reset() {
|
||||||
row.Net = slimPar("-")
|
row.Cpu.Percent = 0
|
||||||
row.Cpu = slimGauge()
|
row.Cpu.Label = "-"
|
||||||
row.Memory = slimGauge()
|
row.Memory.Percent = 0
|
||||||
|
row.Memory.Label = "-"
|
||||||
|
row.Net.Text = "-"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (row *Compact) all() []ui.GridBufferer {
|
func (row *Compact) all() []ui.GridBufferer {
|
||||||
@ -88,7 +90,6 @@ func (row *Compact) SetWidth(width int) {
|
|||||||
x += autoWidth + colSpacing
|
x += autoWidth + colSpacing
|
||||||
}
|
}
|
||||||
row.Width = width
|
row.Width = width
|
||||||
log.Info("resized row width")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (row *Compact) Buffer() ui.Buffer {
|
func (row *Compact) Buffer() ui.Buffer {
|
||||||
|
Loading…
Reference in New Issue
Block a user