File tree Expand file tree Collapse file tree 2 files changed +16
-5
lines changed
Expand file tree Collapse file tree 2 files changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -9,13 +9,15 @@ pub fn build(b: *std.Build) void {
99 .root_source_file = b .path ("src/root.zig" ),
1010 .target = target ,
1111 .optimize = optimize ,
12+ .link_libc = true ,
1213 });
1314
1415 // ── Tests ───────────────────────────────────────────────────────────
1516 const test_module = b .createModule (.{
1617 .root_source_file = b .path ("src/root.zig" ),
1718 .target = target ,
1819 .optimize = optimize ,
20+ .link_libc = true ,
1921 });
2022 const lib_tests = b .addTest (.{
2123 .root_module = test_module ,
Original file line number Diff line number Diff line change @@ -122,6 +122,15 @@ const TerminalSize = struct {
122122 height : usize ,
123123};
124124
125+ /// Manually defined winsize struct for ioctl TIOCGWINSZ.
126+ /// In Zig 0.16+, std.posix.system.winsize / std.c.winsize is no longer pub.
127+ const Winsize = extern struct {
128+ row : u16 ,
129+ col : u16 ,
130+ xpixel : u16 ,
131+ ypixel : u16 ,
132+ };
133+
125134fn detectTerminalSize () TerminalSize {
126135 if (builtin .os .tag == .windows ) {
127136 // Windows console API would go here
@@ -130,13 +139,13 @@ fn detectTerminalSize() TerminalSize {
130139
131140 // Try to get terminal size via ioctl
132141 const stdout = std .Io .File .stdout ();
133- var winsize : posix.system.winsize = undefined ;
142+ var ws : Winsize = undefined ;
134143
135- const result = posix .system .ioctl (stdout .handle , posix .T .IOCGWINSZ , @intFromPtr (& winsize ));
136- if (result == 0 and winsize .col > 0 and winsize .row > 0 ) {
144+ const result = posix .system .ioctl (stdout .handle , posix .T .IOCGWINSZ , @intFromPtr (& ws ));
145+ if (result == 0 and ws .col > 0 and ws .row > 0 ) {
137146 return .{
138- .width = winsize .col ,
139- .height = winsize .row ,
147+ .width = ws .col ,
148+ .height = ws .row ,
140149 };
141150 }
142151
You can’t perform that action at this time.
0 commit comments