mirror of
https://github.com/wez/wezterm.git
synced 2024-12-23 21:32:13 +03:00
fix colors.indexed in toml file
refs: https://github.com/wez/wezterm/issues/2197
This commit is contained in:
parent
f1c53495e7
commit
a10dc25e0c
@ -410,3 +410,36 @@ impl ColorSchemeFile {
|
||||
ColorSchemeFile::from_toml_value(&scheme)
|
||||
}
|
||||
}
|
||||
|
||||
#[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())
|
||||
);
|
||||
}
|
||||
|
@ -73,6 +73,10 @@ thread_local! {
|
||||
static LUA_CONFIG: RefCell<Option<LuaConfigState>> = RefCell::new(None);
|
||||
}
|
||||
|
||||
fn toml_table_has_numeric_keys(t: &toml::value::Table) -> bool {
|
||||
t.keys().all(|k| k.parse::<isize>().is_ok())
|
||||
}
|
||||
|
||||
fn toml_to_dynamic(value: &toml::Value) -> Value {
|
||||
match value {
|
||||
toml::Value::String(s) => s.to_dynamic(),
|
||||
@ -85,6 +89,13 @@ fn toml_to_dynamic(value: &toml::Value) -> Value {
|
||||
.map(|element| toml_to_dynamic(&element))
|
||||
.collect::<Vec<_>>()
|
||||
.to_dynamic(),
|
||||
// Allow `colors.indexed` to be passed through with actual integer keys
|
||||
toml::Value::Table(t) if toml_table_has_numeric_keys(t) => Value::Object(
|
||||
t.iter()
|
||||
.map(|(k, v)| (k.parse::<isize>().unwrap().to_dynamic(), toml_to_dynamic(v)))
|
||||
.collect::<BTreeMap<_, _>>()
|
||||
.into(),
|
||||
),
|
||||
toml::Value::Table(t) => Value::Object(
|
||||
t.iter()
|
||||
.map(|(k, v)| (Value::String(k.to_string()), toml_to_dynamic(v)))
|
||||
|
@ -15,6 +15,7 @@ As features stabilize some brief notes about them will accumulate here.
|
||||
* [ActivateKeyTable](config/lua/keyassignment/ActivateKeyTable.md)'s `replace_current` field was not actually optional. Made it optional. [#2179](https://github.com/wez/wezterm/issues/2179)
|
||||
* `winget` causes toast notification spam [#2185](https://github.com/wez/wezterm/issues/2185)
|
||||
* `wezterm connect sshdomain` could hang on startup if password authentication was required [#2194](https://github.com/wez/wezterm/issues/2194)
|
||||
* `colors.indexed` would error out with `Cannot convert String to u8`. [#2197](https://github.com/wez/wezterm/issues/2197)
|
||||
|
||||
### 20220624-141144-bd1b7c5d
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user