summaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
authorCaleb Bassi <calebjbassi@gmail.com>2018-03-09 16:29:05 -0800
committerCaleb Bassi <calebjbassi@gmail.com>2018-03-09 16:29:05 -0800
commit75220b3db8e4ed759eec75b75aada8fa63f49283 (patch)
tree0226cc52c129fe35d65b4d76acc28c852a68574d /widgets
parentd3bf834aa398c186fa0ab250c51291fac5cd76ac (diff)
Added graph zooming; closes #3
Diffstat (limited to 'widgets')
-rw-r--r--widgets/cpu.go3
-rw-r--r--widgets/help.go6
-rw-r--r--widgets/mem.go3
3 files changed, 8 insertions, 4 deletions
diff --git a/widgets/cpu.go b/widgets/cpu.go
index 82c097c..6065279 100644
--- a/widgets/cpu.go
+++ b/widgets/cpu.go
@@ -14,7 +14,7 @@ type CPU struct {
interval time.Duration
}
-func NewCPU(interval time.Duration) *CPU {
+func NewCPU(interval time.Duration, zoom int) *CPU {
count, _ := psCPU.Counts(false)
c := &CPU{
LineGraph: ui.NewLineGraph(),
@@ -22,6 +22,7 @@ func NewCPU(interval time.Duration) *CPU {
interval: interval,
}
c.Label = "CPU Usage"
+ c.Zoom = zoom
for i := 0; i < c.count; i++ {
key := "CPU" + strconv.Itoa(i+1)
c.Data[key] = []float64{0}
diff --git a/widgets/help.go b/widgets/help.go
index ff5c716..faa64b9 100644
--- a/widgets/help.go
+++ b/widgets/help.go
@@ -9,7 +9,7 @@ import (
const KEYBINDS = `
Quit: q or <C-c>
-Navigation
+Process Navigation
- <up>/<down> and j/k: up and down
- <C-d> and <C-u>: up and down half a page
- <C-f> and <C-b>: up and down a full page
@@ -22,6 +22,8 @@ Process Sorting
<tab>: toggle process grouping
dd: kill the selected process or process group
+
+h and l: zoom in and out of CPU and Mem graphs
`
type HelpMenu struct {
@@ -31,7 +33,7 @@ type HelpMenu struct {
func NewHelpMenu() *HelpMenu {
block := ui.NewBlock()
block.X = 48 // width - 1
- block.Y = 15 // height - 1
+ block.Y = 17 // height - 1
block.XOffset = (ui.Body.Width - block.X) / 2 // X coordinate
block.YOffset = (ui.Body.Height - block.Y) / 2 // Y coordinate
return &HelpMenu{block}
diff --git a/widgets/mem.go b/widgets/mem.go
index 70bf9ae..073d9e6 100644
--- a/widgets/mem.go
+++ b/widgets/mem.go
@@ -12,12 +12,13 @@ type Mem struct {
interval time.Duration
}
-func NewMem(interval time.Duration) *Mem {
+func NewMem(interval time.Duration, zoom int) *Mem {
m := &Mem{
LineGraph: ui.NewLineGraph(),
interval: interval,
}
m.Label = "Memory Usage"
+ m.Zoom = zoom
m.Data["Main"] = []float64{0}
m.Data["Swap"] = []float64{0}