╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Repo.zig ─────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
409 410 pub fn deinit(self: *View, allocator: std.mem.Allocator) void { 411 self.box.deinit(allocator); 412 } 413 414 pub fn build(self: *View, allocator: std.mem.Allocator, constraint: layout.Constraint, root_focus: *Focus) !void { 415 self.clearGrid(); 416 const header = &self.box.children.values()[header_index].widget.repo_header; 417 const stack = &self.box.children.values()[stack_index].widget.stack; 418 419 // each header tab maps 1:1 to a stack child by position 420 if (header.getSelectedIndex()) |index| 421 stack.getFocus().child_id = stack.children.keys()[index]; 422 try self.box.build(allocator, constraint, root_focus); 423 } 424 425 pub fn input(self: *View, allocator: std.mem.Allocator, key: Key, root_focus: *Focus) !void { 426 const stack = &self.box.children.values()[stack_index].widget.stack; 427 if (self.getFocus().child_id) |child_id| { 428 if (self.box.children.getIndex(child_id)) |current_index| { 429 const child = &self.box.children.values()[current_index].widget; 430 var index = current_index; 431 432 const direction = inp.vertDirection(key); 433 434 switch (direction) { 435 .up => { 436 switch (child.*) { 437 .repo_header => { 438 try child.input(allocator, key, root_focus); 439 }, 440 .stack => { 441 if (child.stack.getSelected()) |selected_widget| { 442 if (selected_widget.atTop(root_focus)) { 443 index = header_index; 444 } else { 445 try child.input(allocator, key, root_focus); 446 } 447 } 448 }, 449 else => {}, 450 } 451 }, 452 .down => { 453 switch (child.*) { 454 .repo_header => { 455 if (stack.getSelected()) |selected_widget| switch (selected_widget.*) { 456 .repo_files => |*v| if (v.focusCloneUrl(root_focus)) return, 457 .repo_commits => |*v| if (v.focusCloneUrl(root_focus)) return, 458 else => {}, 459 }; 460 index = stack_index; 461 }, 462 .stack => { 463 try child.input(allocator, key, root_focus); 464 }, 465 else => {}, 466 } 467 }, 468 .none => { 469 try child.input(allocator, key, root_focus); 470 }, 471 } 472 473 if (index != current_index) { 474 root_focus.setFocus(self.box.children.keys()[index]); 475 } 476 } 477 } 478 } 479 480 pub fn clearGrid(self: *View) void { 481 self.box.clearGrid(); 482 } 483 484 pub fn getGrid(self: View) ?Grid { 485 return self.box.getGrid(); 486 } 487 488 pub fn getFocus(self: *View) *Focus { 489 return self.box.getFocus(); 490 } 491 }; 492