Commit 7785934
Eric Bower
·
2026-03-19 21:57:22 -0400 EDT
parent a9dc983
chore: detach key cleanup
1 files changed,
+11,
-11
+11,
-11
| ... | ... | @@ -207,7 +207,7 @@ pub fn findTaskExitMarker(output: []const u8) ?u8 { | |
| 207 | 207 | /// | |
| 208 | 208 | /// Matches when key-code is 92 (backslash), ctrl bit is set in modifiers, | |
| 209 | 209 | /// and event type is press (1 or absent) or repeat (2). Rejects release (3). | |
| 210 | - | /// Tolerates additional modifiers (shift, alt, caps_lock, num_lock, etc.) | |
| 210 | + | /// Tolerates additional modifiers (caps_lock, num_lock) | |
| 211 | 211 | /// and alternate key sub-fields from the kitty protocol's progressive | |
| 212 | 212 | /// enhancement flags. | |
| 213 | 213 | pub fn isKittyCtrlBackslash(buf: []const u8) bool { |
| ... | ... | @@ -227,7 +227,7 @@ pub fn isKittyCtrlBackslash(buf: []const u8) bool { | |
| 227 | 227 | fn parseKittyCtrlBackslash(buf: []const u8) bool { | |
| 228 | 228 | var pos: usize = 0; | |
| 229 | 229 | ||
| 230 | - | // 1. Parse key code — must be 92 (backslash). | |
| 230 | + | // 1. Parse key code -- must be 92 (backslash). | |
| 231 | 231 | const key_code = parseDecimal(buf, &pos) orelse return false; | |
| 232 | 232 | if (key_code != 92) return false; | |
| 233 | 233 |
| ... | ... | @@ -256,7 +256,7 @@ fn parseKittyCtrlBackslash(buf: []const u8) bool { | |
| 256 | 256 | if (pos < buf.len and buf[pos] == ':') { | |
| 257 | 257 | pos += 1; | |
| 258 | 258 | const event_type = parseDecimal(buf, &pos) orelse return false; | |
| 259 | - | // 3 = release — reject. Accept press (1) and repeat (2). | |
| 259 | + | // 3 = release -- reject. Accept press (1) and repeat (2). | |
| 260 | 260 | if (event_type == 3) return false; | |
| 261 | 261 | } | |
| 262 | 262 |
| ... | ... | @@ -619,10 +619,10 @@ test "isKittyCtrlBackslash" { | |
| 619 | 619 | // Explicit press event type (:1) | |
| 620 | 620 | try expect(isKittyCtrlBackslash("\x1b[92;5:1u")); | |
| 621 | 621 | ||
| 622 | - | // Repeat event (:2) — user holding Ctrl+\ | |
| 622 | + | // Repeat event (:2) -- user holding Ctrl+\ | |
| 623 | 623 | try expect(isKittyCtrlBackslash("\x1b[92;5:2u")); | |
| 624 | 624 | ||
| 625 | - | // Release event (:3) — must NOT trigger detach | |
| 625 | + | // Release event (:3) -- must NOT trigger detach | |
| 626 | 626 | try expect(!isKittyCtrlBackslash("\x1b[92;5:3u")); | |
| 627 | 627 | ||
| 628 | 628 | // Lock modifiers: caps_lock (bit 6) changes modifier value |
| ... | ... | @@ -637,7 +637,7 @@ test "isKittyCtrlBackslash" { | |
| 637 | 637 | // ctrl + caps_lock + num_lock = 1 + (4 + 64 + 128) = 197 | |
| 638 | 638 | try expect(isKittyCtrlBackslash("\x1b[92;197u")); | |
| 639 | 639 | ||
| 640 | - | // Combined intentional modifiers — must NOT match (ctrl+\ is the | |
| 640 | + | // Combined intentional modifiers -- must NOT match (ctrl+\ is the | |
| 641 | 641 | // detach key, not ctrl+shift+\ or ctrl+alt+\) | |
| 642 | 642 | // ctrl + shift = 1 + (4 + 1) = 6 | |
| 643 | 643 | try expect(!isKittyCtrlBackslash("\x1b[92;6u")); |
| ... | ... | @@ -648,13 +648,13 @@ test "isKittyCtrlBackslash" { | |
| 648 | 648 | // ctrl + super = 1 + (4 + 8) = 13 | |
| 649 | 649 | try expect(!isKittyCtrlBackslash("\x1b[92;13u")); | |
| 650 | 650 | ||
| 651 | - | // ctrl + shift + caps_lock = 1 + (1 + 4 + 64) = 70 — shift is intentional | |
| 651 | + | // ctrl + shift + caps_lock = 1 + (1 + 4 + 64) = 70 -- shift is intentional | |
| 652 | 652 | try expect(!isKittyCtrlBackslash("\x1b[92;70u")); | |
| 653 | 653 | ||
| 654 | - | // ctrl + shift + num_lock = 1 + (1 + 4 + 128) = 134 — shift is intentional | |
| 654 | + | // ctrl + shift + num_lock = 1 + (1 + 4 + 128) = 134 -- shift is intentional | |
| 655 | 655 | try expect(!isKittyCtrlBackslash("\x1b[92;134u")); | |
| 656 | 656 | ||
| 657 | - | // Modifier without ctrl bit — must NOT match | |
| 657 | + | // Modifier without ctrl bit -- must NOT match | |
| 658 | 658 | // shift only = 1 + 1 = 2 | |
| 659 | 659 | try expect(!isKittyCtrlBackslash("\x1b[92;1u")); | |
| 660 | 660 | try expect(!isKittyCtrlBackslash("\x1b[92;2u")); |
| ... | ... | @@ -673,12 +673,12 @@ test "isKittyCtrlBackslash" { | |
| 673 | 673 | try expect(isKittyCtrlBackslash("\x1b[92:124;69:1u")); | |
| 674 | 674 | try expect(!isKittyCtrlBackslash("\x1b[92:124;69:3u")); | |
| 675 | 675 | ||
| 676 | - | // Text codepoints section (flag 0b10000) — tolerated and skipped | |
| 676 | + | // Text codepoints section (flag 0b10000) -- tolerated and skipped | |
| 677 | 677 | // Even though ctrl+\ text is typically empty, terminals may vary | |
| 678 | 678 | try expect(isKittyCtrlBackslash("\x1b[92;5;28u")); | |
| 679 | 679 | try expect(isKittyCtrlBackslash("\x1b[92;5;28:92u")); | |
| 680 | 680 | ||
| 681 | - | // Wrong key code — must NOT match | |
| 681 | + | // Wrong key code -- must NOT match | |
| 682 | 682 | try expect(!isKittyCtrlBackslash("\x1b[91;5u")); | |
| 683 | 683 | try expect(!isKittyCtrlBackslash("\x1b[93;5u")); | |
| 684 | 684 | try expect(!isKittyCtrlBackslash("\x1b[9;5u")); |