summaryrefslogtreecommitdiffstats
path: root/src/draw.rs
diff options
context:
space:
mode:
authorDan Davison <dandavison7@gmail.com>2019-07-12 01:20:56 -0400
committerDan Davison <dandavison7@gmail.com>2019-07-12 01:20:56 -0400
commit2b8ea87fbee0be021e76efb773bce311ce5e2e20 (patch)
tree9e3e39f2c17a57b2c72d572e1203ca16b1a26ec5 /src/draw.rs
parent58f4cbfffc8d5f52df8fc510e3dcdc93ed9d2551 (diff)
Support heavy line weight boxes
Diffstat (limited to 'src/draw.rs')
-rw-r--r--src/draw.rs57
1 files changed, 41 insertions, 16 deletions
diff --git a/src/draw.rs b/src/draw.rs
index 5a9947a6..fc4b3b3d 100644
--- a/src/draw.rs
+++ b/src/draw.rs
@@ -8,43 +8,68 @@ use box_drawing;
pub fn write_boxed(
text: &str,
box_width: usize,
- box_style: Style,
+ line_style: Style,
+ heavy: bool,
writer: &mut Write,
) -> std::io::Result<()> {
- _write_boxed_partial(text, box_width, box_style, writer)?;
- write!(writer, "{}", box_style.paint(box_drawing::light::UP_LEFT))?;
+ _write_boxed_partial(text, box_width, line_style, heavy, writer)?;
+ let up_left = if heavy {
+ box_drawing::heavy::UP_LEFT
+ } else {
+ box_drawing::light::UP_LEFT
+ };
+ write!(writer, "{}", line_style.paint(up_left))?;
Ok(())
}
pub fn write_boxed_with_line(
text: &str,
box_width: usize,
- box_style: Style,
+ line_style: Style,
+ heavy: bool,
writer: &mut Write,
) -> std::io::Result<()> {
- _write_boxed_partial(text, box_width, box_style, writer)?;
- write!(
- writer,
- "{}",
- box_style.paint(box_drawing::light::UP_HORIZONTAL)
- )?;
+ _write_boxed_partial(text, box_width, line_style, heavy, writer)?;
+ let up_horizontal = if heavy {
+ box_drawing::heavy::UP_HORIZONTAL
+ } else {
+ box_drawing::light::UP_HORIZONTAL
+ };
+ write!(writer, "{}", line_style.paint(up_horizontal))?;
Ok(())
}
fn _write_boxed_partial(
text: &str,
box_width: usize,
- box_style: Style,
+ line_style: Style,
+ heavy: bool,
writer: &mut Write,
) -> std::io::Result<()> {
- let horizontal_edge = box_drawing::light::HORIZONTAL.repeat(box_width);
+ let horizontal = if heavy {
+ box_drawing::heavy::HORIZONTAL
+ } else {
+ box_drawing::light::HORIZONTAL
+ };
+ let down_left = if heavy {
+ box_drawing::heavy::DOWN_LEFT
+ } else {
+ box_drawing::light::DOWN_LEFT
+ };
+ let vertical = if heavy {
+ box_drawing::heavy::VERTICAL
+ } else {
+ box_drawing::light::VERTICAL
+ };
+
+ let horizontal_edge = horizontal.repeat(box_width);
write!(
writer,
"{}{}\n{} {}\n{}",
- box_style.paint(&horizontal_edge),
- box_style.paint(box_drawing::light::DOWN_LEFT),
+ line_style.paint(&horizontal_edge),
+ line_style.paint(down_left),
text,
- box_style.paint(box_drawing::light::VERTICAL),
- box_style.paint(&horizontal_edge),
+ line_style.paint(vertical),
+ line_style.paint(&horizontal_edge),
)
}