refactor byte unit formatting, add unit-specific display precision

This commit is contained in:
Bradley Cicenas
2020-10-25 14:08:06 +00:00
parent c446fb0e11
commit 4d7d69d4cf
6 changed files with 75 additions and 43 deletions

View File

@@ -37,8 +37,9 @@ func NewMemCol() CompactCol {
}
func (w *MemCol) SetMetrics(m models.Metrics) {
log.Warningf("MEM WIDTH: %d", w.Width)
w.BarColor = ui.ThemeAttr("gauge.bar.bg")
w.Label = fmt.Sprintf("%s / %s", cwidgets.ByteFormat(m.MemUsage), cwidgets.ByteFormat(m.MemLimit))
w.Label = fmt.Sprintf("%s / %s", cwidgets.ByteFormat64Short(m.MemUsage), cwidgets.ByteFormat64Short(m.MemLimit))
w.Percent = m.MemPercent
}

View File

@@ -49,7 +49,7 @@ func NewNetCol() CompactCol {
}
func (w *NetCol) SetMetrics(m models.Metrics) {
label := fmt.Sprintf("%s / %s", cwidgets.ByteFormat(m.NetRx), cwidgets.ByteFormat(m.NetTx))
label := fmt.Sprintf("%s / %s", cwidgets.ByteFormat64Short(m.NetRx), cwidgets.ByteFormat64Short(m.NetTx))
w.Text = label
}
@@ -62,7 +62,7 @@ func NewIOCol() CompactCol {
}
func (w *IOCol) SetMetrics(m models.Metrics) {
label := fmt.Sprintf("%s / %s", cwidgets.ByteFormat(m.IOBytesRead), cwidgets.ByteFormat(m.IOBytesWrite))
label := fmt.Sprintf("%s / %s", cwidgets.ByteFormat64Short(m.IOBytesRead), cwidgets.ByteFormat64Short(m.IOBytesWrite))
w.Text = label
}