feat: fix macos support

This commit is contained in:
2025-06-25 11:52:17 +02:00
parent cf17c6354f
commit 12fe0287da
2 changed files with 17 additions and 2 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -9,15 +9,18 @@ pub fn getTerminalDimensions() !Dimensions {
const os_tag = builtin.os.tag;
switch (os_tag) {
.linux, .macos, .freebsd, .openbsd, .netbsd => {
.linux, .freebsd, .openbsd, .netbsd => {
return try getUnixTerminalDimensions();
},
.windows => {
return try getWindowsTerminalDimensions();
},
.macos => {
return try getMacOsTerminalDimensions();
},
else => {
return Error.UnsupportedOs;
}
},
}
}
@@ -32,6 +35,18 @@ fn getUnixTerminalDimensions() !Dimensions {
return Dimensions{ .width = size.ws_col, .height = size.ws_row };
}
pub fn getMacOsTerminalDimensions() !Dimensions {
var ws: std.posix.winsize = undefined;
const fd = std.io.getStdOut().handle;
_ = std.c.ioctl(fd, std.posix.T.IOCGWINSZ, @intFromPtr(&ws));
return Dimensions{
.width = ws.col,
.height = ws.row,
};
}
fn getWindowsTerminalDimensions() !Dimensions {
const win = std.os.windows;
const handle = win.GetStdHandle(win.STD_OUTPUT_HANDLE) catch return Error.ErrorFetchingDimensions;