╭ changed ──────────────╮ │src/ui/Repo/Commits.zig│ ╰───────────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭──────────╮ │← previous│ ╰──────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │841 const url = try route.toUrl(page_arena); │ │842 return std.fmt.allocPrint(page_arena.allocator(), "a:{s}", .{url}); │ │843 } │ │730 - │ │731 -// the clone url shown above the log. │ │732 -pub const Header = struct { │ │733 - pub const View = struct { │ │734 - box: wgt.Box(ui.Widget), │ │735 - │ │736 - pub fn init(allocator: std.mem.Allocator, session: *ui.Session, location: ui.RoutablePage.RepoLocation) !Header.View { │ │737 - var box = try wgt.Box(ui.Widget).init(allocator, .{ .border_style = null, .direction = .horiz }); │ │738 - errdefer box.deinit(allocator); │ │844 │ │740 - // the spacer pushes the clone url to the right edge. │ │741 - { │ │742 - var spacer = try ui.widget.Spacer.init(allocator); │ │743 - errdefer spacer.deinit(allocator); │ │744 - try box.children.put(allocator, spacer.getFocus().id, .{ .widget = .{ .spacer = spacer }, .rect = null, .min_size = null }); │ │745 - } │ │746 - │ │747 - if (session.data.host_kind == .server) { │ │748 - if (try ui.widget.CopyableText.initClone(allocator, session, location)) |value| { │ │749 - var clone_url = value; │ │750 - errdefer clone_url.deinit(allocator); │ │751 - const min_width = clone_url.minWidth(); │ │752 - box.getFocus().child_id = clone_url.getFocus().id; │ │753 - 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 } });│ │754 - } │ │755 - } │ │756 - │ │757 - return .{ .box = box }; │ │758 - } │ │759 - │ │760 - pub fn deinit(self: *Header.View, allocator: std.mem.Allocator) void { │ │761 - self.box.deinit(allocator); │ │762 - } │ │763 - │ │764 - pub fn build(self: *Header.View, allocator: std.mem.Allocator, constraint: layout.Constraint, root_focus: *Focus) !void { │ │765 - self.clearGrid(); │ │766 - try self.box.build(allocator, constraint, root_focus); │ │767 - } │ │768 - │ │769 - pub fn input(self: *Header.View, allocator: std.mem.Allocator, key: Key, root_focus: *Focus) !void { │ │770 - const clone_url = self.cloneUrl() orelse return; │ │771 - try clone_url.input(allocator, key, root_focus); │ │772 - } │ │773 - │ │774 - pub fn focusCloneUrl(self: *Header.View, root_focus: *Focus) bool { │ │775 - const clone_url = self.cloneUrl() orelse return false; │ │776 - root_focus.setFocus(clone_url.getFocus().id); │ │777 - return true; │ │778 - } │ │779 - │ │780 - pub fn hasCloneUrl(self: *Header.View) bool { │ │781 - return self.cloneUrl() != null; │ │782 - } │ │783 - │ │784 - fn cloneUrl(self: *Header.View) ?*ui.widget.CopyableText { │ │785 - for (self.box.children.values()) |*child| switch (child.widget) { │ │786 - .copyable_text => |*copyable_text| return copyable_text, │ │787 - else => {}, │ │788 - }; │ │789 - return null; │ │790 - } │ │791 - │ │792 - pub fn clearGrid(self: *Header.View) void { │ │793 - self.box.clearGrid(); │ │794 - } │ │795 - │ │796 - pub fn getGrid(self: Header.View) ?Grid { │ │797 - return self.box.getGrid(); │ │798 - } │ │799 - │ │800 - pub fn getFocus(self: *Header.View) *Focus { │ │801 - return self.box.getFocus(); │ │802 - } │ │803 - }; │ │804 -}; │ │805 - │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯