╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Commits.zig ──────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭ find file ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ ╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ │ │ │http│ ssh │ │ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯
821 } 822 823 // only the header's own row sits directly below the repository header. 824 pub fn atTop(self: *View) bool { 825 if (self.data.no_commits or self.data.isEmpty()) return true; 826 const focusable = if (self.header()) |header_view| header_view.hasFocusable() else false; 827 return self.headerActive() or (!focusable and self.contentAtTop()); 828 } 829 830 pub fn focusHeader(self: *View, root_focus: *Focus) bool { 831 const header_view = self.header() orelse return false; 832 return header_view.focusHeader(root_focus); 833 } 834 }; 835 836 // the "a:" navigation link for the commits page walking from commit `oid` within 837 // `data.handle.location`. 838 fn commitsLink(page_arena: *std.heap.ArenaAllocator, data: *const Self, oid: []const u8) ![]const u8 { 839 const route = data.handle.location.commitsRoute(.object, oid, data.base_oid) orelse return error.RouteTooLong; 840 const url = try route.toUrl(page_arena); 841 return page_arena.allocator().print("a:{s}", .{url}); 842 } 843 844 // this list's page starting at `oid`: a repo's branch or tag keeps its ref (and 845 // its query) and moves `from` along, so the search box survives paging. a fork 846 // or an object view roots the page at the commit itself. 847 fn pageRoute(data: *const Self, oid: []const u8) ?ui.RoutablePage { 848 if (data.handle.location != .repo or data.ref_or_oid == .object) { 849 return data.handle.location.commitsRoute(.object, oid, data.base_oid); 850 } 851 const route = data.handle.location.commitsRoute(data.ref_or_oid, data.ref_or_oid_value, data.base_oid) orelse return null; 852 const paged = route.withFrom(oid) orelse return null; 853 return paged.withSearch(data.search orelse return paged); 854 } 855 856 fn nextPageLink(page_arena: *std.heap.ArenaAllocator, data: *const Self, oid: []const u8) ![]const u8 { 857 const route = pageRoute(data, oid) orelse return error.RouteTooLong; 858 const url = try route.toUrl(page_arena); 859 return page_arena.allocator().print("a:{s}", .{url}); 860 } 861 862 // the "a:" link to the files tab at commit `oid` (an object ref), at its root 863 // directory, within `location`. 864 fn filesObjectLink(page_arena: *std.heap.ArenaAllocator, location: ui.RoutablePage.RepoLocation, oid: []const u8) ![]const u8 { 865 const route = location.filesRoute(.object, oid, "", 0) orelse return error.RouteTooLong; 866 const url = try route.toUrl(page_arena); 867 return page_arena.allocator().print("a:{s}", .{url}); 868 } 869 870 // the in-page "ai:" anchor for selecting a commit, showing its whole message 871 // when `message` is set. the href is only followed with js off. 872 fn commitRowLink(page_arena: *std.heap.ArenaAllocator, data: *const Self, commit: Commit, message: bool) ![]const u8 { 873 // a result roots the same results page at its commit, so the query 874 // survives following the row 875 if (data.search != null) { 876 const route = pageRoute(data, commit.oid) orelse return error.RouteTooLong; 877 return page_arena.allocator().print("ai:{s}", .{try route.toUrl(page_arena)}); 878 } 879 const route = (if (message) 880 data.handle.location.commitMessageRoute(.object, commit.oid, data.base_oid) 881 else 882 data.handle.location.commitsRoute(.object, commit.oid, data.base_oid)) orelse return error.RouteTooLong; 883 const url = try route.toUrl(page_arena); 884 return page_arena.allocator().print("ai:{s}", .{url}); 885 } 886 887 // the "a:" link to the page showing `oid`'s message on its own. 888 fn messageLink(page_arena: *std.heap.ArenaAllocator, data: *const Self, oid: []const u8) ![]const u8 { 889 const route = data.handle.location.commitMessageRoute(.object, oid, data.base_oid) orelse return error.RouteTooLong; 890 const url = try route.toUrl(page_arena); 891 return page_arena.allocator().print("a:{s}", .{url}); 892 } 893