╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Commits.zig ──────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
784 } 785 786 // return to the list. 787 fn focusList(self: *View, root_focus: *Focus) !void { 788 root_focus.setFocus(self.listScroll().getFocus().id); 789 } 790 791 pub fn clearGrid(self: *View) void { 792 self.box.clearGrid(); 793 } 794 795 pub fn getGrid(self: View) ?Grid { 796 return self.box.getGrid(); 797 } 798 799 pub fn getFocus(self: *View) *Focus { 800 return self.box.getFocus(); 801 } 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