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