Something went wrong. Try again.
A charm-like tui library
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198//! Border character sets. Field defaults are the normal (light box-drawing)//! border, so `Border{}` == [normal]. The `middle*` fields are used by grid//! layouts such as tables; [Style] rendering reads only the edges and corners.
const expectEqualStrings = @import("std").testing.expectEqualStrings;const Border = @This();
top: []const u8 = "─",bottom: []const u8 = "─",left: []const u8 = "│",right: []const u8 = "│",top_left: []const u8 = "┌",top_right: []const u8 = "┐",bottom_left: []const u8 = "└",bottom_right: []const u8 = "┘",middle_left: []const u8 = "├",middle_right: []const u8 = "┤",middle: []const u8 = "┼",middle_top: []const u8 = "┬",middle_bottom: []const u8 = "┴",
/// Standard light border with 90° corners (lipgloss `NormalBorder`).pub const normal: Border = .{};
/// Light border with rounded corners (lipgloss `RoundedBorder`).pub const rounded: Border = .{ .top_left = "╭", .top_right = "╮", .bottom_left = "╰", .bottom_right = "╯",};
/// Heavy-weight border (lipgloss `ThickBorder`).pub const thick: Border = .{ .top = "━", .bottom = "━", .left = "┃", .right = "┃", .top_left = "┏", .top_right = "┓", .bottom_left = "┗", .bottom_right = "┛", .middle_left = "┣", .middle_right = "┫", .middle = "╋", .middle_top = "┳", .middle_bottom = "┻",};
/// Double-stroke border (lipgloss `DoubleBorder`).pub const double: Border = .{ .top = "═", .bottom = "═", .left = "║", .right = "║", .top_left = "╔", .top_right = "╗", .bottom_left = "╚", .bottom_right = "╝", .middle_left = "╠", .middle_right = "╣", .middle = "╬", .middle_top = "╦", .middle_bottom = "╩",};
/// Solid block border occupying the whole frame (lipgloss `BlockBorder`).pub const block: Border = .{ .top = "█", .bottom = "█", .left = "█", .right = "█", .top_left = "█", .top_right = "█", .bottom_left = "█", .bottom_right = "█", .middle_left = "█", .middle_right = "█", .middle = "█", .middle_top = "█", .middle_bottom = "█",};
/// Half-block border that sits outside the frame (lipgloss/// `OuterHalfBlockBorder`). Has no middle pieces.pub const outer_half_block: Border = .{ .top = "▀", .bottom = "▄", .left = "▌", .right = "▐", .top_left = "▛", .top_right = "▜", .bottom_left = "▙", .bottom_right = "▟", .middle_left = "", .middle_right = "", .middle = "", .middle_top = "", .middle_bottom = "",};
/// Half-block border that sits inside the frame (lipgloss/// `InnerHalfBlockBorder`). Has no middle pieces.pub const inner_half_block: Border = .{ .top = "▄", .bottom = "▀", .left = "▐", .right = "▌", .top_left = "▗", .top_right = "▖", .bottom_left = "▝", .bottom_right = "▘", .middle_left = "", .middle_right = "", .middle = "", .middle_top = "", .middle_bottom = "",};
/// ASCII-only border (lipgloss `ASCIIBorder`).pub const ascii: Border = .{ .top = "-", .bottom = "-", .left = "|", .right = "|", .top_left = "+", .top_right = "+", .bottom_left = "+", .bottom_right = "+", .middle_left = "+", .middle_right = "+", .middle = "+", .middle_top = "+", .middle_bottom = "+",};
/// Markdown-table border (lipgloss `MarkdownBorder`). Disable the top and/// bottom edges for valid markdown output.pub const markdown: Border = .{ .top = "-", .bottom = "-", .left = "|", .right = "|", .top_left = "|", .top_right = "|", .bottom_left = "|", .bottom_right = "|", .middle_left = "|", .middle_right = "|", .middle = "|", .middle_top = "|", .middle_bottom = "|",};
/// Blank border of single-cell spaces — keeps layout positioning without a/// visible border (lipgloss `HiddenBorder`).pub const hidden: Border = .{ .top = " ", .bottom = " ", .left = " ", .right = " ", .top_left = " ", .top_right = " ", .bottom_left = " ", .bottom_right = " ", .middle_left = " ", .middle_right = " ", .middle = " ", .middle_top = " ", .middle_bottom = " ",};
test "predefined border edges and corners" { try expectEqualStrings("─", normal.top); try expectEqualStrings("╭", rounded.top_left); try expectEqualStrings("┃", thick.left); try expectEqualStrings("═", double.top); try expectEqualStrings("+", ascii.top_left); try expectEqualStrings("█", block.top_left); try expectEqualStrings("▀", outer_half_block.top); try expectEqualStrings("▄", inner_half_block.top); try expectEqualStrings("|", markdown.top_left); try expectEqualStrings(" ", hidden.bottom_right);}
test "predefined border middle pieces" { try expectEqualStrings("┼", normal.middle); try expectEqualStrings("┼", rounded.middle); // rounded inherits normal middles try expectEqualStrings("╋", thick.middle); try expectEqualStrings("╬", double.middle); try expectEqualStrings("+", ascii.middle_top); try expectEqualStrings("█", block.middle); try expectEqualStrings("|", markdown.middle); try expectEqualStrings(" ", hidden.middle); try expectEqualStrings("", outer_half_block.middle); try expectEqualStrings("", inner_half_block.middle_left);}