From 2c6748daa63e91e50e7bfa92cd94263919c0058c Mon Sep 17 00:00:00 2001 From: KevinSilvester Date: Sun, 30 Oct 2022 20:56:03 +0000 Subject: [PATCH] gui: improve error message for unsupported height/width values for Color and Gradient closes: https://github.com/wez/wezterm/pull/2681 --- wezterm-gui/src/termwindow/background.rs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/wezterm-gui/src/termwindow/background.rs b/wezterm-gui/src/termwindow/background.rs index a5ae2ab35..fe6f07403 100644 --- a/wezterm-gui/src/termwindow/background.rs +++ b/wezterm-gui/src/termwindow/background.rs @@ -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);