add(border): seperator line options with corresponding code points
This commit is contained in:
@@ -63,11 +63,16 @@ pub fn main() !void {
|
||||
const element = element_wrapper.element();
|
||||
|
||||
var container = try App.Container.init(allocator, .{
|
||||
.border = .{ .separator = .{ .enabled = true } },
|
||||
.border = .{
|
||||
.separator = .{
|
||||
.enabled = true,
|
||||
.line = .double,
|
||||
},
|
||||
},
|
||||
.layout = .{
|
||||
.gap = 2,
|
||||
.padding = .all(5),
|
||||
.direction = .horizontal,
|
||||
.direction = .vertical,
|
||||
},
|
||||
}, element);
|
||||
var box = try App.Container.init(allocator, .{
|
||||
|
||||
@@ -13,6 +13,9 @@ const log = std.log.scoped(.container);
|
||||
pub const Border = packed struct {
|
||||
pub const rounded_border: [6]u21 = .{ '╭', '─', '╮', '│', '╰', '╯' };
|
||||
pub const squared_border: [6]u21 = .{ '┌', '─', '┐', '│', '└', '┘' };
|
||||
pub const line: [2]u21 = .{ '│', '─' };
|
||||
pub const dotted: [2]u21 = .{ '┆', '┄' };
|
||||
pub const double: [2]u21 = .{ '║', '═' };
|
||||
/// Color to use for the border
|
||||
color: Color = .default,
|
||||
/// Configure the corner type to be used for the border
|
||||
@@ -38,10 +41,10 @@ pub const Border = packed struct {
|
||||
separator: packed struct {
|
||||
enabled: bool = false,
|
||||
color: Color = .white,
|
||||
line: enum(u1) {
|
||||
line: enum(u2) {
|
||||
line,
|
||||
dotted,
|
||||
// TODO: add more variations which could be used for the separator
|
||||
double,
|
||||
} = .line,
|
||||
} = .{},
|
||||
|
||||
@@ -126,6 +129,11 @@ pub const Border = packed struct {
|
||||
break :blk rows - element_rows * len;
|
||||
},
|
||||
};
|
||||
const line_cps: [2]u21 = switch (this.separator.line) {
|
||||
.line => line,
|
||||
.dotted => dotted,
|
||||
.double => double,
|
||||
};
|
||||
switch (layout.direction) {
|
||||
.horizontal => {
|
||||
offset += layout.gap / 2;
|
||||
@@ -137,8 +145,7 @@ pub const Border = packed struct {
|
||||
}
|
||||
offset += cols;
|
||||
for (1..size.rows -| 1) |row| {
|
||||
// TODO: support the line options
|
||||
cells[row * size.cols + offset].cp = frame[3];
|
||||
cells[row * size.cols + offset].cp = line_cps[0];
|
||||
cells[row * size.cols + offset].style.fg = this.separator.color;
|
||||
}
|
||||
offset += layout.gap;
|
||||
@@ -154,8 +161,7 @@ pub const Border = packed struct {
|
||||
}
|
||||
offset += rows;
|
||||
for (1..size.cols -| 1) |col| {
|
||||
// TODO: support the line options
|
||||
cells[offset * size.cols + col].cp = frame[1];
|
||||
cells[offset * size.cols + col].cp = line_cps[1];
|
||||
cells[offset * size.cols + col].style.fg = this.separator.color;
|
||||
}
|
||||
offset += layout.gap;
|
||||
|
||||
Reference in New Issue
Block a user