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:
parent
dbeef72630
commit
a17c4af217
1 changed files with 3 additions and 1 deletions
|
@ -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 });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue