From a17c4af217349846bca9b0b65bf067c91f1982ff Mon Sep 17 00:00:00 2001 From: 00JCIV00 Date: Thu, 15 Aug 2024 22:05:19 -0400 Subject: [PATCH] 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. --- src/widgets/Table.zig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/widgets/Table.zig b/src/widgets/Table.zig index 04b7de9..05f4fce 100644 --- a/src/widgets/Table.zig +++ b/src/widgets/Table.zig @@ -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 }); } } }