╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ NotFound.zig ─────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭ find file ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ ╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ │ │ │http│ ssh │ │ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯
5 const wgt = xitui.widget; 6 const layout = xitui.layout; 7 const Key = xitui.input.Key; 8 const Grid = xitui.grid.Grid; 9 const Focus = xitui.focus.Focus; 10 11 // shown in place of a page whose build found nothing to show 12 pub const View = struct { 13 box: wgt.Box(ui.Widget), 14 session: *ui.Session, 15 16 const header_index: usize = 0; 17 18 pub fn init(allocator: std.mem.Allocator, session: *ui.Session) !View { 19 var box = try wgt.Box(ui.Widget).init(allocator, .{ .border = null, .direction = .vert }); 20 errdefer box.deinit(allocator); 21 22 { 23 var header = try wgt.Box(ui.Widget).init(allocator, .{ .border = .hidden, .direction = .horiz }); 24 errdefer header.deinit(allocator); 25 try ui.widget.addBackButton(allocator, &header, session); 26 try box.children.put(allocator, header.getFocus().id, .{ .widget = .{ .box = header }, .rect = null, .min_size = null }); 27 } 28 29 { 30 var text_box = try wgt.TextBox.init(allocator, "can't find it, homie", .{ .border = null, .wrap_kind = .none }); 31 errdefer text_box.deinit(allocator); 32 var center = try ui.widget.Center.init(allocator, .{ .text_box = text_box }); 33 errdefer center.deinit(allocator); 34 try box.children.put(allocator, center.getFocus().id, .{ .widget = .{ .center = center }, .rect = null, .min_size = null }); 35 } 36 37 return .{ .box = box, .session = session }; 38 } 39 40 pub fn deinit(self: *View, allocator: std.mem.Allocator) void { 41 self.box.deinit(allocator); 42 } 43 44 pub fn build(self: *View, allocator: std.mem.Allocator, constraint: layout.Constraint, root_focus: *Focus) !void { 45 self.clearGrid(); 46 ui.widget.setBackButtonVisible(&self.box.children.values()[header_index].widget.box, self.session.back == .available); 47 try self.box.build(allocator, constraint, root_focus); 48 } 49 50 pub fn input(self: *View, allocator: std.mem.Allocator, key: Key, root_focus: *Focus) !void { 51 _ = self; 52 _ = allocator; 53 _ = key; 54 _ = root_focus; 55 } 56 57 pub fn clearGrid(self: *View) void { 58 self.box.clearGrid(); 59 } 60 61 pub fn getGrid(self: View) ?Grid { 62 return self.box.getGrid(); 63 } 64 65 pub fn getFocus(self: *View) *Focus { 66 return self.box.getFocus(); 67 } 68 }; 69