╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ User.zig ─────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
185 if (self.getFocus().child_id) |child_id| { 186 if (self.box.children.getIndex(child_id)) |current_index| { 187 const child = &self.box.children.values()[current_index].widget; 188 var index = current_index; 189 190 const Direction = enum { up, down, none }; 191 const direction: Direction = switch (key) { 192 .arrow_up => .up, 193 .arrow_down => .down, 194 .mouse => |mouse| if (mouse.action == .scroll) 195 (if (mouse.action.scroll == .up) .up else .down) 196 else 197 .none, 198 else => .none, 199 }; 200 201 switch (direction) { 202 .up => { 203 switch (child.*) { 204 .user_header => { 205 try child.input(allocator, key, root_focus); 206 }, 207 .stack => { 208 if (child.stack.getSelected()) |selected_widget| { 209 const at_top = switch (selected_widget.*) { 210 .flow_box_scroll => |*v| v.getSelectedIndex() == 0, 211 .home_settings => |*v| v.getSelectedIndex() == 0, 212 .home_auth => |*v| v.getSelectedIndex() == 0, 213 .quit => |*v| v.getSelectedIndex() == 0, 214 else => false, 215 }; 216 if (at_top) { 217 index = header_index; 218 } else { 219 try child.input(allocator, key, root_focus); 220 } 221 } 222 }, 223 else => {}, 224 } 225 }, 226 .down => { 227 switch (child.*) { 228 .user_header => { 229 index = stack_index; 230 }, 231 .stack => { 232 try child.input(allocator, key, root_focus); 233 }, 234 else => {}, 235 } 236 }, 237 .none => { 238 try child.input(allocator, key, root_focus); 239 }, 240 } 241 242 if (index != current_index) { 243 try root_focus.setFocus(self.box.children.keys()[index]); 244 } 245 } 246 } 247 } 248 249 pub fn clearGrid(self: *View) void { 250 self.box.clearGrid(); 251 } 252 253 pub fn getGrid(self: View) ?Grid { 254 return self.box.getGrid(); 255 } 256 257 pub fn getFocus(self: *View) *Focus { 258 return self.box.getFocus(); 259 } 260 }; 261