╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Refs.zig ─────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
342 343 pub fn clearGrid(self: *View) void { 344 self.box.clearGrid(); 345 } 346 347 pub fn getGrid(self: View) ?Grid { 348 return self.box.getGrid(); 349 } 350 351 pub fn getFocus(self: *View) *Focus { 352 return self.box.getFocus(); 353 } 354 355 // the selected row's offset within the active column (0 = first row), so the 356 // parent knows when up should escape to the header. 357 pub fn getSelectedIndex(self: View) ?usize { 358 var copy = self; 359 const col = copy.activeColumn() orelse return null; 360 const cur_id = col.getFocus().child_id orelse return null; 361 return col.children.getIndex(cur_id); 362 } 363 }; 364 365 // the "a:" link to `kind`'s column paginated to `after` within `identity` 366 // ("owner/name"). the other column resets to its first window. 367 fn windowLink(page_arena: *std.heap.ArenaAllocator, identity: []const u8, kind: ui.RoutablePage.RefKind, after: usize) ![]const u8 { 368 const route = ui.RoutablePage.repoRefsRoute(identity, kind, after) orelse return error.RouteTooLong; 369 const url = try route.urlAlloc(page_arena); 370 return std.fmt.allocPrint(page_arena.allocator(), "a:{s}", .{url}); 371 } 372 373 // the "a:" link to the files tab at ref `name` (a branch or tag) within 374 // `identity` ("owner/name"), at its root directory. the name is percent-encoded 375 // since it can contain a '/'. 376 fn refLink(page_arena: *std.heap.ArenaAllocator, identity: []const u8, kind: ui.RoutablePage.RefKind, name: []const u8) ![]const u8 { 377 const aa = page_arena.allocator(); 378 const ref_or_oid: ui.RoutablePage.RefOrOid = switch (kind) { 379 .branch => .branch, 380 .tag => .tag, 381 }; 382 const value = try ui.urlEncodeRef(aa, name); 383 const route = ui.RoutablePage.repoFilesRoute(identity, ref_or_oid, value, "", 0) orelse return error.RouteTooLong; 384 const url = try route.urlAlloc(page_arena); 385 return std.fmt.allocPrint(aa, "a:{s}", .{url}); 386 } 387