* Parse an SGR mouse event sequence into a ParsedMouse, or null if not a * mouse event or if it's a wheel event (wheel stays as ParsedKey for the * keybinding system). Button bit 0x40 = wheel, bit 0x20 = drag/motion.
(s: string)
| 592 | * keybinding system). Button bit 0x40 = wheel, bit 0x20 = drag/motion. |
| 593 | */ |
| 594 | function parseMouseEvent(s: string): ParsedMouse | null { |
| 595 | const match = SGR_MOUSE_RE.exec(s) |
| 596 | if (!match) return null |
| 597 | const button = parseInt(match[1]!, 10) |
| 598 | // Wheel events (bit 6 set, low bits 0/1 for up/down) stay as ParsedKey |
| 599 | // so the keybinding system can route them to scroll handlers. |
| 600 | if ((button & 0x40) !== 0) return null |
| 601 | return { |
| 602 | kind: 'mouse', |
| 603 | button, |
| 604 | action: match[4] === 'M' ? 'press' : 'release', |
| 605 | col: parseInt(match[2]!, 10), |
| 606 | row: parseInt(match[3]!, 10), |
| 607 | sequence: s, |
| 608 | } |
| 609 | } |
| 610 | |
| 611 | function parseKeypress(s: string = ''): ParsedKey { |
| 612 | let parts |
no outgoing calls
no test coverage detected