╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Header.zig ───────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
217 }; 218 if (tb) |t| { 219 t.options.border_style = if (self.getFocus().child_id == id) .single else .hidden; 220 } 221 } 222 var scroll_constraint = constraint; 223 scroll_constraint.min_size.width = constraint.max_size.width orelse constraint.min_size.width; 224 try self.scroll.build(allocator, scroll_constraint, root_focus); 225 } 226 227 pub fn input(self: *View, allocator: std.mem.Allocator, key: Key, root_focus: *Focus) !void { 228 _ = allocator; 229 const current_tab = self.currentTabIndex() orelse return; 230 if (inp.moveTab(key, current_tab, self.tab_ids.count())) |new_tab| { 231 const tab_id = self.tab_ids.keys()[new_tab]; 232 root_focus.setFocus(tab_id); 233 const tab = self.scroll.child.box.children.get(tab_id) orelse return; 234 if (tab.rect) |rect| self.scroll.scrollToRect(rect); 235 } 236 } 237 238 pub fn clearGrid(self: *View) void { 239 self.scroll.clearGrid(); 240 } 241 242 pub fn getGrid(self: View) ?Grid { 243 return self.scroll.getGrid(); 244 } 245 246 pub fn getFocus(self: *View) *Focus { 247 return self.scroll.getFocus(); 248 } 249 250 pub fn getSelectedIndex(self: View) ?usize { 251 return self.currentTabIndex(); 252 } 253 254 fn currentTabIndex(self: View) ?usize { 255 const child_id = self.scroll.child.box.focus.child_id orelse return null; 256 return self.tab_ids.getIndex(child_id); 257 } 258 }; 259