╭ changed ───────────────╮ │src/ui/Repo/Branches.zig│ ╰────────────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────╮ │74 data: *const Self, │ │75 session: *ui.Session, │ │76 │ │77 - const add_index = 0; │ │77 + const about_index = 0; │ │78 + const add_index = 1; │ │79 │ │80 pub fn init(allocator: std.mem.Allocator, data: *const Self, session: *ui.Session) !View {│ │81 const aa = session.page_arena.allocator(); │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ 85 const url = try route.toUrl(session.page_arena); │ │ 86 │ │ 87 { │ │ 87 - // the gap leaves a blank line between the text and the input │ │ 88 - var add = try wgt.Box(ui.Widget).init(allocator, .{ .border = null, .direction = .vert, .gap = 1 }); │ │ 88 + var about = try ui.widget.initAbout(allocator, &.{ │ │ 89 + .{ .text = "protected branches can't be deleted or force pushed.\n" }, │ │ 90 + .{ .text = "owners", .style = .{ .bold = true } }, │ │ 91 + .{ .text = " can push directly to them.\n" }, │ │ 92 + .{ .text = "members", .style = .{ .bold = true } }, │ │ 93 + .{ .text = " can only change them by merging a patch." }, │ │ 94 + }); │ │ 95 + errdefer about.deinit(allocator); │ │ 96 + try box.children.put(allocator, about.getFocus().id, .{ .widget = .{ .box = about }, .rect = null, .min_size = null }); │ │ 97 + } │ │ 98 + { │ │ 99 + var add = try wgt.Box(ui.Widget).init(allocator, .{ .border = null, .direction = .horiz }); │ │100 errdefer add.deinit(allocator); │ │101 add.getFocus().kind = .{ .custom = try aa.print("form:{s}/protect", .{url}) }; │ │ 91 - { │ │ 92 - var about = try ui.widget.RichText.init(allocator, &.{ │ │ 93 - .{ .text = "protected branches can't be deleted or force pushed." }, │ │ 94 - }); │ │ 95 - errdefer about.deinit(allocator); │ │ 96 - try add.children.put(allocator, about.getFocus().id, .{ .widget = .{ .rich_text = about }, .rect = null, .min_size = null }); │ │ 97 - } │ │102 var name = try wgt.TextInput.init(allocator, .{ .top_label = .{ .text = " add a protected branch " }, .name = "name", .visible_width = 30, .round_corners = true, .render_content = session.is_terminal });│ │103 errdefer name.deinit(allocator); │ │104 name.getFocus().mode = .all; │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │105 if (session.formFeedback(.repo_branches)) |saved| try name.setContent(allocator, saved.name); │ │106 add.getFocus().child_id = name.getFocus().id; │ │107 try add.children.put(allocator, name.getFocus().id, .{ .widget = .{ .text_input = name }, .rect = null, .min_size = .{ .width = null, .height = 3 } });│ │104 - try box.children.put(allocator, add.getFocus().id, .{ .widget = .{ .box = add }, .rect = null, .min_size = .{ .width = null, .height = 5 } }); │ │108 + try box.children.put(allocator, add.getFocus().id, .{ .widget = .{ .box = add }, .rect = null, .min_size = .{ .width = null, .height = 3 } }); │ │109 } │ │110 │ │111 // the branch rows follow the add row in the same box │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │135 try box.children.put(allocator, row_box.getFocus().id, .{ .widget = .{ .box = row_box }, .rect = null, .min_size = null });│ │136 } │ │137 │ │134 - box.getFocus().child_id = box.children.keys()[add_index]; │ │138 + box.getFocus().child_id = box.children.keys()[about_index]; │ │139 var center = try ui.widget.Center.init(allocator, .{ .box = box }); │ │140 errdefer center.deinit(allocator); │ │141 return .{ │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────╮ │158 } │ │159 │ │160 fn nameInput(self: *View) *wgt.TextInput { │ │157 - return &self.addBox().children.values()[1].widget.text_input;│ │161 + return &self.addBox().children.values()[0].widget.text_input;│ │162 } │ │163 │ │164 fn addActive(self: *View) bool { │ ╰──────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │165 return self.contentBox().getFocus().child_id == self.addBox().getFocus().id; │ │166 + } │ │167 + │ │168 + fn aboutBox(self: *View) *wgt.Box(ui.Widget) { │ │169 + return &self.contentBox().children.values()[about_index].widget.box; │ │170 } │ │171 │ │172 pub fn build(self: *View, allocator: std.mem.Allocator, constraint: layout.Constraint, root_focus: *Focus) !void {│ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │173 self.clearGrid(); │ │174 try self.labelAddInput(root_focus); │ │175 + ui.widget.markAboutFocused(self.aboutBox(), root_focus); │ │176 // the window's height as a minimum centers rows that fit │ │177 try self.scroll.build(allocator, .{ │ │178 .min_size = .{ .width = constraint.min_size.width, .height = constraint.max_size.height orelse constraint.min_size.height },│ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │215 switch (key) { │ │216 .arrow_left, .arrow_right => _ = ui.widget.moveInSelectedRow(rows, root_focus, key == .arrow_right),│ │217 else => { │ │209 - // the add row sits above the rows, and a row's name is a link the host follows │ │218 + // the text and the add row sit above the rows, and a row's name is a link the host follows │ │219 if (current <= add_index) return; │ │220 const row_box = &rows.children.values()[current].widget.box; │ │221 const button_id = row_box.getFocus().child_id orelse return; │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────╮ │250 return self.scroll.getFocus(); │ │251 } │ │252 │ │244 - // up leaves the view from the add row │ │253 + // up leaves the view from the explanatory text │ │254 pub fn atTop(self: *View) bool { │ │246 - return self.addActive(); │ │255 + return self.contentBox().getFocus().child_id == self.aboutBox().getFocus().id;│ │256 } │ │257 }; │ │258 │ ╰───────────────────────────────────────────────────────────────────────────────────────────╯