1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
package app
import "regexp"
// mouseLeakRE matches a string that is entirely SGR mouse-event residue —
// one or more `<button;col;row` groups ending in M (press) or m (release),
// with the leading `<` sometimes consumed by the parser.
var mouseLeakRE = regexp.MustCompile(`^(<?\d+;\d+;\d+[Mm])+$`)
// looksLikeMouseLeak reports whether a KeyRunes payload is leaked mouse data
// rather than typed text. Bubble Tea's input parser can split a burst of SGR
// mouse sequences (fast wheel scrolling) across read boundaries and emit the
// leftover as a single KeyRunes text event; without this guard those bytes get
// inserted into the buffer as literal `<64;68;26M…` junk (TASK-029). A genuine
// keystroke never delivers a full `digits;digits;digits[Mm]` group as one rune
// event, so this only ever drops parser residue.
func looksLikeMouseLeak(s string) bool {
return mouseLeakRE.MatchString(s)
}
|