1
1
mirror of https://github.com/wez/wezterm.git synced 2024-10-27 16:19:25 +03:00

termwiz: use 6 for the rgba colorspace

`4` is actually defined as CMYK according to ITU-T Rec. T.416:

> A parameter substring for values 38 or 48 may be divided by one or more separators (03/10) into parameter elements,
> denoted as Pe. The format of such a parameter sub-string is indicated as:
>
>     Pe : P ...
>
> Each parameter element consists of zero, one or more bit combinations from 03/00 to 03/09, representing the digits
> 0 to 9. An empty parameter element represents a default value for this parameter element. Empty parameter elements at
> the end of the parameter substring need not be included.
>
> The first parameter element indicates a choice between:
>
> 0    implementation defined (only applicable for the character foreground colour)
> 1    transparent;
> 2    direct colour in RGB space;
> 3    direct colour in CMY space;
> 4    direct colour in CMYK space;
> 5    indexed colour.

refs: 6e9a22e199 (commitcomment-79669016)
This commit is contained in:
Wez Furlong 2022-07-28 17:09:15 -07:00
parent c7c81e3161
commit 718a021817
2 changed files with 7 additions and 7 deletions

View File

@ -1448,7 +1448,7 @@ impl Display for Sgr {
} else {
write!(
f,
"{}:4::{}:{}:{}:{}m",
"{}:6::{}:{}:{}:{}m",
SgrCode::ForegroundColor as i64,
red,
green,
@ -1494,7 +1494,7 @@ impl Display for Sgr {
} else {
write!(
f,
"{}:4::{}:{}:{}:{}m",
"{}:6::{}:{}:{}:{}m",
SgrCode::BackgroundColor as i64,
red,
green,
@ -1518,7 +1518,7 @@ impl Display for Sgr {
} else {
write!(
f,
"{}:4::{}:{}:{}:{}m",
"{}:6::{}:{}:{}:{}m",
SgrCode::UnderlineColor as i64,
red,
green,
@ -2240,19 +2240,19 @@ impl<'a> CSIParser<'a> {
fn parse_sgr_color(&mut self, params: &'a [CsiParam]) -> Result<ColorSpec, ()> {
match params {
// wezterm extension to support an optional alpha channel in the `:` form only
[_, CsiParam::P(b':'), CsiParam::Integer(4), CsiParam::P(b':'),
[_, CsiParam::P(b':'), CsiParam::Integer(6), CsiParam::P(b':'),
CsiParam::Integer(_colorspace), CsiParam::P(b':'),
red, CsiParam::P(b':'), green, CsiParam::P(b':'), blue, CsiParam::P(b':'), alpha, ..] => {
let res: SrgbaTuple = (to_u8(red)?, to_u8(green)?, to_u8(blue)?, to_u8(alpha)?).into();
Ok(self.advance_by(13, params, res.into()))
}
[_, CsiParam::P(b':'), CsiParam::Integer(4), CsiParam::P(b':'),
[_, CsiParam::P(b':'), CsiParam::Integer(6), CsiParam::P(b':'),
/* empty colorspace */ CsiParam::P(b':'),
red, CsiParam::P(b':'), green, CsiParam::P(b':'), blue, CsiParam::P(b':'), alpha, ..] => {
let res: SrgbaTuple = (to_u8(red)?, to_u8(green)?, to_u8(blue)?, to_u8(alpha)?).into();
Ok(self.advance_by(12, params, res.into()))
}
[_, CsiParam::P(b':'), CsiParam::Integer(4), CsiParam::P(b':'), red, CsiParam::P(b':'), green,
[_, CsiParam::P(b':'), CsiParam::Integer(6), CsiParam::P(b':'), red, CsiParam::P(b':'), green,
CsiParam::P(b':'), blue, CsiParam::P(b':'), alpha, ..] =>
{
let res: SrgbaTuple = (to_u8(red)?, to_u8(green)?, to_u8(blue)?, to_u8(alpha)?).into();

View File

@ -453,7 +453,7 @@ mod test {
actions
);
let actions = p.parse_as_vec(b"\x1b[38:4:0:255:0:127mw");
let actions = p.parse_as_vec(b"\x1b[38:6:0:255:0:127mw");
assert_eq!(
vec![
Action::CSI(CSI::Sgr(Sgr::Foreground(ColorSpec::TrueColor(