╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ User.zig ─────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
447 // up from the first row reaches the search box 448 if (direction == .up and self.listScroll().atTop()) return self.focusHeader(root_focus); 449 try self.listScroll().input(allocator, key, root_focus); 450 } 451 452 // the repos narrowed to `text` from the first window. an empty box on an 453 // unsearched page has nothing to clear. 454 fn submit(self: *ReposView, text: []const u8) !void { 455 if (text.len == 0 and self.data.repos_search == null) return; 456 const route = reposRoute(self.data.user.name) orelse return; 457 try self.session.navigate(route.withSearch(text) orelse return); 458 } 459 460 fn searchBox(self: *ReposView) *ui.widget.SearchBox { 461 return &self.box.children.values()[header_index].widget.box.children.values()[0].widget.search_box; 462 } 463 464 fn listScroll(self: *ReposView) *ui.widget.FlowBox.Scroll { 465 return &self.box.children.values()[list_index].widget.flow_box_scroll; 466 } 467 468 fn headerActive(self: *ReposView) bool { 469 return self.box.getFocus().child_id == self.box.children.keys()[header_index]; 470 } 471 472 pub fn clearGrid(self: *ReposView) void { 473 self.box.clearGrid(); 474 } 475 476 pub fn getGrid(self: ReposView) ?Grid { 477 return self.box.getGrid(); 478 } 479 480 pub fn getFocus(self: *ReposView) *Focus { 481 return self.box.getFocus(); 482 } 483 484 // up leaves the tab from the search box 485 pub fn atTop(self: *ReposView) bool { 486 return self.headerActive(); 487 } 488 489 pub fn focusHeader(self: *ReposView, root_focus: *Focus) void { 490 root_focus.setFocus(self.searchBox().getFocus().id); 491 } 492 }; 493 494 // the first window of `name`'s repos 495 fn reposRoute(name: []const u8) ?ui.RoutablePage { 496 return .{ .user_repos = .{ .name = ui.RoutablePage.Array(evt.User.name_max_len).from(name) orelse return null } }; 497 } 498