╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Repos.zig ────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
48 errdefer list.deinit(allocator); 49 50 break :blk View{ 51 .list = list, 52 .data = data, 53 }; 54 }; 55 errdefer self.deinit(allocator); 56 57 var arena = std.heap.ArenaAllocator.init(allocator); 58 defer arena.deinit(); 59 const aa = arena.allocator(); 60 61 const lines = try aa.alloc([]const u8, data.repos.len); 62 for (data.repos, 0..) |repo, i| { 63 lines[i] = try std.fmt.allocPrint(aa, "{s} - {s}", .{ repo.name, repo.description }); 64 } 65 try self.list.setItems(allocator, lines); 66 67 return self; 68 } 69 70 pub fn deinit(self: *View, allocator: std.mem.Allocator) void { 71 self.list.deinit(allocator); 72 } 73 74 pub fn build(self: *View, allocator: std.mem.Allocator, constraint: layout.Constraint, root_focus: *Focus) !void { 75 try self.list.build(allocator, constraint, root_focus); 76 } 77 78 pub fn input(self: *View, allocator: std.mem.Allocator, key: inp.Key, root_focus: *Focus) !void { 79 try self.list.input(allocator, key, root_focus); 80 } 81 82 pub fn clearGrid(self: *View) void { 83 self.list.clearGrid(); 84 } 85 86 pub fn getGrid(self: View) ?Grid { 87 return self.list.getGrid(); 88 } 89 90 pub fn getFocus(self: *View) *Focus { 91 return self.list.getFocus(); 92 } 93 94 pub fn getSelectedIndex(self: View) ?usize { 95 return self.list.getSelectedIndex(); 96 } 97 }; 98