a modern tui library written in zig
1const Window = @import("../Window.zig");
2const cell = @import("../cell.zig");
3const Character = cell.Character;
4const Style = cell.Style;
5
6const horizontal = Character{ .grapheme = "─", .width = 1 };
7const vertical = Character{ .grapheme = "│", .width = 1 };
8const top_left = Character{ .grapheme = "╭", .width = 1 };
9const top_right = Character{ .grapheme = "╮", .width = 1 };
10const bottom_right = Character{ .grapheme = "╯", .width = 1 };
11const bottom_left = Character{ .grapheme = "╰", .width = 1 };
12
13pub fn all(win: Window, style: Style) Window {
14 const h = win.height;
15 const w = win.width;
16 win.writeCell(0, 0, .{ .char = top_left, .style = style });
17 win.writeCell(0, h - 1, .{ .char = bottom_left, .style = style });
18 win.writeCell(w - 1, 0, .{ .char = top_right, .style = style });
19 win.writeCell(w - 1, h - 1, .{ .char = bottom_right, .style = style });
20 var i: usize = 1;
21 while (i < (h - 1)) : (i += 1) {
22 win.writeCell(0, i, .{ .char = vertical, .style = style });
23 win.writeCell(w - 1, i, .{ .char = vertical, .style = style });
24 }
25 i = 1;
26 while (i < w - 1) : (i += 1) {
27 win.writeCell(i, 0, .{ .char = horizontal, .style = style });
28 win.writeCell(i, h - 1, .{ .char = horizontal, .style = style });
29 }
30 return win.initChild(1, 1, .{ .limit = w - 2 }, .{ .limit = w - 2 });
31}