mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
wip: big flat pt.4: extract layout crate
This commit is contained in:
parent
cb680ab096
commit
34e731f111
21 changed files with 2125 additions and 83 deletions
|
|
@ -25,18 +25,6 @@ pub(crate) use ratatui::{
|
|||
|
||||
impl Coordinate for u16 {}
|
||||
|
||||
impl Size<u16> for [u16;2] {
|
||||
fn x (&self) -> u16 { self[0] }
|
||||
fn y (&self) -> u16 { self[1] }
|
||||
}
|
||||
|
||||
impl Area<u16> for [u16;4] {
|
||||
fn x (&self) -> u16 { self[0] }
|
||||
fn y (&self) -> u16 { self[1] }
|
||||
fn w (&self) -> u16 { self[2] }
|
||||
fn h (&self) -> u16 { self[3] }
|
||||
}
|
||||
|
||||
pub struct Tui {
|
||||
pub exited: Arc<AtomicBool>,
|
||||
pub buffer: Buffer,
|
||||
|
|
@ -349,19 +337,7 @@ pub fn half_block (lower: bool, upper: bool) -> Option<char> {
|
|||
|
||||
//impl<T: Content<Tui>> Render<Tui> for T {}
|
||||
|
||||
impl Render<Tui> for &str {
|
||||
fn min_size (&self, _: [u16;2]) -> Perhaps<[u16;2]> {
|
||||
// TODO: line breaks
|
||||
Ok(Some([self.chars().count() as u16, 1]))
|
||||
}
|
||||
fn render (&self, to: &mut TuiOutput) -> Usually<()> {
|
||||
let [x, y, ..] = to.area();
|
||||
//let [w, h] = self.min_size(to.area().wh())?.unwrap();
|
||||
Ok(to.blit(&self, x, y, None))
|
||||
}
|
||||
}
|
||||
|
||||
impl Render<Tui> for &String {
|
||||
impl Render<Tui> for str {
|
||||
fn min_size (&self, _: [u16;2]) -> Perhaps<[u16;2]> {
|
||||
// TODO: line breaks
|
||||
Ok(Some([self.chars().count() as u16, 1]))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue