-
Notifications
You must be signed in to change notification settings - Fork 0
/
keys.go
118 lines (115 loc) · 2.88 KB
/
keys.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
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
package main
import "github.com/charmbracelet/bubbles/key"
type KeyMap struct {
Up key.Binding
Down key.Binding
Right key.Binding
Left key.Binding
GoToTop key.Binding
GoToBot key.Binding
PgDn key.Binding
PgUp key.Binding
HalfPgDn key.Binding
HalfPgUp key.Binding
ToggleDots key.Binding
GoHome key.Binding
FilterOn key.Binding
FilterOff key.Binding
FilterAccept key.Binding
ToggleSelect key.Binding
ToggleSelectAll key.Binding
Yank key.Binding
Cut key.Binding
Paste key.Binding
Quit key.Binding
ForceQuit key.Binding
}
func DefaultKeyMap() KeyMap {
return KeyMap{
Up: key.NewBinding(
key.WithKeys("k", "up"),
key.WithHelp("^/k", "up"),
),
Down: key.NewBinding(
key.WithKeys("down", "j"),
key.WithHelp("v/j", "down"),
),
Right: key.NewBinding(
key.WithKeys("right", "l"),
key.WithHelp(">/l", "open directory"),
),
Left: key.NewBinding(
key.WithKeys("left", "h"),
key.WithHelp("</h", "go to parent directory"),
),
GoToTop: key.NewBinding(
key.WithKeys("home", "g"),
key.WithHelp("g/home", "go to top"),
),
GoToBot: key.NewBinding(
key.WithKeys("end", "G"),
key.WithHelp("G/end", "go to bottom"),
),
PgDn: key.NewBinding(
key.WithKeys("pgdown", "ctrl+f"),
key.WithHelp("pagedown/ctrl+f", "page down"),
),
PgUp: key.NewBinding(
key.WithKeys("pgup", "ctrl+b"),
key.WithHelp("pageup/ctrl+b", "page up"),
),
HalfPgDn: key.NewBinding(
key.WithKeys("ctrl+d"),
key.WithHelp("ctrl+d", "half page down"),
),
HalfPgUp: key.NewBinding(
key.WithKeys("ctrl+u"),
key.WithHelp("ctrl+u", "half page up"),
),
ToggleDots: key.NewBinding(
key.WithKeys("."),
key.WithHelp(".", "toggle show hidden files"),
),
GoHome: key.NewBinding(
key.WithKeys("~"),
key.WithHelp("~", "go to home directory"),
),
FilterOn: key.NewBinding(
key.WithKeys("/"),
key.WithHelp("/", "search mode on"),
),
FilterOff: key.NewBinding(
key.WithKeys("esc"),
key.WithHelp("esc", "search mode off"),
),
FilterAccept: key.NewBinding(
key.WithKeys("enter", "tab", "shift+tab", "ctrl+k", "up", "ctrl+j", "down"),
key.WithHelp("enter", "apply filter"),
),
ToggleSelect: key.NewBinding(
key.WithKeys(" "),
key.WithHelp("space", "toggle selection"),
),
ToggleSelectAll: key.NewBinding(
key.WithKeys("v"),
key.WithHelp("v", "toggle select all"),
),
Yank: key.NewBinding(
key.WithKeys("y"),
key.WithHelp("y", "yank"),
),
Cut: key.NewBinding(
key.WithKeys("d"),
key.WithHelp("d", "cut"),
),
Paste: key.NewBinding(
key.WithKeys("p"),
key.WithHelp("p", "paste"),
),
Quit: key.NewBinding(
key.WithKeys("q"),
key.WithHelp("q", "quit"),
),
ForceQuit: key.NewBinding(key.WithKeys("ctrl+c")),
}
}