recognize kitty style CSI 4:3 m underlines
refs: https://github.com/wez/wezterm/issues/415
This commit is contained in:
1 parent
b6a422a542
commit
3df0201d42
2 files changed
+25
-30
No files matched your search
+17
-12
@@ -1133,9 +1133,9 @@ impl Display for Sgr {
|
||||
Sgr::Intensity(Intensity::Normal) => code!(NormalIntensity),
|
||||
Sgr::Underline(Underline::Single) => code!(UnderlineOn),
|
||||
Sgr::Underline(Underline::Double) => code!(UnderlineDouble),
|
||||
Sgr::Underline(Underline::Curly) => code!(UnderlineCurly),
|
||||
Sgr::Underline(Underline::Dotted) => code!(UnderlineDotted),
|
||||
Sgr::Underline(Underline::Dashed) => code!(UnderlineDashed),
|
||||
Sgr::Underline(Underline::Curly) => write!(f, "4:3m")?,
|
||||
Sgr::Underline(Underline::Dotted) => write!(f, "4:4m")?,
|
||||
Sgr::Underline(Underline::Dashed) => write!(f, "4:5m")?,
|
||||
Sgr::Underline(Underline::None) => code!(UnderlineOff),
|
||||
Sgr::Blink(Blink::Slow) => code!(BlinkOn),
|
||||
Sgr::Blink(Blink::Rapid) => code!(RapidBlinkOn),
|
||||
@@ -1848,8 +1848,8 @@ impl<'a> CSIParser<'a> {
|
||||
};
|
||||
};
|
||||
|
||||
match params[0] {
|
||||
CsiParam::Integer(i) => match FromPrimitive::from_i64(i) {
|
||||
match ¶ms[0] {
|
||||
CsiParam::Integer(i) => match FromPrimitive::from_i64(*i) {
|
||||
None => Err(()),
|
||||
Some(sgr) => match sgr {
|
||||
SgrCode::Reset => one!(Sgr::Reset),
|
||||
@@ -1858,9 +1858,6 @@ impl<'a> CSIParser<'a> {
|
||||
SgrCode::NormalIntensity => one!(Sgr::Intensity(Intensity::Normal)),
|
||||
SgrCode::UnderlineOn => one!(Sgr::Underline(Underline::Single)),
|
||||
SgrCode::UnderlineDouble => one!(Sgr::Underline(Underline::Double)),
|
||||
SgrCode::UnderlineCurly => one!(Sgr::Underline(Underline::Curly)),
|
||||
SgrCode::UnderlineDotted => one!(Sgr::Underline(Underline::Dotted)),
|
||||
SgrCode::UnderlineDashed => one!(Sgr::Underline(Underline::Dashed)),
|
||||
SgrCode::UnderlineOff => one!(Sgr::Underline(Underline::None)),
|
||||
SgrCode::UnderlineColor => {
|
||||
self.parse_sgr_color(params).map(Sgr::UnderlineColor)
|
||||
@@ -1971,7 +1968,18 @@ impl<'a> CSIParser<'a> {
|
||||
SgrCode::AltFont9 => one!(Sgr::Font(Font::Alternate(9))),
|
||||
},
|
||||
},
|
||||
CsiParam::ColonList(_) => Err(()),
|
||||
CsiParam::ColonList(list) => {
|
||||
match list.as_slice() {
|
||||
// Kitty styled underlines
|
||||
&[Some(4), Some(0)] => one!(Sgr::Underline(Underline::None)),
|
||||
&[Some(4), Some(1)] => one!(Sgr::Underline(Underline::Single)),
|
||||
&[Some(4), Some(2)] => one!(Sgr::Underline(Underline::Double)),
|
||||
&[Some(4), Some(3)] => one!(Sgr::Underline(Underline::Curly)),
|
||||
&[Some(4), Some(4)] => one!(Sgr::Underline(Underline::Dotted)),
|
||||
&[Some(4), Some(5)] => one!(Sgr::Underline(Underline::Dashed)),
|
||||
_ => Err(()),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2033,9 +2041,6 @@ pub enum SgrCode {
|
||||
|
||||
UnderlineColor = 58,
|
||||
ResetUnderlineColor = 59,
|
||||
UnderlineCurly = 60,
|
||||
UnderlineDotted = 61,
|
||||
UnderlineDashed = 62,
|
||||
|
||||
ForegroundBrightBlack = 90,
|
||||
ForegroundBrightRed = 91,
|
||||
|
||||
@@ -482,25 +482,12 @@ mod test {
|
||||
fn fancy_underline() {
|
||||
let mut p = Parser::new();
|
||||
|
||||
let actions = p.parse_as_vec(b"\x1b[4:0mb");
|
||||
assert_eq!(
|
||||
vec![
|
||||
Action::CSI(CSI::Unspecified(Box::new(
|
||||
crate::escape::csi::Unspecified {
|
||||
params: vec![CsiParam::ColonList(vec![Some(4), Some(0)])],
|
||||
intermediates: vec![],
|
||||
ignored_extra_intermediates: false,
|
||||
control: 'm'
|
||||
}
|
||||
))),
|
||||
Action::Print('b'),
|
||||
],
|
||||
actions
|
||||
);
|
||||
|
||||
let actions = p.parse_as_vec(b"\x1b[60;61;62mb");
|
||||
let actions = p.parse_as_vec(b"\x1b[4:0;4:1;4:2;4:3;4:4;4:5mb");
|
||||
assert_eq!(
|
||||
vec![
|
||||
Action::CSI(CSI::Sgr(Sgr::Underline(Underline::None))),
|
||||
Action::CSI(CSI::Sgr(Sgr::Underline(Underline::Single))),
|
||||
Action::CSI(CSI::Sgr(Sgr::Underline(Underline::Double))),
|
||||
Action::CSI(CSI::Sgr(Sgr::Underline(Underline::Curly))),
|
||||
Action::CSI(CSI::Sgr(Sgr::Underline(Underline::Dotted))),
|
||||
Action::CSI(CSI::Sgr(Sgr::Underline(Underline::Dashed))),
|
||||
@@ -509,7 +496,10 @@ mod test {
|
||||
actions
|
||||
);
|
||||
|
||||
assert_eq!(encode(&actions), "\x1b[60m\x1b[61m\x1b[62mb");
|
||||
assert_eq!(
|
||||
encode(&actions),
|
||||
"\x1b[24m\x1b[4m\x1b[21m\x1b[4:3m\x1b[4:4m\x1b[4:5mb"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in new issue
Block a user