- commit
- 6b48bf4
- parent
- acfa1ec
- author
- Eric Bower
- date
- 2025-10-13 11:35:11 -0400 EDT
fix(attach): carriage return required in raw mode
1 files changed,
+16,
-16
+16,
-16
1@@ -151,7 +151,7 @@ fn writeCallback(
2 if (write_result) |_| {
3 // Request sent successfully
4 } else |err| {
5- std.debug.print("write failed: {s}\n", .{@errorName(err)});
6+ std.debug.print("write failed: {s}\r\n", .{@errorName(err)});
7 return cleanup(ctx, completion);
8 }
9
10@@ -194,7 +194,7 @@ fn readCallback(
11
12 if (read_result) |len| {
13 if (len == 0) {
14- std.debug.print("Server closed connection\n", .{});
15+ std.debug.print("Server closed connection\r\n", .{});
16 return cleanup(ctx, completion);
17 }
18
19@@ -248,27 +248,27 @@ fn readCallback(
20 const msg_line = data[0..newline_idx];
21
22 const msg_type_parsed = protocol.parseMessageType(ctx.allocator, msg_line) catch |err| {
23- std.debug.print("JSON parse error: {s}\n", .{@errorName(err)});
24+ std.debug.print("JSON parse error: {s}\r\n", .{@errorName(err)});
25 return .rearm;
26 };
27 defer msg_type_parsed.deinit();
28
29 const msg_type = protocol.MessageType.fromString(msg_type_parsed.value.type) orelse {
30- std.debug.print("Unknown message type: {s}\n", .{msg_type_parsed.value.type});
31+ std.debug.print("Unknown message type: {s}\r\n", .{msg_type_parsed.value.type});
32 return .rearm;
33 };
34
35 switch (msg_type) {
36 .attach_session_response => {
37 const parsed = protocol.parseMessage(protocol.AttachSessionResponse, ctx.allocator, msg_line) catch |err| {
38- std.debug.print("Failed to parse attach response: {s}\n", .{@errorName(err)});
39+ std.debug.print("Failed to parse attach response: {s}\r\n", .{@errorName(err)});
40 return .rearm;
41 };
42 defer parsed.deinit();
43
44 if (std.mem.eql(u8, parsed.value.payload.status, "ok")) {
45 const client_fd = parsed.value.payload.client_fd orelse {
46- std.debug.print("Missing client_fd in response\n", .{});
47+ std.debug.print("Missing client_fd in response\r\n", .{});
48 return .rearm;
49 };
50
51@@ -279,13 +279,13 @@ fn readCallback(
52 "{s}/.zmx_client_fd_{s}",
53 .{ home_dir, ctx.session_name },
54 ) catch |err| {
55- std.debug.print("Failed to create client_fd path: {s}\n", .{@errorName(err)});
56+ std.debug.print("Failed to create client_fd path: {s}\r\n", .{@errorName(err)});
57 return .rearm;
58 };
59 defer ctx.allocator.free(client_fd_path);
60
61 const file = std.fs.cwd().createFile(client_fd_path, .{ .truncate = true }) catch |err| {
62- std.debug.print("Failed to create client_fd file: {s}\n", .{@errorName(err)});
63+ std.debug.print("Failed to create client_fd file: {s}\r\n", .{@errorName(err)});
64 return .rearm;
65 };
66 defer file.close();
67@@ -294,7 +294,7 @@ fn readCallback(
68 defer ctx.allocator.free(fd_str);
69
70 file.writeAll(fd_str) catch |err| {
71- std.debug.print("Failed to write client_fd: {s}\n", .{@errorName(err)});
72+ std.debug.print("Failed to write client_fd: {s}\r\n", .{@errorName(err)});
73 return .rearm;
74 };
75
76@@ -307,7 +307,7 @@ fn readCallback(
77 },
78 .detach_session_response => {
79 const parsed = protocol.parseMessage(protocol.DetachSessionResponse, ctx.allocator, msg_line) catch |err| {
80- std.debug.print("Failed to parse detach response: {s}\n", .{@errorName(err)});
81+ std.debug.print("Failed to parse detach response: {s}\r\n", .{@errorName(err)});
82 return .rearm;
83 };
84 defer parsed.deinit();
85@@ -330,7 +330,7 @@ fn readCallback(
86 },
87 .pty_out => {
88 const parsed = protocol.parseMessage(protocol.PtyOutput, ctx.allocator, msg_line) catch |err| {
89- std.debug.print("Failed to parse pty_out: {s}\n", .{@errorName(err)});
90+ std.debug.print("Failed to parse pty_out: {s}\r\n", .{@errorName(err)});
91 return .rearm;
92 };
93 defer parsed.deinit();
94@@ -338,13 +338,13 @@ fn readCallback(
95 writeToStdout(ctx, parsed.value.payload.text);
96 },
97 else => {
98- std.debug.print("Unexpected message type in attach client: {s}\n", .{msg_type.toString()});
99+ std.debug.print("Unexpected message type in attach client: {s}\r\n", .{msg_type.toString()});
100 },
101 }
102
103 return .rearm;
104 } else |err| {
105- std.debug.print("read failed: {s}\n", .{@errorName(err)});
106+ std.debug.print("read failed: {s}\r\n", .{@errorName(err)});
107 }
108
109 ctx.allocator.destroy(read_ctx);
110@@ -546,7 +546,7 @@ fn stdinReadCallback(
111
112 return .rearm;
113 } else |err| {
114- std.debug.print("stdin read failed: {s}\n", .{@errorName(err)});
115+ std.debug.print("stdin read failed: {s}\r\n", .{@errorName(err)});
116 ctx.stdin_completion = null;
117 ctx.stdin_ctx = null;
118 ctx.allocator.destroy(stdin_ctx);
119@@ -629,9 +629,9 @@ fn closeCallback(
120 ) xev.CallbackAction {
121 const ctx = ctx_opt.?;
122 if (close_result) |_| {
123- std.debug.print("Connection closed\n", .{});
124+ std.debug.print("Connection closed\r\n", .{});
125 } else |err| {
126- std.debug.print("close failed: {s}\n", .{@errorName(err)});
127+ std.debug.print("close failed: {s}\r\n", .{@errorName(err)});
128 }
129 const allocator = ctx.allocator;
130 ctx.frame_buffer.deinit(allocator);