Fix cell alignment to default to Left using ZII

This commit is contained in:
oskarnp
2023-03-26 21:41:16 +02:00
parent 020b147222
commit b6d4853a33
+1 -8
View File
@@ -22,7 +22,7 @@ Cell :: struct {
} }
Cell_Alignment :: enum { Cell_Alignment :: enum {
Left = 1, Left,
Center, Center,
Right, Right,
} }
@@ -92,9 +92,6 @@ set_cell_value_and_alignment :: proc(tbl: ^Table, row, col: int, value: string,
set_cell_value :: proc(tbl: ^Table, row, col: int, value: any, loc := #caller_location) { set_cell_value :: proc(tbl: ^Table, row, col: int, value: any, loc := #caller_location) {
cell := get_cell(tbl, row, col, loc) cell := get_cell(tbl, row, col, loc)
if cell.alignment == nil {
cell.alignment = .Left
}
switch val in value { switch val in value {
case nil: case nil:
cell.text = "" cell.text = ""
@@ -345,8 +342,6 @@ write_markdown_table :: proc(w: io.Writer, tbl: ^Table) {
case .Right: case .Right:
write_byte_repeat(w, max(1, tbl.colw[col]-1, tbl.lpad, tbl.rpad), '-') write_byte_repeat(w, max(1, tbl.colw[col]-1, tbl.lpad, tbl.rpad), '-')
io.write_byte(w, ':') io.write_byte(w, ':')
case:
panic("unhandled cell alignment")
} }
io.write_byte(w, '|') io.write_byte(w, '|')
} }
@@ -384,8 +379,6 @@ write_text_align :: proc(w: io.Writer, colw, lpad, rpad: int, text: string, alig
case .Right: case .Right:
write_byte_repeat(w, colw - len(text), ' ') write_byte_repeat(w, colw - len(text), ' ')
io.write_string(w, text) io.write_string(w, text)
case:
panic("unhandled alignment")
} }
write_byte_repeat(w, rpad, ' ') write_byte_repeat(w, rpad, ' ')
} }