diff --git a/src/main.rs b/src/main.rs index 83d413714..f3d1e0613 100644 --- a/src/main.rs +++ b/src/main.rs @@ -278,7 +278,7 @@ fn run() -> Result<(), Error> { println!("Connected screen {}", screen_num); let mut terminal = term::Terminal::new(24, 80, 3000); - let message = "x_advance != foo->bar(); ❤ 😍🤢\n\x1b[91;mw00t\n\x1b[37;104;m bleet\x1b[0;m."; + let message = "x_advance != \x1b[38;2;1;0;125;145;mfoo->bar(); ❤ 😍🤢\n\x1b[91;mw00t\n\x1b[37;104;m bleet\x1b[0;m."; terminal.advance_bytes(message); let mut window = TerminalWindow::new(&conn, screen_num, 1024, 300, terminal)?; diff --git a/src/term/mod.rs b/src/term/mod.rs index e24975798..558938ef9 100644 --- a/src/term/mod.rs +++ b/src/term/mod.rs @@ -388,6 +388,34 @@ impl CSIAction { /// parameter stream. Returns None if we couldn't decode one of /// the parameter elements. fn parse_sgr(params: &[i64]) -> Option<(CSIAction, &[i64])> { + if params.len() > 5 { + // ISO-8613-6 foreground and background color specification + // using full RGB color codes. + if params[0] == 38 && params[1] == 2 { + return Some(( + CSIAction::SetForegroundColor( + color::ColorAttribute::Rgb(color::RgbColor { + red: params[3] as u8, + green: params[4] as u8, + blue: params[5] as u8, + }), + ), + ¶ms[6..], + )); + } + if params[0] == 48 && params[1] == 2 { + return Some(( + CSIAction::SetBackgroundColor( + color::ColorAttribute::Rgb(color::RgbColor { + red: params[3] as u8, + green: params[4] as u8, + blue: params[5] as u8, + }), + ), + ¶ms[6..], + )); + } + } if params.len() > 2 { // Some special look-ahead cases for 88 and 256 color support if params[0] == 38 && params[1] == 5 {