diff options
author | Dan Davison <dandavison7@gmail.com> | 2019-10-13 22:53:36 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-13 22:53:36 -0700 |
commit | b235110c1ed72fc581c2df41e85de2dc21377fe9 (patch) | |
tree | af5729ae7c5412117c78fcad9eb9946a65154f0f /src/draw.rs | |
parent | bc6212e3c6a24214731980ab3a8ae2d26dab9db6 (diff) | |
parent | 8e4ade1bf1ed4a6b0b453af8e2ff6c7168df0b59 (diff) |
Merge pull request #21 from dandavison/18-terminal-width-subtraction
Don't compute negative line lengths
Diffstat (limited to 'src/draw.rs')
-rw-r--r-- | src/draw.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/draw.rs b/src/draw.rs index 7e82e76b..bf3cf5f1 100644 --- a/src/draw.rs +++ b/src/draw.rs @@ -36,7 +36,16 @@ pub fn write_boxed_with_line( ) -> std::io::Result<()> { 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)?; + write_horizontal_line( + writer, + if line_width > box_width { + line_width - box_width - 1 + } else { + 0 + }, + line_style, + heavy, + )?; Ok(()) } |