use ratatui::layout::{Constraint, Layout, Rect};
#[must_use]
pub fn main_chrome(area: Rect) -> (Rect, Rect, Rect) {
let rows = Layout::vertical([
Constraint::Length(1),
Constraint::Min(1),
Constraint::Length(1),
])
.split(area);
(rows[0], rows[1], rows[2])
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn main_chrome_splits_80x24() {
let (top, body, bottom) = main_chrome(Rect::new(0, 0, 80, 24));
assert_eq!(top.height, 1);
assert_eq!(bottom.height, 1);
assert_eq!(body.height, 22);
assert_eq!(top.width, 80);
assert_eq!(body.width, 80);
assert_eq!(bottom.width, 80);
}
#[test]
fn main_chrome_preserves_origin() {
let (top, body, bottom) = main_chrome(Rect::new(5, 2, 40, 10));
assert_eq!(top.y, 2);
assert_eq!(body.y, 3);
assert_eq!(bottom.y, 11);
assert_eq!(top.x, 5);
assert_eq!(body.x, 5);
assert_eq!(bottom.x, 5);
}
}