Moar code cleanup

This commit is contained in:
Caleb Bassi
2018-02-23 21:15:38 -08:00
parent b06502d7f2
commit a2fd8dc4fa
10 changed files with 61 additions and 43 deletions

View File

@ -15,7 +15,7 @@ const (
UP = "▲"
)
// Process represents each process
// Process represents each process.
type Process struct {
PID int32
Command string
@ -23,7 +23,7 @@ type Process struct {
Mem float32
}
// Proc is the widget
// Proc widget.
type Proc struct {
*ui.Table
cpuCount int
@ -35,7 +35,7 @@ type Proc struct {
KeyPressed chan bool
}
// Creates a new Proc widget
// NewProc creates a new Proc widget.
func NewProc(loaded, keyPressed chan bool) *Proc {
cpuCount, _ := cpu.Counts(false)
p := &Proc{
@ -70,6 +70,7 @@ func NewProc(loaded, keyPressed chan bool) *Proc {
return p
}
// update updates proc widget.
func (p *Proc) update() {
psProcs, _ := proc.Processes()
processes := make([]Process, len(psProcs))
@ -92,7 +93,8 @@ func (p *Proc) update() {
p.Sort()
}
// Sort sorts either the grouped or ungrouped []Process based on the sortMethod
// Sort sorts either the grouped or ungrouped []Process based on the sortMethod.
// Called with every update, when the sort method is changed, and when processes are grouped and ungrouped.
func (p *Proc) Sort() {
p.Header = []string{"Count", "Command", "CPU%", "Mem%"}