mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
75176dae70
instead of always reserving 6 spaces for the line number and gutter, we now dynamically adjust to the width of the longest number. <img width="871" height="616" alt="Screenshot 2025-10-03 at 8 21 00 AM" src="https://github.com/user-attachments/assets/5f18eae6-7c85-48fc-9a41-31978ae71a62" /> <img width="871" height="616" alt="Screenshot 2025-10-03 at 8 21 21 AM" src="https://github.com/user-attachments/assets/9009297d-7690-42b9-ae42-9566b3fea86c" /> <img width="871" height="616" alt="Screenshot 2025-10-03 at 8 21 57 AM" src="https://github.com/user-attachments/assets/669096fd-dddc-407e-bae8-d0c6626fa0bc" />
49 lines
952 B
Rust
49 lines
952 B
Rust
use ratatui::layout::Rect;
|
|
|
|
pub mod highlight;
|
|
pub mod line_utils;
|
|
pub mod renderable;
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
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 {
|
|
Rect {
|
|
x: self.x + insets.left,
|
|
y: self.y + insets.top,
|
|
width: self.width - insets.left - insets.right,
|
|
height: self.height - insets.top - insets.bottom,
|
|
}
|
|
}
|
|
}
|