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