conf: pad: add center-when-fullscreen and center-when-maximized-and-fullscreen

Before this patch, the grid content was *always* centered when the
window was maximized or fullscreened, regardless of how the user had
configured padding.

Now, the behavior is controlled by the 'pad' option. Before this
patch, the syntax was

    pad MxN [center]

Now it is

    pad MxN [center|center-when-fullscreen|center-when-maximized-and-fullscreen]

The default is "pad 0x0 center-when-maximized-and-fullscreen", to
match current behavior.

Closes #2111
This commit is contained in:
Daniel Eklöf 2025-05-23 08:38:00 +02:00
parent 5621829bb0
commit 5a84f8d841
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
6 changed files with 60 additions and 20 deletions

View file

@ -4596,9 +4596,12 @@ render_resize(struct terminal *term, int width, int height, uint8_t opts)
const int total_x_pad = term->width - grid_width;
const int total_y_pad = term->height - grid_height;
const bool centered_padding = term->conf->center
|| term->window->is_fullscreen
|| term->window->is_maximized;
const enum center_when center = term->conf->center_when;
const bool centered_padding =
center == CENTER_ALWAYS ||
(center == CENTER_MAXIMIZED_AND_FULLSCREEN &&
(term->window->is_fullscreen || term->window->is_maximized)) ||
(center == CENTER_FULLSCREEN && term->window->is_fullscreen);
if (centered_padding && !term->window->is_resizing) {
term->margins.left = total_x_pad / 2;