1 use super::*;
2 use ascii_canvas::AsciiView;
3 
4 #[derive(Debug)]
5 pub struct Vert {
6     items: Vec<Box<dyn Content>>,
7     separate: usize, // 0 => overlapping, 1 => each on its own line, 2 => paragraphs
8 }
9 
10 impl Vert {
new(items: Vec<Box<dyn Content>>, separate: usize) -> Self11     pub fn new(items: Vec<Box<dyn Content>>, separate: usize) -> Self {
12         Vert { items, separate }
13     }
14 }
15 
16 impl Content for Vert {
min_width(&self) -> usize17     fn min_width(&self) -> usize {
18         self.items.iter().map(|c| c.min_width()).max().unwrap()
19     }
20 
emit(&self, view: &mut dyn AsciiView)21     fn emit(&self, view: &mut dyn AsciiView) {
22         emit_vert(view, &self.items, self.separate);
23     }
24 
into_wrap_items(self: Box<Self>, wrap_items: &mut Vec<Box<dyn Content>>)25     fn into_wrap_items(self: Box<Self>, wrap_items: &mut Vec<Box<dyn Content>>) {
26         wrap_items.push(self);
27     }
28 }
29 
emit_vert(view: &mut dyn AsciiView, items: &[Box<dyn Content>], separate: usize)30 pub fn emit_vert(view: &mut dyn AsciiView, items: &[Box<dyn Content>], separate: usize) {
31     let mut row = 0;
32     for item in items {
33         let (end_row, _) = item.emit_at(view, row, 0);
34         row = end_row + separate;
35     }
36 }
37