╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Repo.zig ─────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
541 } 542 543 pub fn deinit(self: *View, allocator: std.mem.Allocator) void { 544 self.box.deinit(allocator); 545 } 546 547 pub fn build(self: *View, allocator: std.mem.Allocator, constraint: layout.Constraint, root_focus: *Focus) !void { 548 self.clearGrid(); 549 const header = &self.box.children.values()[header_index].widget.repo_header; 550 const stack = &self.box.children.values()[stack_index].widget.stack; 551 552 // each header tab maps 1:1 to a stack child by position 553 if (header.getSelectedIndex()) |index| 554 stack.getFocus().child_id = stack.children.keys()[index]; 555 try self.box.build(allocator, constraint, root_focus); 556 } 557 558 pub fn input(self: *View, allocator: std.mem.Allocator, key: Key, root_focus: *Focus) !void { 559 const stack = &self.box.children.values()[stack_index].widget.stack; 560 if (self.getFocus().child_id) |child_id| { 561 if (self.box.children.getIndex(child_id)) |current_index| { 562 const child = &self.box.children.values()[current_index].widget; 563 var index = current_index; 564 565 const direction = inp.vertDirection(key); 566 567 switch (direction) { 568 .up => { 569 switch (child.*) { 570 .repo_header => { 571 try child.input(allocator, key, root_focus); 572 }, 573 .stack => { 574 if (child.stack.getSelected()) |selected_widget| { 575 if (selected_widget.atTop(root_focus)) { 576 index = header_index; 577 } else { 578 try child.input(allocator, key, root_focus); 579 } 580 } 581 }, 582 else => {}, 583 } 584 }, 585 .down => { 586 switch (child.*) { 587 .repo_header => { 588 if (stack.getSelected()) |selected_widget| switch (selected_widget.*) { 589 .repo_files => |*v| if (v.focusHeader(root_focus)) return, 590 .repo_commits => |*v| if (v.focusHeader(root_focus)) return, 591 .repo_refs => |*v| if (v.focusHeader(root_focus)) return, 592 .repo_events => |*v| if (v.focusHeader(root_focus)) return, 593 .repo_undo => |*v| if (v.focusHeader(root_focus)) return, 594 .repo_settings => |*v| if (v.focusHeader(root_focus)) return, 595 else => {}, 596 }; 597 index = stack_index; 598 }, 599 .stack => { 600 try child.input(allocator, key, root_focus); 601 }, 602 else => {}, 603 } 604 }, 605 .none => { 606 try child.input(allocator, key, root_focus); 607 }, 608 } 609 610 if (index != current_index) { 611 root_focus.setFocus(self.box.children.keys()[index]); 612 } 613 } 614 } 615 } 616 617 pub fn clearGrid(self: *View) void { 618 self.box.clearGrid(); 619 } 620 621 pub fn getGrid(self: View) ?Grid { 622 return self.box.getGrid(); 623 } 624 625 pub fn getFocus(self: *View) *Focus { 626 return self.box.getFocus(); 627 } 628 }; 629