From 95b4f57a5bc0e17c62a5216a8a56fa83c2940843 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sat, 4 Aug 2018 11:51:57 -0700 Subject: [PATCH] fixup handling of multiple decsets in a single csi --- src/color.rs | 3 ++- src/escape/csi.rs | 23 +++++++++++++++-------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/color.rs b/src/color.rs index 73959d9f9..8ea6b47df 100644 --- a/src/color.rs +++ b/src/color.rs @@ -76,7 +76,8 @@ impl RgbColor { pub fn to_tuple_rgba(&self) -> RgbaTuple { Srgba::::new(self.red, self.green, self.blue, 0xff) - .into_format().into_components() + .into_format() + .into_components() } pub fn to_linear_tuple_rgba(&self) -> RgbaTuple { diff --git a/src/escape/csi.rs b/src/escape/csi.rs index c93c0765f..60032d49c 100644 --- a/src/escape/csi.rs +++ b/src/escape/csi.rs @@ -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 { - 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]