-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathappKeyMap.go
More file actions
120 lines (111 loc) · 2.58 KB
/
Copy pathappKeyMap.go
File metadata and controls
120 lines (111 loc) · 2.58 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
package main
import "github.com/charmbracelet/bubbles/key"
type KeyMap struct {
// Global keys
Help key.Binding
Quit key.Binding
ToggleUserIdInput key.Binding
// View keys
Trending key.Binding
Underground key.Binding
Favorites key.Binding
Queue key.Binding
Search key.Binding
// Table keys
Up key.Binding
Down key.Binding
// Left key.Binding
// Right key.Binding
Top key.Binding
Bottom key.Binding
PageUp key.Binding
PageDown key.Binding
HalfPageUp key.Binding
HalfPageDown key.Binding
}
func (k KeyMap) ShortHelp() []key.Binding {
return []key.Binding{k.Help, k.Quit}
}
func (k KeyMap) FullHelp() [][]key.Binding {
return [][]key.Binding{
{k.Up, k.Down, k.Top, k.Bottom},
{k.HalfPageUp, k.HalfPageDown, k.PageUp, k.PageDown},
{k.ToggleUserIdInput, k.Search, k.Help, k.Quit},
}
}
var AppKeyMap = KeyMap{
Up: key.NewBinding(
key.WithKeys("up", "k"),
key.WithHelp("↑/k", "move up"),
),
Down: key.NewBinding(
key.WithKeys("down", "j"),
key.WithHelp("↓/j", "move down"),
),
// Left: key.NewBinding(
// key.WithKeys("left", "h"),
// key.WithHelp("←/h", "move left"),
// ),
// Right: key.NewBinding(
// key.WithKeys("right", "l"),
// key.WithHelp("→/l", "move right"),
// ),
Top: key.NewBinding(
key.WithKeys("g"),
key.WithHelp("g", "jump to top"),
),
Bottom: key.NewBinding(
key.WithKeys("G"),
key.WithHelp("G", "jump to bottom"),
),
HalfPageUp: key.NewBinding(
key.WithKeys("u"),
key.WithHelp("u", "jump 1/2 page up"),
),
HalfPageDown: key.NewBinding(
key.WithKeys("d"),
key.WithHelp("d", "jump 1/2 page down"),
),
PageUp: key.NewBinding(
key.WithKeys("b"),
key.WithHelp("b", "jump page up"),
),
PageDown: key.NewBinding(
key.WithKeys("f"),
key.WithHelp("f", "jump page down"),
),
Trending: key.NewBinding(
key.WithKeys("T"),
key.WithHelp("T", "trending"),
),
Underground: key.NewBinding(
key.WithKeys("U"),
key.WithHelp("U", "underground"),
),
Favorites: key.NewBinding(
key.WithKeys("F"),
key.WithHelp("F", "favorites"),
),
Queue: key.NewBinding(
key.WithKeys("Q"),
key.WithHelp("Q", "queue"),
),
ToggleUserIdInput: key.NewBinding(
key.WithKeys("="),
key.WithHelp("=", "enter user id"),
),
Search: key.NewBinding(
key.WithKeys("S", "/"),
// key.WithHelp("S", "search"),
key.WithHelp("/", "search"),
),
Help: key.NewBinding(
key.WithKeys("?"),
key.WithHelp("?", "toggle help"),
),
Quit: key.NewBinding(
// key.WithKeys("esc", "q", "ctrl+c"),
key.WithKeys("esc", "ctrl+c"),
key.WithHelp("esc", "quit"),
),
}