╭──────────╮ │← previous│ ╰──────────╯ ╭ changed ────────────╮ │src/ui/Repo/Files.zig│ ╰─────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────╮ │736 } │ │737 │ │738 pub fn input(self: *View, allocator: std.mem.Allocator, key: Key, root_focus: *Focus) !void {│ │739 + if (self.data.no_commits) return self.box.input(allocator, key, root_focus); │ │740 // scrolling crosses the sub header boundary the same way arrows do │ │741 const direction = inp.vertDirection(key); │ │742 if (self.headerActive()) { │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────╮ │945 │ │946 // only the header's own row sits directly below the repository header. │ │947 pub fn atTop(self: *View) bool { │ │948 + if (self.data.no_commits) return true; │ │949 const focusable = if (self.header()) |header_view| header_view.hasFocusable() else false;│ │950 return self.headerActive() or (!focusable and self.contentAtTop()); │ │951 } │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭ changed ────────╮ │src/ui/widget.zig│ ╰─────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │190 root_focus.setFocus(row.children.keys()[target]); │ │191 return true; │ │192 } │ │193 + │ │194 +// a repo tab's placeholder while the repo has no commits, with the remote to │ │195 +// push to for a viewer who can │ │196 +pub fn initNoCommits(allocator: std.mem.Allocator, session: *ui.Session, handle: ui.RepoHandle) !Center { │ │197 + var box = try wgt.Box(Widget).init(allocator, .{ .border_style = null, .direction = .vert }); │ │198 + errdefer box.deinit(allocator); │ │199 + │ │200 + // built first so the text can center over it │ │201 + var remote_maybe: ?CopyableText = if (session.data.host_kind == .server and handle.canWrite()) if (session.data.git_ssh_port) |port| blk: { │ │202 + // only repo pages flag a repo without commits │ │203 + const identity = switch (handle.location) { │ │204 + .repo => |identity| identity, │ │205 + .fork => unreachable, │ │206 + }; │ │207 + const aa = session.page_arena.allocator(); │ │208 + const url = try std.fmt.allocPrint(aa, "ssh://localhost:{d}/repo/{s}", .{ port, identity }); │ │209 + break :blk try CopyableText.init(allocator, session, &.{.{ │ │210 + .text = url, │ │211 + .copyable_text = try std.fmt.allocPrint(aa, "git remote add origin {s}", .{url}), │ │212 + .label = " git remote add origin ", │ │213 + }}, 0); │ │214 + } else null else null; │ │215 + errdefer if (remote_maybe) |*remote| remote.deinit(allocator); │ │216 │ │217 + { │ │218 + var text_widget: Widget = blk: { │ │219 + var text_box = try wgt.TextBox.init(allocator, "no commits yet", .{ .border_style = null, .wrap_kind = .none }); │ │220 + errdefer text_box.deinit(allocator); │ │221 + break :blk if (remote_maybe != null) .{ .center = try Center.init(allocator, .{ .text_box = text_box }) } else .{ .text_box = text_box }; │ │222 + }; │ │223 + errdefer text_widget.deinit(allocator); │ │224 + // over the remote widget, the text centers across its width │ │225 + const size: ?layout.MaybeSize = if (remote_maybe) |*remote| .{ .width = remote.minWidth(), .height = 1 } else null; │ │226 + try box.children.put(allocator, text_widget.getFocus().id, .{ .widget = text_widget, .rect = null, .min_size = size, .max_size = size }); │ │227 + } │ │228 + │ │229 + if (remote_maybe) |*remote| { │ │230 + { │ │231 + var gap = try wgt.Text.init(allocator, " "); │ │232 + errdefer gap.deinit(allocator); │ │233 + try box.children.put(allocator, gap.getFocus().id, .{ .widget = .{ .text = gap }, .rect = null, .min_size = null }); │ │234 + } │ │235 + const min_width = remote.minWidth(); │ │236 + box.getFocus().child_id = remote.getFocus().id; │ │237 + try box.children.put(allocator, remote.getFocus().id, .{ .widget = .{ .copyable_text = remote.* }, .rect = null, .min_size = .{ .width = min_width, .height = 3 }, .max_size = .{ .width = min_width, .height = 3 } });│ │238 + // the box owns it now │ │239 + remote_maybe = null; │ │240 + } │ │241 + │ │242 + return Center.init(allocator, .{ .box = box }); │ │243 +} │ │244 + │ │245 pub const FlowBox = struct { │ │246 focus: *Focus, │ │247 grid: ?Grid, │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯