Skip to content

Commit 2ede417

Browse files
authored
fix: Respond to the device attributes sequences (#101) (#102)
1 parent 65aeac9 commit 2ede417

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

patches/ghostty-wasm-api.patch

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ new file mode 100644
396396
index 000000000..d57b4e405
397397
--- /dev/null
398398
+++ b/src/terminal/c/terminal.zig
399-
@@ -0,0 +1,1004 @@
399+
@@ -0,0 +1,1025 @@
400400
+//! C API wrapper for Terminal
401401
+//!
402402
+//! This provides a minimal, high-performance interface to Ghostty's Terminal
@@ -419,6 +419,7 @@ index 000000000..d57b4e405
419419
+const Terminal = @import("../Terminal.zig");
420420
+const stream = @import("../stream.zig");
421421
+const Action = stream.Action;
422+
+const ansi = @import("../ansi.zig");
422423
+const render = @import("../render.zig");
423424
+const RenderState = render.RenderState;
424425
+const color = @import("../color.zig");
@@ -456,6 +457,7 @@ index 000000000..d57b4e405
456457
+ switch (action) {
457458
+ // Device status reports - these need responses
458459
+ .device_status => try self.handleDeviceStatus(value.request),
460+
+ .device_attributes => try self.handleDeviceAttributes(value),
459461
+
460462
+ // All the terminal state modifications (same as stream_readonly.zig)
461463
+ .print => try self.terminal.print(value.cp),
@@ -589,7 +591,6 @@ index 000000000..d57b4e405
589591
+ .request_mode_unknown,
590592
+ .size_report,
591593
+ .xtversion,
592-
+ .device_attributes,
593594
+ .kitty_keyboard_query,
594595
+ .window_title,
595596
+ .report_pwd,
@@ -632,6 +633,26 @@ index 000000000..d57b4e405
632633
+ }
633634
+ }
634635
+
636+
+ fn handleDeviceAttributes(self: *ResponseHandler, req: ansi.DeviceAttributeReq) !void {
637+
+ // Match main Ghostty behavior for device attribute responses
638+
+ switch (req) {
639+
+ .primary => {
640+
+ // DA1 - Primary Device Attributes
641+
+ // Report as VT220 with color support (simplified for WASM)
642+
+ // 62 = Level 2 conformance, 22 = Color text
643+
+ try self.response_buffer.appendSlice(self.alloc, "\x1B[?62;22c");
644+
+ },
645+
+ .secondary => {
646+
+ // DA2 - Secondary Device Attributes
647+
+ // Report firmware version 1.10.0 (matching main Ghostty)
648+
+ try self.response_buffer.appendSlice(self.alloc, "\x1B[>1;10;0c");
649+
+ },
650+
+ else => {
651+
+ // DA3 and other requests - not implemented in WASM context
652+
+ },
653+
+ }
654+
+ }
655+
+
635656
+ inline fn horizontalTab(self: *ResponseHandler, count: u16) !void {
636657
+ for (0..count) |_| {
637658
+ const x = self.terminal.screens.active.cursor.x;

0 commit comments

Comments
 (0)