mirror of
https://github.com/alacritty/alacritty.git
synced 2024-11-25 14:05:41 -05:00
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.
This commit is contained in:
parent
ba76ac8661
commit
d68ecb0def
6 changed files with 37 additions and 8 deletions
10
CHANGELOG.md
10
CHANGELOG.md
|
@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.
|
||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Option for evenly spreading extra padding around the terminal (`window.dynamic_padding`)
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Extra padding is not evenly spread around the terminal by default anymore
|
||||||
|
|
||||||
## Version 0.2.3
|
## Version 0.2.3
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
|
@ -29,6 +29,9 @@ window:
|
||||||
x: 2
|
x: 2
|
||||||
y: 2
|
y: 2
|
||||||
|
|
||||||
|
# Spread additional padding evenly around the terminal content.
|
||||||
|
dynamic_padding: false
|
||||||
|
|
||||||
# Window decorations
|
# Window decorations
|
||||||
#
|
#
|
||||||
# Values for `decorations`:
|
# Values for `decorations`:
|
||||||
|
|
|
@ -29,6 +29,9 @@ window:
|
||||||
x: 2
|
x: 2
|
||||||
y: 2
|
y: 2
|
||||||
|
|
||||||
|
# Spread additional padding evenly around the terminal content.
|
||||||
|
dynamic_padding: false
|
||||||
|
|
||||||
# Window decorations
|
# Window decorations
|
||||||
#
|
#
|
||||||
# Available values:
|
# Available values:
|
||||||
|
|
|
@ -29,6 +29,9 @@ window:
|
||||||
x: 2
|
x: 2
|
||||||
y: 2
|
y: 2
|
||||||
|
|
||||||
|
# Spread additional padding evenly around the terminal content.
|
||||||
|
dynamic_padding: false
|
||||||
|
|
||||||
# Window decorations
|
# Window decorations
|
||||||
#
|
#
|
||||||
# Values for `decorations`:
|
# Values for `decorations`:
|
||||||
|
|
|
@ -376,6 +376,10 @@ pub struct WindowConfig {
|
||||||
/// Draw the window with title bar / borders
|
/// Draw the window with title bar / borders
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
decorations: Decorations,
|
decorations: Decorations,
|
||||||
|
|
||||||
|
/// Spread out additional padding evenly
|
||||||
|
#[serde(default, deserialize_with = "failure_default")]
|
||||||
|
dynamic_padding: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn default_padding() -> Delta<u8> {
|
fn default_padding() -> Delta<u8> {
|
||||||
|
@ -398,6 +402,10 @@ impl WindowConfig {
|
||||||
pub fn decorations(&self) -> Decorations {
|
pub fn decorations(&self) -> Decorations {
|
||||||
self.decorations
|
self.decorations
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn dynamic_padding(&self) -> bool {
|
||||||
|
self.dynamic_padding
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for WindowConfig {
|
impl Default for WindowConfig {
|
||||||
|
@ -406,6 +414,7 @@ impl Default for WindowConfig {
|
||||||
dimensions: Default::default(),
|
dimensions: Default::default(),
|
||||||
padding: default_padding(),
|
padding: default_padding(),
|
||||||
decorations: Default::default(),
|
decorations: Default::default(),
|
||||||
|
dynamic_padding: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,22 +152,19 @@ impl Display {
|
||||||
let dimensions = options.dimensions()
|
let dimensions = options.dimensions()
|
||||||
.unwrap_or_else(|| config.dimensions());
|
.unwrap_or_else(|| config.dimensions());
|
||||||
|
|
||||||
let mut padding_x = f64::from(config.padding().x) * dpr;
|
let mut padding_x = (f64::from(config.padding().x) * dpr).floor();
|
||||||
let mut padding_y = f64::from(config.padding().y) * dpr;
|
let mut padding_y = (f64::from(config.padding().y) * dpr).floor();
|
||||||
|
|
||||||
if dimensions.columns_u32() > 0 && dimensions.lines_u32() > 0 {
|
if dimensions.columns_u32() > 0 && dimensions.lines_u32() > 0 {
|
||||||
// Calculate new size based on cols/lines specified in config
|
// Calculate new size based on cols/lines specified in config
|
||||||
let width = cell_width as u32 * dimensions.columns_u32();
|
let width = cell_width as u32 * dimensions.columns_u32();
|
||||||
let height = cell_height as u32 * dimensions.lines_u32();
|
let height = cell_height as u32 * dimensions.lines_u32();
|
||||||
|
|
||||||
padding_x = padding_x.floor();
|
|
||||||
padding_y = padding_y.floor();
|
|
||||||
|
|
||||||
viewport_size = PhysicalSize::new(
|
viewport_size = PhysicalSize::new(
|
||||||
f64::from(width) + 2. * padding_x,
|
f64::from(width) + 2. * padding_x,
|
||||||
f64::from(height) + 2. * padding_y,
|
f64::from(height) + 2. * padding_y,
|
||||||
);
|
);
|
||||||
} else {
|
} else if config.window().dynamic_padding() {
|
||||||
// Make sure additional padding is spread evenly
|
// Make sure additional padding is spread evenly
|
||||||
let cw = f64::from(cell_width);
|
let cw = f64::from(cell_width);
|
||||||
let ch = f64::from(cell_height);
|
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_x = f32::from(config.padding().x) * dpr as f32;
|
||||||
let mut padding_y = f32::from(config.padding().y) * 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_x = padding_x;
|
||||||
self.size_info.padding_y = padding_y;
|
self.size_info.padding_y = padding_y;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue