╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Commits.zig ──────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
759 const min_width = clone_url.minWidth(); 760 box.getFocus().child_id = clone_url.getFocus().id; 761 try box.children.put(allocator, clone_url.getFocus().id, .{ .widget = .{ .copyable_text = clone_url }, .rect = null, .min_size = .{ .width = min_width, .height = 3 }, .max_size = .{ .width = min_width, .height = 3 } }); 762 } 763 } 764 765 var spacer = try ui.widget.Spacer.init(allocator); 766 errdefer spacer.deinit(allocator); 767 try box.children.put(allocator, spacer.getFocus().id, .{ .widget = .{ .spacer = spacer }, .rect = null, .min_size = null }); 768 769 var text_box = try wgt.TextBox.init(allocator, data.content, .{ .border_style = .hidden, .wrap_kind = .none }); 770 errdefer text_box.deinit(allocator); 771 try box.children.put(allocator, text_box.getFocus().id, .{ .widget = .{ .text_box = text_box }, .rect = null, .min_size = null, .flex = .shrink }); 772 773 return .{ .box = box, .data = data }; 774 } 775 776 pub fn deinit(self: *Header.View, allocator: std.mem.Allocator) void { 777 self.box.deinit(allocator); 778 } 779 780 pub fn build(self: *Header.View, allocator: std.mem.Allocator, constraint: layout.Constraint, root_focus: *Focus) !void { 781 self.clearGrid(); 782 try self.box.build(allocator, constraint, root_focus); 783 } 784 785 pub fn input(self: *Header.View, allocator: std.mem.Allocator, key: Key, root_focus: *Focus) !void { 786 const clone_url = self.cloneUrl() orelse return; 787 try clone_url.input(allocator, key, root_focus); 788 } 789 790 pub fn focusCloneUrl(self: *Header.View, root_focus: *Focus) bool { 791 const clone_url = self.cloneUrl() orelse return false; 792 root_focus.setFocus(clone_url.getFocus().id); 793 return true; 794 } 795 796 pub fn hasCloneUrl(self: *Header.View) bool { 797 return self.cloneUrl() != null; 798 } 799 800 fn cloneUrl(self: *Header.View) ?*ui.widget.CopyableText { 801 for (self.box.children.values()) |*child| switch (child.widget) { 802 .copyable_text => |*copyable_text| return copyable_text, 803 else => {}, 804 }; 805 return null; 806 } 807 808 pub fn clearGrid(self: *Header.View) void { 809 self.box.clearGrid(); 810 } 811 812 pub fn getGrid(self: Header.View) ?Grid { 813 return self.box.getGrid(); 814 } 815 816 pub fn getFocus(self: *Header.View) *Focus { 817 return self.box.getFocus(); 818 } 819 }; 820 }; 821