╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Commits.zig ──────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
802 803 // for the parent's "scroll up at the top jumps to the header" check. in the 804 // diff pane that means the first hunk is focused and the diff can't scroll up 805 // any further; otherwise up-arrow stays in the pane (scrolling or moving 806 // between hunks). when the list holds focus, report its selection directly. 807 pub fn getSelectedIndex(self: *View) ?usize { 808 if (self.diffActive()) { 809 const inner = self.diffInner(); 810 const cid = inner.getFocus().child_id orelse return 1; 811 const first_focused = inner.children.count() > 0 and cid == inner.children.keys()[0]; 812 return if (first_focused and self.diffScroll().y == 0) 0 else 1; 813 } 814 const lb = self.listBox(); 815 const cid = lb.getFocus().child_id orelse return null; 816 return lb.children.getIndex(cid); 817 } 818 }; 819 820 // the "a:" navigation link for the commits page walking from commit `oid` within 821 // `identity`, showing the selected commit's first `after` hunks (0 = default). 822 fn commitsLink(page_arena: *std.heap.ArenaAllocator, identity: []const u8, oid: []const u8, after: usize) ![]const u8 { 823 const route = ui.RoutablePage.repoCommitsRoute(identity, .object, oid, after) orelse return error.RouteTooLong; 824 const url = try route.urlAlloc(page_arena); 825 return std.fmt.allocPrint(page_arena.allocator(), "a:{s}", .{url}); 826 } 827 828 // the "a:" link to the files tab at commit `oid` (an object ref), at its root 829 // directory, within `identity` ("owner/name"). 830 fn filesObjectLink(page_arena: *std.heap.ArenaAllocator, identity: []const u8, oid: []const u8) ![]const u8 { 831 const route = ui.RoutablePage.repoFilesRoute(identity, .object, oid, "", 0) orelse return error.RouteTooLong; 832 const url = try route.urlAlloc(page_arena); 833 return std.fmt.allocPrint(page_arena.allocator(), "a:{s}", .{url}); 834 } 835 836 // the in-page "ai:" anchor for selecting `oid` in `identity`'s commit list. it 837 // points at the same route as commitsLink but the "ai:" prefix keeps wasm clicks 838 // in-page (crossPageLink ignores it); the href is only followed with js off. 839 fn commitRowLink(page_arena: *std.heap.ArenaAllocator, identity: []const u8, oid: []const u8) ![]const u8 { 840 const route = ui.RoutablePage.repoCommitsRoute(identity, .object, oid, 0) orelse return error.RouteTooLong; 841 const url = try route.urlAlloc(page_arena); 842 return std.fmt.allocPrint(page_arena.allocator(), "ai:{s}", .{url}); 843 } 844