diff --git a/config/src/lib.rs b/config/src/lib.rs index 007df61c4..c9cb6c466 100644 --- a/config/src/lib.rs +++ b/config/src/lib.rs @@ -845,6 +845,9 @@ pub struct Config { #[serde(default = "default_word_boundary")] pub selection_word_boundary: String, + + #[serde(default = "default_true")] + pub adjust_window_size_when_changing_font_size: bool, } fn default_word_boundary() -> String { diff --git a/docs/changelog.markdown b/docs/changelog.markdown index ed3959037..b7de6ccd6 100644 --- a/docs/changelog.markdown +++ b/docs/changelog.markdown @@ -44,6 +44,7 @@ brief notes about them may accumulate here. * Fixed an issue where the mouse wheel wasn't mapped to cursor up/down when the alternate screen was active [#429](https://github.com/wez/wezterm/issues/429) * Fixed `ToggleFullScreen` not working on macOS and X11. It still doesn't function on Windows. `native_macos_fullscreen_mode = false` uses a fast full-screen window on macOS. Set it to `true` to use the slower macOS native "Spaces" style fullscreen mode. [#177](https://github.com/wez/wezterm/issues/177) * Windows: fix an issue where the initial window size didn't factor the correct DPI when the system-wide display scaling was not 100%. [#427](https://github.com/wez/wezterm/issues/427) +* New: `adjust_window_size_when_changing_font_size` option to control whether changing the font size adjusts the dimensions of the window (true) or adjusts the number of terminal rows/columns (false). The default is `true`. [#431](https://github.com/wez/wezterm/issues/431) ### 20201101-103216-403d002d diff --git a/wezterm-gui/src/gui/termwindow.rs b/wezterm-gui/src/gui/termwindow.rs index 70e751461..fe7c5e96a 100644 --- a/wezterm-gui/src/gui/termwindow.rs +++ b/wezterm-gui/src/gui/termwindow.rs @@ -2306,14 +2306,29 @@ impl TermWindow { self.apply_dimensions(&dimensions, scale_changed_cells); } + // Used for applying font size changes only; this takes into account + // the `adjust_window_size_when_changing_font_size` configuration and + // revises the scaling/resize change accordingly + fn adjust_font_scale(&mut self, font_scale: f64) { + if configuration().adjust_window_size_when_changing_font_size { + self.scaling_changed(self.dimensions, font_scale); + } else { + let dimensions = self.dimensions; + // Compute new font metrics + self.apply_scale_change(&dimensions, font_scale); + // Now revise the pty size to fit the window + self.apply_dimensions(&dimensions, None); + } + } + fn decrease_font_size(&mut self) { - self.scaling_changed(self.dimensions, self.fonts.get_font_scale() * 0.9); + self.adjust_font_scale(self.fonts.get_font_scale() * 0.9); } fn increase_font_size(&mut self) { - self.scaling_changed(self.dimensions, self.fonts.get_font_scale() * 1.1); + self.adjust_font_scale(self.fonts.get_font_scale() * 1.1); } fn reset_font_size(&mut self) { - self.scaling_changed(self.dimensions, 1.); + self.adjust_font_scale(1.0); } fn close_current_pane(&mut self, confirm: bool) {