gui: improve error message for unsupported height/width values for Color and Gradient

closes: https://github.com/wez/wezterm/pull/2681
This commit is contained in:
KevinSilvester authored and Wez Furlong committed 2022-11-19 08:01:57 -07:00
1 parent e0aa66489f
commit 2c6748daa6
1 file changed
+16 -4
+16 -4
View File
@@ -266,11 +266,17 @@ fn load_background_layer(
BackgroundSource::Gradient(g) => {
let mut width = match layer.width {
BackgroundSize::Dimension(d) => d.evaluate_as_pixels(h_context),
unsup => anyhow::bail!("{:?} not yet implemented", unsup),
unsup => anyhow::bail!(
"{unsup:?} is not implemented for background gradients. \
Use e.g. `width = '100%'` instead"
),
} as u32;
let mut height = match layer.height {
BackgroundSize::Dimension(d) => d.evaluate_as_pixels(v_context),
unsup => anyhow::bail!("{:?} not yet implemented", unsup),
unsup => anyhow::bail!(
"{unsup:?} is not implemented for background gradients. \
Use e.g. `height = '100%'` instead"
),
} as u32;
if matches!(g.orientation, GradientOrientation::Radial { .. }) {
@@ -292,11 +298,17 @@ fn load_background_layer(
// It's not ideal.
let width = match layer.width {
BackgroundSize::Dimension(d) => d.evaluate_as_pixels(h_context),
unsup => anyhow::bail!("{:?} not yet implemented", unsup),
unsup => anyhow::bail!(
"{unsup:?} is not implemented for background color. \
Use e.g. `width = '100%'` instead"
),
} as u32;
let height = match layer.height {
BackgroundSize::Dimension(d) => d.evaluate_as_pixels(v_context),
unsup => anyhow::bail!("{:?} not yet implemented", unsup),
unsup => anyhow::bail!(
"{unsup:?} is not implemented for background color. \
Use e.g. `height = '100%'` instead"
),
} as u32;
let size = width.min(height);