diff --git a/core/text/table/table.odin b/core/text/table/table.odin index 7b4942478..27c99b1f1 100644 --- a/core/text/table/table.odin +++ b/core/text/table/table.odin @@ -51,6 +51,19 @@ Table :: struct { tblw: int, // Width of entire table (including padding, excluding borders) } +Decorations :: struct { + // These are strings, because of multi-codepoint Unicode graphemes. + + // Connecting decorations: + nw, n, ne, + w, x, e, + sw, s, se: string, + + // Straight lines: + vert: string, + horz: string, +} + ascii_width_proc :: proc(str: string) -> int { return len(str) } @@ -397,6 +410,72 @@ write_plain_table :: proc(w: io.Writer, tbl: ^Table, width_proc: Width_Proc = un write_table_separator(w, tbl) } +write_decorated_table :: proc(w: io.Writer, tbl: ^Table, decorations: Decorations, width_proc: Width_Proc = unicode_width_proc) { + draw_dividing_row :: proc(w: io.Writer, tbl: ^Table, left, horz, divider, right: string) { + io.write_string(w, left) + for col in 0..