widgets(table): implemented customizable x offset for cells/items

- Added `cell_x_off` to the `TableContext` to allow changing the X Offset of Cells/Items as they're printed to their rows.
This commit is contained in:
00JCIV00 2024-08-15 22:05:19 -04:00 committed by Tim Culverhouse
parent dbeef72630
commit a17c4af217

View file

@ -48,6 +48,8 @@ pub const TableContext = struct {
/// Y Offset for drawing to the parent Window.
y_off: usize = 0,
/// X Offset for printing each Cell/Item.
cell_x_off: usize = 1,
/// Column Width
/// Note, if this is left `null` the Column Width will be dynamically calculated during `drawTable()`.
@ -327,7 +329,7 @@ pub fn drawTable(
.text = if (item_txt.len > col_width and alloc != null) try fmt.allocPrint(alloc.?, "{s}...", .{item_txt[0..(col_width -| 4)]}) else item_txt,
.style = .{ .fg = row_fg, .bg = row_bg },
}};
_ = try item_win.print(seg[0..], .{ .wrap = .word });
_ = try item_win.print(seg[0..], .{ .wrap = .word, .col_offset = table_ctx.cell_x_off });
}
}
}