2020-10-02 21:50:50 +03:00
|
|
|
use crate::*;
|
2022-05-14 18:00:03 +03:00
|
|
|
use luahelper::impl_lua_conversion_dynamic;
|
2022-07-15 09:22:02 +03:00
|
|
|
use std::convert::{TryFrom, TryInto};
|
2022-02-06 01:13:19 +03:00
|
|
|
use std::str::FromStr;
|
2019-11-24 18:55:13 +03:00
|
|
|
use termwiz::cell::CellAttributes;
|
2022-07-29 03:54:07 +03:00
|
|
|
use termwiz::color::ColorSpec as TWColorSpec;
|
|
|
|
pub use termwiz::color::{AnsiColor, ColorAttribute, RgbColor, SrgbaTuple};
|
2022-05-18 19:31:10 +03:00
|
|
|
use wezterm_dynamic::{FromDynamic, ToDynamic};
|
2022-07-15 07:41:39 +03:00
|
|
|
use wezterm_term::color::ColorPalette;
|
2019-11-24 18:44:17 +03:00
|
|
|
|
2022-05-14 18:00:03 +03:00
|
|
|
#[derive(Debug, Copy, Clone, FromDynamic, ToDynamic)]
|
wezterm: revise opacity configuration
This commit revises the opacity configuration to make it more
consistently applied.
* `window_background_opacity` controls the overall window capacity,
whether a background image is present or not.
* When a background image is present, or if the window is transparent,
then text whose background color is the default background is
changed to have a fully transparent background.
* `text_background_opacity` controls the alpha channel value for
text whose background color is NOT the default background.
It defaults to 1.0 (fully opaque), but can be set to be
transparent by setting it to a number between 0.0 and 1.0.
* The inactive pane hue, saturation, brightness multipliers
have been factored out into their own struct which changes
that set of options to:
```lua
return {
inactive_pane_hsb = {
hue = 1.0,
saturation = 1.0,
brightness = 1.0,
},
}
```
* `window_background_image_hsb` is a new option that can apply
a hue, saturation, brightness transformation to a background
image. This is primarily useful to make a background image
darker:
```lua
return {
window_background_image = "/some/pic.png",
window_background_image_hsb = {
brightness = 0.3,
},
}
```
refs: #302
refs: #297
2020-10-24 09:16:00 +03:00
|
|
|
pub struct HsbTransform {
|
2022-05-14 18:00:03 +03:00
|
|
|
#[dynamic(default = "default_one_point_oh")]
|
wezterm: revise opacity configuration
This commit revises the opacity configuration to make it more
consistently applied.
* `window_background_opacity` controls the overall window capacity,
whether a background image is present or not.
* When a background image is present, or if the window is transparent,
then text whose background color is the default background is
changed to have a fully transparent background.
* `text_background_opacity` controls the alpha channel value for
text whose background color is NOT the default background.
It defaults to 1.0 (fully opaque), but can be set to be
transparent by setting it to a number between 0.0 and 1.0.
* The inactive pane hue, saturation, brightness multipliers
have been factored out into their own struct which changes
that set of options to:
```lua
return {
inactive_pane_hsb = {
hue = 1.0,
saturation = 1.0,
brightness = 1.0,
},
}
```
* `window_background_image_hsb` is a new option that can apply
a hue, saturation, brightness transformation to a background
image. This is primarily useful to make a background image
darker:
```lua
return {
window_background_image = "/some/pic.png",
window_background_image_hsb = {
brightness = 0.3,
},
}
```
refs: #302
refs: #297
2020-10-24 09:16:00 +03:00
|
|
|
pub hue: f32,
|
2022-05-14 18:00:03 +03:00
|
|
|
#[dynamic(default = "default_one_point_oh")]
|
wezterm: revise opacity configuration
This commit revises the opacity configuration to make it more
consistently applied.
* `window_background_opacity` controls the overall window capacity,
whether a background image is present or not.
* When a background image is present, or if the window is transparent,
then text whose background color is the default background is
changed to have a fully transparent background.
* `text_background_opacity` controls the alpha channel value for
text whose background color is NOT the default background.
It defaults to 1.0 (fully opaque), but can be set to be
transparent by setting it to a number between 0.0 and 1.0.
* The inactive pane hue, saturation, brightness multipliers
have been factored out into their own struct which changes
that set of options to:
```lua
return {
inactive_pane_hsb = {
hue = 1.0,
saturation = 1.0,
brightness = 1.0,
},
}
```
* `window_background_image_hsb` is a new option that can apply
a hue, saturation, brightness transformation to a background
image. This is primarily useful to make a background image
darker:
```lua
return {
window_background_image = "/some/pic.png",
window_background_image_hsb = {
brightness = 0.3,
},
}
```
refs: #302
refs: #297
2020-10-24 09:16:00 +03:00
|
|
|
pub saturation: f32,
|
2022-05-14 18:00:03 +03:00
|
|
|
#[dynamic(default = "default_one_point_oh")]
|
wezterm: revise opacity configuration
This commit revises the opacity configuration to make it more
consistently applied.
* `window_background_opacity` controls the overall window capacity,
whether a background image is present or not.
* When a background image is present, or if the window is transparent,
then text whose background color is the default background is
changed to have a fully transparent background.
* `text_background_opacity` controls the alpha channel value for
text whose background color is NOT the default background.
It defaults to 1.0 (fully opaque), but can be set to be
transparent by setting it to a number between 0.0 and 1.0.
* The inactive pane hue, saturation, brightness multipliers
have been factored out into their own struct which changes
that set of options to:
```lua
return {
inactive_pane_hsb = {
hue = 1.0,
saturation = 1.0,
brightness = 1.0,
},
}
```
* `window_background_image_hsb` is a new option that can apply
a hue, saturation, brightness transformation to a background
image. This is primarily useful to make a background image
darker:
```lua
return {
window_background_image = "/some/pic.png",
window_background_image_hsb = {
brightness = 0.3,
},
}
```
refs: #302
refs: #297
2020-10-24 09:16:00 +03:00
|
|
|
pub brightness: f32,
|
|
|
|
}
|
|
|
|
|
2021-02-19 19:28:19 +03:00
|
|
|
impl Default for HsbTransform {
|
|
|
|
fn default() -> Self {
|
|
|
|
Self {
|
|
|
|
hue: 1.,
|
|
|
|
saturation: 1.,
|
|
|
|
brightness: 1.,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-14 18:00:03 +03:00
|
|
|
#[derive(Default, Debug, Clone, Copy, PartialEq, Eq, Hash, FromDynamic, ToDynamic)]
|
|
|
|
#[dynamic(try_from = "String", into = "String")]
|
2022-02-06 01:13:19 +03:00
|
|
|
pub struct RgbaColor {
|
2022-05-14 18:00:03 +03:00
|
|
|
#[dynamic(flatten)]
|
2022-02-06 01:13:19 +03:00
|
|
|
color: SrgbaTuple,
|
|
|
|
}
|
|
|
|
|
2022-04-08 17:08:33 +03:00
|
|
|
impl From<RgbColor> for RgbaColor {
|
|
|
|
fn from(color: RgbColor) -> Self {
|
|
|
|
Self {
|
|
|
|
color: color.into(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-26 09:25:09 +03:00
|
|
|
impl From<SrgbaTuple> for RgbaColor {
|
|
|
|
fn from(color: SrgbaTuple) -> Self {
|
|
|
|
Self { color }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-27 05:39:53 +03:00
|
|
|
impl From<(u8, u8, u8)> for RgbaColor {
|
|
|
|
fn from((r, g, b): (u8, u8, u8)) -> Self {
|
|
|
|
let color: SrgbaTuple = (r, g, b).into();
|
|
|
|
Self { color }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-08 17:08:33 +03:00
|
|
|
impl std::ops::Deref for RgbaColor {
|
|
|
|
type Target = SrgbaTuple;
|
|
|
|
fn deref(&self) -> &SrgbaTuple {
|
|
|
|
&self.color
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-18 06:03:54 +03:00
|
|
|
impl From<&RgbaColor> for String {
|
|
|
|
fn from(val: &RgbaColor) -> Self {
|
|
|
|
val.color.to_string()
|
2022-05-14 18:00:03 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-18 06:03:54 +03:00
|
|
|
impl From<RgbaColor> for String {
|
|
|
|
fn from(val: RgbaColor) -> Self {
|
|
|
|
val.color.to_string()
|
2022-02-06 01:13:19 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-18 06:03:54 +03:00
|
|
|
impl From<RgbaColor> for SrgbaTuple {
|
|
|
|
fn from(val: RgbaColor) -> Self {
|
|
|
|
val.color
|
2022-02-06 01:13:19 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-18 19:31:10 +03:00
|
|
|
impl TryFrom<String> for RgbaColor {
|
2022-02-06 01:13:19 +03:00
|
|
|
type Error = anyhow::Error;
|
|
|
|
fn try_from(s: String) -> anyhow::Result<RgbaColor> {
|
|
|
|
Ok(RgbaColor {
|
|
|
|
color: SrgbaTuple::from_str(&s)
|
|
|
|
.map_err(|_| anyhow::anyhow!("failed to parse {} as RgbaColor", &s))?,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-29 03:54:07 +03:00
|
|
|
#[derive(Debug, FromDynamic, ToDynamic, Clone, Copy, PartialEq, Eq)]
|
|
|
|
pub enum ColorSpec {
|
|
|
|
AnsiColor(AnsiColor),
|
|
|
|
Color(RgbaColor),
|
|
|
|
Default,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<AnsiColor> for ColorSpec {
|
|
|
|
fn from(color: AnsiColor) -> ColorSpec {
|
|
|
|
Self::AnsiColor(color)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-18 06:03:54 +03:00
|
|
|
impl From<ColorSpec> for ColorAttribute {
|
|
|
|
fn from(val: ColorSpec) -> Self {
|
|
|
|
match val {
|
|
|
|
ColorSpec::AnsiColor(c) => ColorAttribute::PaletteIndex(c.into()),
|
|
|
|
ColorSpec::Color(RgbaColor { color }) => {
|
|
|
|
ColorAttribute::TrueColorWithDefaultFallback(color)
|
|
|
|
}
|
|
|
|
ColorSpec::Default => ColorAttribute::Default,
|
2022-07-29 03:54:07 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-18 06:03:54 +03:00
|
|
|
impl From<ColorSpec> for TWColorSpec {
|
|
|
|
fn from(val: ColorSpec) -> Self {
|
|
|
|
match val {
|
|
|
|
ColorSpec::AnsiColor(c) => c.into(),
|
|
|
|
ColorSpec::Color(RgbaColor { color }) => TWColorSpec::TrueColor(color),
|
|
|
|
ColorSpec::Default => TWColorSpec::Default,
|
2022-07-29 03:54:07 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-10 23:26:33 +03:00
|
|
|
#[derive(Default, Debug, Clone, PartialEq, FromDynamic, ToDynamic)]
|
2019-11-24 18:44:17 +03:00
|
|
|
pub struct Palette {
|
|
|
|
/// The text color to use when the attributes are reset to default
|
2022-04-08 17:08:33 +03:00
|
|
|
pub foreground: Option<RgbaColor>,
|
2019-11-24 18:44:17 +03:00
|
|
|
/// The background color to use when the attributes are reset to default
|
2022-04-08 17:08:33 +03:00
|
|
|
pub background: Option<RgbaColor>,
|
2019-11-24 18:44:17 +03:00
|
|
|
/// The color of the cursor
|
2022-04-08 17:08:33 +03:00
|
|
|
pub cursor_fg: Option<RgbaColor>,
|
|
|
|
pub cursor_bg: Option<RgbaColor>,
|
|
|
|
pub cursor_border: Option<RgbaColor>,
|
2019-11-24 18:44:17 +03:00
|
|
|
/// The color of selected text
|
2022-02-06 01:13:19 +03:00
|
|
|
pub selection_fg: Option<RgbaColor>,
|
|
|
|
pub selection_bg: Option<RgbaColor>,
|
2019-11-24 18:44:17 +03:00
|
|
|
/// A list of 8 colors corresponding to the basic ANSI palette
|
2022-04-08 17:08:33 +03:00
|
|
|
pub ansi: Option<[RgbaColor; 8]>,
|
2019-11-24 18:44:17 +03:00
|
|
|
/// A list of 8 colors corresponding to bright versions of the
|
|
|
|
/// ANSI palette
|
2022-04-08 17:08:33 +03:00
|
|
|
pub brights: Option<[RgbaColor; 8]>,
|
2021-08-21 14:46:52 +03:00
|
|
|
/// A map for setting arbitrary colors ranging from 16 to 256 in the color
|
|
|
|
/// palette
|
2022-05-18 19:31:10 +03:00
|
|
|
#[dynamic(default)]
|
2022-04-08 17:08:33 +03:00
|
|
|
pub indexed: HashMap<u8, RgbaColor>,
|
2019-11-24 18:44:17 +03:00
|
|
|
/// Configure the colors and styling of the tab bar
|
|
|
|
pub tab_bar: Option<TabBarColors>,
|
2019-12-23 05:57:54 +03:00
|
|
|
/// The color of the "thumb" of the scrollbar; the segment that
|
|
|
|
/// represents the current viewable area
|
2022-04-08 17:08:33 +03:00
|
|
|
pub scrollbar_thumb: Option<RgbaColor>,
|
2020-10-20 08:03:21 +03:00
|
|
|
/// The color of the split line between panes
|
2022-04-08 17:08:33 +03:00
|
|
|
pub split: Option<RgbaColor>,
|
2021-09-25 22:40:22 +03:00
|
|
|
/// The color of the visual bell. If unspecified, the foreground
|
|
|
|
/// color is used instead.
|
2022-04-08 17:08:33 +03:00
|
|
|
pub visual_bell: Option<RgbaColor>,
|
2022-01-03 03:49:32 +03:00
|
|
|
/// The color to use for the cursor when a dead key or leader state is active
|
2022-04-08 17:08:33 +03:00
|
|
|
pub compose_cursor: Option<RgbaColor>,
|
2022-07-29 03:54:07 +03:00
|
|
|
|
|
|
|
pub copy_mode_active_highlight_fg: Option<ColorSpec>,
|
|
|
|
pub copy_mode_active_highlight_bg: Option<ColorSpec>,
|
|
|
|
pub copy_mode_inactive_highlight_fg: Option<ColorSpec>,
|
|
|
|
pub copy_mode_inactive_highlight_bg: Option<ColorSpec>,
|
|
|
|
|
|
|
|
pub quick_select_label_fg: Option<ColorSpec>,
|
|
|
|
pub quick_select_label_bg: Option<ColorSpec>,
|
|
|
|
pub quick_select_match_fg: Option<ColorSpec>,
|
|
|
|
pub quick_select_match_bg: Option<ColorSpec>,
|
2019-11-24 18:44:17 +03:00
|
|
|
}
|
2022-05-14 18:00:03 +03:00
|
|
|
impl_lua_conversion_dynamic!(Palette);
|
2019-11-24 18:44:17 +03:00
|
|
|
|
2022-08-20 21:48:22 +03:00
|
|
|
impl Palette {
|
|
|
|
pub fn overlay_with(&self, other: &Self) -> Self {
|
|
|
|
macro_rules! overlay {
|
|
|
|
($name:ident) => {
|
|
|
|
if let Some(c) = &other.$name {
|
|
|
|
Some(c.clone())
|
|
|
|
} else {
|
|
|
|
self.$name.clone()
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
Self {
|
|
|
|
foreground: overlay!(foreground),
|
|
|
|
background: overlay!(background),
|
|
|
|
cursor_fg: overlay!(cursor_fg),
|
|
|
|
cursor_bg: overlay!(cursor_bg),
|
|
|
|
cursor_border: overlay!(cursor_border),
|
|
|
|
selection_fg: overlay!(selection_fg),
|
|
|
|
selection_bg: overlay!(selection_bg),
|
|
|
|
ansi: overlay!(ansi),
|
|
|
|
brights: overlay!(brights),
|
|
|
|
tab_bar: match (&self.tab_bar, &other.tab_bar) {
|
|
|
|
(Some(a), Some(b)) => Some(a.overlay_with(&b)),
|
|
|
|
(None, Some(b)) => Some(b.clone()),
|
|
|
|
(Some(a), None) => Some(a.clone()),
|
|
|
|
(None, None) => None,
|
|
|
|
},
|
|
|
|
indexed: {
|
|
|
|
let mut map = self.indexed.clone();
|
|
|
|
for (k, v) in &other.indexed {
|
2023-03-15 05:37:44 +03:00
|
|
|
map.insert(*k, *v);
|
2022-08-20 21:48:22 +03:00
|
|
|
}
|
|
|
|
map
|
|
|
|
},
|
|
|
|
scrollbar_thumb: overlay!(scrollbar_thumb),
|
|
|
|
split: overlay!(split),
|
|
|
|
visual_bell: overlay!(visual_bell),
|
|
|
|
compose_cursor: overlay!(compose_cursor),
|
|
|
|
copy_mode_active_highlight_fg: overlay!(copy_mode_active_highlight_fg),
|
|
|
|
copy_mode_active_highlight_bg: overlay!(copy_mode_active_highlight_bg),
|
|
|
|
copy_mode_inactive_highlight_fg: overlay!(copy_mode_inactive_highlight_fg),
|
|
|
|
copy_mode_inactive_highlight_bg: overlay!(copy_mode_inactive_highlight_bg),
|
|
|
|
quick_select_label_fg: overlay!(quick_select_label_fg),
|
|
|
|
quick_select_label_bg: overlay!(quick_select_label_bg),
|
|
|
|
quick_select_match_fg: overlay!(quick_select_match_fg),
|
|
|
|
quick_select_match_bg: overlay!(quick_select_match_bg),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-15 07:41:39 +03:00
|
|
|
impl From<ColorPalette> for Palette {
|
|
|
|
fn from(cp: ColorPalette) -> Palette {
|
|
|
|
let mut p = Palette::default();
|
|
|
|
macro_rules! apply_color {
|
|
|
|
($name:ident) => {
|
|
|
|
p.$name = Some(cp.$name.into());
|
|
|
|
};
|
|
|
|
}
|
|
|
|
apply_color!(foreground);
|
|
|
|
apply_color!(background);
|
|
|
|
apply_color!(cursor_fg);
|
|
|
|
apply_color!(cursor_bg);
|
|
|
|
apply_color!(cursor_border);
|
|
|
|
apply_color!(selection_fg);
|
|
|
|
apply_color!(selection_bg);
|
|
|
|
apply_color!(scrollbar_thumb);
|
|
|
|
apply_color!(split);
|
|
|
|
|
|
|
|
let mut ansi = [RgbaColor::default(); 8];
|
|
|
|
for (idx, col) in cp.colors.0[0..8].iter().enumerate() {
|
|
|
|
ansi[idx] = (*col).into();
|
|
|
|
}
|
|
|
|
p.ansi = Some(ansi);
|
|
|
|
|
|
|
|
let mut brights = [RgbaColor::default(); 8];
|
|
|
|
for (idx, col) in cp.colors.0[8..16].iter().enumerate() {
|
|
|
|
brights[idx] = (*col).into();
|
|
|
|
}
|
|
|
|
p.brights = Some(brights);
|
|
|
|
|
|
|
|
for (idx, col) in cp.colors.0.iter().enumerate().skip(16) {
|
|
|
|
p.indexed.insert(idx as u8, (*col).into());
|
|
|
|
}
|
|
|
|
|
|
|
|
p
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<Palette> for ColorPalette {
|
|
|
|
fn from(cfg: Palette) -> ColorPalette {
|
|
|
|
let mut p = ColorPalette::default();
|
2019-11-24 18:44:17 +03:00
|
|
|
macro_rules! apply_color {
|
|
|
|
($name:ident) => {
|
|
|
|
if let Some($name) = cfg.$name {
|
2022-02-06 01:13:19 +03:00
|
|
|
p.$name = $name.into();
|
2019-11-24 18:44:17 +03:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
apply_color!(foreground);
|
|
|
|
apply_color!(background);
|
|
|
|
apply_color!(cursor_fg);
|
|
|
|
apply_color!(cursor_bg);
|
2019-12-22 23:58:07 +03:00
|
|
|
apply_color!(cursor_border);
|
2019-11-24 18:44:17 +03:00
|
|
|
apply_color!(selection_fg);
|
|
|
|
apply_color!(selection_bg);
|
2019-12-23 05:57:54 +03:00
|
|
|
apply_color!(scrollbar_thumb);
|
2020-10-20 08:03:21 +03:00
|
|
|
apply_color!(split);
|
2019-11-24 18:44:17 +03:00
|
|
|
|
|
|
|
if let Some(ansi) = cfg.ansi {
|
|
|
|
for (idx, col) in ansi.iter().enumerate() {
|
2022-04-08 17:08:33 +03:00
|
|
|
p.colors.0[idx] = (*col).into();
|
2019-11-24 18:44:17 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if let Some(brights) = cfg.brights {
|
|
|
|
for (idx, col) in brights.iter().enumerate() {
|
2022-04-08 17:08:33 +03:00
|
|
|
p.colors.0[idx + 8] = (*col).into();
|
2019-11-24 18:44:17 +03:00
|
|
|
}
|
|
|
|
}
|
2021-08-22 11:10:38 +03:00
|
|
|
for (&idx, &col) in &cfg.indexed {
|
2022-05-18 19:31:10 +03:00
|
|
|
if idx < 16 {
|
|
|
|
log::warn!(
|
|
|
|
"Ignoring invalid colors.indexed index {}; \
|
|
|
|
use `ansi` or `brights` to specify lower indices",
|
|
|
|
idx
|
|
|
|
);
|
|
|
|
continue;
|
|
|
|
}
|
2022-04-08 17:08:33 +03:00
|
|
|
p.colors.0[idx as usize] = col.into();
|
2021-08-21 14:46:52 +03:00
|
|
|
}
|
2019-11-24 18:44:17 +03:00
|
|
|
p
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Specify the text styling for a tab in the tab bar
|
2022-07-10 23:26:33 +03:00
|
|
|
#[derive(Debug, Clone, Default, PartialEq, FromDynamic, ToDynamic)]
|
2019-11-24 18:44:17 +03:00
|
|
|
pub struct TabBarColor {
|
|
|
|
/// Specifies the intensity attribute for the tab title text
|
2022-05-14 18:00:03 +03:00
|
|
|
#[dynamic(default)]
|
2020-06-13 19:04:13 +03:00
|
|
|
pub intensity: wezterm_term::Intensity,
|
2019-11-24 18:44:17 +03:00
|
|
|
/// Specifies the underline attribute for the tab title text
|
2022-05-14 18:00:03 +03:00
|
|
|
#[dynamic(default)]
|
2020-06-13 19:04:13 +03:00
|
|
|
pub underline: wezterm_term::Underline,
|
2019-11-24 18:44:17 +03:00
|
|
|
/// Specifies the italic attribute for the tab title text
|
2022-05-14 18:00:03 +03:00
|
|
|
#[dynamic(default)]
|
2019-11-24 18:44:17 +03:00
|
|
|
pub italic: bool,
|
|
|
|
/// Specifies the strikethrough attribute for the tab title text
|
2022-05-14 18:00:03 +03:00
|
|
|
#[dynamic(default)]
|
2019-11-24 18:44:17 +03:00
|
|
|
pub strikethrough: bool,
|
|
|
|
/// The background color for the tab
|
2022-07-27 05:39:53 +03:00
|
|
|
pub bg_color: RgbaColor,
|
2019-11-24 18:44:17 +03:00
|
|
|
/// The forgeground/text color for the tab
|
2022-07-27 05:39:53 +03:00
|
|
|
pub fg_color: RgbaColor,
|
2019-11-24 18:44:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
impl TabBarColor {
|
|
|
|
pub fn as_cell_attributes(&self) -> CellAttributes {
|
|
|
|
let mut attr = CellAttributes::default();
|
|
|
|
attr.set_intensity(self.intensity)
|
|
|
|
.set_underline(self.underline)
|
|
|
|
.set_italic(self.italic)
|
|
|
|
.set_strikethrough(self.strikethrough)
|
2022-07-29 03:54:07 +03:00
|
|
|
.set_background(TWColorSpec::TrueColor(*self.bg_color))
|
|
|
|
.set_foreground(TWColorSpec::TrueColor(*self.fg_color));
|
2019-11-24 18:44:17 +03:00
|
|
|
attr
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Specifies the colors to use for the tab bar portion of the UI.
|
|
|
|
/// These are not part of the terminal model and cannot be updated
|
|
|
|
/// in the same way that the dynamic color schemes are.
|
2022-08-20 21:48:22 +03:00
|
|
|
#[derive(Default, Debug, Clone, PartialEq, FromDynamic, ToDynamic)]
|
2019-11-24 18:44:17 +03:00
|
|
|
pub struct TabBarColors {
|
|
|
|
/// The background color for the tab bar
|
2022-08-20 21:48:22 +03:00
|
|
|
#[dynamic(default)]
|
|
|
|
pub background: Option<RgbaColor>,
|
2019-11-24 18:44:17 +03:00
|
|
|
|
|
|
|
/// Styling for the active tab
|
2022-08-20 21:48:22 +03:00
|
|
|
#[dynamic(default)]
|
|
|
|
pub active_tab: Option<TabBarColor>,
|
2020-02-09 20:34:59 +03:00
|
|
|
|
2019-11-24 18:44:17 +03:00
|
|
|
/// Styling for other inactive tabs
|
2022-08-20 21:48:22 +03:00
|
|
|
#[dynamic(default)]
|
|
|
|
pub inactive_tab: Option<TabBarColor>,
|
2020-02-09 20:34:59 +03:00
|
|
|
|
2019-11-24 18:44:17 +03:00
|
|
|
/// Styling for an inactive tab with a mouse hovering
|
2022-08-20 21:48:22 +03:00
|
|
|
#[dynamic(default)]
|
|
|
|
pub inactive_tab_hover: Option<TabBarColor>,
|
2021-07-17 18:31:11 +03:00
|
|
|
|
|
|
|
/// Styling for the new tab button
|
2022-08-20 21:48:22 +03:00
|
|
|
#[dynamic(default)]
|
|
|
|
pub new_tab: Option<TabBarColor>,
|
2021-07-17 18:31:11 +03:00
|
|
|
|
|
|
|
/// Styling for the new tab button with a mouse hovering
|
2022-08-20 21:48:22 +03:00
|
|
|
#[dynamic(default)]
|
|
|
|
pub new_tab_hover: Option<TabBarColor>,
|
2021-12-25 02:23:01 +03:00
|
|
|
|
2022-08-20 21:48:22 +03:00
|
|
|
#[dynamic(default)]
|
|
|
|
pub inactive_tab_edge: Option<RgbaColor>,
|
2021-12-25 02:23:01 +03:00
|
|
|
|
2022-08-20 21:48:22 +03:00
|
|
|
#[dynamic(default)]
|
|
|
|
pub inactive_tab_edge_hover: Option<RgbaColor>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl TabBarColors {
|
|
|
|
pub fn background(&self) -> RgbaColor {
|
|
|
|
self.background.unwrap_or_else(default_background)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn active_tab(&self) -> TabBarColor {
|
|
|
|
self.active_tab.clone().unwrap_or_else(default_active_tab)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn inactive_tab(&self) -> TabBarColor {
|
|
|
|
self.inactive_tab
|
|
|
|
.clone()
|
|
|
|
.unwrap_or_else(default_inactive_tab)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn inactive_tab_hover(&self) -> TabBarColor {
|
|
|
|
self.inactive_tab_hover
|
|
|
|
.clone()
|
|
|
|
.unwrap_or_else(default_inactive_tab_hover)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn new_tab(&self) -> TabBarColor {
|
|
|
|
self.new_tab.clone().unwrap_or_else(default_inactive_tab)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn new_tab_hover(&self) -> TabBarColor {
|
|
|
|
self.new_tab_hover
|
|
|
|
.clone()
|
|
|
|
.unwrap_or_else(default_inactive_tab_hover)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn inactive_tab_edge(&self) -> RgbaColor {
|
|
|
|
self.inactive_tab_edge
|
|
|
|
.unwrap_or_else(default_inactive_tab_edge)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn inactive_tab_edge_hover(&self) -> RgbaColor {
|
|
|
|
self.inactive_tab_edge_hover
|
|
|
|
.unwrap_or_else(default_inactive_tab_edge_hover)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn overlay_with(&self, other: &Self) -> Self {
|
|
|
|
macro_rules! overlay {
|
|
|
|
($name:ident) => {
|
|
|
|
if let Some(c) = &other.$name {
|
|
|
|
Some(c.clone())
|
|
|
|
} else {
|
|
|
|
self.$name.clone()
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
Self {
|
|
|
|
active_tab: overlay!(active_tab),
|
|
|
|
background: overlay!(background),
|
|
|
|
inactive_tab: overlay!(inactive_tab),
|
|
|
|
inactive_tab_hover: overlay!(inactive_tab_hover),
|
|
|
|
inactive_tab_edge: overlay!(inactive_tab_edge),
|
|
|
|
inactive_tab_edge_hover: overlay!(inactive_tab_edge_hover),
|
|
|
|
new_tab: overlay!(new_tab),
|
|
|
|
new_tab_hover: overlay!(new_tab_hover),
|
2022-11-18 18:15:14 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Default, Debug, Clone, PartialEq, FromDynamic, ToDynamic)]
|
|
|
|
#[dynamic(try_from = "String")]
|
|
|
|
pub enum IntegratedTitleButtonColor {
|
|
|
|
#[default]
|
|
|
|
Auto,
|
|
|
|
Custom(RgbaColor),
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Into<String> for IntegratedTitleButtonColor {
|
|
|
|
fn into(self) -> String {
|
|
|
|
match self {
|
|
|
|
Self::Auto => "auto".to_string(),
|
|
|
|
Self::Custom(color) => color.into(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl TryFrom<String> for IntegratedTitleButtonColor {
|
|
|
|
type Error = <RgbaColor as TryFrom<String>>::Error;
|
|
|
|
|
|
|
|
fn try_from(value: String) -> Result<Self, Self::Error> {
|
2023-04-01 07:52:54 +03:00
|
|
|
if value.eq_ignore_ascii_case("auto") {
|
2022-11-18 18:15:14 +03:00
|
|
|
Ok(Self::Auto)
|
|
|
|
} else {
|
|
|
|
Ok(Self::Custom(RgbaColor::try_from(value)?))
|
2022-08-20 21:48:22 +03:00
|
|
|
}
|
|
|
|
}
|
2019-11-24 18:44:17 +03:00
|
|
|
}
|
|
|
|
|
2022-07-27 05:39:53 +03:00
|
|
|
fn default_background() -> RgbaColor {
|
|
|
|
(0x33, 0x33, 0x33).into()
|
2021-12-25 02:23:01 +03:00
|
|
|
}
|
|
|
|
|
2022-04-08 17:08:33 +03:00
|
|
|
fn default_inactive_tab_edge() -> RgbaColor {
|
|
|
|
RgbColor::new_8bpc(0x57, 0x57, 0x57).into()
|
2021-12-25 02:23:01 +03:00
|
|
|
}
|
|
|
|
|
2022-04-08 17:08:33 +03:00
|
|
|
fn default_inactive_tab_edge_hover() -> RgbaColor {
|
|
|
|
RgbColor::new_8bpc(0x36, 0x36, 0x36).into()
|
2020-02-09 20:34:59 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
fn default_inactive_tab() -> TabBarColor {
|
|
|
|
TabBarColor {
|
2022-07-27 05:39:53 +03:00
|
|
|
bg_color: (0x33, 0x33, 0x33).into(),
|
|
|
|
fg_color: (0x80, 0x80, 0x80).into(),
|
2020-02-09 20:34:59 +03:00
|
|
|
..TabBarColor::default()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn default_inactive_tab_hover() -> TabBarColor {
|
|
|
|
TabBarColor {
|
2022-07-27 05:39:53 +03:00
|
|
|
bg_color: (0x1f, 0x1f, 0x1f).into(),
|
|
|
|
fg_color: (0x90, 0x90, 0x90).into(),
|
2020-02-09 20:34:59 +03:00
|
|
|
italic: true,
|
|
|
|
..TabBarColor::default()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn default_active_tab() -> TabBarColor {
|
|
|
|
TabBarColor {
|
2022-07-27 05:39:53 +03:00
|
|
|
bg_color: (0x00, 0x00, 0x00).into(),
|
|
|
|
fg_color: (0xc0, 0xc0, 0xc0).into(),
|
2020-02-09 20:34:59 +03:00
|
|
|
..TabBarColor::default()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-14 18:00:03 +03:00
|
|
|
#[derive(Debug, Clone, FromDynamic, ToDynamic)]
|
add config for customizing the tabs and new tab button
```lua
local wezterm = require 'wezterm';
-- The filled in variant of the < symbol
local SOLID_LEFT_ARROW = utf8.char(0xe0b2)
-- The filled in variant of the > symbol
local SOLID_RIGHT_ARROW = utf8.char(0xe0b0)
return {
tab_bar_style = {
active_tab_left = wezterm.format({
{Background={Color="#0b0022"}},
{Foreground={Color="#2b2042"}},
{Text=SOLID_LEFT_ARROW},
}),
active_tab_right = wezterm.format({
{Background={Color="#0b0022"}},
{Foreground={Color="#2b2042"}},
{Text=SOLID_RIGHT_ARROW},
}),
inactive_tab_left = wezterm.format({
{Background={Color="#0b0022"}},
{Foreground={Color="#1b1032"}},
{Text=SOLID_LEFT_ARROW},
}),
inactive_tab_right = wezterm.format({
{Background={Color="#0b0022"}},
{Foreground={Color="#1b1032"}},
{Text=SOLID_RIGHT_ARROW},
}),
}
}
```
2021-03-12 08:21:31 +03:00
|
|
|
pub struct TabBarStyle {
|
2022-05-14 18:00:03 +03:00
|
|
|
#[dynamic(default = "default_new_tab")]
|
2021-07-17 18:31:11 +03:00
|
|
|
pub new_tab: String,
|
2022-05-14 18:00:03 +03:00
|
|
|
#[dynamic(default = "default_new_tab")]
|
2021-07-17 18:31:11 +03:00
|
|
|
pub new_tab_hover: String,
|
2022-11-07 21:39:44 +03:00
|
|
|
#[dynamic(default = "default_window_hide")]
|
|
|
|
pub window_hide: String,
|
|
|
|
#[dynamic(default = "default_window_hide")]
|
|
|
|
pub window_hide_hover: String,
|
|
|
|
#[dynamic(default = "default_window_maximize")]
|
|
|
|
pub window_maximize: String,
|
|
|
|
#[dynamic(default = "default_window_maximize")]
|
|
|
|
pub window_maximize_hover: String,
|
|
|
|
#[dynamic(default = "default_window_close")]
|
|
|
|
pub window_close: String,
|
|
|
|
#[dynamic(default = "default_window_close")]
|
|
|
|
pub window_close_hover: String,
|
add config for customizing the tabs and new tab button
```lua
local wezterm = require 'wezterm';
-- The filled in variant of the < symbol
local SOLID_LEFT_ARROW = utf8.char(0xe0b2)
-- The filled in variant of the > symbol
local SOLID_RIGHT_ARROW = utf8.char(0xe0b0)
return {
tab_bar_style = {
active_tab_left = wezterm.format({
{Background={Color="#0b0022"}},
{Foreground={Color="#2b2042"}},
{Text=SOLID_LEFT_ARROW},
}),
active_tab_right = wezterm.format({
{Background={Color="#0b0022"}},
{Foreground={Color="#2b2042"}},
{Text=SOLID_RIGHT_ARROW},
}),
inactive_tab_left = wezterm.format({
{Background={Color="#0b0022"}},
{Foreground={Color="#1b1032"}},
{Text=SOLID_LEFT_ARROW},
}),
inactive_tab_right = wezterm.format({
{Background={Color="#0b0022"}},
{Foreground={Color="#1b1032"}},
{Text=SOLID_RIGHT_ARROW},
}),
}
}
```
2021-03-12 08:21:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Default for TabBarStyle {
|
|
|
|
fn default() -> Self {
|
|
|
|
Self {
|
2021-07-17 18:31:11 +03:00
|
|
|
new_tab: default_new_tab(),
|
|
|
|
new_tab_hover: default_new_tab(),
|
2022-11-07 21:39:44 +03:00
|
|
|
window_hide: default_window_hide(),
|
|
|
|
window_hide_hover: default_window_hide(),
|
|
|
|
window_maximize: default_window_maximize(),
|
|
|
|
window_maximize_hover: default_window_maximize(),
|
|
|
|
window_close: default_window_close(),
|
|
|
|
window_close_hover: default_window_close(),
|
add config for customizing the tabs and new tab button
```lua
local wezterm = require 'wezterm';
-- The filled in variant of the < symbol
local SOLID_LEFT_ARROW = utf8.char(0xe0b2)
-- The filled in variant of the > symbol
local SOLID_RIGHT_ARROW = utf8.char(0xe0b0)
return {
tab_bar_style = {
active_tab_left = wezterm.format({
{Background={Color="#0b0022"}},
{Foreground={Color="#2b2042"}},
{Text=SOLID_LEFT_ARROW},
}),
active_tab_right = wezterm.format({
{Background={Color="#0b0022"}},
{Foreground={Color="#2b2042"}},
{Text=SOLID_RIGHT_ARROW},
}),
inactive_tab_left = wezterm.format({
{Background={Color="#0b0022"}},
{Foreground={Color="#1b1032"}},
{Text=SOLID_LEFT_ARROW},
}),
inactive_tab_right = wezterm.format({
{Background={Color="#0b0022"}},
{Foreground={Color="#1b1032"}},
{Text=SOLID_RIGHT_ARROW},
}),
}
}
```
2021-03-12 08:21:31 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-17 18:31:11 +03:00
|
|
|
fn default_new_tab() -> String {
|
2022-05-19 08:49:53 +03:00
|
|
|
" + ".to_string()
|
add config for customizing the tabs and new tab button
```lua
local wezterm = require 'wezterm';
-- The filled in variant of the < symbol
local SOLID_LEFT_ARROW = utf8.char(0xe0b2)
-- The filled in variant of the > symbol
local SOLID_RIGHT_ARROW = utf8.char(0xe0b0)
return {
tab_bar_style = {
active_tab_left = wezterm.format({
{Background={Color="#0b0022"}},
{Foreground={Color="#2b2042"}},
{Text=SOLID_LEFT_ARROW},
}),
active_tab_right = wezterm.format({
{Background={Color="#0b0022"}},
{Foreground={Color="#2b2042"}},
{Text=SOLID_RIGHT_ARROW},
}),
inactive_tab_left = wezterm.format({
{Background={Color="#0b0022"}},
{Foreground={Color="#1b1032"}},
{Text=SOLID_LEFT_ARROW},
}),
inactive_tab_right = wezterm.format({
{Background={Color="#0b0022"}},
{Foreground={Color="#1b1032"}},
{Text=SOLID_RIGHT_ARROW},
}),
}
}
```
2021-03-12 08:21:31 +03:00
|
|
|
}
|
|
|
|
|
2022-11-07 21:39:44 +03:00
|
|
|
fn default_window_hide() -> String {
|
|
|
|
" . ".to_string()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn default_window_maximize() -> String {
|
|
|
|
" - ".to_string()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn default_window_close() -> String {
|
|
|
|
" X ".to_string()
|
|
|
|
}
|
|
|
|
|
2022-05-14 18:00:03 +03:00
|
|
|
#[derive(Debug, Clone, FromDynamic, ToDynamic)]
|
wayland: move frame color config to the config file
This simplifies it a bit and exposes the config via the config file;
the following options are possible, each one specifies a color
```lua
return {
window_frame = {
inactive_titlebar_bg = "",
active_titlebar_bg = "",
inactive_titlebar_fg = "",
active_titlebar_fg = "",
inactive_titlebar_border_bottom = "",
active_titlebar_border_bottom = "",
button_fg = "",
button_bg = "",
button_hover_fg = "",
button_hover_bg = "",
}
}
```
refs: https://github.com/wez/wezterm/issues/761
2021-06-27 22:19:42 +03:00
|
|
|
pub struct WindowFrameConfig {
|
2022-05-14 18:00:03 +03:00
|
|
|
#[dynamic(default = "default_inactive_titlebar_bg")]
|
wayland: move frame color config to the config file
This simplifies it a bit and exposes the config via the config file;
the following options are possible, each one specifies a color
```lua
return {
window_frame = {
inactive_titlebar_bg = "",
active_titlebar_bg = "",
inactive_titlebar_fg = "",
active_titlebar_fg = "",
inactive_titlebar_border_bottom = "",
active_titlebar_border_bottom = "",
button_fg = "",
button_bg = "",
button_hover_fg = "",
button_hover_bg = "",
}
}
```
refs: https://github.com/wez/wezterm/issues/761
2021-06-27 22:19:42 +03:00
|
|
|
pub inactive_titlebar_bg: RgbColor,
|
2022-05-14 18:00:03 +03:00
|
|
|
#[dynamic(default = "default_active_titlebar_bg")]
|
wayland: move frame color config to the config file
This simplifies it a bit and exposes the config via the config file;
the following options are possible, each one specifies a color
```lua
return {
window_frame = {
inactive_titlebar_bg = "",
active_titlebar_bg = "",
inactive_titlebar_fg = "",
active_titlebar_fg = "",
inactive_titlebar_border_bottom = "",
active_titlebar_border_bottom = "",
button_fg = "",
button_bg = "",
button_hover_fg = "",
button_hover_bg = "",
}
}
```
refs: https://github.com/wez/wezterm/issues/761
2021-06-27 22:19:42 +03:00
|
|
|
pub active_titlebar_bg: RgbColor,
|
2022-05-14 18:00:03 +03:00
|
|
|
#[dynamic(default = "default_inactive_titlebar_fg")]
|
wayland: move frame color config to the config file
This simplifies it a bit and exposes the config via the config file;
the following options are possible, each one specifies a color
```lua
return {
window_frame = {
inactive_titlebar_bg = "",
active_titlebar_bg = "",
inactive_titlebar_fg = "",
active_titlebar_fg = "",
inactive_titlebar_border_bottom = "",
active_titlebar_border_bottom = "",
button_fg = "",
button_bg = "",
button_hover_fg = "",
button_hover_bg = "",
}
}
```
refs: https://github.com/wez/wezterm/issues/761
2021-06-27 22:19:42 +03:00
|
|
|
pub inactive_titlebar_fg: RgbColor,
|
2022-05-14 18:00:03 +03:00
|
|
|
#[dynamic(default = "default_active_titlebar_fg")]
|
wayland: move frame color config to the config file
This simplifies it a bit and exposes the config via the config file;
the following options are possible, each one specifies a color
```lua
return {
window_frame = {
inactive_titlebar_bg = "",
active_titlebar_bg = "",
inactive_titlebar_fg = "",
active_titlebar_fg = "",
inactive_titlebar_border_bottom = "",
active_titlebar_border_bottom = "",
button_fg = "",
button_bg = "",
button_hover_fg = "",
button_hover_bg = "",
}
}
```
refs: https://github.com/wez/wezterm/issues/761
2021-06-27 22:19:42 +03:00
|
|
|
pub active_titlebar_fg: RgbColor,
|
2022-05-14 18:00:03 +03:00
|
|
|
#[dynamic(default = "default_inactive_titlebar_border_bottom")]
|
wayland: move frame color config to the config file
This simplifies it a bit and exposes the config via the config file;
the following options are possible, each one specifies a color
```lua
return {
window_frame = {
inactive_titlebar_bg = "",
active_titlebar_bg = "",
inactive_titlebar_fg = "",
active_titlebar_fg = "",
inactive_titlebar_border_bottom = "",
active_titlebar_border_bottom = "",
button_fg = "",
button_bg = "",
button_hover_fg = "",
button_hover_bg = "",
}
}
```
refs: https://github.com/wez/wezterm/issues/761
2021-06-27 22:19:42 +03:00
|
|
|
pub inactive_titlebar_border_bottom: RgbColor,
|
2022-05-14 18:00:03 +03:00
|
|
|
#[dynamic(default = "default_active_titlebar_border_bottom")]
|
wayland: move frame color config to the config file
This simplifies it a bit and exposes the config via the config file;
the following options are possible, each one specifies a color
```lua
return {
window_frame = {
inactive_titlebar_bg = "",
active_titlebar_bg = "",
inactive_titlebar_fg = "",
active_titlebar_fg = "",
inactive_titlebar_border_bottom = "",
active_titlebar_border_bottom = "",
button_fg = "",
button_bg = "",
button_hover_fg = "",
button_hover_bg = "",
}
}
```
refs: https://github.com/wez/wezterm/issues/761
2021-06-27 22:19:42 +03:00
|
|
|
pub active_titlebar_border_bottom: RgbColor,
|
2022-05-14 18:00:03 +03:00
|
|
|
#[dynamic(default = "default_button_fg")]
|
wayland: move frame color config to the config file
This simplifies it a bit and exposes the config via the config file;
the following options are possible, each one specifies a color
```lua
return {
window_frame = {
inactive_titlebar_bg = "",
active_titlebar_bg = "",
inactive_titlebar_fg = "",
active_titlebar_fg = "",
inactive_titlebar_border_bottom = "",
active_titlebar_border_bottom = "",
button_fg = "",
button_bg = "",
button_hover_fg = "",
button_hover_bg = "",
}
}
```
refs: https://github.com/wez/wezterm/issues/761
2021-06-27 22:19:42 +03:00
|
|
|
pub button_fg: RgbColor,
|
2022-05-14 18:00:03 +03:00
|
|
|
#[dynamic(default = "default_button_bg")]
|
wayland: move frame color config to the config file
This simplifies it a bit and exposes the config via the config file;
the following options are possible, each one specifies a color
```lua
return {
window_frame = {
inactive_titlebar_bg = "",
active_titlebar_bg = "",
inactive_titlebar_fg = "",
active_titlebar_fg = "",
inactive_titlebar_border_bottom = "",
active_titlebar_border_bottom = "",
button_fg = "",
button_bg = "",
button_hover_fg = "",
button_hover_bg = "",
}
}
```
refs: https://github.com/wez/wezterm/issues/761
2021-06-27 22:19:42 +03:00
|
|
|
pub button_bg: RgbColor,
|
2022-05-14 18:00:03 +03:00
|
|
|
#[dynamic(default = "default_button_hover_fg")]
|
wayland: move frame color config to the config file
This simplifies it a bit and exposes the config via the config file;
the following options are possible, each one specifies a color
```lua
return {
window_frame = {
inactive_titlebar_bg = "",
active_titlebar_bg = "",
inactive_titlebar_fg = "",
active_titlebar_fg = "",
inactive_titlebar_border_bottom = "",
active_titlebar_border_bottom = "",
button_fg = "",
button_bg = "",
button_hover_fg = "",
button_hover_bg = "",
}
}
```
refs: https://github.com/wez/wezterm/issues/761
2021-06-27 22:19:42 +03:00
|
|
|
pub button_hover_fg: RgbColor,
|
2022-05-14 18:00:03 +03:00
|
|
|
#[dynamic(default = "default_button_hover_bg")]
|
wayland: move frame color config to the config file
This simplifies it a bit and exposes the config via the config file;
the following options are possible, each one specifies a color
```lua
return {
window_frame = {
inactive_titlebar_bg = "",
active_titlebar_bg = "",
inactive_titlebar_fg = "",
active_titlebar_fg = "",
inactive_titlebar_border_bottom = "",
active_titlebar_border_bottom = "",
button_fg = "",
button_bg = "",
button_hover_fg = "",
button_hover_bg = "",
}
}
```
refs: https://github.com/wez/wezterm/issues/761
2021-06-27 22:19:42 +03:00
|
|
|
pub button_hover_bg: RgbColor,
|
2021-06-27 23:04:20 +03:00
|
|
|
|
2022-05-14 18:00:03 +03:00
|
|
|
#[dynamic(default)]
|
2021-12-25 17:49:46 +03:00
|
|
|
pub font: Option<TextStyle>,
|
2022-05-14 18:00:03 +03:00
|
|
|
#[dynamic(default)]
|
2021-12-25 17:49:46 +03:00
|
|
|
pub font_size: Option<f64>,
|
2022-08-21 02:39:44 +03:00
|
|
|
|
|
|
|
#[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.)
|
wayland: move frame color config to the config file
This simplifies it a bit and exposes the config via the config file;
the following options are possible, each one specifies a color
```lua
return {
window_frame = {
inactive_titlebar_bg = "",
active_titlebar_bg = "",
inactive_titlebar_fg = "",
active_titlebar_fg = "",
inactive_titlebar_border_bottom = "",
active_titlebar_border_bottom = "",
button_fg = "",
button_bg = "",
button_hover_fg = "",
button_hover_bg = "",
}
}
```
refs: https://github.com/wez/wezterm/issues/761
2021-06-27 22:19:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Default for WindowFrameConfig {
|
|
|
|
fn default() -> Self {
|
|
|
|
Self {
|
|
|
|
inactive_titlebar_bg: default_inactive_titlebar_bg(),
|
|
|
|
active_titlebar_bg: default_active_titlebar_bg(),
|
|
|
|
inactive_titlebar_fg: default_inactive_titlebar_fg(),
|
|
|
|
active_titlebar_fg: default_active_titlebar_fg(),
|
|
|
|
inactive_titlebar_border_bottom: default_inactive_titlebar_border_bottom(),
|
|
|
|
active_titlebar_border_bottom: default_active_titlebar_border_bottom(),
|
|
|
|
button_fg: default_button_fg(),
|
|
|
|
button_bg: default_button_bg(),
|
|
|
|
button_hover_fg: default_button_hover_fg(),
|
|
|
|
button_hover_bg: default_button_hover_bg(),
|
2021-12-25 17:49:46 +03:00
|
|
|
font: None,
|
|
|
|
font_size: None,
|
2022-08-21 02:39:44 +03:00
|
|
|
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,
|
wayland: move frame color config to the config file
This simplifies it a bit and exposes the config via the config file;
the following options are possible, each one specifies a color
```lua
return {
window_frame = {
inactive_titlebar_bg = "",
active_titlebar_bg = "",
inactive_titlebar_fg = "",
active_titlebar_fg = "",
inactive_titlebar_border_bottom = "",
active_titlebar_border_bottom = "",
button_fg = "",
button_bg = "",
button_hover_fg = "",
button_hover_bg = "",
}
}
```
refs: https://github.com/wez/wezterm/issues/761
2021-06-27 22:19:42 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn default_inactive_titlebar_bg() -> RgbColor {
|
2021-12-25 02:23:01 +03:00
|
|
|
RgbColor::new_8bpc(0x33, 0x33, 0x33)
|
wayland: move frame color config to the config file
This simplifies it a bit and exposes the config via the config file;
the following options are possible, each one specifies a color
```lua
return {
window_frame = {
inactive_titlebar_bg = "",
active_titlebar_bg = "",
inactive_titlebar_fg = "",
active_titlebar_fg = "",
inactive_titlebar_border_bottom = "",
active_titlebar_border_bottom = "",
button_fg = "",
button_bg = "",
button_hover_fg = "",
button_hover_bg = "",
}
}
```
refs: https://github.com/wez/wezterm/issues/761
2021-06-27 22:19:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
fn default_active_titlebar_bg() -> RgbColor {
|
2021-12-25 02:23:01 +03:00
|
|
|
RgbColor::new_8bpc(0x33, 0x33, 0x33)
|
wayland: move frame color config to the config file
This simplifies it a bit and exposes the config via the config file;
the following options are possible, each one specifies a color
```lua
return {
window_frame = {
inactive_titlebar_bg = "",
active_titlebar_bg = "",
inactive_titlebar_fg = "",
active_titlebar_fg = "",
inactive_titlebar_border_bottom = "",
active_titlebar_border_bottom = "",
button_fg = "",
button_bg = "",
button_hover_fg = "",
button_hover_bg = "",
}
}
```
refs: https://github.com/wez/wezterm/issues/761
2021-06-27 22:19:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
fn default_inactive_titlebar_fg() -> RgbColor {
|
2021-07-11 00:16:57 +03:00
|
|
|
RgbColor::new_8bpc(0xcc, 0xcc, 0xcc)
|
wayland: move frame color config to the config file
This simplifies it a bit and exposes the config via the config file;
the following options are possible, each one specifies a color
```lua
return {
window_frame = {
inactive_titlebar_bg = "",
active_titlebar_bg = "",
inactive_titlebar_fg = "",
active_titlebar_fg = "",
inactive_titlebar_border_bottom = "",
active_titlebar_border_bottom = "",
button_fg = "",
button_bg = "",
button_hover_fg = "",
button_hover_bg = "",
}
}
```
refs: https://github.com/wez/wezterm/issues/761
2021-06-27 22:19:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
fn default_active_titlebar_fg() -> RgbColor {
|
2021-07-11 00:16:57 +03:00
|
|
|
RgbColor::new_8bpc(0xff, 0xff, 0xff)
|
wayland: move frame color config to the config file
This simplifies it a bit and exposes the config via the config file;
the following options are possible, each one specifies a color
```lua
return {
window_frame = {
inactive_titlebar_bg = "",
active_titlebar_bg = "",
inactive_titlebar_fg = "",
active_titlebar_fg = "",
inactive_titlebar_border_bottom = "",
active_titlebar_border_bottom = "",
button_fg = "",
button_bg = "",
button_hover_fg = "",
button_hover_bg = "",
}
}
```
refs: https://github.com/wez/wezterm/issues/761
2021-06-27 22:19:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
fn default_inactive_titlebar_border_bottom() -> RgbColor {
|
2021-07-11 00:16:57 +03:00
|
|
|
RgbColor::new_8bpc(0x2b, 0x20, 0x42)
|
wayland: move frame color config to the config file
This simplifies it a bit and exposes the config via the config file;
the following options are possible, each one specifies a color
```lua
return {
window_frame = {
inactive_titlebar_bg = "",
active_titlebar_bg = "",
inactive_titlebar_fg = "",
active_titlebar_fg = "",
inactive_titlebar_border_bottom = "",
active_titlebar_border_bottom = "",
button_fg = "",
button_bg = "",
button_hover_fg = "",
button_hover_bg = "",
}
}
```
refs: https://github.com/wez/wezterm/issues/761
2021-06-27 22:19:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
fn default_active_titlebar_border_bottom() -> RgbColor {
|
2021-07-11 00:16:57 +03:00
|
|
|
RgbColor::new_8bpc(0x2b, 0x20, 0x42)
|
wayland: move frame color config to the config file
This simplifies it a bit and exposes the config via the config file;
the following options are possible, each one specifies a color
```lua
return {
window_frame = {
inactive_titlebar_bg = "",
active_titlebar_bg = "",
inactive_titlebar_fg = "",
active_titlebar_fg = "",
inactive_titlebar_border_bottom = "",
active_titlebar_border_bottom = "",
button_fg = "",
button_bg = "",
button_hover_fg = "",
button_hover_bg = "",
}
}
```
refs: https://github.com/wez/wezterm/issues/761
2021-06-27 22:19:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
fn default_button_hover_fg() -> RgbColor {
|
2021-07-11 00:16:57 +03:00
|
|
|
RgbColor::new_8bpc(0xff, 0xff, 0xff)
|
wayland: move frame color config to the config file
This simplifies it a bit and exposes the config via the config file;
the following options are possible, each one specifies a color
```lua
return {
window_frame = {
inactive_titlebar_bg = "",
active_titlebar_bg = "",
inactive_titlebar_fg = "",
active_titlebar_fg = "",
inactive_titlebar_border_bottom = "",
active_titlebar_border_bottom = "",
button_fg = "",
button_bg = "",
button_hover_fg = "",
button_hover_bg = "",
}
}
```
refs: https://github.com/wez/wezterm/issues/761
2021-06-27 22:19:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
fn default_button_fg() -> RgbColor {
|
2021-07-11 00:16:57 +03:00
|
|
|
RgbColor::new_8bpc(0xcc, 0xcc, 0xcc)
|
wayland: move frame color config to the config file
This simplifies it a bit and exposes the config via the config file;
the following options are possible, each one specifies a color
```lua
return {
window_frame = {
inactive_titlebar_bg = "",
active_titlebar_bg = "",
inactive_titlebar_fg = "",
active_titlebar_fg = "",
inactive_titlebar_border_bottom = "",
active_titlebar_border_bottom = "",
button_fg = "",
button_bg = "",
button_hover_fg = "",
button_hover_bg = "",
}
}
```
refs: https://github.com/wez/wezterm/issues/761
2021-06-27 22:19:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
fn default_button_hover_bg() -> RgbColor {
|
2021-12-25 02:23:01 +03:00
|
|
|
RgbColor::new_8bpc(0x1f, 0x1f, 0x1f)
|
wayland: move frame color config to the config file
This simplifies it a bit and exposes the config via the config file;
the following options are possible, each one specifies a color
```lua
return {
window_frame = {
inactive_titlebar_bg = "",
active_titlebar_bg = "",
inactive_titlebar_fg = "",
active_titlebar_fg = "",
inactive_titlebar_border_bottom = "",
active_titlebar_border_bottom = "",
button_fg = "",
button_bg = "",
button_hover_fg = "",
button_hover_bg = "",
}
}
```
refs: https://github.com/wez/wezterm/issues/761
2021-06-27 22:19:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
fn default_button_bg() -> RgbColor {
|
2021-12-25 02:23:01 +03:00
|
|
|
RgbColor::new_8bpc(0x33, 0x33, 0x33)
|
wayland: move frame color config to the config file
This simplifies it a bit and exposes the config via the config file;
the following options are possible, each one specifies a color
```lua
return {
window_frame = {
inactive_titlebar_bg = "",
active_titlebar_bg = "",
inactive_titlebar_fg = "",
active_titlebar_fg = "",
inactive_titlebar_border_bottom = "",
active_titlebar_border_bottom = "",
button_fg = "",
button_bg = "",
button_hover_fg = "",
button_hover_bg = "",
}
}
```
refs: https://github.com/wez/wezterm/issues/761
2021-06-27 22:19:42 +03:00
|
|
|
}
|
|
|
|
|
2022-07-10 23:26:33 +03:00
|
|
|
#[derive(Debug, Default, Clone, Eq, PartialEq, FromDynamic, ToDynamic)]
|
|
|
|
pub struct ColorSchemeMetaData {
|
|
|
|
pub name: Option<String>,
|
|
|
|
pub author: Option<String>,
|
|
|
|
pub origin_url: Option<String>,
|
2022-07-14 18:45:29 +03:00
|
|
|
pub wezterm_version: Option<String>,
|
2022-07-20 17:32:46 +03:00
|
|
|
#[dynamic(default)]
|
|
|
|
pub aliases: Vec<String>,
|
2022-07-10 23:26:33 +03:00
|
|
|
}
|
2022-07-15 09:03:18 +03:00
|
|
|
impl_lua_conversion_dynamic!(ColorSchemeMetaData);
|
2022-07-10 23:26:33 +03:00
|
|
|
|
|
|
|
#[derive(Debug, Clone, PartialEq, FromDynamic, ToDynamic)]
|
2020-01-13 08:40:30 +03:00
|
|
|
pub struct ColorSchemeFile {
|
|
|
|
/// The color palette
|
|
|
|
pub colors: Palette,
|
2022-07-10 23:26:33 +03:00
|
|
|
/// Info about the scheme
|
|
|
|
#[dynamic(default)]
|
|
|
|
pub metadata: ColorSchemeMetaData,
|
2020-01-13 08:40:30 +03:00
|
|
|
}
|
2022-07-15 09:03:18 +03:00
|
|
|
impl_lua_conversion_dynamic!(ColorSchemeFile);
|
2022-05-14 18:00:03 +03:00
|
|
|
|
2022-07-15 09:22:02 +03:00
|
|
|
fn dynamic_to_toml(value: Value) -> anyhow::Result<toml::Value> {
|
|
|
|
Ok(match value {
|
|
|
|
Value::Null => anyhow::bail!("cannot map Null to toml"),
|
|
|
|
Value::Bool(b) => toml::Value::Boolean(b),
|
|
|
|
Value::String(s) => toml::Value::String(s),
|
|
|
|
Value::Array(a) => {
|
|
|
|
let mut arr = vec![];
|
|
|
|
for v in a {
|
|
|
|
arr.push(dynamic_to_toml(v)?);
|
|
|
|
}
|
|
|
|
toml::Value::Array(arr)
|
|
|
|
}
|
|
|
|
Value::Object(o) => {
|
2023-01-30 07:08:25 +03:00
|
|
|
let mut map = toml::map::Map::new();
|
2022-07-15 09:22:02 +03:00
|
|
|
for (k, v) in o {
|
|
|
|
let k = match k {
|
|
|
|
Value::String(s) => s,
|
2022-07-16 01:42:26 +03:00
|
|
|
Value::U64(u) => u.to_string(),
|
|
|
|
Value::I64(u) => u.to_string(),
|
|
|
|
Value::F64(u) => u.to_string(),
|
2022-07-15 09:22:02 +03:00
|
|
|
_ => anyhow::bail!("toml keys must be strings {k:?}"),
|
|
|
|
};
|
|
|
|
let v = match v {
|
|
|
|
Value::Null => continue,
|
|
|
|
other => dynamic_to_toml(other)?,
|
|
|
|
};
|
|
|
|
map.insert(k, v);
|
|
|
|
}
|
|
|
|
toml::Value::Table(map)
|
|
|
|
}
|
|
|
|
Value::U64(i) => toml::Value::Integer(i.try_into()?),
|
|
|
|
Value::I64(i) => toml::Value::Integer(i.try_into()?),
|
|
|
|
Value::F64(f) => toml::Value::Float(*f),
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2022-05-14 18:00:03 +03:00
|
|
|
impl ColorSchemeFile {
|
|
|
|
pub fn from_toml_value(value: &toml::Value) -> anyhow::Result<Self> {
|
|
|
|
Self::from_dynamic(&crate::toml_to_dynamic(value), Default::default())
|
|
|
|
.map_err(|e| anyhow::anyhow!("{}", e))
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn from_toml_str(s: &str) -> anyhow::Result<Self> {
|
|
|
|
let scheme: toml::Value = toml::from_str(s)?;
|
2022-07-19 22:00:49 +03:00
|
|
|
Self::from_toml_value(&scheme)
|
2022-05-14 18:00:03 +03:00
|
|
|
}
|
2022-07-15 09:22:02 +03:00
|
|
|
|
|
|
|
pub fn to_toml_value(&self) -> anyhow::Result<toml::Value> {
|
|
|
|
let value = self.to_dynamic();
|
|
|
|
Ok(dynamic_to_toml(value)?)
|
|
|
|
}
|
|
|
|
|
2023-07-10 07:20:48 +03:00
|
|
|
pub fn from_json_value(value: &serde_json::Value) -> anyhow::Result<Self> {
|
|
|
|
Self::from_dynamic(&crate::json_to_dynamic(value), Default::default())
|
|
|
|
.map_err(|e| anyhow::anyhow!("{}", e))
|
|
|
|
}
|
|
|
|
|
2022-07-15 09:22:02 +03:00
|
|
|
pub fn save_to_file<P: AsRef<Path>>(&self, path: P) -> anyhow::Result<()> {
|
|
|
|
let value = self.to_toml_value()?;
|
|
|
|
let text = toml::to_string_pretty(&value)?;
|
|
|
|
std::fs::write(&path, text)
|
|
|
|
.with_context(|| format!("writing toml to {}", path.as_ref().display()))
|
|
|
|
}
|
2022-05-14 18:00:03 +03:00
|
|
|
}
|
2022-06-28 16:22:31 +03:00
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
#[test]
|
|
|
|
fn test_indexed_colors() {
|
|
|
|
let scheme = r##"
|
|
|
|
[colors]
|
|
|
|
foreground = "#005661"
|
|
|
|
background = "#fef8ec"
|
|
|
|
cursor_bg = "#005661"
|
|
|
|
cursor_border = "#005661"
|
|
|
|
cursor_fg = "#ffffff"
|
|
|
|
selection_bg = "#cfe7f0"
|
|
|
|
selection_fg = "#005661"
|
|
|
|
|
|
|
|
ansi = [ "#8ca6a6" ,"#e64100" ,"#00b368" ,"#fa8900" ,"#0095a8" ,"#ff5792" ,"#00bdd6" ,"#005661" ]
|
|
|
|
brights = [ "#8ca6a6" ,"#e5164a" ,"#00b368" ,"#b3694d" ,"#0094f0" ,"#ff5792" ,"#00bdd6" ,"#004d57" ]
|
|
|
|
|
|
|
|
[colors.indexed]
|
|
|
|
52 = "#fbdada" # minus
|
|
|
|
88 = "#f6b6b6" # minus emph
|
|
|
|
22 = "#d6ffd6" # plus
|
|
|
|
28 = "#adffad" # plus emph
|
|
|
|
53 = "#feecf7" # purple
|
|
|
|
17 = "#e5dff6" # blue
|
|
|
|
23 = "#d8fdf6" # cyan
|
|
|
|
58 = "#f4ffe0" # yellow
|
|
|
|
"##;
|
|
|
|
let scheme = ColorSchemeFile::from_toml_str(scheme).unwrap();
|
|
|
|
assert_eq!(
|
|
|
|
scheme.colors.indexed.get(&52),
|
|
|
|
Some(&RgbColor::new_8bpc(0xfb, 0xda, 0xda).into())
|
|
|
|
);
|
|
|
|
}
|