fix: ensure palettes are never smaller than their input hint
This commit is contained in:
parent
8ea3356b57
commit
4ca455cbba
2 changed files with 5 additions and 3 deletions
|
@ -36,6 +36,8 @@ longest: usize = 0,
|
|||
commands: Commands = undefined,
|
||||
buffer_manager: ?*BufferManager,
|
||||
|
||||
const inputbox_label = "Search files by name";
|
||||
|
||||
pub fn create(allocator: std.mem.Allocator) !tui.Mode {
|
||||
const mv = tui.mainview() orelse return error.NotFound;
|
||||
const self = try allocator.create(Self);
|
||||
|
@ -51,7 +53,7 @@ pub fn create(allocator: std.mem.Allocator) !tui.Mode {
|
|||
.logger = log.logger(@typeName(Self)),
|
||||
.inputbox = (try self.menu.add_header(try InputBox.create(*Self, self.allocator, self.menu.menu.parent, .{
|
||||
.ctx = self,
|
||||
.label = "Search files by name",
|
||||
.label = inputbox_label,
|
||||
}))).dynamic_cast(InputBox.State(*Self)) orelse unreachable,
|
||||
.buffer_manager = tui.get_buffer_manager(),
|
||||
};
|
||||
|
@ -82,7 +84,7 @@ pub fn deinit(self: *Self) void {
|
|||
}
|
||||
|
||||
inline fn menu_width(self: *Self) usize {
|
||||
return @min(self.longest, max_menu_width()) + 2;
|
||||
return @max(@min(self.longest, max_menu_width()) + 2, inputbox_label.len + 2);
|
||||
}
|
||||
|
||||
inline fn menu_pos_x(self: *Self) usize {
|
||||
|
|
|
@ -153,7 +153,7 @@ pub fn Create(options: type) type {
|
|||
|
||||
fn do_resize(self: *Self) void {
|
||||
const screen = tui.screen();
|
||||
const w = @min(self.longest, max_menu_width) + 2 + 1 + self.longest_hint;
|
||||
const w = @max(@min(self.longest, max_menu_width) + 2 + 1 + self.longest_hint, options.label.len + 2);
|
||||
const x = if (screen.w > w) (screen.w - w) / 2 else 0;
|
||||
self.view_rows = get_view_rows(screen);
|
||||
const h = @min(self.items + self.menu.header_count, self.view_rows + self.menu.header_count);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue