about summary refs log tree commit diff
path: root/src/display/draw_box.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/display/draw_box.rs')
-rw-r--r--src/display/draw_box.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/display/draw_box.rs b/src/display/draw_box.rs
index 986f09a49f7c..5dc1627a298d 100644
--- a/src/display/draw_box.rs
+++ b/src/display/draw_box.rs
@@ -1,10 +1,12 @@
 use crate::display::utils::clone_times;
 use crate::display::utils::times;
+use crate::types::BoundingBox;
 use crate::types::Dimensions;
 use itertools::Itertools;
 use proptest::prelude::Arbitrary;
 use proptest::strategy;
 use proptest_derive::Arbitrary;
+use std::io::{self, Write};
 
 // Box Drawing
 //  	    0 	1 	2 	3 	4 	5 	6 	7 	8 	9 	A 	B 	C 	D 	E 	F
@@ -164,6 +166,21 @@ pub fn make_box(style: BoxStyle, dims: Dimensions) -> String {
     }
 }
 
+/// Draw the box described by the given BoundingBox's position and dimensions to
+/// the given output, with the given style
+pub fn draw_box<W: Write>(
+    out: &mut W,
+    bbox: BoundingBox,
+    style: BoxStyle,
+) -> io::Result<()> {
+    write!(
+        out,
+        "{}{}",
+        bbox.position.cursor_goto(),
+        make_box(style, bbox.dimensions)
+    )
+}
+
 #[cfg(test)]
 mod tests {
     use super::*;