-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathevent.go
More file actions
357 lines (277 loc) · 5.74 KB
/
event.go
File metadata and controls
357 lines (277 loc) · 5.74 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
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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
package interactive
import (
"time"
)
// 导出事件
// 用户按上键
const EventMaskKeyUp = 1
// 按下键
const EventMaskKeyDown = 2 << 0
// 已经在顶端, 此时用户按上键
const EventMaskTryToMoveUpper = 2 << 1
// 已经在底端, 此时用户按下键
const EventMaskTryToMoveLower = 2 << 2
// 用户在trace模式下按上下键
const EventMaskKeyUpWhenTrace = 2 << 3
const EventMaskKeyDownWhenTrace = 2 << 4
// 一些控制案按键, 为什么不提供Ctrl+M? 因为它就是Enter, 这个键位有特殊用途, 因此不提供使用
const EventMaskKeyCtrlSpace = 2 << 5
const EventMaskKeyCtrlA = 2 << 6
const EventMaskKeyCtrlB = 2 << 7
const EventMaskKeyCtrlC = 2 << 8
const EventMaskKeyCtrlD = 2 << 9
const EventMaskKeyCtrlE = 2 << 10
const EventMaskKeyCtrlF = 2 << 11
const EventMaskKeyCtrlG = 2 << 12
const EvnetMaskKeyCtrlH = 2 << 13
const EventMaskKeyCtrlI = 2 << 14
const EventMaskKeyCtrlJ = 2 << 15
const EventMaskKeyCtrlK = 2 << 16
const EventMaskKeyCtrlL = 2 << 17
const EventMaskKeyCtrlN = 2 << 18
const EventMaskKeyCtrlO = 2 << 19
const EventMaskKeyCtrlP = 2 << 20
const EventMaskKeyCtrlQ = 2 << 21
const EventMaskKeyCtrlR = 2 << 22
const EventMaskKeyCtrlS = 2 << 23
const EventMaskKeyCtrlT = 2 << 24
const EventMaskKeyCtrlU = 2 << 25
const EventMaskKeyCtrlV = 2 << 26
const EventMaskKeyCtrlW = 2 << 27
const EventMaskKeyCtrlX = 2 << 28
const EventMaskKeyCtrlY = 2 << 29
const EventMaskKeyCtrlZ = 2 << 30
const EventMaskWindowResize = 2 << 31
// 上移事件
type EventMoveUp struct {
When time.Time
LineOffsetBeforeMove int
}
// 下移事件
type EventMoveDown struct {
When time.Time
LineOffsetBeforeMove int
}
// 如果已经在最顶端, 还按上键, 那么产生这个事件
// 可以用来做聊天软件的查看历史消息功能
type EventTryToGetUpper struct {
When time.Time
}
// 如果已经在最底端, 还按下键, 那么产生这个事件
// 可以指示程序输出更多
type EventTryToGetLower struct {
When time.Time
}
// 在trace状态时按上键
type EventTypeUpWhenTrace struct {
When time.Time
}
// 在trace状态时按下键
type EventTypeDownWhenTrace struct {
When time.Time
}
type EventKeyCtrlSpace struct {
When time.Time
}
type EventKeyCtrlA struct {
When time.Time
}
type EventKeyCtrlB struct {
When time.Time
}
type EventKeyCtrlC struct {
When time.Time
}
type EventKeyCtrlD struct {
When time.Time
}
type EventKeyCtrlE struct {
When time.Time
}
type EventKeyCtrlF struct {
When time.Time
}
type EventKeyCtrlG struct {
When time.Time
}
type EventKeyCtrlH struct {
When time.Time
}
type EventKeyCtrlI struct {
When time.Time
}
type EventKeyCtrlJ struct {
When time.Time
}
type EventKeyCtrlK struct {
When time.Time
}
type EventKeyCtrlL struct {
When time.Time
}
type EventKeyCtrlN struct {
When time.Time
}
type EventKeyCtrlO struct {
When time.Time
}
type EventKeyCtrlP struct {
When time.Time
}
type EventKeyCtrlQ struct {
When time.Time
}
type EventKeyCtrlR struct {
When time.Time
}
type EventKeyCtrlS struct {
When time.Time
}
type EventKeyCtrlT struct {
When time.Time
}
type EventKeyCtrlU struct {
When time.Time
}
type EventKeyCtrlV struct {
When time.Time
}
type EventKeyCtrlW struct {
When time.Time
}
type EventKeyCtrlX struct {
When time.Time
}
type EventKeyCtrlY struct {
When time.Time
}
type EventKeyCtrlZ struct {
When time.Time
}
type EventWindowResize struct {
Height int
Width int
When time.Time
}
// 内部事件
type stopEvent struct {
when time.Time
}
func (ev *stopEvent) When() time.Time {
return ev.when
}
type clearEvent struct {
when time.Time
}
func (me *clearEvent) When() time.Time {
return me.when
}
type gotoBottomEvent struct {
when time.Time
}
func (me *gotoBottomEvent) When() time.Time {
return me.when
}
type gotoTopEvent struct {
when time.Time
}
func (me *gotoTopEvent) When() time.Time {
return me.when
}
type setBlockInputAfterEnterEvent struct {
when time.Time
data bool
}
func (me *setBlockInputAfterEnterEvent) When() time.Time {
return me.when
}
type setTraceEvent struct {
when time.Time
data bool
}
func (me *setTraceEvent) When() time.Time {
return me.when
}
type setBlockInputChangeEvent struct {
when time.Time
data bool
}
func (me *setBlockInputChangeEvent) When() time.Time {
return me.when
}
type gotoLeftEvent struct {
when time.Time
}
func (me *gotoLeftEvent) When() time.Time {
return me.when
}
type gotoLineEvent struct {
when time.Time
data int
}
func (me *gotoLineEvent) When() time.Time {
return me.when
}
type gotoNextLineEvent struct {
when time.Time
}
func (me *gotoNextLineEvent) When() time.Time {
return me.when
}
type gotoPreviousLineEvent struct {
when time.Time
}
func (me *gotoPreviousLineEvent) When() time.Time {
return me.when
}
type popFrontLineEvent struct {
when time.Time
}
func (me *popFrontLineEvent) When() time.Time {
return me.when
}
type popBackLineEvent struct {
when time.Time
}
func (me *popBackLineEvent) When() time.Time {
return me.when
}
type sendLineBackWithColorEvent struct {
when time.Time
data []interface{}
}
func (me *sendLineBackWithColorEvent) When() time.Time {
return me.when
}
type sendLineFrontWithColorEvent struct {
when time.Time
data []interface{}
}
func (me *sendLineFrontWithColorEvent) When() time.Time {
return me.when
}
type setPromptEvent struct {
when time.Time
dataRune *rune
dataStyle *StyleAttr
}
func (me *setPromptEvent) When() time.Time {
return me.when
}
type getWindowSizeEventResp struct {
height int
width int
}
type getWindowSizeEvent struct {
when time.Time
resp chan *getWindowSizeEventResp
}
func (me *getWindowSizeEvent) When() time.Time {
return me.when
}
// type gotoRightEvent struct {
// when time.Time
// }
// func (me *gotoRightEvent) When() time.Time {
// return me.when
// }