Skip to content

Commit

Permalink
fix(deps): use forked version of libvaxis, update zf (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
water-sucks authored Nov 16, 2024
1 parent 0f1ba04 commit 7bc2624
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 89 deletions.
8 changes: 4 additions & 4 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@
.hash = "1220ced9b2f6943f688ce1e20a40f143d83c4182320e4b9d30e470b010d44b356f0a",
},
.zf = .{
.url = "https://github.com/natecraddock/zf/archive/91bc9808bebddd5e1663ffde009bf4510a45e48d.tar.gz",
.hash = "1220a763e0496d7dade9329044fbac181eaf7c1a1f4f51ab5e3a0a77d986615aa4e4",
.url = "https://github.com/natecraddock/zf/archive/ed99ca18b02dda052e20ba467e90b623c04690dd.tar.gz",
.hash = "1220edc3b8d8bedbb50555947987e5e8e2f93871ca3c8e8d4cc8f1377c15b5dd35e8",
},
.zeit = .{
.url = "https://github.com/rockorager/zeit/archive/1d2dc95d73160096f84830e54b419514e41e78e8.tar.gz",
.hash = "1220aad3a3b05b27a2453ddb68caa70a656c530f69e321cf79a89d2a9c4b2dd51640",
},
.vaxis = .{
.url = "https://github.com/rockorager/libvaxis/archive/d36ab043caf7cbb24cae1bd0346dd6b654df0653.tar.gz",
.hash = "12206c252ee00b9dd0214989dfa35a6eea29ac7d65d4053817f161f4c23b6e09dd89",
.url = "https://github.com/water-sucks/libvaxis/archive/2dce933ccca04a87bc6ccf690ddf516516cb2acb.tar.gz",
.hash = "12208b59a13aa5211bc93dcdc00c05ca171f87a7d1ca3599aeaa83bb3bf1df388eb1",
},
.koino = .{
.url = "https://github.com/kivikakk/koino/archive/0151bb37714d93688f31e3d7a3d0369106818f26.tar.gz",
Expand Down
2 changes: 1 addition & 1 deletion package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ stdenv.mkDerivation rec {
inherit stdenv zig;
name = pname;
src = ./.;
depsHash = "sha256-TNiG5pxvESsAWCAz4BEwie+CMO6ZoNKdnm3qo6wNc4c=";
depsHash = "sha256-HvGYGbvfhgdVY9i6HrEMyhtLlWb8xo6G3zvoUz7LMas=";
};
in ''
mkdir -p .cache
Expand Down
85 changes: 45 additions & 40 deletions src/generation/ui.zig
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,9 @@ pub const GenerationTUI = struct {

.gen_list = gen_list,
.gen_list_ctx = .{
.active_bg = .{ .index = 1 },
.selected_bg = .{ .index = 1 },
.row = current_gen_idx,
.row = @truncate(current_gen_idx),
},
.candidate_filter_buf = candidate_filter_buf,
.filtered_gen_list = initial_filtered_gen_slice,
Expand Down Expand Up @@ -148,7 +149,7 @@ pub const GenerationTUI = struct {
} else {
try self.search_input.update(.{ .key_press = key });

const search_query = self.search_input.buf.items;
const search_query = self.getSearchQuery();
const tokens: []const []const u8 = toks: {
var items = ArrayList([]const u8).init(allocator);
errdefer items.deinit();
Expand All @@ -165,7 +166,7 @@ pub const GenerationTUI = struct {
self.gen_list_ctx.row = if (self.filtered_gen_list.len == 0)
0
else
self.filtered_gen_list.len - 1;
@truncate(self.filtered_gen_list.len - 1);
}
} else {
if (key.matchesAny(&.{ vaxis.Key.up, 'k' }, .{})) {
Expand Down Expand Up @@ -226,8 +227,8 @@ pub const GenerationTUI = struct {
const root_win = self.vx.window();

var main_win = root_win.child(.{
.width = .{ .limit = root_win.width / 6 },
.height = .{ .limit = root_win.height },
.width = root_win.width / 6,
.height = root_win.height,
.border = .{
.where = .all,
.style = .{ .fg = .{ .index = 7 } },
Expand All @@ -238,13 +239,13 @@ pub const GenerationTUI = struct {
.text = "Generations",
.style = .{ .bold = true },
};
const title_bar_win: vaxis.Window = main_win.child(.{ .height = .{ .limit = 1 } });
const title_bar_win: vaxis.Window = main_win.child(.{ .height = 1 });
const centered: vaxis.Window = vaxis.widgets.alignment.center(title_bar_win, title_seg.text.len, 2);
_ = try centered.printSegment(title_seg, .{});
_ = centered.printSegment(title_seg, .{});

const table_win: vaxis.Window = main_win.child(.{
.y_off = 2,
.height = .{ .limit = main_win.height - 2 },
.height = main_win.height - 2,
});

const gen_list = self.filtered_gen_list;
Expand All @@ -262,9 +263,9 @@ pub const GenerationTUI = struct {
if (ctx.row < ctx.start)
break :tableStart ctx.start - (ctx.start - ctx.row);
if (ctx.row >= gen_list.len - 1)
ctx.row = gen_list.len - 1;
ctx.row = @truncate(gen_list.len - 1);
if (ctx.row >= end)
break :tableStart ctx.start + (ctx.row - end + 1);
break :tableStart @truncate(ctx.start + (ctx.row - end + 1));
break :tableStart ctx.start;
};
end = ctx.start + max_items;
Expand All @@ -276,9 +277,9 @@ pub const GenerationTUI = struct {
const gen = data.value;

const tile = table_win.child(.{
.y_off = i,
.width = .{ .limit = table_win.width },
.height = .{ .limit = 1 },
.y_off = @intCast(i),
.width = table_win.width,
.height = 1,
});

const generation_segment: vaxis.Segment = .{
Expand All @@ -298,18 +299,18 @@ pub const GenerationTUI = struct {
break :blk false;
};

_ = try tile.printSegment(generation_segment, .{ .col_offset = 3 });
_ = tile.printSegment(generation_segment, .{ .col_offset = 3 });
if (deletion_toggled) {
_ = try tile.printSegment(.{ .text = "*" }, .{ .col_offset = 1 });
_ = tile.printSegment(.{ .text = "*" }, .{ .col_offset = 1 });
}
}

const mode_win: vaxis.Window = main_win.child(.{
.y_off = main_win.height - 1,
.height = .{ .limit = 1 },
.height = 1,
});
const mode_seg: vaxis.Segment = .{ .text = try fmt.allocPrint(allocator, "{s}", .{@tagName(self.mode)}) };
_ = try mode_win.printSegment(mode_seg, .{});
_ = mode_win.printSegment(mode_seg, .{});

return main_win;
}
Expand All @@ -321,8 +322,8 @@ pub const GenerationTUI = struct {
const search_bar_win = root_win.child(.{
.x_off = root_win.width / 6,
.y_off = root_win.height - 3,
.width = .{ .limit = root_win.width - (root_win.width / 6) },
.height = .{ .limit = 3 },
.width = root_win.width - (root_win.width / 6),
.height = 3,
.border = .{
.where = .all,
.style = .{ .fg = .{ .index = 7 } },
Expand All @@ -343,9 +344,9 @@ pub const GenerationTUI = struct {
.text = value,
.style = .{ .italic = true },
};
_ = try win.printSegment(gen_number_title_seg, .{ .row_offset = row_offset.*, .col_offset = 3 });
_ = win.printSegment(gen_number_title_seg, .{ .row_offset = @truncate(row_offset.*), .col_offset = 3 });
row_offset.* += 1;
_ = try win.printSegment(gen_number_seg, .{ .row_offset = row_offset.*, .col_offset = 3 });
_ = win.printSegment(gen_number_seg, .{ .row_offset = @truncate(row_offset.*), .col_offset = 3 });
row_offset.* += 2;
}

Expand All @@ -355,8 +356,8 @@ pub const GenerationTUI = struct {

const main_win: vaxis.Window = root_win.child(.{
.x_off = root_win.width / 6,
.width = .{ .limit = root_win.width / 2 },
.height = .{ .limit = root_win.height - 3 },
.width = root_win.width / 2,
.height = root_win.height - 3,
.border = .{
.where = .all,
.style = .{ .fg = .{ .index = 7 } },
Expand All @@ -367,21 +368,21 @@ pub const GenerationTUI = struct {
.text = "Information",
.style = .{ .bold = true },
};
const title_bar_win: vaxis.Window = main_win.child(.{ .height = .{ .limit = 1 } });
const title_bar_win: vaxis.Window = main_win.child(.{ .height = 1 });
const centered: vaxis.Window = vaxis.widgets.alignment.center(title_bar_win, title_seg.text.len, 2);
_ = try centered.printSegment(title_seg, .{});
_ = centered.printSegment(title_seg, .{});

const info_win: vaxis.Window = main_win.child(.{
.y_off = 2,
.height = .{ .limit = main_win.height - 2 },
.height = main_win.height - 2,
});

if (self.filtered_gen_list.len == 0) {
const no_selected_gen_seg: vaxis.Segment = .{
.text = "No generations found",
.style = .{ .italic = true },
};
_ = try info_win.printSegment(no_selected_gen_seg, .{ .col_offset = 3 });
_ = info_win.printSegment(no_selected_gen_seg, .{ .col_offset = 3 });
return main_win;
}

Expand Down Expand Up @@ -420,8 +421,8 @@ pub const GenerationTUI = struct {

const main_win: vaxis.Window = root.child(.{
.x_off = (root.width * 2) / 3,
.width = .{ .limit = root.width / 3 },
.height = .{ .limit = root.height / 2 },
.width = root.width / 3,
.height = root.height / 2,
.border = .{
.where = .all,
.style = .{
Expand All @@ -434,13 +435,13 @@ pub const GenerationTUI = struct {
.text = "Selected Generations",
.style = .{ .bold = true },
};
const title_win: vaxis.Window = main_win.child(.{ .height = .{ .limit = 1 } });
const title_win: vaxis.Window = main_win.child(.{ .height = 1 });
const centered: vaxis.Window = vaxis.widgets.alignment.center(title_win, title_seg.text.len, 2);
_ = try centered.printSegment(title_seg, .{});
_ = centered.printSegment(title_seg, .{});

const info_win: vaxis.Window = main_win.child(.{
.y_off = 2,
.height = .{ .limit = main_win.height - 2 },
.height = main_win.height - 2,
});

const selected_gens = self.gens_to_delete.items;
Expand All @@ -452,7 +453,7 @@ pub const GenerationTUI = struct {
}
break :blk try utils.concatStringsSep(allocator, gen_number_strs.items, ", ");
};
_ = try info_win.printSegment(.{ .text = selected_gens_str }, .{ .wrap = .word });
_ = info_win.printSegment(.{ .text = selected_gens_str }, .{ .wrap = .word });

return main_win;
}
Expand All @@ -464,8 +465,8 @@ pub const GenerationTUI = struct {
const main_win: vaxis.Window = root_win.child(.{
.x_off = (root_win.width * 2) / 3,
.y_off = root_win.height / 2,
.width = .{ .limit = root_win.width / 3 },
.height = .{ .limit = root_win.height / 2 - 2 },
.width = root_win.width / 3,
.height = root_win.height / 2 - 2,
.border = .{
.where = .all,
.style = .{ .fg = .{ .index = 7 } },
Expand All @@ -476,13 +477,13 @@ pub const GenerationTUI = struct {
.text = "Keybinds",
.style = .{ .bold = true },
};
const title_win: vaxis.Window = main_win.child(.{ .height = .{ .limit = 1 } });
const title_win: vaxis.Window = main_win.child(.{ .height = 1 });
const centered: vaxis.Window = vaxis.widgets.alignment.center(title_win, title_seg.text.len, 2);
_ = try centered.printSegment(title_seg, .{});
_ = centered.printSegment(title_seg, .{});

const info_win: vaxis.Window = main_win.child(.{
.y_off = 2,
.height = .{ .limit = main_win.height - 2 },
.height = main_win.height - 2,
});

const keybinds: []const []const []const u8 = &.{
Expand Down Expand Up @@ -516,14 +517,18 @@ pub const GenerationTUI = struct {
.text = " :: " ++ key_desc,
};

_ = try info_win.printSegment(key_seg, .{ .row_offset = row_offset, .col_offset = 1 });
_ = try info_win.printSegment(key_desc_seg, .{ .row_offset = row_offset, .col_offset = desc_col_offset });
_ = info_win.printSegment(key_seg, .{ .row_offset = row_offset, .col_offset = 1 });
_ = info_win.printSegment(key_desc_seg, .{ .row_offset = row_offset, .col_offset = desc_col_offset });
row_offset += 1;
}

return main_win;
}

fn getSearchQuery(self: Self) []const u8 {
return self.search_input.buf.buffer[0..self.search_input.buf.realLength()];
}

pub fn deinit(self: *Self) void {
self.gens_to_delete.deinit();
self.allocator.free(self.candidate_filter_buf);
Expand Down
Loading

0 comments on commit 7bc2624

Please sign in to comment.