╭──────────╮ │← previous│ ╰──────────╯ ╭ changed ────────────╮ │src/ui/Repo/Files.zig│ ╰─────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │592 } │ │593 │ │594 pub fn input(self: *View, allocator: std.mem.Allocator, key: Key, root_focus: *Focus) !void { │ │587 - _ = allocator; │ │595 + if (self.headerActive()) { │ │596 + if (key == .arrow_down) { │ │597 + root_focus.setFocus(self.contentBox().getFocus().id); │ │598 + } else { │ │599 + try self.header().input(allocator, key, root_focus); │ │600 + } │ │601 + return; │ │602 + } │ │603 + if (key == .arrow_up and self.contentAtTop() and self.header().focusCloneUrl(root_focus)) return;│ │604 if (self.detailActive()) { │ │605 try self.detailInput(key, root_focus); │ │606 } else { │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │756 return self.box.getFocus(); │ │757 } │ │758 │ │743 - // for the parent's "up at the top jumps to the header" check: report 0 │ │744 - // whenever up would otherwise do nothing here. │ │745 - pub fn getSelectedIndex(self: *View) ?usize { │ │759 + fn contentAtTop(self: *View) bool { │ │760 if (self.detailActive()) { │ │747 - if (self.detailOuter().getFocus().child_id == self.navBox().getFocus().id) return 0; │ │748 - if (self.navBox().children.count() == 0 and │ │749 - (!self.session.is_terminal or self.detailScroll().y == 0)) return 0; │ │750 - return 1; │ │761 + if (self.detailOuter().getFocus().child_id == self.navBox().getFocus().id) return true;│ │762 + return self.navBox().children.count() == 0 and │ │763 + (!self.session.is_terminal or self.detailScroll().y == 0); │ │764 } │ │765 const lb = self.listBox(); │ │753 - const cid = lb.getFocus().child_id orelse return null; │ │754 - return lb.children.getIndex(cid); │ │766 + const cid = lb.getFocus().child_id orelse return true; │ │767 + return lb.children.getIndex(cid) == 0; │ │768 + } │ │769 + │ │770 + // only the clone-url row sits directly below the repository header. │ │771 + pub fn getSelectedIndex(self: *View) ?usize { │ │772 + if (self.headerActive()) return 0; │ │773 + return if (self.header().hasCloneUrl() or !self.contentAtTop()) 1 else 0; │ │774 + } │ │775 + │ │776 + pub fn focusCloneUrl(self: *View, root_focus: *Focus) bool { │ │777 + return self.header().focusCloneUrl(root_focus); │ │778 } │ │779 }; │ │780 │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────╮ │856 return dir[0..slash]; │ │857 } │ │858 │ │836 -// the "viewing <ref_or_oid> <value>" banner shown above the listing.│ │859 +// the "<ref_or_oid> <value>" banner shown above the listing. │ │860 pub const Header = struct { │ │861 content: []const u8, │ │862 │ ╰──────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │864 pub fn init(aa: std.mem.Allocator, ref_or_oid: ui.RoutablePage.RefOrOid, value: []const u8) !Header {│ │865 const decoded = std.Uri.percentDecodeInPlace(try aa.dupe(u8, value)); │ │866 return .{ │ │844 - .content = try std.fmt.allocPrint(aa, "viewing {s} {s}", .{ @tagName(ref_or_oid), decoded }),│ │867 + .content = try std.fmt.allocPrint(aa, "{s} {s}", .{ @tagName(ref_or_oid), decoded }), │ │868 }; │ │869 } │ │870 │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │872 box: wgt.Box(ui.Widget), │ │873 data: *const Header, │ │874 │ │852 - pub fn init(allocator: std.mem.Allocator, data: *const Header, session: *ui.Session) !Header.View { │ │853 - _ = session; │ │875 + pub fn init(allocator: std.mem.Allocator, data: *const Header, session: *ui.Session, identity: []const u8) !Header.View { │ │876 var box = try wgt.Box(ui.Widget).init(allocator, .{ .border_style = null, .direction = .horiz }); │ │877 errdefer box.deinit(allocator); │ │878 + │ │879 + if (!session.data.is_local and session.data.clone_http_port != null and session.data.clone_ssh_port != null) { │ │880 + var clone_url = try ui.CloneUrl.View.init(allocator, session, identity); │ │881 + errdefer clone_url.deinit(allocator); │ │882 + const min_width = clone_url.minWidth(); │ │883 + box.getFocus().child_id = clone_url.getFocus().id; │ │884 + try box.children.put(allocator, clone_url.getFocus().id, .{ .widget = .{ .clone_url = clone_url }, .rect = null, .min_size = .{ .width = min_width, .height = 3 } });│ │885 + } │ │886 + │ │887 + var spacer = try ui.Spacer.init(allocator); │ │888 + errdefer spacer.deinit(allocator); │ │889 + try box.children.put(allocator, spacer.getFocus().id, .{ .widget = .{ .spacer = spacer }, .rect = null, .min_size = null }); │ │890 │ │891 var text_box = try wgt.TextBox(ui.Widget).init(allocator, data.content, .{ .border_style = .hidden, .wrap_kind = .none }); │ │892 errdefer text_box.deinit(allocator); │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │859 - try box.children.put(allocator, text_box.getFocus().id, .{ .widget = .{ .text_box = text_box }, .rect = null, .min_size = null }); │ │893 + try box.children.put(allocator, text_box.getFocus().id, .{ .widget = .{ .text_box = text_box }, .rect = null, .min_size = null, .shrink = true });│ │894 │ │895 return .{ .box = box, .data = data }; │ │896 } │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │905 } │ │906 │ │907 pub fn input(self: *Header.View, allocator: std.mem.Allocator, key: Key, root_focus: *Focus) !void {│ │874 - _ = self; │ │875 - _ = allocator; │ │876 - _ = key; │ │877 - _ = root_focus; │ │908 + const clone_url = self.cloneUrl() orelse return; │ │909 + try clone_url.input(allocator, key, root_focus); │ │910 + } │ │911 + │ │912 + pub fn focusCloneUrl(self: *Header.View, root_focus: *Focus) bool { │ │913 + const clone_url = self.cloneUrl() orelse return false; │ │914 + root_focus.setFocus(clone_url.getFocus().id); │ │915 + return true; │ │916 + } │ │917 + │ │918 + pub fn hasCloneUrl(self: *Header.View) bool { │ │919 + return self.cloneUrl() != null; │ │920 + } │ │921 + │ │922 + fn cloneUrl(self: *Header.View) ?*ui.CloneUrl.View { │ │923 + for (self.box.children.values()) |*child| switch (child.widget) { │ │924 + .clone_url => |*clone_url| return clone_url, │ │925 + else => {}, │ │926 + }; │ │927 + return null; │ │928 } │ │929 │ │930 pub fn clearGrid(self: *Header.View) void { │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭ added ────────────╮ │src/ui/CloneUrl.zig│ ╰───────────────────╯ ╭ changed ──╮ │src/web.zig│ ╰───────────╯ ╭────────────────────────────────────────╮ │38 remote: struct { │ │39 admin_repo_path: []const u8,│ │40 session_store: SessionStore,│ │41 + clone_http_port: u16, │ │42 + clone_ssh_port: u16, │ │43 }, │ │44 local: ui.RepoSource, │ │45 }; │ ╰────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────╮ │194 .local => {}, │ │195 } │ │196 │ │197 + const clone_http_port: ?u16, const clone_ssh_port: ?u16 = switch (host) { │ │198 + .remote => |remote| .{ remote.clone_http_port, remote.clone_ssh_port },│ │199 + .local => .{ null, null }, │ │200 + }; │ │201 const html = renderIndexHtml(io, allocator, host, .{ │ │202 .user_id = user_id, │ │203 .login_failure = login_failure, │ ╰────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────╮ │next →│ ╰──────╯