MCPcopy
hub / github.com/mmulet/term.everything / PointerCode

Function PointerCode

termeverything/PointerCode.go:253–343  ·  view source on GitHub ↗
(data []byte)

Source from the content-addressed store, hash-verified

251}
252
253func PointerCode(data []byte) PointerEvent {
254 if !(len(data) >= 3 && data[0] == 27 && data[1] == 91 && data[2] == 77) {
255 return nil
256 }
257
258 d := int(data[3])
259
260 /**
261 * Mouse time!
262 */
263 switch d {
264
265 case 67, 75, 83, 91:
266 // @TODO why 33
267 if len(data) < 6 {
268 return nil
269 }
270 col := int(data[4]) - 33
271 row := int(data[5]) - 33
272 modifiers := MouseModifiers(d, 67)
273 return &PointerMove{
274 Row: row,
275 Col: col,
276 Modifiers: modifiers,
277 }
278 case 64, 72, 80, 88:
279 // @again why 33
280 if len(data) < 6 {
281 return nil
282 }
283 col := int(data[4]) - 33
284 row := int(data[5]) - 33
285 /**
286 * This is pointer moving while
287 * holding a button down
288 *
289 * so far it has always followed
290 * a button down event,
291 * so I'm just sending a pointer move
292 * rather than a button followed by a move
293 */
294 modifiers := MouseModifiers(d, 64)
295 return &PointerMove{
296 Row: row,
297 Col: col,
298 Modifiers: modifiers,
299 }
300
301 // Mouse button left down
302 case 32, 40, 48, 56:
303 return &PointerButtonPress{
304 Button: BTN_LEFT,
305 NeedToReleaseOtherButtons: true,
306 Modifiers: MouseModifiers(d, 32),
307 }
308 // Mouse button middle down
309 case 33, 41, 49, 57:
310 return &PointerButtonPress{

Callers

nothing calls this directly

Calls 1

MouseModifiersFunction · 0.85

Tested by

no test coverage detected