╭ changed ────────────╮ │src/ui/Repo/Files.zig│ ╰─────────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │239 │ │240 // the ref banner at the top. │ │241 { │ │242 - var header = try Header.View.init(allocator, &data.header, session); │ │243 - errdefer header.deinit(allocator); │ │244 - try outer.children.put(allocator, header.getFocus().id, .{ .widget = .{ .repo_files_header = header }, .rect = null, .min_size = .{ .width = null, .height = 3 } }); │ │242 + var header_view = try Header.View.init(allocator, &data.header, session, data.identity); │ │243 + errdefer header_view.deinit(allocator); │ │244 + try outer.children.put(allocator, header_view.getFocus().id, .{ .widget = .{ .repo_files_header = header_view }, .rect = null, .min_size = .{ .width = null, .height = 3 } });│ │245 } │ │246 │ │247 var box = try wgt.Box(ui.Widget).init(allocator, .{ .border_style = null, .direction = .horiz }); │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────╮ │374 │ │375 fn contentBox(self: *View) *wgt.Box(ui.Widget) { │ │376 return &self.box.children.values()[content_index].widget.box; │ │377 + } │ │378 + │ │379 + fn header(self: *View) *Header.View { │ │380 + return &self.box.children.values()[header_index].widget.repo_files_header;│ │381 + } │ │382 + │ │383 + fn headerActive(self: *View) bool { │ │384 + return self.box.getFocus().child_id == self.header().getFocus().id; │ │385 } │ │386 │ │387 fn listScroll(self: *View) *wgt.Scroll(ui.Widget) { │ ╰───────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │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 { │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯