╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Header.zig ───────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
107 pub fn input(self: *View, allocator: std.mem.Allocator, key: inp.Key, root_focus: *Focus) !void { 108 _ = allocator; 109 const current_tab = self.currentTabIndex() orelse return; 110 var new_tab = current_tab; 111 switch (key) { 112 .arrow_left => new_tab -|= 1, 113 .arrow_right => if (new_tab + 1 < self.tab_ids.len) { 114 new_tab += 1; 115 }, 116 else => {}, 117 } 118 if (new_tab != current_tab) { 119 try root_focus.setFocus(self.tab_ids[new_tab]); 120 } 121 } 122 123 pub fn clearGrid(self: *View) void { 124 self.box.clearGrid(); 125 } 126 127 pub fn getGrid(self: View) ?Grid { 128 return self.box.getGrid(); 129 } 130 131 pub fn getFocus(self: *View) *Focus { 132 return self.box.getFocus(); 133 } 134 135 pub fn getSelectedIndex(self: View) ?usize { 136 return self.currentTabIndex(); 137 } 138 139 fn currentTabIndex(self: View) ?usize { 140 const child_id = self.box.focus.child_id orelse return null; 141 for (self.tab_ids, 0..) |id, i| { 142 if (id == child_id) return i; 143 } 144 return null; 145 } 146 }; 147