blob: 90eeec9b7e03d37fc780dd509736d983e04f844e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
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
block.XOffset = (ui.Body.Width - block.X) / 2
block.YOffset = (ui.Body.Height - block.Y) / 2
// block.XOffset = ui.Body.Width - 50
// block.YOffset = ui.Body.Height - 50
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.Color(7), ui.ColorDefault))
}
}
buf.SetAreaXY(hm.X+2, hm.Y+2)
return buf
}
|