glim-tui 0.2.0

A TUI for monitoring GitLab CI/CD pipelines and projects
1
2
3
4
5
6
7
8
9
10
11
12
13
use ratatui::layout::Rect;

pub trait CenteredShrink {
    fn inner_centered(&self, width: u16, height: u16) -> Rect;
}

impl CenteredShrink for Rect {
    fn inner_centered(&self, width: u16, height: u16) -> Rect {
        let x = self.x + (self.width.saturating_sub(width) / 2);
        let y = self.y + (self.height.saturating_sub(height) / 2);
        Rect::new(x, y, width.min(self.width), height.min(self.height))
    }
}