feat: add centered_view_min_screen_width config option

This commit is contained in:
CJ van den Berg 2025-11-18 12:49:37 +01:00
parent c3808d11c0
commit ed7c0f0c46
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
2 changed files with 5 additions and 1 deletions

View file

@ -48,6 +48,7 @@ pane_right_style: WidgetStyle = .bar_left,
centered_view: bool = false, centered_view: bool = false,
centered_view_width: usize = 145, centered_view_width: usize = 145,
centered_view_min_screen_width: usize = 145,
lsp_output: enum { quiet, verbose } = .quiet, lsp_output: enum { quiet, verbose } = .quiet,

View file

@ -195,7 +195,10 @@ pub fn update_panes_layout(self: *Self) !void {
const centered_view_width = tui.config().centered_view_width; const centered_view_width = tui.config().centered_view_width;
const screen_width = tui.screen().w; const screen_width = tui.screen().w;
const need_padding = screen_width > centered_view_width; const need_padding = screen_width > centered_view_width;
if (need_padding and tui.config().centered_view and self.views.widgets.items.len == 1) { const have_vsplits = self.views.widgets.items.len > 1;
const have_min_screen_width = screen_width > tui.config().centered_view_min_screen_width;
const centered_view = need_padding and tui.config().centered_view and !have_vsplits and have_min_screen_width;
if (centered_view) {
const padding = (screen_width - centered_view_width) / 2; const padding = (screen_width - centered_view_width) / 2;
try self.panes.add(try self.create_padding_pane(padding, .pane_left)); try self.panes.add(try self.create_padding_pane(padding, .pane_left));
try self.panes.add(self.views_widget); try self.panes.add(self.views_widget);