╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Repo.zig ─────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭ find file ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ ╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ │ │ │http│ ssh │ │ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯
638 const header = &self.box.children.values()[header_index].widget.repo_header; 639 const stack = &self.box.children.values()[stack_index].widget.stack; 640 641 // each header tab maps 1:1 to a stack child by position 642 if (header.getSelectedIndex()) |index| 643 stack.getFocus().child_id = stack.children.keys()[index]; 644 try self.box.build(allocator, constraint, root_focus); 645 } 646 647 pub fn input(self: *View, allocator: std.mem.Allocator, key: Key, root_focus: *Focus) !void { 648 const stack = &self.box.children.values()[stack_index].widget.stack; 649 if (self.getFocus().child_id) |child_id| { 650 if (self.box.children.getIndex(child_id)) |current_index| { 651 const child = &self.box.children.values()[current_index].widget; 652 var index = current_index; 653 654 const direction = inp.vertDirection(key); 655 656 switch (direction) { 657 .up => { 658 switch (child.*) { 659 .repo_header => { 660 try child.input(allocator, key, root_focus); 661 }, 662 .stack => { 663 if (child.stack.getSelected()) |selected_widget| { 664 if (selected_widget.atTop(root_focus)) { 665 index = header_index; 666 } else { 667 try child.input(allocator, key, root_focus); 668 } 669 } 670 }, 671 else => {}, 672 } 673 }, 674 .down => { 675 switch (child.*) { 676 .repo_header => { 677 if (stack.getSelected()) |selected_widget| switch (selected_widget.*) { 678 .repo_files => |*v| if (v.focusHeader(root_focus)) return, 679 .repo_commits => |*v| if (v.focusHeader(root_focus)) return, 680 .repo_refs => |*v| if (v.focusHeader(root_focus)) return, 681 .repo_events => |*v| if (v.focusHeader(root_focus)) return, 682 .repo_undo => |*v| if (v.focusHeader(root_focus)) return, 683 .repo_settings => |*v| if (v.focusHeader(root_focus)) return, 684 .user_notifications => |*v| if (v.focusHeader(root_focus)) return, 685 else => {}, 686 }; 687 index = stack_index; 688 }, 689 .stack => { 690 try child.input(allocator, key, root_focus); 691 }, 692 else => {}, 693 } 694 }, 695 .none => { 696 try child.input(allocator, key, root_focus); 697 }, 698 } 699 700 if (index != current_index) { 701 root_focus.setFocus(self.box.children.keys()[index]); 702 } 703 } 704 } 705 } 706 707 pub fn clearGrid(self: *View) void { 708 self.box.clearGrid(); 709 } 710 711 pub fn getGrid(self: View) ?Grid { 712 return self.box.getGrid(); 713 } 714 715 pub fn getFocus(self: *View) *Focus { 716 return self.box.getFocus(); 717 } 718 }; 719