//! 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); }