diff options
author | Christian Duerr <chrisduerr@users.noreply.github.com> | 2018-11-15 19:57:15 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-15 19:57:15 +0000 |
commit | d68ecb0deff8b966a0c7d09203d14bfdf5ccd8ad (patch) | |
tree | 4b0326cf4ea450d6870d2604f464b8ecfd354c9c /src/display.rs | |
parent | ba76ac8661539727c96362d501590d4a18936b39 (diff) | |
download | alacritty-d68ecb0deff8b966a0c7d09203d14bfdf5ccd8ad.tar.gz alacritty-d68ecb0deff8b966a0c7d09203d14bfdf5ccd8ad.zip |
Add option for dynamic padding (#1780)
This adds the `window.dynamic_padding` option which allows disabling the
dynamic spread of additional padding around the grid's content.
Based on the feedback I've gotten so far and the fact that most other
terminal emulators do not seem to center the content inside themselves,
I've changed the default configuration option to disable centering of the grid.
This fixes #1778.
Diffstat (limited to 'src/display.rs')
-rw-r--r-- | src/display.rs | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/display.rs b/src/display.rs index a664b4a2..3fe5fbc4 100644 --- a/src/display.rs +++ b/src/display.rs @@ -152,22 +152,19 @@ impl Display { let dimensions = options.dimensions() .unwrap_or_else(|| config.dimensions()); - let mut padding_x = f64::from(config.padding().x) * dpr; - let mut padding_y = f64::from(config.padding().y) * dpr; + let mut padding_x = (f64::from(config.padding().x) * dpr).floor(); + let mut padding_y = (f64::from(config.padding().y) * dpr).floor(); if dimensions.columns_u32() > 0 && dimensions.lines_u32() > 0 { // Calculate new size based on cols/lines specified in config let width = cell_width as u32 * dimensions.columns_u32(); let height = cell_height as u32 * dimensions.lines_u32(); - padding_x = padding_x.floor(); - padding_y = padding_y.floor(); - viewport_size = PhysicalSize::new( f64::from(width) + 2. * padding_x, f64::from(height) + 2. * padding_y, ); - } else { + } else if config.window().dynamic_padding() { // Make sure additional padding is spread evenly let cw = f64::from(cell_width); let ch = f64::from(cell_height); @@ -331,8 +328,12 @@ impl Display { let mut padding_x = f32::from(config.padding().x) * dpr as f32; let mut padding_y = f32::from(config.padding().y) * dpr as f32; - padding_x = (padding_x + ((width - 2. * padding_x) % cell_width) / 2.).floor(); - padding_y = (padding_y + ((height - 2. * padding_y) % cell_height) / 2.).floor(); + + if config.window().dynamic_padding() { + padding_x = (padding_x + ((width - 2. * padding_x) % cell_width) / 2.).floor(); + padding_y = (padding_y + ((height - 2. * padding_y) % cell_height) / 2.).floor(); + } + self.size_info.padding_x = padding_x; self.size_info.padding_y = padding_y; |