mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 16:56:09 +03:00
set IUTF8 on the pty
This is important on Mac since the pty by default on Mac does NOT have this enabled. Without this, attempting to read/write UTF-8 characters in the raw pty layer would sometimes turn into '?' even though ghostty fully supports it.
This commit is contained in:
13
src/Pty.zig
13
src/Pty.zig
@ -55,6 +55,19 @@ pub fn open(size: winsize) !Pty {
|
|||||||
@ptrCast([*c]c.struct_winsize, &sizeCopy),
|
@ptrCast([*c]c.struct_winsize, &sizeCopy),
|
||||||
) < 0)
|
) < 0)
|
||||||
return error.OpenptyFailed;
|
return error.OpenptyFailed;
|
||||||
|
errdefer {
|
||||||
|
_ = std.os.system.close(master_fd);
|
||||||
|
_ = std.os.system.close(slave_fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Enable UTF-8 mode. I think this is on by default on Linux but it
|
||||||
|
// is NOT on by default on macOS so we ensure that it is always set.
|
||||||
|
var attrs: c.termios = undefined;
|
||||||
|
if (c.tcgetattr(master_fd, &attrs) != 0)
|
||||||
|
return error.OpenptyFailed;
|
||||||
|
attrs.c_iflag |= c.IUTF8;
|
||||||
|
if (c.tcsetattr(master_fd, c.TCSANOW, &attrs) != 0)
|
||||||
|
return error.OpenptyFailed;
|
||||||
|
|
||||||
return Pty{
|
return Pty{
|
||||||
.master = master_fd,
|
.master = master_fd,
|
||||||
|
Reference in New Issue
Block a user