diff --git a/config.c b/config.c index 1ec73da0..a80a26b4 100644 --- a/config.c +++ b/config.c @@ -931,6 +931,9 @@ parse_section_main(struct context *ctx) else if (streq(key, "resize-by-cells")) return value_to_bool(ctx, &conf->resize_by_cells); + else if (streq(key, "resize-keep-grid")) + return value_to_bool(ctx, &conf->resize_keep_grid); + else if (streq(key, "bold-text-in-bright")) { if (streq(value, "palette-based")) { conf->bold_in_bright.enabled = true; @@ -3101,6 +3104,7 @@ config_load(struct config *conf, const char *conf_path, .pad_x = 0, .pad_y = 0, .resize_by_cells = true, + .resize_keep_grid = true, .resize_delay_ms = 100, .bold_in_bright = { .enabled = false, diff --git a/config.h b/config.h index 246b479f..be99987b 100644 --- a/config.h +++ b/config.h @@ -140,6 +140,7 @@ struct config { bool center; bool resize_by_cells; + bool resize_keep_grid; uint16_t resize_delay_ms; diff --git a/doc/foot.ini.5.scd b/doc/foot.ini.5.scd index da887aee..47c5939e 100644 --- a/doc/foot.ini.5.scd +++ b/doc/foot.ini.5.scd @@ -287,6 +287,18 @@ empty string to be set, but it must be quoted: *KEY=""*) Default: _yes_ +*resize-keep-grid* + Boolean. + + When set to *yes*, the window size will be adjusted with changes in font + size to preserve the dimensions of the text grid. When set to *no*, the + window size will remain constant and the text grid will be adjusted as + necessary to fit the window. + + This option only applies to floating windows. + + Default: _yes_ + *initial-window-size-pixels* Initial window width and height in _pixels_ (subject to output scaling), in the form _WIDTHxHEIGHT_. The height _includes_ the diff --git a/foot.ini b/foot.ini index 9e2f5f29..c2c80fa3 100644 --- a/foot.ini +++ b/foot.ini @@ -27,6 +27,7 @@ # initial-window-mode=windowed # pad=0x0 # optionally append 'center' # resize-by-cells=yes +# resize-keep-grid=yes # resize-delay-ms=100 # bold-text-in-bright=no diff --git a/terminal.c b/terminal.c index e7812e2e..dee0b038 100644 --- a/terminal.c +++ b/terminal.c @@ -819,11 +819,15 @@ term_set_fonts(struct terminal *term, struct fcft_font *fonts[static 4], * render_resize() after this function */ if (resize_grid) { /* Use force, since cell-width/height may have changed */ + enum resize_options resize_opts = RESIZE_FORCE; + if (conf->resize_keep_grid) + resize_opts |= RESIZE_KEEP_GRID; + render_resize( term, (int)roundf(term->width / term->scale), (int)roundf(term->height / term->scale), - RESIZE_FORCE | RESIZE_KEEP_GRID); + resize_opts); } return true; }