╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Commits.zig ──────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
747 const cur: isize = @intCast(lb.children.getIndex(cur_id) orelse return); 748 const last: isize = @intCast(keys.len - 1); 749 const next: usize = @intCast(std.math.clamp(cur + delta, 0, last)); 750 if (next == @as(usize, @intCast(cur))) return; 751 try root_focus.setFocus(keys[next]); 752 if (lb.children.values()[next].rect) |rect| self.listScroll().scrollToRect(rect); 753 } 754 755 pub fn clearGrid(self: *View) void { 756 self.box.clearGrid(); 757 } 758 759 pub fn getGrid(self: View) ?Grid { 760 return self.box.getGrid(); 761 } 762 763 pub fn getFocus(self: *View) *Focus { 764 return self.box.getFocus(); 765 } 766 767 // for the parent's "scroll up at the top jumps to the header" check. in the 768 // diff pane that means the first hunk is focused and the diff can't scroll up 769 // any further; otherwise up-arrow stays in the pane (scrolling or moving 770 // between hunks). when the list holds focus, report its selection directly. 771 pub fn getSelectedIndex(self: *View) ?usize { 772 if (self.diffActive()) { 773 const inner = self.diffInner(); 774 const cid = inner.getFocus().child_id orelse return 1; 775 const first_focused = inner.children.count() > 0 and cid == inner.children.keys()[0]; 776 return if (first_focused and self.diffScroll().y == 0) 0 else 1; 777 } 778 const lb = self.listBox(); 779 const cid = lb.getFocus().child_id orelse return null; 780 return lb.children.getIndex(cid); 781 } 782 }; 783 784 // the "a:" navigation link for the commits page walking from commit `oid` within 785 // `identity`, showing the selected commit's first `after` hunks (0 = default). 786 fn commitsLink(page_arena: *std.heap.ArenaAllocator, identity: []const u8, oid: []const u8, after: usize) ![]const u8 { 787 const route = ui.RoutablePage.repoCommitsRoute(identity, .object, oid, after) orelse return error.RouteTooLong; 788 const url = try route.urlAlloc(page_arena); 789 return std.fmt.allocPrint(page_arena.allocator(), "a:{s}", .{url}); 790 } 791 792 // the in-page "ai:" anchor for selecting `oid` in `identity`'s commit list. it 793 // points at the same route as commitsLink but the "ai:" prefix keeps wasm clicks 794 // in-page (crossPageLink ignores it); the href is only followed with js off. 795 fn commitRowLink(page_arena: *std.heap.ArenaAllocator, identity: []const u8, oid: []const u8) ![]const u8 { 796 const route = ui.RoutablePage.repoCommitsRoute(identity, .object, oid, 0) orelse return error.RouteTooLong; 797 const url = try route.urlAlloc(page_arena); 798 return std.fmt.allocPrint(page_arena.allocator(), "ai:{s}", .{url}); 799 } 800