4a463cfa3a
- Added standard .gitattributes file for Zig projects. - Reworked build.zig a little, hopefully it's a bit clearer. Also, now zig build will run all steps. - outer: while in examples was redundant since there's only one loop to break from. switch expressions don't allow breaking from them, so breaking is only for loops, i.e. while and for. - When returning a struct instance from a function, the compiler infers the return type from function signature, so instead of return MyType{...}; , it's more idiomatic to write return .{...};. - Logging adds a new line by default, so you don't usually need to write \n like here: log.debug("event: {}\r\n", .{event});.
7 lines
295 B
Zig
7 lines
295 B
Zig
const Window = @import("../Window.zig");
|
|
|
|
pub fn center(parent: Window, cols: usize, rows: usize) Window {
|
|
const y_off = (parent.height / 2) - (rows / 2);
|
|
const x_off = (parent.width / 2) - (cols / 2);
|
|
return parent.initChild(x_off, y_off, .{ .limit = cols }, .{ .limit = rows });
|
|
}
|