╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Files.zig ────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
829 return dir[0..slash]; 830 } 831 832 // the "viewing <ref_or_oid> <value>" banner shown above the listing. 833 pub const Header = struct { 834 content: []const u8, 835 836 pub fn init(aa: std.mem.Allocator, ref_or_oid: ui.RoutablePage.RefOrOid, value: []const u8) !Header { 837 return .{ 838 .content = try std.fmt.allocPrint(aa, "viewing {s} {s}", .{ @tagName(ref_or_oid), value }), 839 }; 840 } 841 842 pub const View = struct { 843 box: wgt.Box(ui.Widget), 844 data: *const Header, 845 846 pub fn init(allocator: std.mem.Allocator, data: *const Header, session: *ui.Session) !Header.View { 847 _ = session; 848 var box = try wgt.Box(ui.Widget).init(allocator, .{ .border_style = null, .direction = .horiz }); 849 errdefer box.deinit(allocator); 850 851 var text_box = try wgt.TextBox(ui.Widget).init(allocator, data.content, .{ .border_style = .hidden, .wrap_kind = .none }); 852 errdefer text_box.deinit(allocator); 853 try box.children.put(allocator, text_box.getFocus().id, .{ .widget = .{ .text_box = text_box }, .rect = null, .min_size = null }); 854 855 return .{ .box = box, .data = data }; 856 } 857 858 pub fn deinit(self: *Header.View, allocator: std.mem.Allocator) void { 859 self.box.deinit(allocator); 860 } 861 862 pub fn build(self: *Header.View, allocator: std.mem.Allocator, constraint: layout.Constraint, root_focus: *Focus) !void { 863 self.clearGrid(); 864 try self.box.build(allocator, constraint, root_focus); 865 } 866 867 pub fn input(self: *Header.View, allocator: std.mem.Allocator, key: Key, root_focus: *Focus) !void { 868 _ = self; 869 _ = allocator; 870 _ = key; 871 _ = root_focus; 872 } 873 874 pub fn clearGrid(self: *Header.View) void { 875 self.box.clearGrid(); 876 } 877 878 pub fn getGrid(self: Header.View) ?Grid { 879 return self.box.getGrid(); 880 } 881 882 pub fn getFocus(self: *Header.View) *Focus { 883 return self.box.getFocus(); 884 } 885 }; 886 }; 887