in src/components/splitting.rs [138:173]
fn draw_unchecked(
&self,
state: &State,
dimensions: Dimensions,
mode: DrawMode,
) -> anyhow::Result<Vec<Line>> {
let outputs = self
.split
.draw(&self.children, self.direction, state, dimensions, mode)?;
Ok(match self.direction {
Direction::Horizontal => {
// unwrap ok because guaranteed > 0 children from constructor
let longest = outputs.iter().map(|output| output.len()).max().unwrap();
// pad all other outputs to be the same length. Then, justify them to be uniform blocks.
let padded = outputs.into_iter().update(|output| {
output.set_lines_to_exact_length(longest);
output.justify();
});
// can't do arbitrary zip, so this'll have to do
padded
.reduce(|mut all, output| {
for (all_line, mut output_line) in all.iter_mut().zip(output.into_iter()) {
all_line.0.append(&mut output_line.0);
}
all
})
// safe to unwrap because at least one child component required
.unwrap()
}
Direction::Vertical => outputs.into_iter().flatten().collect(),
})
}