╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Issues.zig ───────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
574 pub fn getSelectedIndex(self: *View) ?usize { 575 if (self.detailActive()) { 576 return if (self.detailScroll().y == 0 and self.paneTopFocused()) 0 else 1; 577 } 578 const lb = self.listBox(); 579 const cid = lb.getFocus().child_id orelse return null; 580 return lb.children.getIndex(cid); 581 } 582 583 // whether the focused element is the detail pane's topmost one, so up has 584 // nowhere further to go within the pane. 585 fn paneTopFocused(self: *View) bool { 586 const tf = self.tagFlow() orelse return true; 587 if (!self.tagsFocused()) return false; 588 const cid = tf.focus.child_id orelse return true; 589 const cur = tf.indexOfFocusId(cid) orelse return true; 590 return tf.rowStep(cur, false) == null; 591 } 592 }; 593 594 // the "a:" navigation link for the issues page filtered to the url-encoded 595 // `tag` and rooted at issue `id` within `identity` ("owner/name"). 596 fn issuesLink(page_arena: *std.heap.ArenaAllocator, identity: []const u8, tag: []const u8, id: []const u8) ![]const u8 { 597 const route = ui.RoutablePage.repoIssuesRoute(identity, tag, id) orelse return error.RouteTooLong; 598 const url = try route.urlAlloc(page_arena); 599 return std.fmt.allocPrint(page_arena.allocator(), "a:{s}", .{url}); 600 } 601 602 // the in-page "ai:" anchor for selecting issue `id` in `identity`'s list; the 603 // href is only followed with js off. 604 fn issueRowLink(page_arena: *std.heap.ArenaAllocator, identity: []const u8, id: []const u8) ![]const u8 { 605 const route = ui.RoutablePage.repoIssuesRoute(identity, "", id) orelse return error.RouteTooLong; 606 const url = try route.urlAlloc(page_arena); 607 return std.fmt.allocPrint(page_arena.allocator(), "ai:{s}", .{url}); 608 } 609 610 // the "a:" link to the issues list filtered to `tag` (raw; encoded here). 611 fn tagLink(page_arena: *std.heap.ArenaAllocator, identity: []const u8, tag: []const u8) ![]const u8 { 612 const encoded = try ui.urlEncodeRef(page_arena.allocator(), tag); 613 const route = ui.RoutablePage.repoIssuesRoute(identity, encoded, "") orelse return error.RouteTooLong; 614 const url = try route.urlAlloc(page_arena); 615 return std.fmt.allocPrint(page_arena.allocator(), "a:{s}", .{url}); 616 } 617