summaryrefslogtreecommitdiffstats
path: root/src/draw.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/draw.rs')
-rw-r--r--src/draw.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/draw.rs b/src/draw.rs
index 1018614f..7fe54e1d 100644
--- a/src/draw.rs
+++ b/src/draw.rs
@@ -3,6 +3,7 @@ use std::io::Write;
use ansi_term::Style;
use box_drawing;
use console::strip_ansi_codes;
+use unicode_segmentation::UnicodeSegmentation;
/// Write text to stream, surrounded by a box, leaving the cursor just
/// beyond the bottom right corner.
@@ -18,7 +19,7 @@ pub fn write_boxed(
} else {
box_drawing::light::UP_LEFT
};
- let box_width = strip_ansi_codes(text).len() + 1;
+ let box_width = strip_ansi_codes(text).graphemes(true).count() + 1;
write_boxed_partial(writer, text, box_width, line_style, heavy)?;
write!(writer, "{}", line_style.paint(up_left))?;
Ok(())
@@ -33,7 +34,7 @@ pub fn write_boxed_with_line(
line_style: Style,
heavy: bool,
) -> std::io::Result<()> {
- let box_width = strip_ansi_codes(text).len() + 1;
+ let box_width = strip_ansi_codes(text).graphemes(true).count() + 1;
write_boxed_with_horizontal_whisker(writer, text, box_width, line_style, heavy)?;
write_horizontal_line(writer, line_width - box_width - 1, line_style, heavy)?;
Ok(())