2025-10-01 14:29:05 -07:00
|
|
|
use ratatui::layout::Rect;
|
|
|
|
|
|
2025-09-05 07:10:32 -07:00
|
|
|
pub mod highlight;
|
2025-08-12 17:37:28 -07:00
|
|
|
pub mod line_utils;
|
2025-10-01 14:29:05 -07:00
|
|
|
pub mod renderable;
|
|
|
|
|
|
2025-10-07 11:32:07 -07:00
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
2025-10-01 14:29:05 -07:00
|
|
|
pub struct Insets {
|
|
|
|
|
pub left: u16,
|
|
|
|
|
pub top: u16,
|
|
|
|
|
pub right: u16,
|
|
|
|
|
pub bottom: u16,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Insets {
|
|
|
|
|
pub fn tlbr(top: u16, left: u16, bottom: u16, right: u16) -> Self {
|
|
|
|
|
Self {
|
|
|
|
|
top,
|
|
|
|
|
left,
|
|
|
|
|
bottom,
|
|
|
|
|
right,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn vh(v: u16, h: u16) -> Self {
|
|
|
|
|
Self {
|
|
|
|
|
top: v,
|
|
|
|
|
left: h,
|
|
|
|
|
bottom: v,
|
|
|
|
|
right: h,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub trait RectExt {
|
|
|
|
|
fn inset(&self, insets: Insets) -> Rect;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl RectExt for Rect {
|
|
|
|
|
fn inset(&self, insets: Insets) -> Rect {
|
2025-10-07 16:18:48 -07:00
|
|
|
let horizontal = insets.left.saturating_add(insets.right);
|
|
|
|
|
let vertical = insets.top.saturating_add(insets.bottom);
|
2025-10-01 14:29:05 -07:00
|
|
|
Rect {
|
2025-10-07 16:18:48 -07:00
|
|
|
x: self.x.saturating_add(insets.left),
|
|
|
|
|
y: self.y.saturating_add(insets.top),
|
|
|
|
|
width: self.width.saturating_sub(horizontal),
|
|
|
|
|
height: self.height.saturating_sub(vertical),
|
2025-10-01 14:29:05 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|