diff options
Diffstat (limited to 'src/protocol/render_ansi.rs')
| -rw-r--r-- | src/protocol/render_ansi.rs | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/protocol/render_ansi.rs b/src/protocol/render_ansi.rs index 12606bff..3346bb9c 100644 --- a/src/protocol/render_ansi.rs +++ b/src/protocol/render_ansi.rs @@ -31,7 +31,7 @@ use std::io::Write; use unicode_width::UnicodeWidthStr; -use crate::protocol::{CellData, FrameData}; +use crate::protocol::{underline_style_from_modifier, CellData, FrameData}; /// Bytes produced by a [`BlitEncoder`] for one terminal frame. pub(crate) struct EncodedBlit { @@ -294,7 +294,13 @@ fn modifier_to_sgr_parts(val: u16) -> Vec<&'static str> { parts.push("3"); } if val & UNDERLINED != 0 { - parts.push("4"); + parts.push(match underline_style_from_modifier(val) { + 2 => "4:2", + 3 => "4:3", + 4 => "4:4", + 5 => "4:5", + _ => "4", + }); } if val & SLOW_BLINK != 0 { parts.push("5"); @@ -843,6 +849,18 @@ mod tests { } #[test] + fn build_sgr_preserves_curly_underline_style() { + let modifier = crate::protocol::modifier_to_u16( + crate::protocol::modifier_with_underline_style(ratatui::style::Modifier::UNDERLINED, 3), + ); + + assert_eq!( + build_sgr(0x00_00_00_00, 0x00_00_00_00, modifier), + "\x1b[0;4:3;39;49m" + ); + } + + #[test] fn cells_equal_identical() { let a = make_cell("A", 2, 1, 0); let b = make_cell("A", 2, 1, 0); |
