mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-12 06:36:41 +01:00
cleanup: sub 4k again
This commit is contained in:
parent
214061a419
commit
d8c9abf744
13 changed files with 101 additions and 505 deletions
|
|
@ -1,5 +1,17 @@
|
|||
use crate::core::*;
|
||||
|
||||
pub struct If<'a>(pub bool, pub &'a (dyn Render + Sync));
|
||||
|
||||
impl<'a> Render for If<'a> {
|
||||
fn render (&self, buf: &mut Buffer, area: Rect) -> Usually<Rect> {
|
||||
if self.0 {
|
||||
self.1.render(buf, area)
|
||||
} else {
|
||||
().render(buf, area)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub enum Direction {
|
||||
Down,
|
||||
Right,
|
||||
|
|
@ -11,6 +23,9 @@ impl<'a, const N: usize> Split<'a, N> {
|
|||
pub fn down (items: [&'a (dyn Render + Sync);N]) -> Self {
|
||||
Self(Direction::Down, items)
|
||||
}
|
||||
pub fn right (items: [&'a (dyn Render + Sync);N]) -> Self {
|
||||
Self(Direction::Right, items)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, const N: usize> Render for Split<'a, N> {
|
||||
|
|
@ -35,63 +50,3 @@ impl<'a, const N: usize> Render for Split<'a, N> {
|
|||
Ok(area)
|
||||
}
|
||||
}
|
||||
|
||||
//pub struct Split<'a> {
|
||||
//a: &'a (dyn Render + Sync),
|
||||
//b: &'a (dyn Render + Sync),
|
||||
//direction: Direction,
|
||||
//reverse: bool
|
||||
//}
|
||||
|
||||
//impl<'a> Split<'a> {
|
||||
//pub fn lr (a: &'a (dyn Render + Sync), b: &'a (dyn Render + Sync)) -> Self {
|
||||
//Self { a, b, direction: Direction::X, reverse: false }
|
||||
//}
|
||||
//pub fn rl (a: &'a (dyn Render + Sync), b: &'a (dyn Render + Sync)) -> Self {
|
||||
//Self { a, b, direction: Direction::X, reverse: true }
|
||||
//}
|
||||
//pub fn tb (a: &'a (dyn Render + Sync), b: &'a (dyn Render + Sync)) -> Self {
|
||||
//Self { a, b, direction: Direction::Y, reverse: false }
|
||||
//}
|
||||
//pub fn bt (a: &'a (dyn Render + Sync), b: &'a (dyn Render + Sync)) -> Self {
|
||||
//Self { a, b, direction: Direction::Y, reverse: true }
|
||||
//}
|
||||
|
||||
//fn split (&self, length: u16) -> (u16, u16) {
|
||||
//let l1 = (length as f64 * self.proportion).round() as u16;
|
||||
//let l2 = length.saturating_sub(l1);
|
||||
//(l1, l2)
|
||||
//}
|
||||
//}
|
||||
|
||||
//impl<'a> Render for Split<'a> {
|
||||
//fn render (&self, buf: &mut Buffer, area: Rect) -> Usually<Rect> {
|
||||
//let Rect { x, y, width, height } = area;
|
||||
//let area1 = if self.reverse { self.b } else { self.a }
|
||||
//.render(buf, area)?;
|
||||
//let area2 = if self.reverse { self.a } else { self.b }
|
||||
//.render(buf, match (self.direction, self.reverse)Rect {
|
||||
//})?;
|
||||
//let (area1, area2) = match self.direction {
|
||||
//Direction::X => {
|
||||
//let (w1, w2) = self.split(width);
|
||||
//(Rect { x, y, width: w1, height }, Rect { x: x + w1, y, width: w2, height })
|
||||
//},
|
||||
//Direction::Y => {
|
||||
//let (h1, h2) = self.split(height);
|
||||
//(Rect { x, y, width, height: h1 }, Rect { x, y: y + h1, width, height: h2 })
|
||||
//},
|
||||
//};
|
||||
//match self.reverse {
|
||||
//true => {
|
||||
//self.b.render(buf, area1)?;
|
||||
//self.a.render(buf, area2)?;
|
||||
//},
|
||||
//false => {
|
||||
//self.a.render(buf, area1)?;
|
||||
//self.b.render(buf, area2)?;
|
||||
//},
|
||||
//};
|
||||
//Ok(area)
|
||||
//}
|
||||
//}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue