1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-22 22:42:48 +03:00

vtparse: increase MAX_OSC to load dynamic color scripts

This commit is contained in:
Wez Furlong 2022-07-10 08:25:08 -07:00
parent d7fa541745
commit c8cb99a512
3 changed files with 213 additions and 23 deletions

View File

@ -39,6 +39,7 @@ As features stabilize some brief notes about them will accumulate here.
* Wayland: transparent gap under tab bar when window is transparent, split and using per-pane color schemes [#1620](https://github.com/wez/wezterm/issues/1620)
* Tab bar could show a gap to the right when resizing
* Padding could show window background rather than pane background around split panes at certain window sizes [#2210](https://github.com/wez/wezterm/issues/2210)
* Loading dynamic escape sequence scripts from the [iTerm2-Color-Scheme dynamic-colors directory](https://github.com/mbadolato/iTerm2-Color-Schemes/tree/master/dynamic-colors) would only apply the first 7 colors
#### Updated
* Bundled harfbuzz to 4.4.1

View File

@ -845,4 +845,201 @@ mod test {
let mut p = Parser::new();
p.parse_as_vec(b"\x9d1337\xff;File\x1b");
}
/// vtparse's MAX_OSC was set too low to fully parse this escape sequence.
/// This test verifies that the correct number of actions comes back.
#[test]
fn dynamic_colors() {
let mut p = Parser::new();
let actions = p.parse_as_vec(b"\x1b]4;0;#000000;1;#aa3731;2;#448c27;3;#cb9000;4;#325cc0;5;#7a3e9d;6;#0083b2;7;#f7f7f7;8;#777777;9;#f05050;10;#60cb00;11;#ffbc5d;12;#007acc;13;#e64ce6;14;#00aacb;15;#f7f7f7\x07");
k9::snapshot!(
actions,
"
[
OperatingSystemCommand(
ChangeColorNumber(
[
ChangeColorPair {
palette_index: 0,
color: Color(
SrgbaTuple(
0.0,
0.0,
0.0,
1.0,
),
),
},
ChangeColorPair {
palette_index: 1,
color: Color(
SrgbaTuple(
0.6666667,
0.21568628,
0.19215687,
1.0,
),
),
},
ChangeColorPair {
palette_index: 2,
color: Color(
SrgbaTuple(
0.26666668,
0.54901963,
0.15294118,
1.0,
),
),
},
ChangeColorPair {
palette_index: 3,
color: Color(
SrgbaTuple(
0.79607844,
0.5647059,
0.0,
1.0,
),
),
},
ChangeColorPair {
palette_index: 4,
color: Color(
SrgbaTuple(
0.19607843,
0.36078432,
0.7529412,
1.0,
),
),
},
ChangeColorPair {
palette_index: 5,
color: Color(
SrgbaTuple(
0.47843137,
0.24313726,
0.6156863,
1.0,
),
),
},
ChangeColorPair {
palette_index: 6,
color: Color(
SrgbaTuple(
0.0,
0.5137255,
0.69803923,
1.0,
),
),
},
ChangeColorPair {
palette_index: 7,
color: Color(
SrgbaTuple(
0.96862745,
0.96862745,
0.96862745,
1.0,
),
),
},
ChangeColorPair {
palette_index: 8,
color: Color(
SrgbaTuple(
0.46666667,
0.46666667,
0.46666667,
1.0,
),
),
},
ChangeColorPair {
palette_index: 9,
color: Color(
SrgbaTuple(
0.9411765,
0.3137255,
0.3137255,
1.0,
),
),
},
ChangeColorPair {
palette_index: 10,
color: Color(
SrgbaTuple(
0.3764706,
0.79607844,
0.0,
1.0,
),
),
},
ChangeColorPair {
palette_index: 11,
color: Color(
SrgbaTuple(
1.0,
0.7372549,
0.3647059,
1.0,
),
),
},
ChangeColorPair {
palette_index: 12,
color: Color(
SrgbaTuple(
0.0,
0.47843137,
0.8,
1.0,
),
),
},
ChangeColorPair {
palette_index: 13,
color: Color(
SrgbaTuple(
0.9019608,
0.29803923,
0.9019608,
1.0,
),
),
},
ChangeColorPair {
palette_index: 14,
color: Color(
SrgbaTuple(
0.0,
0.6666667,
0.79607844,
1.0,
),
),
},
ChangeColorPair {
palette_index: 15,
color: Color(
SrgbaTuple(
0.96862745,
0.96862745,
0.96862745,
1.0,
),
),
},
],
),
),
]
"
);
}
}

View File

@ -294,7 +294,7 @@ impl VTActor for CollectingVTActor {
}
const MAX_INTERMEDIATES: usize = 2;
const MAX_OSC: usize = 16;
const MAX_OSC: usize = 64;
const MAX_PARAMS: usize = 32;
struct OscState {
@ -779,28 +779,20 @@ mod test {
#[test]
fn test_osc_too_many_params() {
assert_eq!(
parse_as_vec(b"\x1b]0;1;2;3;4;5;6;7;8;9;a;b;c;d;e;f;g\x07"),
vec![VTAction::OscDispatch(vec![
b"0".to_vec(),
b"1".to_vec(),
b"2".to_vec(),
b"3".to_vec(),
b"4".to_vec(),
b"5".to_vec(),
b"6".to_vec(),
b"7".to_vec(),
b"8".to_vec(),
b"9".to_vec(),
b"a".to_vec(),
b"b".to_vec(),
b"c".to_vec(),
b"d".to_vec(),
b"e".to_vec(),
b"f".to_vec(),
// g is discarded
])]
);
let fields = (0..MAX_OSC + 2)
.into_iter()
.map(|i| i.to_string())
.collect::<Vec<_>>();
let input = format!("\x1b]{}\x07", fields.join(";"));
let actions = parse_as_vec(input.as_bytes());
assert_eq!(actions.len(), 1);
match &actions[0] {
VTAction::OscDispatch(parsed_fields) => {
let fields: Vec<_> = fields.into_iter().map(|s| s.as_bytes().to_vec()).collect();
assert_eq!(parsed_fields.as_slice(), &fields[0..MAX_OSC]);
}
other => panic!("Expected OscDispatch but got {:?}", other),
}
}
#[test]