╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Header.zig ───────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭ find file ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ ╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ │ │ │http│ ssh │ │ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯
466 try self.scroll.build(allocator, scroll_constraint, root_focus); 467 } 468 469 pub fn input(self: *View, allocator: std.mem.Allocator, key: Key, root_focus: *Focus) !void { 470 _ = allocator; 471 const current_tab = self.currentTabIndex() orelse return; 472 if (inp.moveTab(key, current_tab, self.tab_ids.count())) |new_tab| { 473 const tab_id = self.tab_ids.keys()[new_tab]; 474 root_focus.setFocus(tab_id); 475 const tabs_child = self.tabsChild(); 476 const tabs_rect = tabs_child.rect orelse return; 477 const tab = tabs_child.widget.box.children.get(tab_id) orelse return; 478 var rect = tab.rect orelse return; 479 rect.x += tabs_rect.x; 480 rect.y += tabs_rect.y; 481 self.scroll.scrollToRect(rect); 482 } 483 } 484 485 pub fn clearGrid(self: *View) void { 486 self.scroll.clearGrid(); 487 } 488 489 pub fn getGrid(self: View) ?Grid { 490 return self.scroll.getGrid(); 491 } 492 493 pub fn getFocus(self: *View) *Focus { 494 return self.scroll.getFocus(); 495 } 496 497 pub fn getSelectedIndex(self: View) ?usize { 498 return self.currentTabIndex(); 499 } 500 501 fn currentTabIndex(self: View) ?usize { 502 if (self.scroll.child.box.focus.child_id != self.tabs_id) return null; 503 const child_id = self.tabsChild().widget.box.focus.child_id orelse return null; 504 return self.tab_ids.getIndex(child_id); 505 } 506 507 fn tabsChild(self: *const View) *wgt.Box(ui.Widget).Child { 508 return self.scroll.child.box.children.getPtr(self.tabs_id) orelse unreachable; 509 } 510 }; 511