summaryrefslogtreecommitdiffstats
path: root/widgets/help.go
diff options
context:
space:
mode:
authorCaleb Bassi <calebjbassi@gmail.com>2018-02-18 23:25:02 -0800
committerCaleb Bassi <calebjbassi@gmail.com>2018-02-19 02:00:21 -0800
commit40775db60b90cd290a206108cc4d22b236be9ba5 (patch)
tree28b5e5d7921a399cdcc8fb9559df0e69a31354be /widgets/help.go
Initial commit
Diffstat (limited to 'widgets/help.go')
-rw-r--r--widgets/help.go52
1 files changed, 52 insertions, 0 deletions
diff --git a/widgets/help.go b/widgets/help.go
new file mode 100644
index 0000000..6ebe9b8
--- /dev/null
+++ b/widgets/help.go
@@ -0,0 +1,52 @@
+package widgets
+
+import (
+ "strings"
+
+ ui "github.com/cjbassi/gotop/termui"
+)
+
+const KEYBINDS = `
+Quit: 'q' or 'Ctrl-c'
+
+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
+ - 'gg' and 'G': jump to top and bottom
+
+Process Sorting:
+ - 'c': CPU
+ - 'm': Mem
+ - 'p': PID
+
+'<tab>': toggle process grouping
+'dd': kill the selected process or process group
+'<left>'/'<right>' and 'h'/'l': ...
+'u': update gotop
+`
+
+type HelpMenu struct {
+ ui.Block
+}
+
+func NewHelpMenu() *HelpMenu {
+ block := *ui.NewBlock()
+ block.X = 48
+ block.Y = 17
+ return &HelpMenu{block}
+}
+
+func (hm *HelpMenu) Buffer() *ui.Buffer {
+ buf := hm.Block.Buffer()
+
+ for y, line := range strings.Split(KEYBINDS, "\n") {
+ for x, char := range line {
+ buf.SetCell(x+1, y, ui.NewCell(char, ui.ColorWhite, ui.ColorDefault))
+ }
+ }
+
+ buf.SetAreaXY(100, 100)
+
+ return buf
+}