chore: zig fmt

This commit is contained in:
Tim Culverhouse 2024-05-12 20:27:24 -05:00
parent 173ff4e216
commit dea1a875e0
3 changed files with 14 additions and 27 deletions

View file

@ -67,9 +67,7 @@ pub fn drawTable(
if (table_ctx.col > headers.len - 1) table_ctx.*.col = headers.len - 1;
for (headers[0..], 0..) |hdr_txt, idx| {
const hdr_bg =
if (table_ctx.active and idx == table_ctx.col) table_ctx.selected_bg
else if (idx % 2 == 0) table_ctx.hdr_bg_1
else table_ctx.hdr_bg_2;
if (table_ctx.active and idx == table_ctx.col) table_ctx.selected_bg else if (idx % 2 == 0) table_ctx.hdr_bg_1 else table_ctx.hdr_bg_2;
const hdr_win = table_win.initChild(
idx * table_ctx.col_width,
0,
@ -79,10 +77,7 @@ pub fn drawTable(
var hdr = vaxis.widgets.alignment.center(hdr_win, @min(table_ctx.col_width -| 1, hdr_txt.len +| 1), 1);
hdr_win.fill(.{ .style = .{ .bg = hdr_bg } });
var seg = [_]vaxis.Cell.Segment{.{
.text =
if (hdr_txt.len > table_ctx.col_width and alloc != null) try fmt.allocPrint(alloc.?, "{s}...", .{ hdr_txt[0..(table_ctx.col_width -| 4)] })
else hdr_txt
,
.text = if (hdr_txt.len > table_ctx.col_width and alloc != null) try fmt.allocPrint(alloc.?, "{s}...", .{hdr_txt[0..(table_ctx.col_width -| 4)]}) else hdr_txt,
.style = .{
.bg = hdr_bg,
.bold = true,
@ -110,9 +105,7 @@ pub fn drawTable(
if (end > data_list.items.len) end = data_list.items.len;
for (data_list.items[table_ctx.start..end], 0..) |data, idx| {
const row_bg =
if (table_ctx.active and table_ctx.start + idx == table_ctx.row) table_ctx.selected_bg
else if (idx % 2 == 0) table_ctx.row_bg_1
else table_ctx.row_bg_2;
if (table_ctx.active and table_ctx.start + idx == table_ctx.row) table_ctx.selected_bg else if (idx % 2 == 0) table_ctx.row_bg_1 else table_ctx.row_bg_2;
const row_win = table_win.initChild(
0,
@ -124,10 +117,7 @@ pub fn drawTable(
if (DataT == []const u8) {
row_win.fill(.{ .style = .{ .bg = row_bg } });
var seg = [_]vaxis.Cell.Segment{.{
.text =
if (data.len > table_ctx.col_width and alloc != null) try fmt.allocPrint(alloc.?, "{s}...", .{ data[0..(table_ctx.col_width -| 4)] })
else data
,
.text = if (data.len > table_ctx.col_width and alloc != null) try fmt.allocPrint(alloc.?, "{s}...", .{data[0..(table_ctx.col_width -| 4)]}) else data,
.style = .{ .bg = row_bg },
}};
try row_win.wrap(seg[0..]);
@ -164,10 +154,7 @@ pub fn drawTable(
};
item_win.fill(.{ .style = .{ .bg = row_bg } });
var seg = [_]vaxis.Cell.Segment{.{
.text =
if (item_txt.len > table_ctx.col_width and alloc != null) try fmt.allocPrint(alloc.?, "{s}...", .{ item_txt[0..(table_ctx.col_width -| 4)] })
else item_txt
,
.text = if (item_txt.len > table_ctx.col_width and alloc != null) try fmt.allocPrint(alloc.?, "{s}...", .{item_txt[0..(table_ctx.col_width -| 4)]}) else item_txt,
.style = .{ .bg = row_bg },
}};
try item_win.wrap(seg[0..]);