this repo has no description
13
fork

Configure Feed

Select the types of activity you want to include in your feed.

widgets(table): implemented header and column borders

- Added the `header_border` and `col_border` to `TableContext`. Note, row borders don't work as well due to borders taking up an entire cell.
- Updated the `table.zig` example.

authored by

00JCIV00 and committed by
Tim Culverhouse
ac9839c7 46ecd65c

+14 -1
+4 -1
examples/table.zig
··· 79 79 var demo_tbl: vaxis.widgets.Table.TableContext = .{ 80 80 .active_bg = active_bg, 81 81 .active_fg = .{ .rgb = .{ 0, 0, 0 } }, 82 + .row_bg_1 = .{ .rgb = .{ 8, 8, 8 } }, 82 83 .selected_bg = selected_bg, 83 84 .header_names = .{ .custom = &.{ "First", "Last", "Username", "Phone#", "Email" } }, 84 85 //.header_align = .left, 85 86 .col_indexes = .{ .by_idx = &.{ 0, 1, 2, 4, 3 } }, 86 87 //.col_align = .{ .by_idx = &.{ .left, .left, .center, .center, .left } }, 87 - .col_align = .{ .all = .center }, 88 + //.col_align = .{ .all = .center }, 89 + //.header_borders = true, 90 + //.col_borders = true, 88 91 //.col_width = .{ .static_all = 15 }, 89 92 //.col_width = .{ .dynamic_header_len = 3 }, 90 93 //.col_width = .{ .static_individual = &.{ 10, 20, 15, 25, 15 } },
+10
src/widgets/Table.zig
··· 64 64 header_align: HorizontalAlignment = .center, 65 65 // Column Alignment 66 66 col_align: ColumnAlignment = .{ .all = .left }, 67 + 68 + // Header Borders 69 + header_borders: bool = false, 70 + // Row Borders 71 + //row_borders: bool = false, 72 + // Col Borders 73 + col_borders: bool = false, 67 74 }; 68 75 69 76 /// Width Styles for `col_width`. ··· 233 240 .y_off = 0, 234 241 .width = .{ .limit = col_width }, 235 242 .height = .{ .limit = 1 }, 243 + .border = .{ .where = if (table_ctx.header_borders and idx > 0) .left else .none } 236 244 }); 237 245 var hdr = switch (table_ctx.header_align) { 238 246 .left => hdr_win, ··· 292 300 .y_off = 1 + row + table_ctx.active_y_off, 293 301 .width = .{ .limit = table_win.width }, 294 302 .height = .{ .limit = 1 }, 303 + //.border = .{ .where = if (table_ctx.row_borders) .top else .none }, 295 304 }); 296 305 if (table_ctx.start + row == table_ctx.row) { 297 306 table_ctx.active_y_off = if (table_ctx.active_content_fn) |content| try content(&row_win, table_ctx.active_ctx) else 0; ··· 322 331 .y_off = 0, 323 332 .width = .{ .limit = col_width }, 324 333 .height = .{ .limit = 1 }, 334 + .border = .{ .where = if (table_ctx.col_borders and col_idx > 0) .left else .none }, 325 335 }); 326 336 const item_txt = switch (ItemT) { 327 337 []const u8 => item,