#get terminal size
1 messages · Page 1 of 1 (latest)
the TIOCGWINSZ ioctl on posix, GetConsoleScreenBufferInfo on windows
How can i utilize it?
the only stuff i found about it are manual pages on C specifically
The way I've been doing it for linux and macos is as such, where file is std.io.getStdOut():
var winsize: std.posix.system.winsize = undefined;
const errno = std.posix.system.ioctl(file.handle, posix.T.IOCGWINSZ, @intFromPtr(&winsize));
// switch on errno to verify .SUCCESS...
const width = winsize.ws_col;
const height = winsize.ws_row;
posix.system.ioctl is a C function (generally). The docs will get you a good way through anything you need to do, and anything that is C can be found in the C manpages
edit: link symbols swapped. random internet person's answer is similar to mine
this worked, ty