a modern tui library written in zig
at main 1.2 kB view raw
1const Window = @import("../Window.zig"); 2 3pub fn center(parent: Window, cols: u16, rows: u16) Window { 4 const y_off = (parent.height / 2) -| (rows / 2); 5 const x_off = (parent.width / 2) -| (cols / 2); 6 return parent.child(.{ 7 .x_off = x_off, 8 .y_off = y_off, 9 .width = cols, 10 .height = rows, 11 }); 12} 13 14pub fn topLeft(parent: Window, cols: u16, rows: u16) Window { 15 const y_off: u16 = 0; 16 const x_off: u16 = 0; 17 return parent.child(.{ .x_off = x_off, .y_off = y_off, .width = cols, .height = rows }); 18} 19 20pub fn topRight(parent: Window, cols: u16, rows: u16) Window { 21 const y_off: u16 = 0; 22 const x_off = parent.width -| cols; 23 return parent.child(.{ .x_off = x_off, .y_off = y_off, .width = cols, .height = rows }); 24} 25 26pub fn bottomLeft(parent: Window, cols: u16, rows: u16) Window { 27 const y_off = parent.height -| rows; 28 const x_off: u16 = 0; 29 return parent.child(.{ .x_off = x_off, .y_off = y_off, .width = cols, .height = rows }); 30} 31 32pub fn bottomRight(parent: Window, cols: u16, rows: u16) Window { 33 const y_off = parent.height -| rows; 34 const x_off = parent.width -| cols; 35 return parent.child(.{ .x_off = x_off, .y_off = y_off, .width = cols, .height = rows }); 36}