╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Commits.zig ──────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
883 const lb = self.listBox(); 884 const cid = lb.getFocus().child_id orelse return true; 885 return lb.children.getIndex(cid) == 0; 886 } 887 888 // only the header's own row sits directly below the repository header. 889 pub fn atTop(self: *View) bool { 890 if (self.data.no_commits) return true; 891 const focusable = if (self.header()) |header_view| header_view.hasFocusable() else false; 892 return self.headerActive() or (!focusable and self.contentAtTop()); 893 } 894 895 pub fn focusHeader(self: *View, root_focus: *Focus) bool { 896 const header_view = self.header() orelse return false; 897 return header_view.focusHeader(root_focus); 898 } 899 }; 900 901 // the "a:" navigation link for the commits page walking from commit `oid` within 902 // `data.handle.location`, windowing the selected commit's diff from hunk `start`, filtered 903 // to `path` ("" = every file). 904 fn commitsLink(page_arena: *std.heap.ArenaAllocator, data: *const Self, oid: []const u8, start: usize, path: []const u8) ![]const u8 { 905 const route = data.handle.location.commitsRoute(.object, oid, start, path, data.base_oid) orelse return error.RouteTooLong; 906 const url = try route.toUrl(page_arena); 907 return std.fmt.allocPrint(page_arena.allocator(), "a:{s}", .{url}); 908 } 909 910 // this list's page starting at `oid`: a repo's branch or tag keeps its ref (and 911 // its query) and moves `from` along, so the search box survives paging. a fork 912 // or an object view roots the page at the commit itself. 913 fn pageRoute(data: *const Self, oid: []const u8) ?ui.RoutablePage { 914 if (data.handle.location != .repo or data.ref_or_oid == .object) { 915 return data.handle.location.commitsRoute(.object, oid, 0, "", data.base_oid); 916 } 917 const route = data.handle.location.commitsRoute(data.ref_or_oid, data.ref_or_oid_value, 0, "", data.base_oid) orelse return null; 918 const paged = route.withFrom(oid) orelse return null; 919 return paged.withSearch(data.search orelse return paged); 920 } 921 922 fn nextPageLink(page_arena: *std.heap.ArenaAllocator, data: *const Self, oid: []const u8) ![]const u8 { 923 const route = pageRoute(data, oid) orelse return error.RouteTooLong; 924 const url = try route.toUrl(page_arena); 925 return std.fmt.allocPrint(page_arena.allocator(), "a:{s}", .{url}); 926 } 927 928 // the "a:" link to the files tab at commit `oid` (an object ref), at its root 929 // directory, within `location`. 930 fn filesObjectLink(page_arena: *std.heap.ArenaAllocator, location: ui.RoutablePage.RepoLocation, oid: []const u8) ![]const u8 { 931 const route = location.filesRoute(.object, oid, "", 0) orelse return error.RouteTooLong; 932 const url = try route.toUrl(page_arena); 933 return std.fmt.allocPrint(page_arena.allocator(), "a:{s}", .{url}); 934 } 935 936 // the in-page "ai:" anchor for selecting a commit with its current pane content 937 // and window. the href is only followed with js off. 938 fn commitRowLink(page_arena: *std.heap.ArenaAllocator, data: *const Self, commit: Commit, content: Content) ![]const u8 { 939 // a result roots the same results page at its commit, so the query 940 // survives following the row 941 if (data.search != null) { 942 const route = pageRoute(data, commit.oid) orelse return error.RouteTooLong; 943 return std.fmt.allocPrint(page_arena.allocator(), "ai:{s}", .{try route.toUrl(page_arena)}); 944 } 945 const route = (switch (content) { 946 .message => data.handle.location.commitMessageRoute(.object, commit.oid, data.base_oid), 947 .diff => |diff| data.handle.location.commitsRoute(.object, commit.oid, commit.window.start, diff.path, data.base_oid), 948 }) orelse return error.RouteTooLong; 949 const url = try route.toUrl(page_arena); 950 return std.fmt.allocPrint(page_arena.allocator(), "ai:{s}", .{url}); 951 } 952 953 // the "a:" link to the page showing `oid`'s message on its own. 954 fn messageLink(page_arena: *std.heap.ArenaAllocator, data: *const Self, oid: []const u8) ![]const u8 { 955 const route = data.handle.location.commitMessageRoute(.object, oid, data.base_oid) orelse return error.RouteTooLong; 956 const url = try route.toUrl(page_arena); 957 return std.fmt.allocPrint(page_arena.allocator(), "a:{s}", .{url}); 958 } 959