╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Refs.zig ─────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭ find file ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ ╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ │ │ │http│ ssh │ │ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯
413 414 fn focusName(self: *View, index: usize, item: usize, root_focus: *Focus) void { 415 const flow = self.flowAt(index); 416 root_focus.setFocus(flow.text_boxes.items[item].getFocus().id); 417 // the browser scrolls natively; the terminal brings the name into view 418 if (self.session.is_terminal and item < flow.rects.items.len) self.scrollAt(index).scrollToRect(flow.rects.items[item]); 419 } 420 421 pub fn clearGrid(self: *View) void { 422 self.box.clearGrid(); 423 } 424 425 pub fn getGrid(self: View) ?Grid { 426 return self.box.getGrid(); 427 } 428 429 pub fn getFocus(self: *View) *Focus { 430 return self.box.getFocus(); 431 } 432 433 // up leaves the tab from the search box 434 pub fn atTop(self: *View) bool { 435 return self.headerActive(); 436 } 437 438 pub fn focusHeader(self: *View, root_focus: *Focus) bool { 439 root_focus.setFocus(self.searchBox().getFocus().id); 440 return true; 441 } 442 }; 443 444 // the "a:" link to `kind`'s column windowed from ref `name` (raw; "" = the 445 // first window) within `identity` ("owner:name"). the other column resets to 446 // its first window. 447 fn windowLink(page_arena: *std.heap.ArenaAllocator, identity: []const u8, kind: ui.RoutablePage.RefKind, name: []const u8, search: []const u8) ![]const u8 { 448 const encoded = try ui.urlEncodeRef(page_arena.allocator(), name); 449 const window = ui.RoutablePage.repoRefsRoute(identity, kind, encoded) orelse return error.RouteTooLong; 450 const route = window.withSearch(search) orelse return error.RouteTooLong; 451 const url = try route.toUrl(page_arena); 452 return page_arena.allocator().print("a:{s}", .{url}); 453 } 454 455 // the "a:" link to the files tab at ref `name` (a branch or tag) within 456 // `identity` ("owner:name"), at its root directory. the name is percent-encoded 457 // since it can contain a '/'. 458 fn refLink(page_arena: *std.heap.ArenaAllocator, identity: []const u8, kind: ui.RoutablePage.RefKind, name: []const u8) ![]const u8 { 459 const aa = page_arena.allocator(); 460 const ref_or_oid: ui.RoutablePage.RefOrOid = switch (kind) { 461 .branch => .branch, 462 .tag => .tag, 463 }; 464 const value = try ui.urlEncodeRef(aa, name); 465 const route = ui.RoutablePage.repoFilesRoute(identity, ref_or_oid, value, "", 0) orelse return error.RouteTooLong; 466 const url = try route.toUrl(page_arena); 467 return aa.print("a:{s}", .{url}); 468 } 469