╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Undo.zig ─────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
622 if (activated(root_focus, details.children.keys()[0], key) and self.data.can_undo and self.data.items[index].index > 0) { 623 self.requestUndo(ui.RoutablePage.repoUndoRoute(self.data.identity, self.data.items[index].index) orelse return error.RouteTooLong); 624 return; 625 } 626 } 627 if (key == .arrow_left) root_focus.setFocus(self.listScroll().getFocus().id) else if (inp.rowDelta(key, @intCast(details.children.count()))) |delta| ui.widget.moveRowFocus(details, self.detailScroll(), root_focus, delta); 628 } else if (inp.rowDelta(key, @intCast(self.listScroll().child.box.children.count()))) |delta| { 629 ui.widget.moveRowFocus(&self.listScroll().child.box, self.listScroll(), root_focus, delta); 630 } else switch (key) { 631 .arrow_right, .enter => if (self.selected() != null) { 632 root_focus.setFocus(self.detailScroll().getFocus().id); 633 }, 634 else => {}, 635 } 636 } 637 638 // the confirm button submits the form the web renderer posts 639 fn clearInput(self: *View, key: Key, root_focus: *Focus) !void { 640 const center = &self.box.children.values()[content_index].widget.center; 641 const button_id = center.child.box.getFocus().child_id orelse return; 642 if (!activated(root_focus, button_id, key) or !self.data.can_undo) return; 643 self.requestUndo(ui.RoutablePage.repoUndoClearRoute(self.data.identity) orelse return error.RouteTooLong); 644 } 645 646 fn contentAtTop(self: *View) bool { 647 const scroll = if (self.detailActive()) self.detailScroll() else self.listScroll(); 648 const rows = &scroll.child.box; 649 const id = rows.getFocus().child_id orelse return true; 650 return rows.children.getIndex(id) == 0 and scroll.y == 0; 651 } 652 653 // moving up from the sub header returns to the page's tabs 654 pub fn atTop(self: *View) bool { 655 return self.headerActive(); 656 } 657 658 // arriving from the page's tabs lands on the sub header, not the content 659 pub fn focusHeader(self: *View, root_focus: *Focus) bool { 660 root_focus.setFocus(self.headerBox().getFocus().id); 661 return true; 662 } 663 pub fn deinit(self: *View, allocator: std.mem.Allocator) void { 664 self.box.deinit(allocator); 665 } 666 pub fn clearGrid(self: *View) void { 667 self.box.clearGrid(); 668 } 669 pub fn getGrid(self: View) ?Grid { 670 return self.box.getGrid(); 671 } 672 pub fn getFocus(self: *View) *Focus { 673 return self.box.getFocus(); 674 } 675 }; 676