mirror of
https://github.com/alacritty/alacritty.git
synced 2025-04-21 18:02:37 -04:00
Warn if only columns XOR lines is set
Co-authored-by: Christian Duerr <contact@christianduerr.com>
This commit is contained in:
parent
1df32309fe
commit
76c5d01ee2
3 changed files with 30 additions and 8 deletions
|
@ -35,6 +35,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||
- Blinking cursor will timeout after `5` seconds by default
|
||||
- Deprecated `colors.search.bar`, use `colors.footer_bar` instead
|
||||
- On macOS, Alacritty now reads `AppleFontSmoothing` from user defaults to control font smoothing
|
||||
- Warn when either `columns` or `lines` is non-zero, but not both
|
||||
|
||||
### Fixed
|
||||
|
||||
|
|
|
@ -26,9 +26,10 @@
|
|||
#window:
|
||||
# Window dimensions (changes require restart)
|
||||
#
|
||||
# Number of lines/columns (not pixels) in the terminal. The number of columns
|
||||
# must be at least `2`, while using a value of `0` for columns and lines will
|
||||
# fall back to the window manager's recommended size.
|
||||
# Number of lines/columns (not pixels) in the terminal. Both lines and columns
|
||||
# must be non-zero for this to take effect. The number of columns must be at
|
||||
# least `2`, while using a value of `0` for columns and lines will fall back
|
||||
# to the window manager's recommended size
|
||||
#dimensions:
|
||||
# columns: 0
|
||||
# lines: 0
|
||||
|
|
|
@ -2,7 +2,7 @@ use std::fmt::{self, Formatter};
|
|||
use std::os::raw::c_ulong;
|
||||
|
||||
use glutin::window::Fullscreen;
|
||||
use log::error;
|
||||
use log::{error, warn};
|
||||
use serde::de::{self, MapAccess, Visitor};
|
||||
use serde::{Deserialize, Deserializer, Serialize};
|
||||
|
||||
|
@ -74,11 +74,31 @@ impl Default for WindowConfig {
|
|||
impl WindowConfig {
|
||||
#[inline]
|
||||
pub fn dimensions(&self) -> Option<Dimensions> {
|
||||
if self.dimensions.columns.0 != 0
|
||||
&& self.dimensions.lines != 0
|
||||
&& self.startup_mode != StartupMode::Maximized
|
||||
{
|
||||
let (lines, columns) = (self.dimensions.lines, self.dimensions.columns.0);
|
||||
let (lines_is_non_zero, columns_is_non_zero) = (lines != 0, columns != 0);
|
||||
|
||||
if lines_is_non_zero && columns_is_non_zero {
|
||||
// Return dimensions if both `lines` and `columns` are non-zero.
|
||||
Some(self.dimensions)
|
||||
} else if lines_is_non_zero || columns_is_non_zero {
|
||||
// Warn if either `columns` or `lines` is non-zero.
|
||||
|
||||
let (zero_key, non_zero_key, non_zero_value) = if lines_is_non_zero {
|
||||
("columns", "lines", lines)
|
||||
} else {
|
||||
("lines", "columns", columns)
|
||||
};
|
||||
|
||||
warn!(
|
||||
target: LOG_TARGET_CONFIG,
|
||||
"Both `lines` and `columns` must be non-zero for `window.dimensions` to take \
|
||||
effect. Configured value of `{}` is 0 while that of `{}` is {}",
|
||||
zero_key,
|
||||
non_zero_key,
|
||||
non_zero_value,
|
||||
);
|
||||
|
||||
None
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue