1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-18 19:01:36 +03:00

fixup handling of multiple decsets in a single csi

This commit is contained in:
Wez Furlong 2018-08-04 11:51:57 -07:00
parent 67128704ff
commit 95b4f57a5b
2 changed files with 17 additions and 9 deletions

View File

@ -76,7 +76,8 @@ impl RgbColor {
pub fn to_tuple_rgba(&self) -> RgbaTuple {
Srgba::<u8>::new(self.red, self.green, self.blue, 0xff)
.into_format().into_components()
.into_format()
.into_components()
}
pub fn to_linear_tuple_rgba(&self) -> RgbaTuple {

View File

@ -42,6 +42,9 @@ pub struct Unspecified {
impl Display for Unspecified {
fn fmt(&self, f: &mut Formatter) -> Result<(), FmtError> {
for i in &self.intermediates {
write!(f, "{}", *i as char)?;
}
for (idx, p) in self.params.iter().enumerate() {
if idx > 0 {
write!(f, ";{}", p)?;
@ -49,9 +52,6 @@ impl Display for Unspecified {
write!(f, "{}", p)?;
}
}
for i in &self.intermediates {
write!(f, "{}", i)?;
}
write!(f, "{}", self.control)
}
}
@ -1231,13 +1231,9 @@ impl<'a> CSIParser<'a> {
}
fn dec(&mut self, params: &'a [i64]) -> Result<DecPrivateMode, ()> {
if params.len() != 1 {
return Err(());
}
match num::FromPrimitive::from_i64(params[0]) {
None => Ok(DecPrivateMode::Unspecified(params[0].to_u16().ok_or(())?)),
Some(mode) => Ok(DecPrivateMode::Code(mode)),
Some(mode) => Ok(self.advance_by(1, params, DecPrivateMode::Code(mode))),
}
}
@ -1638,6 +1634,17 @@ mod test {
DecPrivateMode::Code(DecPrivateModeCode::BracketedPaste),
))]
);
assert_eq!(
parse_int('h', &[12, 25], b'?', "\x1b[?12h\x1b[?25h"),
vec![
CSI::Mode(Mode::SetDecPrivateMode(DecPrivateMode::Code(
DecPrivateModeCode::StartBlinkingCursor,
))),
CSI::Mode(Mode::SetDecPrivateMode(DecPrivateMode::Code(
DecPrivateModeCode::ShowCursor,
))),
]
);
}
#[test]