forked from lesovsky/pgcenter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelp.go
70 lines (58 loc) · 2.24 KB
/
help.go
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Stuff related to displaying built-in help
package top
import (
"fmt"
"github.com/jroimartin/gocui"
)
const (
helpTemplate = `Help for interactive commands
general actions:
a,d,f,r mode: 'a' activity, 'd' databases, 'f' functions, 'r' replication,
s,t,i,v 's' tables sizes, 't' tables, 'i' indexes, 'v' vacuum progress,
x,X 'x' pg_stat_statements switch, 'X' pg_stat_statements menu.
Left,Right,<,/ 'Left,Right' change column sort, '<' desc/asc sort toggle, '/' set filter.
Up,Down 'Up' increase column width, 'Down' decrease column width.
C,E,R config: 'C' show config, 'E' edit configs, 'R' reload config.
p start psql session.
l open log file with pager.
aux stats actions:
B,N,L 'B' diskstat, 'N' nicstat, 'L' logtail.
activity actions:
-,_ '-' cancel backend by pid, '_' terminate backend by pid.
n,m 'n' set new mask, 'm' show current mask.
k,K 'k' cancel group of queries using mask, 'K' terminate group of backends using mask.
I show IDLE connections toggle.
A change activity age threshold.
G get query report.
other actions:
, Q ',' show system tables on/off, 'Q' reset postgresql statistics counters.
z,Z 'z' set refresh interval, 'Z' change color scheme.
space pause program execution.
h,F1 show this tab.
Ctrl+Q quit.
Type 'Esc' to continue.`
)
// Open gocui view and shows built-in help.
func showHelp(g *gocui.Gui, _ *gocui.View) error {
maxX, maxY := g.Size()
if v, err := g.SetView("help", -1, -1, maxX-1, maxY-1); err != nil {
if err != gocui.ErrUnknownView {
return fmt.Errorf("set 'help' view on layout failed: %s", err)
}
v.Frame = false
fmt.Fprintf(v, helpTemplate)
if _, err := g.SetCurrentView("help"); err != nil {
return fmt.Errorf("set 'help' view as current on layout failed: %s", err)
}
}
return nil
}
// Close gocui view and return
func closeHelp(g *gocui.Gui, v *gocui.View) error {
v.Clear()
g.DeleteView("help")
if _, err := g.SetCurrentView("sysstat"); err != nil {
return fmt.Errorf("set sysstat view as current on layout failed: %s", err)
}
return nil
}