╭ changed ────────╮ │src/ui/widget.zig│ ╰─────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │1042 pub const SearchBox = struct { │ │1043 text_input: wgt.TextInput, │ │1044 session: *ui.Session, │ │1045 + │ │1046 + // the text width, narrowed toward the minimum when the row is tight │ │1047 + const min_width = 18; │ │1048 + const max_width = 30; │ │1049 │ │1050 // the room the box asks its row for │ │1047 - pub const min_size: layout.MaybeSize = .{ .width = 20, .height = 3 }; │ │1051 + pub const min_size: layout.MaybeSize = .{ .width = min_width + 2, .height = 3 }; │ │1052 │ │1053 pub fn init(allocator: std.mem.Allocator, session: *ui.Session, label: []const u8, name: []const u8, text_value: ?[]const u8) !SearchBox { │ │1050 - var text_input = try wgt.TextInput.init(allocator, .{ .top_label = .{ .text = label }, .name = name, .round_corners = true, .visible_width = 18, .render_content = session.is_terminal }); │ │1054 + var text_input = try wgt.TextInput.init(allocator, .{ .top_label = .{ .text = label }, .name = name, .round_corners = true, .visible_width = max_width, .render_content = session.is_terminal });│ │1055 errdefer text_input.deinit(allocator); │ │1056 text_input.getFocus().mode = .all; │ │1057 if (text_value) |value| try text_input.setContent(allocator, value); │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │1063 } │ │1064 │ │1065 pub fn build(self: *SearchBox, allocator: std.mem.Allocator, constraint: layout.Constraint, root_focus: *Focus) !void { │ │1066 + // the row leaves room for its other children's minimums, so this is what can be spared │ │1067 + const room = (constraint.max_size.width orelse max_width + 2) -| 2; │ │1068 + self.text_input.options.visible_width = std.math.clamp(room, min_width, max_width); │ │1069 self.text_input.options.bottom_label.text = if (root_focus.grandchild_id == self.getFocus().id) " press enter " else "";│ │1070 try self.text_input.build(allocator, constraint, root_focus); │ │1071 if (!self.session.is_terminal) { │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯