diff options
Diffstat (limited to 'src/draw.rs')
-rw-r--r-- | src/draw.rs | 41 |
1 files changed, 28 insertions, 13 deletions
diff --git a/src/draw.rs b/src/draw.rs index 751f99f9..03b93bdb 100644 --- a/src/draw.rs +++ b/src/draw.rs @@ -15,6 +15,7 @@ pub fn write_boxed( _line_width: usize, // ignored color: Color, heavy: bool, + true_color: bool, ) -> std::io::Result<()> { let up_left = if heavy { box_drawing::heavy::UP_LEFT @@ -22,8 +23,12 @@ pub fn write_boxed( box_drawing::light::UP_LEFT }; let box_width = strip_ansi_codes(text).graphemes(true).count() + 1; - write_boxed_partial(writer, text, box_width, color, heavy)?; - write!(writer, "{}", paint::paint_text_foreground(up_left, color))?; + write_boxed_partial(writer, text, box_width, color, heavy, true_color)?; + write!( + writer, + "{}", + paint::paint_text_foreground(up_left, color, true_color) + )?; Ok(()) } @@ -35,9 +40,10 @@ pub fn write_boxed_with_line( line_width: usize, color: Color, heavy: bool, + true_color: bool, ) -> std::io::Result<()> { let box_width = strip_ansi_codes(text).graphemes(true).count() + 1; - write_boxed_with_horizontal_whisker(writer, text, box_width, color, heavy)?; + write_boxed_with_horizontal_whisker(writer, text, box_width, color, heavy, true_color)?; write_horizontal_line( writer, if line_width > box_width { @@ -47,6 +53,7 @@ pub fn write_boxed_with_line( }, color, heavy, + true_color, )?; write!(writer, "\n")?; Ok(()) @@ -58,9 +65,14 @@ pub fn write_underlined( line_width: usize, color: Color, heavy: bool, + true_color: bool, ) -> std::io::Result<()> { - writeln!(writer, "{}", paint::paint_text_foreground(text, color))?; - write_horizontal_line(writer, line_width - 1, color, heavy)?; + writeln!( + writer, + "{}", + paint::paint_text_foreground(text, color, true_color) + )?; + write_horizontal_line(writer, line_width - 1, color, heavy, true_color)?; write!(writer, "\n")?; Ok(()) } @@ -70,6 +82,7 @@ fn write_horizontal_line( line_width: usize, color: Color, heavy: bool, + true_color: bool, ) -> std::io::Result<()> { let horizontal = if heavy { box_drawing::heavy::HORIZONTAL @@ -79,7 +92,7 @@ fn write_horizontal_line( write!( writer, "{}", - paint::paint_text_foreground(&horizontal.repeat(line_width), color) + paint::paint_text_foreground(&horizontal.repeat(line_width), color, true_color) ) } @@ -89,17 +102,18 @@ pub fn write_boxed_with_horizontal_whisker( box_width: usize, color: Color, heavy: bool, + true_color: bool, ) -> std::io::Result<()> { let up_horizontal = if heavy { box_drawing::heavy::UP_HORIZONTAL } else { box_drawing::light::UP_HORIZONTAL }; - write_boxed_partial(writer, text, box_width, color, heavy)?; + write_boxed_partial(writer, text, box_width, color, heavy, true_color)?; write!( writer, "{}", - paint::paint_text_foreground(up_horizontal, color) + paint::paint_text_foreground(up_horizontal, color, true_color) )?; Ok(()) } @@ -110,6 +124,7 @@ fn write_boxed_partial( box_width: usize, color: Color, heavy: bool, + true_color: bool, ) -> std::io::Result<()> { let horizontal = if heavy { box_drawing::heavy::HORIZONTAL @@ -131,10 +146,10 @@ fn write_boxed_partial( write!( writer, "{}{}\n{} {}\n{}", - paint::paint_text_foreground(&horizontal_edge, color), - paint::paint_text_foreground(down_left, color), - paint::paint_text_foreground(text, color), - paint::paint_text_foreground(vertical, color), - paint::paint_text_foreground(&horizontal_edge, color), + paint::paint_text_foreground(&horizontal_edge, color, true_color), + paint::paint_text_foreground(down_left, color, true_color), + paint::paint_text_foreground(text, color, true_color), + paint::paint_text_foreground(vertical, color, true_color), + paint::paint_text_foreground(&horizontal_edge, color, true_color), ) } |