╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Repo.zig ─────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
473 474 pub fn deinit(self: *View, allocator: std.mem.Allocator) void { 475 self.box.deinit(allocator); 476 } 477 478 pub fn build(self: *View, allocator: std.mem.Allocator, constraint: layout.Constraint, root_focus: *Focus) !void { 479 self.clearGrid(); 480 const header = &self.box.children.values()[header_index].widget.repo_header; 481 const stack = &self.box.children.values()[stack_index].widget.stack; 482 483 // each header tab maps 1:1 to a stack child by position 484 if (header.getSelectedIndex()) |index| 485 stack.getFocus().child_id = stack.children.keys()[index]; 486 try self.box.build(allocator, constraint, root_focus); 487 } 488 489 pub fn input(self: *View, allocator: std.mem.Allocator, key: Key, root_focus: *Focus) !void { 490 const stack = &self.box.children.values()[stack_index].widget.stack; 491 if (self.getFocus().child_id) |child_id| { 492 if (self.box.children.getIndex(child_id)) |current_index| { 493 const child = &self.box.children.values()[current_index].widget; 494 var index = current_index; 495 496 const direction = inp.vertDirection(key); 497 498 switch (direction) { 499 .up => { 500 switch (child.*) { 501 .repo_header => { 502 try child.input(allocator, key, root_focus); 503 }, 504 .stack => { 505 if (child.stack.getSelected()) |selected_widget| { 506 if (selected_widget.atTop(root_focus)) { 507 index = header_index; 508 } else { 509 try child.input(allocator, key, root_focus); 510 } 511 } 512 }, 513 else => {}, 514 } 515 }, 516 .down => { 517 switch (child.*) { 518 .repo_header => { 519 if (stack.getSelected()) |selected_widget| switch (selected_widget.*) { 520 .repo_files => |*v| if (v.focusHeader(root_focus)) return, 521 .repo_commits => |*v| if (v.focusHeader(root_focus)) return, 522 .repo_events => |*v| if (v.focusHeader(root_focus)) return, 523 .repo_undo => |*v| if (v.focusHeader(root_focus)) return, 524 else => {}, 525 }; 526 index = stack_index; 527 }, 528 .stack => { 529 try child.input(allocator, key, root_focus); 530 }, 531 else => {}, 532 } 533 }, 534 .none => { 535 try child.input(allocator, key, root_focus); 536 }, 537 } 538 539 if (index != current_index) { 540 root_focus.setFocus(self.box.children.keys()[index]); 541 } 542 } 543 } 544 } 545 546 pub fn clearGrid(self: *View) void { 547 self.box.clearGrid(); 548 } 549 550 pub fn getGrid(self: View) ?Grid { 551 return self.box.getGrid(); 552 } 553 554 pub fn getFocus(self: *View) *Focus { 555 return self.box.getFocus(); 556 } 557 }; 558