-
Notifications
You must be signed in to change notification settings - Fork 0
/
keys.go
211 lines (199 loc) · 6.46 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
// Copyright (c) 2022 Stephan Lukits. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package lines
import "github.com/slukits/lines/internal/api"
// A KeyEventer is implemented by a reported key-event. Key events may
// be received from a [Componenter] by implementing the [Keyer] interface.
// KeyEventer.Source() provides the backend event triggering the key
// event.
type KeyEventer = api.KeyEventer
// A RuneEventer is implemented by a reported rune-event. Rune events may
// be received from a [Componenter] by implementing the [Runer] interface.
// RuneEventer.Source() provides the backend event triggering the rune
// event.
type RuneEventer = api.RuneEventer
// Keyer is implemented by components who want to take over the user's
// key-input if they are focused. Note a [Component]'s Register property
// allows to register handler for specific keys (see [Listeners.Key]).
type Keyer interface {
// OnKey is provided with every key-press and reported modifiers which
// were pressed at the same time.
OnKey(*Env, Key, ModifierMask)
}
// Runer is implemented by components who want to take over the user's
// rune-input if they are focused.
type Runer interface {
// OnRune is provided with every rune-input.
OnRune(*Env, rune, ModifierMask)
}
// A ModifierMask are the pressed modifier keys of a key, rune or mouse
// event. Note that the shift modifier of a capital rune event is not
// reported.
type ModifierMask = api.ModifierMask
const (
Shift ModifierMask = api.Shift
Ctrl ModifierMask = api.Ctrl
Alt ModifierMask = api.Alt
Meta ModifierMask = api.Meta
ZeroModifier ModifierMask = api.ZeroModifier
)
// A Key is the pressed key of a key event.
type Key = api.Key
const (
NUL Key = api.NUL
SOH Key = api.SOH
STX Key = api.STX
ETX Key = api.ETX
EOT Key = api.EOT
ENQ Key = api.ENQ
ACK Key = api.ACK
BEL Key = api.BEL
BS Key = api.BS
TAB Key = api.TAB
LF Key = api.LF
VT Key = api.VT
FF Key = api.FF
CR Key = api.CR
SO Key = api.SO
SI Key = api.SI
DLE Key = api.DLE
DC1 Key = api.DC1
DC2 Key = api.DC2
DC3 Key = api.DC3
DC4 Key = api.DC4
NAK Key = api.NAK
SYN Key = api.SYN
ETB Key = api.ETB
CAN Key = api.CAN
EM Key = api.EM
SUB Key = api.SUB
ESC Key = api.ESC
FS Key = api.FS
GS Key = api.GS
RS Key = api.RS
US Key = api.US
DEL Key = api.DEL
Up Key = api.Up
Down Key = api.Down
Right Key = api.Right
Left Key = api.Left
UpLeft Key = api.UpLeft
UpRight Key = api.UpRight
DownLeft Key = api.DownLeft
DownRight Key = api.DownRight
Center Key = api.Center
PgUp Key = api.PgUp
PgDn Key = api.PgDn
Home Key = api.Home
End Key = api.End
Insert Key = api.Insert
Delete Key = api.Delete
Help Key = api.Help
Exit Key = api.Exit
Clear Key = api.Clear
Cancel Key = api.Cancel
PrintScr Key = api.Print
Pause Key = api.Pause
Backtab Key = api.Backtab
F1 Key = api.F1
F2 Key = api.F2
F3 Key = api.F3
F4 Key = api.F4
F5 Key = api.F5
F6 Key = api.F6
F7 Key = api.F7
F8 Key = api.F8
F9 Key = api.F9
F10 Key = api.F10
F11 Key = api.F11
F12 Key = api.F12
F13 Key = api.F13
F14 Key = api.F14
F15 Key = api.F15
F16 Key = api.F16
F17 Key = api.F17
F18 Key = api.F18
F19 Key = api.F19
F20 Key = api.F20
F21 Key = api.F21
F22 Key = api.F22
F23 Key = api.F23
F24 Key = api.F24
F25 Key = api.F25
F26 Key = api.F26
F27 Key = api.F27
F28 Key = api.F28
F29 Key = api.F29
F30 Key = api.F30
F31 Key = api.F31
F32 Key = api.F32
F33 Key = api.F33
F34 Key = api.F34
F35 Key = api.F35
F36 Key = api.F36
F37 Key = api.F37
F38 Key = api.F38
F39 Key = api.F39
F40 Key = api.F40
F41 Key = api.F41
F42 Key = api.F42
F43 Key = api.F43
F44 Key = api.F44
F45 Key = api.F45
F46 Key = api.F46
F47 Key = api.F47
F48 Key = api.F48
F49 Key = api.F49
F50 Key = api.F50
F51 Key = api.F51
F52 Key = api.F52
F53 Key = api.F53
F54 Key = api.F54
F55 Key = api.F55
F56 Key = api.F56
F57 Key = api.F57
F58 Key = api.F58
F59 Key = api.F59
F60 Key = api.F60
F61 Key = api.F61
F62 Key = api.F62
F63 Key = api.F63
F64 Key = api.F64
CtrlSpace Key = api.CtrlSpace
CtrlA Key = api.CtrlA
CtrlB Key = api.CtrlB
CtrlC Key = api.CtrlC
CtrlD Key = api.CtrlD
CtrlE Key = api.CtrlE
CtrlF Key = api.CtrlF
CtrlG Key = api.CtrlG
CtrlH Key = api.CtrlH
CtrlI Key = api.CtrlI
CtrlJ Key = api.CtrlJ
CtrlK Key = api.CtrlK
CtrlL Key = api.CtrlL
CtrlM Key = api.CtrlM
CtrlN Key = api.CtrlN
CtrlO Key = api.CtrlO
CtrlP Key = api.CtrlP
CtrlQ Key = api.CtrlQ
CtrlR Key = api.CtrlR
CtrlS Key = api.CtrlS
CtrlT Key = api.CtrlT
CtrlU Key = api.CtrlU
CtrlV Key = api.CtrlV
CtrlW Key = api.CtrlW
CtrlX Key = api.CtrlX
CtrlY Key = api.CtrlY
CtrlZ Key = api.CtrlZ
CtrlLeftSq Key = api.CtrlLeftSq
CtrlBackslash Key = api.CtrlBackslash
CtrlRightSq Key = api.CtrlRightSq
CtrlCarat Key = api.CtrlCarat
CtrlUnderscore Key = api.CtrlUnderscore
Enter Key = api.Enter
Tab Key = api.Tab
Backspace Key = api.Backspace
Esc Key = api.Esc
)