Skip to content

Commit

Permalink
Merge pull request #2 from VarusHsu/main
Browse files Browse the repository at this point in the history
feat: Dynamic display of cpu usage.
  • Loading branch information
lqs committed Oct 11, 2023
2 parents 21f6d2d + 8b802e4 commit 408fd52
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ui/processdetail.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ui

import (
"context"
"fmt"
"strconv"

Expand Down Expand Up @@ -53,7 +54,16 @@ func NewProcessDetailView(params ProcessDetailViewParams) ProcessDetailView {
}
form.SetButtonStyle(buttonStyle)
form.SetButtonActivatedStyle(buttonActivatedStyle)

ctx, cancel := context.WithCancel(context.Background())
NewReloader(ctx, func() {
cpuPercent, _ := p.CPUPercent()
form.GetFormItemByLabel("%CPU (average)").(*tview.TextView).SetText(fmt.Sprintf("%.1f%%", cpuPercent*100))

})

form.SetCancelFunc(func() {
cancel()
params.OnClose()
})

Expand Down

0 comments on commit 408fd52

Please sign in to comment.