add border size and color config
refs: https://github.com/wez/wezterm/issues/2417
This commit is contained in:
1 parent
8b3a52ba9a
commit
78b5ac0eb5
5 files changed
+193
-55
No files matched your search
@@ -521,6 +521,24 @@ pub struct WindowFrameConfig {
|
||||
pub font: Option<TextStyle>,
|
||||
#[dynamic(default)]
|
||||
pub font_size: Option<f64>,
|
||||
|
||||
#[dynamic(try_from = "crate::units::PixelUnit", default = "default_zero_pixel")]
|
||||
pub border_left_width: Dimension,
|
||||
#[dynamic(try_from = "crate::units::PixelUnit", default = "default_zero_pixel")]
|
||||
pub border_right_width: Dimension,
|
||||
#[dynamic(try_from = "crate::units::PixelUnit", default = "default_zero_pixel")]
|
||||
pub border_top_height: Dimension,
|
||||
#[dynamic(try_from = "crate::units::PixelUnit", default = "default_zero_pixel")]
|
||||
pub border_bottom_height: Dimension,
|
||||
|
||||
pub border_left_color: Option<RgbaColor>,
|
||||
pub border_right_color: Option<RgbaColor>,
|
||||
pub border_top_color: Option<RgbaColor>,
|
||||
pub border_bottom_color: Option<RgbaColor>,
|
||||
}
|
||||
|
||||
const fn default_zero_pixel() -> Dimension {
|
||||
Dimension::Pixels(0.)
|
||||
}
|
||||
|
||||
impl Default for WindowFrameConfig {
|
||||
@@ -538,6 +556,14 @@ impl Default for WindowFrameConfig {
|
||||
button_hover_bg: default_button_hover_bg(),
|
||||
font: None,
|
||||
font_size: None,
|
||||
border_left_width: default_zero_pixel(),
|
||||
border_right_width: default_zero_pixel(),
|
||||
border_top_height: default_zero_pixel(),
|
||||
border_bottom_height: default_zero_pixel(),
|
||||
border_left_color: None,
|
||||
border_right_color: None,
|
||||
border_top_color: None,
|
||||
border_bottom_color: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ As features stabilize some brief notes about them will accumulate here.
|
||||
#### New
|
||||
|
||||
* Color schemes: [carbonfox](colorschemes/c/index.md#carbonfox), [DanQing Light (base16)](colorschemes/d/index.md#danqing-light-base16), [SynthwaveAlpha](colorschemes/s/index.md#synthwavealpha), [SynthwaveAlpha (Gogh)](colorschemes/s/index.md#synthwavealpha-gogh)
|
||||
* [window_frame](config/lua/config/window_frame.md) now supports setting border size and color [#2417](https://github.com/wez/wezterm/issues/2417)
|
||||
|
||||
#### Changed
|
||||
|
||||
|
||||
@@ -2,10 +2,13 @@
|
||||
|
||||
*Since: 20210814-124438-54e29167*
|
||||
|
||||
This setting is applicable only on Wayland systems when client side decorations are in use.
|
||||
This setting is applicable primarily on Wayland systems when client side
|
||||
decorations are in use.
|
||||
|
||||
It allows you to customize the colors of the window frame.
|
||||
|
||||
Some of these colors are used by the fancy tab bar.
|
||||
|
||||
```lua
|
||||
return {
|
||||
window_frame = {
|
||||
@@ -22,3 +25,22 @@ return {
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
*Since: nightly builds only*
|
||||
|
||||
You may explicitly add a border around the window area:
|
||||
|
||||
```lua
|
||||
return {
|
||||
window_frame = {
|
||||
border_left_width = '0.5cell',
|
||||
border_right_width = '0.5cell',
|
||||
border_bottom_height = '0.25cell',
|
||||
border_top_height = '0.25cell',
|
||||
border_left_color = 'purple',
|
||||
border_right_color = 'purple',
|
||||
border_bottom_color = 'purple',
|
||||
border_top_color = 'purple',
|
||||
},
|
||||
}
|
||||
```
|
||||
@@ -81,7 +81,11 @@ impl super::TermWindow {
|
||||
.max(0)
|
||||
/ self.render_metrics.cell_size.height) as i64;
|
||||
|
||||
let x = (event.coords.x.sub(padding_left as isize).max(0) as f32)
|
||||
let x = (event
|
||||
.coords
|
||||
.x
|
||||
.sub((padding_left + border.left.get() as f32) as isize)
|
||||
.max(0) as f32)
|
||||
/ self.render_metrics.cell_size.width as f32;
|
||||
let x = if !pane.is_mouse_grabbed() {
|
||||
// Round the x coordinate so that we're a bit more forgiving of
|
||||
@@ -101,7 +105,10 @@ impl super::TermWindow {
|
||||
y_pixel_offset = y_pixel_offset.max(0) % self.render_metrics.cell_size.height;
|
||||
}
|
||||
|
||||
let mut x_pixel_offset = event.coords.x.sub(padding_left as isize);
|
||||
let mut x_pixel_offset = event
|
||||
.coords
|
||||
.x
|
||||
.sub((padding_left + border.left.get() as f32) as isize);
|
||||
if x > 0 {
|
||||
x_pixel_offset = x_pixel_offset.max(0) % self.render_metrics.cell_size.width;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ use ::window::glium::uniforms::{
|
||||
MagnifySamplerFilter, MinifySamplerFilter, Sampler, SamplerWrapFunction,
|
||||
};
|
||||
use ::window::glium::{uniform, BlendingFunction, LinearBlendingFactor, Surface};
|
||||
use ::window::{glium, DeadKeyStatus, PointF, RectF, SizeF, WindowOps};
|
||||
use ::window::{glium, DeadKeyStatus, PointF, RectF, SizeF, ULength, WindowOps};
|
||||
use anyhow::anyhow;
|
||||
use config::{
|
||||
ConfigHandle, Dimension, DimensionContext, FreeTypeLoadTarget, HsbTransform, TabBarColors,
|
||||
@@ -895,10 +895,58 @@ impl super::TermWindow {
|
||||
}
|
||||
|
||||
pub fn get_os_border(&self) -> window::parameters::Border {
|
||||
self.os_parameters
|
||||
let mut border = self
|
||||
.os_parameters
|
||||
.as_ref()
|
||||
.and_then(|p| p.border_dimensions.clone())
|
||||
.unwrap_or_default()
|
||||
.unwrap_or_default();
|
||||
|
||||
border.left += ULength::new(
|
||||
self.config
|
||||
.window_frame
|
||||
.border_left_width
|
||||
.evaluate_as_pixels(DimensionContext {
|
||||
dpi: self.dimensions.dpi as f32,
|
||||
pixel_max: self.dimensions.pixel_width as f32,
|
||||
pixel_cell: self.render_metrics.cell_size.width as f32,
|
||||
})
|
||||
.ceil() as usize,
|
||||
);
|
||||
border.right += ULength::new(
|
||||
self.config
|
||||
.window_frame
|
||||
.border_right_width
|
||||
.evaluate_as_pixels(DimensionContext {
|
||||
dpi: self.dimensions.dpi as f32,
|
||||
pixel_max: self.dimensions.pixel_width as f32,
|
||||
pixel_cell: self.render_metrics.cell_size.width as f32,
|
||||
})
|
||||
.ceil() as usize,
|
||||
);
|
||||
border.top += ULength::new(
|
||||
self.config
|
||||
.window_frame
|
||||
.border_top_height
|
||||
.evaluate_as_pixels(DimensionContext {
|
||||
dpi: self.dimensions.dpi as f32,
|
||||
pixel_max: self.dimensions.pixel_height as f32,
|
||||
pixel_cell: self.render_metrics.cell_size.height as f32,
|
||||
})
|
||||
.ceil() as usize,
|
||||
);
|
||||
border.bottom += ULength::new(
|
||||
self.config
|
||||
.window_frame
|
||||
.border_bottom_height
|
||||
.evaluate_as_pixels(DimensionContext {
|
||||
dpi: self.dimensions.dpi as f32,
|
||||
pixel_max: self.dimensions.pixel_height as f32,
|
||||
pixel_cell: self.render_metrics.cell_size.height as f32,
|
||||
})
|
||||
.ceil() as usize,
|
||||
);
|
||||
|
||||
border
|
||||
}
|
||||
|
||||
fn paint_tab_bar(&mut self) -> anyhow::Result<()> {
|
||||
@@ -1003,52 +1051,72 @@ impl super::TermWindow {
|
||||
}
|
||||
|
||||
fn paint_window_borders(&mut self) -> anyhow::Result<()> {
|
||||
if let Some(ref os_params) = self.os_parameters {
|
||||
if let Some(ref border_dimensions) = os_params.border_dimensions {
|
||||
let gl_state = self.render_state.as_ref().unwrap();
|
||||
let layer = gl_state.layer_for_zindex(0)?;
|
||||
let vb = &layer.vb.borrow()[2];
|
||||
let mut vb_mut = vb.current_vb_mut();
|
||||
let mut layer1 = vb.map(&mut vb_mut);
|
||||
let border_dimensions = self.get_os_border();
|
||||
|
||||
let height = self.dimensions.pixel_height as f32;
|
||||
let width = self.dimensions.pixel_width as f32;
|
||||
if border_dimensions.top.get() > 0
|
||||
|| border_dimensions.bottom.get() > 0
|
||||
|| border_dimensions.left.get() > 0
|
||||
|| border_dimensions.right.get() > 0
|
||||
{
|
||||
let gl_state = self.render_state.as_ref().unwrap();
|
||||
let layer = gl_state.layer_for_zindex(0)?;
|
||||
let vb = &layer.vb.borrow()[2];
|
||||
let mut vb_mut = vb.current_vb_mut();
|
||||
let mut layer1 = vb.map(&mut vb_mut);
|
||||
|
||||
let border_top = border_dimensions.top.get() as f32;
|
||||
if border_top > 0.0 {
|
||||
self.filled_rectangle(
|
||||
&mut layer1,
|
||||
euclid::rect(0.0, 0.0, width, border_top),
|
||||
border_dimensions.color,
|
||||
)?;
|
||||
}
|
||||
let height = self.dimensions.pixel_height as f32;
|
||||
let width = self.dimensions.pixel_width as f32;
|
||||
|
||||
let border_left = border_dimensions.left.get() as f32;
|
||||
if border_left > 0.0 {
|
||||
self.filled_rectangle(
|
||||
&mut layer1,
|
||||
euclid::rect(0.0, 0.0, border_left, height),
|
||||
border_dimensions.color,
|
||||
)?;
|
||||
}
|
||||
let border_top = border_dimensions.top.get() as f32;
|
||||
if border_top > 0.0 {
|
||||
self.filled_rectangle(
|
||||
&mut layer1,
|
||||
euclid::rect(0.0, 0.0, width, border_top),
|
||||
self.config
|
||||
.window_frame
|
||||
.border_top_color
|
||||
.map(|c| c.to_linear())
|
||||
.unwrap_or(border_dimensions.color),
|
||||
)?;
|
||||
}
|
||||
|
||||
let border_bottom = border_dimensions.bottom.get() as f32;
|
||||
if border_bottom > 0.0 {
|
||||
self.filled_rectangle(
|
||||
&mut layer1,
|
||||
euclid::rect(0.0, height - border_bottom, width, height),
|
||||
border_dimensions.color,
|
||||
)?;
|
||||
}
|
||||
let border_left = border_dimensions.left.get() as f32;
|
||||
if border_left > 0.0 {
|
||||
self.filled_rectangle(
|
||||
&mut layer1,
|
||||
euclid::rect(0.0, 0.0, border_left, height),
|
||||
self.config
|
||||
.window_frame
|
||||
.border_left_color
|
||||
.map(|c| c.to_linear())
|
||||
.unwrap_or(border_dimensions.color),
|
||||
)?;
|
||||
}
|
||||
|
||||
let border_right = border_dimensions.right.get() as f32;
|
||||
if border_right > 0.0 {
|
||||
self.filled_rectangle(
|
||||
&mut layer1,
|
||||
euclid::rect(width - border_right, 0.0, width, height),
|
||||
border_dimensions.color,
|
||||
)?;
|
||||
}
|
||||
let border_bottom = border_dimensions.bottom.get() as f32;
|
||||
if border_bottom > 0.0 {
|
||||
self.filled_rectangle(
|
||||
&mut layer1,
|
||||
euclid::rect(0.0, height - border_bottom, width, height),
|
||||
self.config
|
||||
.window_frame
|
||||
.border_bottom_color
|
||||
.map(|c| c.to_linear())
|
||||
.unwrap_or(border_dimensions.color),
|
||||
)?;
|
||||
}
|
||||
|
||||
let border_right = border_dimensions.right.get() as f32;
|
||||
if border_right > 0.0 {
|
||||
self.filled_rectangle(
|
||||
&mut layer1,
|
||||
euclid::rect(width - border_right, 0.0, border_right, height),
|
||||
self.config
|
||||
.window_frame
|
||||
.border_right_color
|
||||
.map(|c| c.to_linear())
|
||||
.unwrap_or(border_dimensions.color),
|
||||
)?;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1177,10 +1245,14 @@ impl super::TermWindow {
|
||||
|
||||
// We want to fill out to the edges of the splits
|
||||
let (x, width_delta) = if pos.left == 0 {
|
||||
(0., padding_left + (cell_width / 2.0))
|
||||
(
|
||||
0.,
|
||||
padding_left + border.left.get() as f32 + (cell_width / 2.0),
|
||||
)
|
||||
} else {
|
||||
(
|
||||
padding_left - (cell_width / 2.0) + (pos.left as f32 * cell_width),
|
||||
padding_left + border.left.get() as f32 - (cell_width / 2.0)
|
||||
+ (pos.left as f32 * cell_width),
|
||||
cell_width,
|
||||
)
|
||||
};
|
||||
@@ -1269,10 +1341,14 @@ impl super::TermWindow {
|
||||
|
||||
// We want to fill out to the edges of the splits
|
||||
let (x, width_delta) = if pos.left == 0 {
|
||||
(0., padding_left + (cell_width / 2.0))
|
||||
(
|
||||
0.,
|
||||
padding_left + border.left.get() as f32 + (cell_width / 2.0),
|
||||
)
|
||||
} else {
|
||||
(
|
||||
padding_left - (cell_width / 2.0) + (pos.left as f32 * cell_width),
|
||||
padding_left + border.left.get() as f32 - (cell_width / 2.0)
|
||||
+ (pos.left as f32 * cell_width),
|
||||
cell_width,
|
||||
)
|
||||
};
|
||||
@@ -1409,6 +1485,7 @@ impl super::TermWindow {
|
||||
top_pixel_y: top_pixel_y
|
||||
+ (line_idx + pos.top) as f32 * self.render_metrics.cell_size.height as f32,
|
||||
left_pixel_x: padding_left
|
||||
+ border.left.get() as f32
|
||||
+ (pos.left as f32 * self.render_metrics.cell_size.width as f32),
|
||||
pixel_width: dims.cols as f32 * self.render_metrics.cell_size.width as f32,
|
||||
stable_line_idx: Some(stable_row),
|
||||
@@ -1599,16 +1676,17 @@ impl super::TermWindow {
|
||||
let cell_width = self.render_metrics.cell_size.width as f32;
|
||||
let cell_height = self.render_metrics.cell_size.height as f32;
|
||||
|
||||
let border = self.get_os_border();
|
||||
let first_row_offset = if self.show_tab_bar && !self.config.tab_bar_at_bottom {
|
||||
self.tab_bar_pixel_height()?
|
||||
} else {
|
||||
0.
|
||||
} + self.get_os_border().top.get() as f32;
|
||||
} + border.top.get() as f32;
|
||||
|
||||
let (padding_left, padding_top) = self.padding_left_top();
|
||||
|
||||
let pos_y = split.top as f32 * cell_height + first_row_offset + padding_top;
|
||||
let pos_x = split.left as f32 * cell_width + padding_left;
|
||||
let pos_x = split.left as f32 * cell_width + padding_left + border.left.get() as f32;
|
||||
|
||||
if split.direction == SplitDirection::Horizontal {
|
||||
self.filled_rectangle(
|
||||
@@ -1622,7 +1700,9 @@ impl super::TermWindow {
|
||||
foreground,
|
||||
)?;
|
||||
self.ui_items.push(UIItem {
|
||||
x: padding_left as usize + (split.left * cell_width as usize),
|
||||
x: border.left.get() as usize
|
||||
+ padding_left as usize
|
||||
+ (split.left * cell_width as usize),
|
||||
width: cell_width as usize,
|
||||
y: padding_top as usize
|
||||
+ first_row_offset as usize
|
||||
@@ -1642,7 +1722,9 @@ impl super::TermWindow {
|
||||
foreground,
|
||||
)?;
|
||||
self.ui_items.push(UIItem {
|
||||
x: padding_left as usize + (split.left * cell_width as usize),
|
||||
x: border.left.get() as usize
|
||||
+ padding_left as usize
|
||||
+ (split.left * cell_width as usize),
|
||||
width: split.size * cell_width as usize,
|
||||
y: padding_top as usize
|
||||
+ first_row_offset as usize
|
||||
|
||||
Reference in new issue
Block a user