- commit
- 7785934
- parent
- a9dc983
- author
- Eric Bower
- date
- 2026-03-19 21:57:22 -0400 EDT
chore: detach key cleanup
1 files changed,
+11,
-11
+11,
-11
1@@ -207,7 +207,7 @@ pub fn findTaskExitMarker(output: []const u8) ?u8 {
2 ///
3 /// Matches when key-code is 92 (backslash), ctrl bit is set in modifiers,
4 /// and event type is press (1 or absent) or repeat (2). Rejects release (3).
5-/// Tolerates additional modifiers (shift, alt, caps_lock, num_lock, etc.)
6+/// Tolerates additional modifiers (caps_lock, num_lock)
7 /// and alternate key sub-fields from the kitty protocol's progressive
8 /// enhancement flags.
9 pub fn isKittyCtrlBackslash(buf: []const u8) bool {
10@@ -227,7 +227,7 @@ pub fn isKittyCtrlBackslash(buf: []const u8) bool {
11 fn parseKittyCtrlBackslash(buf: []const u8) bool {
12 var pos: usize = 0;
13
14- // 1. Parse key code — must be 92 (backslash).
15+ // 1. Parse key code -- must be 92 (backslash).
16 const key_code = parseDecimal(buf, &pos) orelse return false;
17 if (key_code != 92) return false;
18
19@@ -256,7 +256,7 @@ fn parseKittyCtrlBackslash(buf: []const u8) bool {
20 if (pos < buf.len and buf[pos] == ':') {
21 pos += 1;
22 const event_type = parseDecimal(buf, &pos) orelse return false;
23- // 3 = release — reject. Accept press (1) and repeat (2).
24+ // 3 = release -- reject. Accept press (1) and repeat (2).
25 if (event_type == 3) return false;
26 }
27
28@@ -619,10 +619,10 @@ test "isKittyCtrlBackslash" {
29 // Explicit press event type (:1)
30 try expect(isKittyCtrlBackslash("\x1b[92;5:1u"));
31
32- // Repeat event (:2) — user holding Ctrl+\
33+ // Repeat event (:2) -- user holding Ctrl+\
34 try expect(isKittyCtrlBackslash("\x1b[92;5:2u"));
35
36- // Release event (:3) — must NOT trigger detach
37+ // Release event (:3) -- must NOT trigger detach
38 try expect(!isKittyCtrlBackslash("\x1b[92;5:3u"));
39
40 // Lock modifiers: caps_lock (bit 6) changes modifier value
41@@ -637,7 +637,7 @@ test "isKittyCtrlBackslash" {
42 // ctrl + caps_lock + num_lock = 1 + (4 + 64 + 128) = 197
43 try expect(isKittyCtrlBackslash("\x1b[92;197u"));
44
45- // Combined intentional modifiers — must NOT match (ctrl+\ is the
46+ // Combined intentional modifiers -- must NOT match (ctrl+\ is the
47 // detach key, not ctrl+shift+\ or ctrl+alt+\)
48 // ctrl + shift = 1 + (4 + 1) = 6
49 try expect(!isKittyCtrlBackslash("\x1b[92;6u"));
50@@ -648,13 +648,13 @@ test "isKittyCtrlBackslash" {
51 // ctrl + super = 1 + (4 + 8) = 13
52 try expect(!isKittyCtrlBackslash("\x1b[92;13u"));
53
54- // ctrl + shift + caps_lock = 1 + (1 + 4 + 64) = 70 — shift is intentional
55+ // ctrl + shift + caps_lock = 1 + (1 + 4 + 64) = 70 -- shift is intentional
56 try expect(!isKittyCtrlBackslash("\x1b[92;70u"));
57
58- // ctrl + shift + num_lock = 1 + (1 + 4 + 128) = 134 — shift is intentional
59+ // ctrl + shift + num_lock = 1 + (1 + 4 + 128) = 134 -- shift is intentional
60 try expect(!isKittyCtrlBackslash("\x1b[92;134u"));
61
62- // Modifier without ctrl bit — must NOT match
63+ // Modifier without ctrl bit -- must NOT match
64 // shift only = 1 + 1 = 2
65 try expect(!isKittyCtrlBackslash("\x1b[92;1u"));
66 try expect(!isKittyCtrlBackslash("\x1b[92;2u"));
67@@ -673,12 +673,12 @@ test "isKittyCtrlBackslash" {
68 try expect(isKittyCtrlBackslash("\x1b[92:124;69:1u"));
69 try expect(!isKittyCtrlBackslash("\x1b[92:124;69:3u"));
70
71- // Text codepoints section (flag 0b10000) — tolerated and skipped
72+ // Text codepoints section (flag 0b10000) -- tolerated and skipped
73 // Even though ctrl+\ text is typically empty, terminals may vary
74 try expect(isKittyCtrlBackslash("\x1b[92;5;28u"));
75 try expect(isKittyCtrlBackslash("\x1b[92;5;28:92u"));
76
77- // Wrong key code — must NOT match
78+ // Wrong key code -- must NOT match
79 try expect(!isKittyCtrlBackslash("\x1b[91;5u"));
80 try expect(!isKittyCtrlBackslash("\x1b[93;5u"));
81 try expect(!isKittyCtrlBackslash("\x1b[9;5u"));