╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Home.zig ─────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
126 if (self.getFocus().child_id) |child_id| { 127 if (self.box.children.getIndex(child_id)) |current_index| { 128 const child = &self.box.children.values()[current_index].widget; 129 var index = current_index; 130 131 const Direction = enum { up, down, none }; 132 const direction: Direction = switch (key) { 133 .arrow_up => .up, 134 .arrow_down => .down, 135 .mouse => |mouse| if (mouse.action == .scroll) 136 (if (mouse.action.scroll == .up) .up else .down) 137 else 138 .none, 139 else => .none, 140 }; 141 142 switch (direction) { 143 .up => { 144 switch (child.*) { 145 .home_header => { 146 try child.input(allocator, key, root_focus); 147 }, 148 .stack => { 149 if (child.stack.getSelected()) |selected_widget| { 150 const at_top = switch (selected_widget.*) { 151 .home_users => |*v| v.getSelectedIndex() == 0, 152 .home_repos => |*v| v.getSelectedIndex() == 0, 153 .home_ansi => |*v| v.getSelectedIndex() == 0, 154 .home_auth => |*v| v.getSelectedIndex() == 0, 155 else => false, 156 }; 157 if (at_top) { 158 index = header_index; 159 } else { 160 try child.input(allocator, key, root_focus); 161 } 162 } 163 }, 164 else => {}, 165 } 166 }, 167 .down => { 168 switch (child.*) { 169 .home_header => { 170 index = stack_index; 171 }, 172 .stack => { 173 try child.input(allocator, key, root_focus); 174 }, 175 else => {}, 176 } 177 }, 178 .none => { 179 try child.input(allocator, key, root_focus); 180 }, 181 } 182 183 if (index != current_index) { 184 try root_focus.setFocus(self.box.children.keys()[index]); 185 } 186 } 187 } 188 } 189 190 pub fn clearGrid(self: *View) void { 191 self.box.clearGrid(); 192 } 193 194 pub fn getGrid(self: View) ?Grid { 195 return self.box.getGrid(); 196 } 197 198 pub fn getFocus(self: *View) *Focus { 199 return self.box.getFocus(); 200 } 201 }; 202