╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ SubHeader.zig ────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
18 pub fn init(aa: std.mem.Allocator, ref_or_oid: RefOrOid, value: []const u8) !Self { 19 return .{ 20 .content = try std.fmt.allocPrint(aa, "viewing {s} {s}", .{ @tagName(ref_or_oid), value }), 21 }; 22 } 23 24 pub const View = struct { 25 text_box: wgt.TextBox(ui.Widget), 26 data: *const Self, 27 28 pub fn init(allocator: std.mem.Allocator, data: *const Self, session: *ui.Session) !View { 29 _ = session; 30 var text_box = try wgt.TextBox(ui.Widget).init(allocator, data.content, .{ .border_style = .hidden, .wrap_kind = .none }); 31 errdefer text_box.deinit(allocator); 32 return .{ .text_box = text_box, .data = data }; 33 } 34 35 pub fn deinit(self: *View, allocator: std.mem.Allocator) void { 36 self.text_box.deinit(allocator); 37 } 38 39 pub fn build(self: *View, allocator: std.mem.Allocator, constraint: layout.Constraint, root_focus: *Focus) !void { 40 // a single line plus the hidden border is 3 rows tall; stretch the box to 41 // the full width by handing the available width down as a min width. 42 try self.text_box.build(allocator, .{ 43 .min_size = .{ .width = constraint.max_size.width, .height = null }, 44 .max_size = constraint.max_size, 45 }, root_focus); 46 } 47 48 pub fn input(self: *View, allocator: std.mem.Allocator, key: Key, root_focus: *Focus) !void { 49 _ = self; 50 _ = allocator; 51 _ = key; 52 _ = root_focus; 53 } 54 55 pub fn clearGrid(self: *View) void { 56 self.text_box.clearGrid(); 57 } 58 59 pub fn getGrid(self: View) ?Grid { 60 return self.text_box.getGrid(); 61 } 62 63 pub fn getFocus(self: *View) *Focus { 64 return self.text_box.getFocus(); 65 } 66 }; 67