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