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 {
207207 ///
208208 /// Matches when key-code is 92 (backslash), ctrl bit is set in modifiers,
209209 /// 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)
211211 /// and alternate key sub-fields from the kitty protocol's progressive
212212 /// enhancement flags.
213213 pub fn isKittyCtrlBackslash(buf: []const u8) bool {
......@@ -227,7 +227,7 @@ pub fn isKittyCtrlBackslash(buf: []const u8) bool {
227227 fn parseKittyCtrlBackslash(buf: []const u8) bool {
228228 var pos: usize = 0;
229229
230- // 1. Parse key code — must be 92 (backslash).
230+ // 1. Parse key code -- must be 92 (backslash).
231231 const key_code = parseDecimal(buf, &pos) orelse return false;
232232 if (key_code != 92) return false;
233233
......@@ -256,7 +256,7 @@ fn parseKittyCtrlBackslash(buf: []const u8) bool {
256256 if (pos < buf.len and buf[pos] == ':') {
257257 pos += 1;
258258 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).
260260 if (event_type == 3) return false;
261261 }
262262
......@@ -619,10 +619,10 @@ test "isKittyCtrlBackslash" {
619619 // Explicit press event type (:1)
620620 try expect(isKittyCtrlBackslash("\x1b[92;5:1u"));
621621
622- // Repeat event (:2) — user holding Ctrl+\
622+ // Repeat event (:2) -- user holding Ctrl+\
623623 try expect(isKittyCtrlBackslash("\x1b[92;5:2u"));
624624
625- // Release event (:3) — must NOT trigger detach
625+ // Release event (:3) -- must NOT trigger detach
626626 try expect(!isKittyCtrlBackslash("\x1b[92;5:3u"));
627627
628628 // Lock modifiers: caps_lock (bit 6) changes modifier value
......@@ -637,7 +637,7 @@ test "isKittyCtrlBackslash" {
637637 // ctrl + caps_lock + num_lock = 1 + (4 + 64 + 128) = 197
638638 try expect(isKittyCtrlBackslash("\x1b[92;197u"));
639639
640- // Combined intentional modifiers — must NOT match (ctrl+\ is the
640+ // Combined intentional modifiers -- must NOT match (ctrl+\ is the
641641 // detach key, not ctrl+shift+\ or ctrl+alt+\)
642642 // ctrl + shift = 1 + (4 + 1) = 6
643643 try expect(!isKittyCtrlBackslash("\x1b[92;6u"));
......@@ -648,13 +648,13 @@ test "isKittyCtrlBackslash" {
648648 // ctrl + super = 1 + (4 + 8) = 13
649649 try expect(!isKittyCtrlBackslash("\x1b[92;13u"));
650650
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
652652 try expect(!isKittyCtrlBackslash("\x1b[92;70u"));
653653
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
655655 try expect(!isKittyCtrlBackslash("\x1b[92;134u"));
656656
657- // Modifier without ctrl bit — must NOT match
657+ // Modifier without ctrl bit -- must NOT match
658658 // shift only = 1 + 1 = 2
659659 try expect(!isKittyCtrlBackslash("\x1b[92;1u"));
660660 try expect(!isKittyCtrlBackslash("\x1b[92;2u"));
......@@ -673,12 +673,12 @@ test "isKittyCtrlBackslash" {
673673 try expect(isKittyCtrlBackslash("\x1b[92:124;69:1u"));
674674 try expect(!isKittyCtrlBackslash("\x1b[92:124;69:3u"));
675675
676- // Text codepoints section (flag 0b10000) — tolerated and skipped
676+ // Text codepoints section (flag 0b10000) -- tolerated and skipped
677677 // Even though ctrl+\ text is typically empty, terminals may vary
678678 try expect(isKittyCtrlBackslash("\x1b[92;5;28u"));
679679 try expect(isKittyCtrlBackslash("\x1b[92;5;28:92u"));
680680
681- // Wrong key code — must NOT match
681+ // Wrong key code -- must NOT match
682682 try expect(!isKittyCtrlBackslash("\x1b[91;5u"));
683683 try expect(!isKittyCtrlBackslash("\x1b[93;5u"));
684684 try expect(!isKittyCtrlBackslash("\x1b[9;5u"));