╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Repo.zig ─────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
349 try self.box.build(allocator, constraint, root_focus); 350 } 351 352 pub fn input(self: *View, allocator: std.mem.Allocator, key: Key, root_focus: *Focus) !void { 353 if (self.getFocus().child_id) |child_id| { 354 if (self.box.children.getIndex(child_id)) |current_index| { 355 const child = &self.box.children.values()[current_index].widget; 356 var index = current_index; 357 358 const direction = inp.vertDirection(key); 359 360 switch (direction) { 361 .up => { 362 switch (child.*) { 363 .repo_header => { 364 try child.input(allocator, key, root_focus); 365 }, 366 .stack => { 367 if (child.stack.getSelected()) |selected_widget| { 368 const at_top = switch (selected_widget.*) { 369 .repo_files => |*v| v.getSelectedIndex() == 0, 370 .repo_commits => |*v| v.getSelectedIndex() == 0, 371 .repo_refs => |*v| v.getSelectedIndex() == 0, 372 .repo_issues => |*v| v.getSelectedIndex() == 0, 373 .home_settings => |*v| v.getSelectedIndex() == 0, 374 .home_auth => |*v| v.getSelectedIndex() == 0, 375 .quit => |*v| v.getSelectedIndex() == 0, 376 else => false, 377 }; 378 if (at_top) { 379 index = header_index; 380 } else { 381 try child.input(allocator, key, root_focus); 382 } 383 } 384 }, 385 else => {}, 386 } 387 }, 388 .down => { 389 switch (child.*) { 390 .repo_header => { 391 index = stack_index; 392 }, 393 .stack => { 394 try child.input(allocator, key, root_focus); 395 }, 396 else => {}, 397 } 398 }, 399 .none => { 400 try child.input(allocator, key, root_focus); 401 }, 402 } 403 404 if (index != current_index) { 405 root_focus.setFocus(self.box.children.keys()[index]); 406 } 407 } 408 } 409 } 410 411 pub fn clearGrid(self: *View) void { 412 self.box.clearGrid(); 413 } 414 415 pub fn getGrid(self: View) ?Grid { 416 return self.box.getGrid(); 417 } 418 419 pub fn getFocus(self: *View) *Focus { 420 return self.box.getFocus(); 421 } 422 }; 423