╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Commits.zig ──────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
735 } 736 737 pub fn clearGrid(self: *View) void { 738 self.box.clearGrid(); 739 } 740 741 pub fn getGrid(self: View) ?Grid { 742 return self.box.getGrid(); 743 } 744 745 pub fn getFocus(self: *View) *Focus { 746 return self.box.getFocus(); 747 } 748 749 // for the parent's "scroll up at the top jumps to the header" check. in the 750 // diff pane that means the first hunk is focused and the diff can't scroll up 751 // any further; otherwise up-arrow stays in the pane (scrolling or moving 752 // between hunks). when the list holds focus, report its selection directly. 753 pub fn getSelectedIndex(self: *View) ?usize { 754 if (self.diffActive()) { 755 const inner = self.diffInner(); 756 const cid = inner.getFocus().child_id orelse return 1; 757 const first_focused = inner.children.count() > 0 and cid == inner.children.keys()[0]; 758 return if (first_focused and self.diffScroll().y == 0) 0 else 1; 759 } 760 const lb = self.listBox(); 761 const cid = lb.getFocus().child_id orelse return null; 762 return lb.children.getIndex(cid); 763 } 764 }; 765 766 // the "a:" navigation link for the commits page starting at `start_oid` within 767 // `identity`, showing the selected commit's first `after` hunks (0 = default). 768 fn commitsLink(page_arena: *std.heap.ArenaAllocator, identity: []const u8, start_oid: []const u8, after: usize) ![]const u8 { 769 const route = ui.RoutablePage.repoCommitsRoute(identity, start_oid, after) orelse return error.RouteTooLong; 770 const url = try route.urlAlloc(page_arena); 771 return std.fmt.allocPrint(page_arena.allocator(), "a:{s}", .{url}); 772 } 773 774 // the in-page "ai:" anchor for selecting `oid` in `identity`'s commit list. it 775 // points at the same route as commitsLink but the "ai:" prefix keeps wasm clicks 776 // in-page (crossPageLink ignores it); the href is only followed with js off. 777 fn commitRowLink(page_arena: *std.heap.ArenaAllocator, identity: []const u8, oid: []const u8) ![]const u8 { 778 const route = ui.RoutablePage.repoCommitsRoute(identity, oid, 0) orelse return error.RouteTooLong; 779 const url = try route.urlAlloc(page_arena); 780 return std.fmt.allocPrint(page_arena.allocator(), "ai:{s}", .{url}); 781 } 782