2024-10-11 15:11:51 +00:00
|
|
|
const dim = @import("dimensions.zig");
|
|
|
|
const pane = @import("pane.zig");
|
|
|
|
const term = @import("term.zig");
|
|
|
|
const borders = @import("borders.zig");
|
2024-10-14 23:05:56 +00:00
|
|
|
|
|
|
|
const Pane = pane.Pane;
|
2024-10-15 01:25:49 +00:00
|
|
|
const Style = pane.Style;
|
2024-10-11 15:11:51 +00:00
|
|
|
const TermIO = term.TermIO;
|
|
|
|
|
|
|
|
pub const HorizontalLine = struct {
|
2024-10-14 23:05:56 +00:00
|
|
|
pane: Pane,
|
2024-10-11 15:11:51 +00:00
|
|
|
border: borders.Border,
|
|
|
|
|
2024-10-15 01:25:49 +00:00
|
|
|
const Config = struct {
|
|
|
|
border: borders.Border,
|
|
|
|
style: Style,
|
|
|
|
};
|
|
|
|
|
|
|
|
pub fn create(mem: *HorizontalLine, config: Config) *Pane {
|
|
|
|
mem.border = config.border;
|
2024-10-14 23:05:56 +00:00
|
|
|
mem.pane = Pane{
|
2024-10-15 01:25:49 +00:00
|
|
|
.style = config.style,
|
2024-10-14 23:05:56 +00:00
|
|
|
.vtable = .{
|
|
|
|
.draw = draw,
|
2024-10-11 15:11:51 +00:00
|
|
|
},
|
|
|
|
};
|
2024-10-14 23:05:56 +00:00
|
|
|
|
|
|
|
return &mem.pane;
|
2024-10-11 15:11:51 +00:00
|
|
|
}
|
|
|
|
|
2024-10-14 23:05:56 +00:00
|
|
|
fn draw(pane_ptr: *Pane, term_io: *TermIO) !void {
|
2024-10-11 15:11:51 +00:00
|
|
|
const self: *HorizontalLine = @fieldParentPtr("pane", pane_ptr);
|
2024-10-14 23:05:56 +00:00
|
|
|
const y = pane_ptr.dimensions.size.height / 2;
|
2024-10-11 15:11:51 +00:00
|
|
|
pane_ptr.cursor = .{ .x = 0, .y = y };
|
|
|
|
pane_ptr.moveCursor(term_io);
|
2024-10-14 23:05:56 +00:00
|
|
|
for (0..pane_ptr.dimensions.size.width) |_| {
|
2024-10-11 15:11:51 +00:00
|
|
|
term_io.print("{u}", .{self.border.top});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
pub const VerticalLine = struct {
|
2024-10-14 23:05:56 +00:00
|
|
|
pane: Pane,
|
2024-10-14 23:35:47 +00:00
|
|
|
border: borders.Border,
|
|
|
|
|
2024-10-15 01:25:49 +00:00
|
|
|
const Config = struct {
|
|
|
|
border: borders.Border,
|
|
|
|
style: Style,
|
|
|
|
};
|
|
|
|
|
|
|
|
pub fn create(mem: *VerticalLine, config: Config) *Pane {
|
|
|
|
mem.border = config.border;
|
2024-10-14 23:35:47 +00:00
|
|
|
mem.pane = Pane{
|
2024-10-15 01:25:49 +00:00
|
|
|
.style = config.style,
|
2024-10-14 23:35:47 +00:00
|
|
|
.vtable = .{
|
|
|
|
.draw = draw,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
return &mem.pane;
|
|
|
|
}
|
|
|
|
|
|
|
|
fn draw(pane_ptr: *Pane, term_io: *TermIO) !void {
|
|
|
|
const self: *VerticalLine = @fieldParentPtr("pane", pane_ptr);
|
|
|
|
const x = pane_ptr.dimensions.size.width / 2;
|
|
|
|
|
|
|
|
for (0..pane_ptr.dimensions.size.height) |h| {
|
|
|
|
pane_ptr.cursor = .{ .x = x, .y = h };
|
|
|
|
pane_ptr.moveCursor(term_io);
|
|
|
|
term_io.print("{u}", .{self.border.left});
|
|
|
|
}
|
|
|
|
}
|
2024-10-11 15:11:51 +00:00
|
|
|
};
|