mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 04:06:45 +01:00
wip: compiles and runs (not enabled yet)
This commit is contained in:
parent
ac3827b8f3
commit
98d2107e4e
15 changed files with 440 additions and 357 deletions
30
src/style.rs
30
src/style.rs
|
|
@ -21,11 +21,8 @@ pub trait TuiStyle {
|
|||
impl TuiStyle for Tui {}
|
||||
|
||||
pub struct Bold<W: Content<Tui>>(pub bool, W);
|
||||
|
||||
impl<W: Content<Tui>> Content<Tui> for Bold<W> {
|
||||
fn content (&self) -> impl Content<Tui> {
|
||||
Some(&self.1)
|
||||
}
|
||||
fn content (&self) -> impl Render<Tui> { &self.1 }
|
||||
fn render (&self, to: &mut TuiOut) {
|
||||
to.fill_bold(to.area(), self.0);
|
||||
self.1.render(to)
|
||||
|
|
@ -33,11 +30,8 @@ impl<W: Content<Tui>> Content<Tui> for Bold<W> {
|
|||
}
|
||||
|
||||
pub struct Foreground<W: Content<Tui>>(pub Color, W);
|
||||
|
||||
impl<W: Content<Tui>> Content<Tui> for Foreground<W> {
|
||||
fn content (&self) -> impl Content<Tui> {
|
||||
Some(&self.1)
|
||||
}
|
||||
fn content (&self) -> impl Render<Tui> { &self.1 }
|
||||
fn render (&self, to: &mut TuiOut) {
|
||||
to.fill_fg(to.area(), self.0);
|
||||
self.1.render(to)
|
||||
|
|
@ -45,11 +39,8 @@ impl<W: Content<Tui>> Content<Tui> for Foreground<W> {
|
|||
}
|
||||
|
||||
pub struct Background<W: Content<Tui>>(pub Color, W);
|
||||
|
||||
impl<W: Content<Tui>> Content<Tui> for Background<W> {
|
||||
fn content (&self) -> impl Content<Tui> {
|
||||
Some(&self.1)
|
||||
}
|
||||
fn content (&self) -> impl Render<Tui> { &self.1 }
|
||||
fn render (&self, to: &mut TuiOut) {
|
||||
to.fill_bg(to.area(), self.0);
|
||||
self.1.render(to)
|
||||
|
|
@ -57,11 +48,8 @@ impl<W: Content<Tui>> Content<Tui> for Background<W> {
|
|||
}
|
||||
|
||||
pub struct Styled<T: Content<Tui>>(pub Option<Style>, pub T);
|
||||
|
||||
impl Content<Tui> for Styled<&str> {
|
||||
fn content (&self) -> impl Content<Tui> {
|
||||
Some(&self.1)
|
||||
}
|
||||
fn content (&self) -> impl Render<Tui> { &self.1 }
|
||||
fn render (&self, to: &mut TuiOut) {
|
||||
// FIXME
|
||||
let [x, y, ..] = to.area();
|
||||
|
|
@ -71,16 +59,16 @@ impl Content<Tui> for Styled<&str> {
|
|||
}
|
||||
|
||||
//pub trait TuiStyle: Content<Tui> + Sized {
|
||||
//fn fg (self, color: Color) -> impl Content<Tui> {
|
||||
//fn fg (self, color: Color) -> impl Render<Tui> {
|
||||
//Layers::new(move |add|{ add(&Foreground(color))?; add(&self) })
|
||||
//}
|
||||
//fn bg (self, color: Color) -> impl Content<Tui> {
|
||||
//fn bg (self, color: Color) -> impl Render<Tui> {
|
||||
//Layers::new(move |add|{ add(&Background(color))?; add(&self) })
|
||||
//}
|
||||
//fn bold (self, on: bool) -> impl Content<Tui> {
|
||||
//fn bold (self, on: bool) -> impl Render<Tui> {
|
||||
//Layers::new(move |add|{ add(&Bold(on))?; add(&self) })
|
||||
//}
|
||||
//fn border <S: BorderStyle> (self, style: S) -> impl Content<Tui> {
|
||||
//fn border <S: BorderStyle> (self, style: S) -> impl Render<Tui> {
|
||||
//Bordered(style, self)
|
||||
//}
|
||||
//}
|
||||
|
|
@ -91,7 +79,7 @@ impl Content<Tui> for Styled<&str> {
|
|||
//}
|
||||
|
||||
//impl<S: BorderStyle, W: Content<Tui>> Content<Tui> for Bordered<S, W> {
|
||||
//fn content (&self) -> impl Content<Tui> {
|
||||
//fn content (&self) -> impl Render<Tui> {
|
||||
//let content: &dyn Content<Tui> = &self.1;
|
||||
//lay! { content.padding_xy(1, 1), Border(self.0) }.fill_xy()
|
||||
//}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue