╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Refs.zig ─────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
321 if (target_col.children.values()[next].rect) |rect| target_scroll.scrollToRect(rect); 322 } 323 324 pub fn clearGrid(self: *View) void { 325 self.box.clearGrid(); 326 } 327 328 pub fn getGrid(self: View) ?Grid { 329 return self.box.getGrid(); 330 } 331 332 pub fn getFocus(self: *View) *Focus { 333 return self.box.getFocus(); 334 } 335 336 // the selected row's offset within the active column (0 = first row), so the 337 // parent knows when up should escape to the header. 338 pub fn getSelectedIndex(self: View) ?usize { 339 var copy = self; 340 const col = copy.activeColumn() orelse return null; 341 const cur_id = col.getFocus().child_id orelse return null; 342 return col.children.getIndex(cur_id); 343 } 344 }; 345 346 // the "a:" link to `kind`'s column paginated to `after` within `identity` 347 // ("owner/name"). the other column resets to its first window. 348 fn windowLink(page_arena: *std.heap.ArenaAllocator, identity: []const u8, kind: ui.RoutablePage.RefKind, after: usize) ![]const u8 { 349 const route = ui.RoutablePage.repoRefsRoute(identity, kind, after) orelse return error.RouteTooLong; 350 const url = try route.urlAlloc(page_arena); 351 return std.fmt.allocPrint(page_arena.allocator(), "a:{s}", .{url}); 352 } 353 354 // the "a:" link to the files tab at ref `name` (a branch or tag) within 355 // `identity` ("owner/name"), at its root directory. the name is percent-encoded 356 // since it can contain a '/'. 357 fn refLink(page_arena: *std.heap.ArenaAllocator, identity: []const u8, kind: ui.RoutablePage.RefKind, name: []const u8) ![]const u8 { 358 const aa = page_arena.allocator(); 359 const ref_or_oid: ui.RoutablePage.RefOrOid = switch (kind) { 360 .branch => .branch, 361 .tag => .tag, 362 }; 363 const value = try ui.urlEncodeRef(aa, name); 364 const route = ui.RoutablePage.repoFilesRoute(identity, ref_or_oid, value, "", 0) orelse return error.RouteTooLong; 365 const url = try route.urlAlloc(page_arena); 366 return std.fmt.allocPrint(aa, "a:{s}", .{url}); 367 } 368