mirror of
https://github.com/bcicen/ctop.git
synced 2026-01-21 05:36:42 +08:00
refactor byte unit formatting, add unit-specific display precision
This commit is contained in:
@@ -42,10 +42,10 @@ func (w *IO) Update(read int64, write int64) {
|
||||
var rate string
|
||||
|
||||
w.readHist.Append(int(read))
|
||||
rate = strings.ToLower(cwidgets.ByteFormatInt(w.readHist.Val))
|
||||
rate = strings.ToLower(cwidgets.ByteFormatShort(w.readHist.Val))
|
||||
w.Lines[0].Title = fmt.Sprintf("read [%s/s]", rate)
|
||||
|
||||
w.writeHist.Append(int(write))
|
||||
rate = strings.ToLower(cwidgets.ByteFormatInt(w.writeHist.Val))
|
||||
rate = strings.ToLower(cwidgets.ByteFormatShort(w.writeHist.Val))
|
||||
w.Lines[1].Title = fmt.Sprintf("write [%s/s]", rate)
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ func newMemChart() *ui.MBarChart {
|
||||
mbar.BarColor[1] = ui.ColorBlack
|
||||
mbar.NumColor[1] = ui.ColorBlack
|
||||
|
||||
mbar.NumFmt = cwidgets.ByteFormatInt
|
||||
mbar.NumFmt = cwidgets.ByteFormatShort
|
||||
//mbar.ShowScale = true
|
||||
return mbar
|
||||
}
|
||||
@@ -78,6 +78,6 @@ func newMemChart() *ui.MBarChart {
|
||||
func (w *Mem) Update(val int, limit int) {
|
||||
w.valHist.Append(val)
|
||||
w.limitHist.Append(limit - val)
|
||||
w.InnerLabel.Text = fmt.Sprintf("%v / %v", cwidgets.ByteFormatInt(val), cwidgets.ByteFormatInt(limit))
|
||||
w.InnerLabel.Text = fmt.Sprintf("%v / %v", cwidgets.ByteFormatShort(val), cwidgets.ByteFormatShort(limit))
|
||||
//w.Data[0] = w.hist.data
|
||||
}
|
||||
|
||||
@@ -42,10 +42,10 @@ func (w *Net) Update(rx int64, tx int64) {
|
||||
var rate string
|
||||
|
||||
w.rxHist.Append(int(rx))
|
||||
rate = strings.ToLower(cwidgets.ByteFormatInt(w.rxHist.Val))
|
||||
rate = strings.ToLower(cwidgets.ByteFormat(w.rxHist.Val))
|
||||
w.Lines[0].Title = fmt.Sprintf("RX [%s/s]", rate)
|
||||
|
||||
w.txHist.Append(int(tx))
|
||||
rate = strings.ToLower(cwidgets.ByteFormatInt(w.txHist.Val))
|
||||
rate = strings.ToLower(cwidgets.ByteFormat(w.txHist.Val))
|
||||
w.Lines[1].Title = fmt.Sprintf("TX [%s/s]", rate)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user