╭ changed ─────────╮ │src/ui/NewRepo.zig│ ╰──────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭─────────────────────────────────────────────────────────────────────────────────╮ │17 // the new-repo form every page's new repo tab shows. the repo is created for│ │18 // the logged-in user. │ │19 pub const View = struct { │ │20 - box: wgt.Box(ui.Widget), │ │20 + center: ui.widget.Center, │ │21 session: *ui.Session, │ │22 │ │23 // `route` is the page's own new-repo route, which the web form posts to │ ╰─────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │29 const saved_fields = if (session.formFeedback(.repo)) |saved| saved.fields else null; │ │30 │ │31 { │ │32 - var name = try wgt.TextInput.init(allocator, .{ .label = " name ", .name = "name", .visible_width = null, .round_corners = true, .render_content = session.is_terminal });│ │32 + var name = try wgt.TextInput.init(allocator, .{ .label = " name ", .name = "name", .visible_width = 20, .round_corners = true, .render_content = session.is_terminal }); │ │33 errdefer name.deinit(allocator); │ │34 name.getFocus().mode = .all; │ │35 if (saved_fields) |saved| try name.setContent(allocator, saved.name); │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │38 } │ │39 │ │40 { │ │41 - var description = try wgt.TextInput.init(allocator, .{ .label = " description ", .name = "description", .visible_width = null, .round_corners = true, .render_content = session.is_terminal });│ │41 + var description = try wgt.TextInput.init(allocator, .{ .label = " description ", .name = "description", .visible_width = 20, .round_corners = true, .render_content = session.is_terminal }); │ │42 errdefer description.deinit(allocator); │ │43 description.getFocus().mode = .all; │ │44 if (saved_fields) |saved| try description.setContent(allocator, saved.description); │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │63 try box.children.put(allocator, submit.getFocus().id, .{ .widget = .{ .submit_button = submit }, .rect = null, .min_size = .{ .width = null, .height = 3 } });│ │64 } │ │65 │ │66 - // absorbs the leftover min-height so the button keeps its natural height │ │67 - { │ │68 - var spacer = try ui.widget.Spacer.init(allocator); │ │69 - errdefer spacer.deinit(allocator); │ │70 - try box.children.put(allocator, spacer.getFocus().id, .{ .widget = .{ .spacer = spacer }, .rect = null, .min_size = null }); │ │71 - } │ │72 - │ │73 - return .{ .box = box, .session = session }; │ │66 + return .{ .center = try ui.widget.Center.init(allocator, .{ .box = box }), .session = session }; │ │67 } │ │68 │ │69 pub fn deinit(self: *View, allocator: std.mem.Allocator) void { │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │77 - self.box.deinit(allocator); │ │70 + self.center.deinit(allocator); │ │71 } │ │72 │ │73 pub fn build(self: *View, allocator: std.mem.Allocator, constraint: layout.Constraint, root_focus: *Focus) !void {│ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │74 self.clearGrid(); │ │75 const failure = if (self.session.formFeedback(.repo)) |saved| saved.failure else null; │ │83 - (try formField(&self.box, "name")).options.label = if (failure) |value| switch (value) { │ │76 + (try formField(self.formBox(), "name")).options.label = if (failure) |value| switch (value) {│ │77 .required_name => " name (required) ", │ │78 .invalid_name => " name (invalid) ", │ │79 .name_taken => " name (taken) ", │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │80 } else " name "; │ │81 // the web form handling finds the inputs by focus id │ │82 const inputs_arena = self.session.arena.allocator(); │ │90 - for (self.box.children.values()) |*child| switch (child.widget) { │ │83 + for (self.formBox().children.values()) |*child| switch (child.widget) { │ │84 .text_input => |*ti| try self.session.text_inputs.put(inputs_arena, ti.getFocus().id, ti),│ │85 else => {}, │ │86 }; │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────╮ │94 - try self.box.build(allocator, constraint, root_focus); │ │87 + try self.center.build(allocator, constraint, root_focus); │ │88 } │ │89 │ │90 pub fn input(self: *View, allocator: std.mem.Allocator, key: Key, root_focus: *Focus) !void {│ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────╮ │ 98 - const cid = self.box.getFocus().child_id orelse return; │ │ 99 - const cur = self.box.children.getIndex(cid) orelse return; │ │100 - const child = &self.box.children.values()[cur]; │ │ 91 + const cid = self.formBox().getFocus().child_id orelse return; │ │ 92 + const cur = self.formBox().children.getIndex(cid) orelse return;│ │ 93 + const child = &self.formBox().children.values()[cur]; │ │ 94 │ │ 95 const on_submit = child.widget == .submit_button; │ │ 96 switch (key) { │ ╰─────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │104 - .arrow_up, .back_tab => return if (formStep(&self.box, cur, false)) |i| root_focus.setFocus(self.box.children.keys()[i]), │ │105 - .arrow_down, .tab => return if (formStep(&self.box, cur, true)) |i| root_focus.setFocus(self.box.children.keys()[i]), │ │ 97 + .arrow_up, .back_tab => return if (cur > 0) root_focus.setFocus(self.formBox().children.keys()[cur - 1]), │ │ 98 + .arrow_down, .tab => return if (cur + 1 < self.formBox().children.count()) root_focus.setFocus(self.formBox().children.keys()[cur + 1]),│ │ 99 .enter => if (on_submit) return self.submitForm(allocator), │ │100 .mouse => |mouse| if (on_submit) { │ │101 if (inp.leftClickOn(root_focus, child.widget.submit_button.buttonId(), mouse)) return self.submitForm(allocator); │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────╮ │next →│ ╰──────╯