Zig 0.17.0-dev (Split by item)
This is an example of documentation generated by
ZigDoc , an alternative to Zig's built-in
Auto Doc feature. See also
examples in other modes/formats . The project being documented here (as the example) is the Zig library itself.
Zig › std/ › Progress.zig › maybeUpdateSize
maybeUpdateSize
Progress.maybeUpdateSize
fn maybeUpdateSize (io : Io , resize_flag : bool ) !void
File
Code
fn maybeUpdateSize (io : Io , resize_flag : bool ) !void {
if (!resize_flag ) return ;
const file = global_progress .terminal ;
if (is_windows ) {
var get_console_info = windows .CONSOLE .USER_IO .GET_SCREEN_BUFFER_INFO ;
switch (try get_console_info .operate (io , file )) {
.SUCCESS => {
global_progress .rows = @intCast (get_console_info .Data .dwWindowSize .Y );
global_progress .cols = @intCast (get_console_info .Data .dwWindowSize .X );
},
else => {
std .log .debug ("failed to determine terminal size; using conservative guess 80x25" , .{});
global_progress .rows = 25 ;
global_progress .cols = 80 ;
},
}
} else {
var winsize : posix .winsize = .{
.row = 0 ,
.col = 0 ,
.xpixel = 0 ,
.ypixel = 0 ,
};
const err = (try io .operate (.{ .device_io_control = .{
.file = file ,
.code = posix .T .IOCGWINSZ ,
.arg = &winsize ,
} })).device_io_control ;
if (err >= 0 ) {
global_progress .rows = winsize .row ;
global_progress .cols = winsize .col ;
} else {
std .log .debug ("failed to determine terminal size; using conservative guess 80x25" , .{});
global_progress .rows = 25 ;
global_progress .cols = 80 ;
}
}
}