╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Commits.zig ──────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
823 } 824 825 // the "a:" link to the files tab at commit `oid` (an object ref), at its root 826 // directory, within `identity` ("owner/name"). 827 fn filesObjectLink(page_arena: *std.heap.ArenaAllocator, identity: []const u8, oid: []const u8) ![]const u8 { 828 const route = ui.RoutablePage.repoFilesRoute(identity, .object, oid, "", 0) orelse return error.RouteTooLong; 829 const url = try route.toUrl(page_arena); 830 return std.fmt.allocPrint(page_arena.allocator(), "a:{s}", .{url}); 831 } 832 833 // the in-page "ai:" anchor for selecting `oid` in `identity`'s commit list. it 834 // points at the same route as commitsLink but the "ai:" prefix keeps wasm clicks 835 // in-page (crossPageLink ignores it); the href is only followed with js off. 836 fn commitRowLink(page_arena: *std.heap.ArenaAllocator, identity: []const u8, oid: []const u8, path: []const u8) ![]const u8 { 837 const route = ui.RoutablePage.repoCommitsRoute(identity, .object, oid, 0, path) orelse return error.RouteTooLong; 838 const url = try route.toUrl(page_arena); 839 return std.fmt.allocPrint(page_arena.allocator(), "ai:{s}", .{url}); 840 } 841 842 // the "viewing <ref_or_oid> <value>" banner shown above the log. 843 pub const Header = struct { 844 content: []const u8, 845 846 pub fn init(aa: std.mem.Allocator, ref_or_oid: ui.RoutablePage.RefOrOid, value: []const u8) !Header { 847 return .{ 848 .content = try std.fmt.allocPrint(aa, "viewing {s} {s}", .{ @tagName(ref_or_oid), value }), 849 }; 850 } 851 852 pub const View = struct { 853 box: wgt.Box(ui.Widget), 854 data: *const Header, 855 856 pub fn init(allocator: std.mem.Allocator, data: *const Header, session: *ui.Session) !Header.View { 857 _ = session; 858 var box = try wgt.Box(ui.Widget).init(allocator, .{ .border_style = null, .direction = .horiz }); 859 errdefer box.deinit(allocator); 860 861 var text_box = try wgt.TextBox(ui.Widget).init(allocator, data.content, .{ .border_style = .hidden, .wrap_kind = .none }); 862 errdefer text_box.deinit(allocator); 863 try box.children.put(allocator, text_box.getFocus().id, .{ .widget = .{ .text_box = text_box }, .rect = null, .min_size = null }); 864 865 return .{ .box = box, .data = data }; 866 } 867 868 pub fn deinit(self: *Header.View, allocator: std.mem.Allocator) void { 869 self.box.deinit(allocator); 870 } 871 872 pub fn build(self: *Header.View, allocator: std.mem.Allocator, constraint: layout.Constraint, root_focus: *Focus) !void { 873 self.clearGrid(); 874 try self.box.build(allocator, constraint, root_focus); 875 } 876 877 pub fn input(self: *Header.View, allocator: std.mem.Allocator, key: Key, root_focus: *Focus) !void { 878 _ = self; 879 _ = allocator; 880 _ = key; 881 _ = root_focus; 882 } 883 884 pub fn clearGrid(self: *Header.View) void { 885 self.box.clearGrid(); 886 } 887 888 pub fn getGrid(self: Header.View) ?Grid { 889 return self.box.getGrid(); 890 } 891 892 pub fn getFocus(self: *Header.View) *Focus { 893 return self.box.getFocus(); 894 } 895 }; 896 }; 897