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