Add support for resetting stats without leaving app
This commit is contained in:
parent
47b9b1e186
commit
fbbc18f2cf
7
data.go
7
data.go
|
@ -53,3 +53,10 @@ func (d *Data) MemoryStats() (used []float64) {
|
|||
func (d *Data) NetworkStats() (rx, tx []float64) {
|
||||
return d.rxBytes.Data(), d.txBytes.Data()
|
||||
}
|
||||
|
||||
// Clear clears all data.
|
||||
func (d *Data) Clear() {
|
||||
for _, b := range [...]*CircularBuffer{d.cpu, d.mem, d.rxBytes, d.txBytes} {
|
||||
b.Reset()
|
||||
}
|
||||
}
|
||||
|
|
5
main.go
5
main.go
|
@ -80,6 +80,11 @@ func main() {
|
|||
ui := initUI(pid, *interval)
|
||||
defer stopUI()
|
||||
|
||||
// handle key r pressing
|
||||
termui.Handle("/sys/kbd/r", func(termui.Event) {
|
||||
data.Clear()
|
||||
})
|
||||
|
||||
ui.HandleKeys()
|
||||
|
||||
ui.AddTimer(*interval, func(e termui.Event) {
|
||||
|
|
2
ui.go
2
ui.go
|
@ -182,7 +182,7 @@ func (ui *UI) createHeader(pid int64) {
|
|||
p.TextFgColor = termui.ColorWhite
|
||||
p.BorderLabel = "Monitoring Status.im via adb"
|
||||
p.BorderFg = termui.ColorCyan
|
||||
p.Text = "press 'q' to exit"
|
||||
p.Text = "press 'q' to exit, 'r' to reset"
|
||||
|
||||
p1 := termui.NewPar("")
|
||||
p1.Height = headerHeight
|
||||
|
|
Loading…
Reference in New Issue