mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
sweeeeping sweep
This commit is contained in:
parent
c9b09b7dea
commit
e677d1d7d4
38 changed files with 766 additions and 691 deletions
62
src/style.rs
62
src/style.rs
|
|
@ -1,30 +1,30 @@
|
|||
use crate::*;
|
||||
|
||||
pub trait TuiStyle {
|
||||
fn fg <W: Render<Tui>> (color: Color, w: W) -> Foreground<W> {
|
||||
fn fg <W: Content<Tui>> (color: Color, w: W) -> Foreground<W> {
|
||||
Foreground(color, w)
|
||||
}
|
||||
fn bg <W: Render<Tui>> (color: Color, w: W) -> Background<W> {
|
||||
fn bg <W: Content<Tui>> (color: Color, w: W) -> Background<W> {
|
||||
Background(color, w)
|
||||
}
|
||||
fn fg_bg <W: Render<Tui>> (fg: Color, bg: Color, w: W) -> Background<Foreground<W>> {
|
||||
fn fg_bg <W: Content<Tui>> (fg: Color, bg: Color, w: W) -> Background<Foreground<W>> {
|
||||
Background(bg, Foreground(fg, w))
|
||||
}
|
||||
fn bold <W: Render<Tui>> (on: bool, w: W) -> Bold<W> {
|
||||
fn bold <W: Content<Tui>> (on: bool, w: W) -> Bold<W> {
|
||||
Bold(on, w)
|
||||
}
|
||||
fn border <W: Render<Tui>, S: BorderStyle> (style: S, w: W) -> Bordered<S, W> {
|
||||
fn border <W: Content<Tui>, S: BorderStyle> (style: S, w: W) -> Bordered<S, W> {
|
||||
Bordered(style, w)
|
||||
}
|
||||
}
|
||||
|
||||
impl TuiStyle for Tui {}
|
||||
|
||||
pub struct Bold<W: Render<Tui>>(pub bool, W);
|
||||
pub struct Bold<W: Content<Tui>>(pub bool, W);
|
||||
|
||||
impl<W: Render<Tui>> Render<Tui> for Bold<W> {
|
||||
fn min_size (&self, to: [u16;2]) -> Perhaps<[u16;2]> {
|
||||
self.1.min_size(to)
|
||||
impl<W: Content<Tui>> Content<Tui> for Bold<W> {
|
||||
fn content (&self) -> Option<impl Content<Tui>> {
|
||||
Some(&self.1)
|
||||
}
|
||||
fn render (&self, to: &mut TuiOutput) -> Usually<()> {
|
||||
to.fill_bold(to.area(), self.0);
|
||||
|
|
@ -32,11 +32,11 @@ impl<W: Render<Tui>> Render<Tui> for Bold<W> {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct Foreground<W: Render<Tui>>(pub Color, W);
|
||||
pub struct Foreground<W: Content<Tui>>(pub Color, W);
|
||||
|
||||
impl<W: Render<Tui>> Render<Tui> for Foreground<W> {
|
||||
fn min_size (&self, to: [u16;2]) -> Perhaps<[u16;2]> {
|
||||
self.1.min_size(to)
|
||||
impl<W: Content<Tui>> Content<Tui> for Foreground<W> {
|
||||
fn content (&self) -> Option<impl Content<Tui>> {
|
||||
Some(&self.1)
|
||||
}
|
||||
fn render (&self, to: &mut TuiOutput) -> Usually<()> {
|
||||
to.fill_fg(to.area(), self.0);
|
||||
|
|
@ -44,11 +44,11 @@ impl<W: Render<Tui>> Render<Tui> for Foreground<W> {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct Background<W: Render<Tui>>(pub Color, W);
|
||||
pub struct Background<W: Content<Tui>>(pub Color, W);
|
||||
|
||||
impl<W: Render<Tui>> Render<Tui> for Background<W> {
|
||||
fn min_size (&self, to: [u16;2]) -> Perhaps<[u16;2]> {
|
||||
self.1.min_size(to)
|
||||
impl<W: Content<Tui>> Content<Tui> for Background<W> {
|
||||
fn content (&self) -> Option<impl Content<Tui>> {
|
||||
Some(&self.1)
|
||||
}
|
||||
fn render (&self, to: &mut TuiOutput) -> Usually<()> {
|
||||
to.fill_bg(to.area(), self.0);
|
||||
|
|
@ -56,11 +56,11 @@ impl<W: Render<Tui>> Render<Tui> for Background<W> {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct Styled<T: Render<Tui>>(pub Option<Style>, pub T);
|
||||
pub struct Styled<T: Content<Tui>>(pub Option<Style>, pub T);
|
||||
|
||||
impl Render<Tui> for Styled<&str> {
|
||||
fn min_size (&self, _: [u16;2]) -> Perhaps<[u16;2]> {
|
||||
Ok(Some([self.1.chars().count() as u16, 1]))
|
||||
impl Content<Tui> for Styled<&str> {
|
||||
fn content (&self) -> Option<impl Content<Tui>> {
|
||||
Some(&self.1)
|
||||
}
|
||||
fn render (&self, to: &mut TuiOutput) -> Usually<()> {
|
||||
// FIXME
|
||||
|
|
@ -70,29 +70,29 @@ impl Render<Tui> for Styled<&str> {
|
|||
}
|
||||
}
|
||||
|
||||
//pub trait TuiStyle: Render<Tui> + Sized {
|
||||
//fn fg (self, color: Color) -> impl Render<Tui> {
|
||||
//pub trait TuiStyle: Content<Tui> + Sized {
|
||||
//fn fg (self, color: Color) -> impl Content<Tui> {
|
||||
//Layers::new(move |add|{ add(&Foreground(color))?; add(&self) })
|
||||
//}
|
||||
//fn bg (self, color: Color) -> impl Render<Tui> {
|
||||
//fn bg (self, color: Color) -> impl Content<Tui> {
|
||||
//Layers::new(move |add|{ add(&Background(color))?; add(&self) })
|
||||
//}
|
||||
//fn bold (self, on: bool) -> impl Render<Tui> {
|
||||
//fn bold (self, on: bool) -> impl Content<Tui> {
|
||||
//Layers::new(move |add|{ add(&Bold(on))?; add(&self) })
|
||||
//}
|
||||
//fn border <S: BorderStyle> (self, style: S) -> impl Render<Tui> {
|
||||
//fn border <S: BorderStyle> (self, style: S) -> impl Content<Tui> {
|
||||
//Bordered(style, self)
|
||||
//}
|
||||
//}
|
||||
|
||||
//impl<W: Render<Tui>> TuiStyle for W {}
|
||||
//impl<W: Content<Tui>> TuiStyle for W {}
|
||||
|
||||
//impl<S: BorderStyle> Render<Tui> for Border<S> {
|
||||
//impl<S: BorderStyle> Content<Tui> for Border<S> {
|
||||
//}
|
||||
|
||||
//impl<S: BorderStyle, W: Render<Tui>> Content<Tui> for Bordered<S, W> {
|
||||
//fn content (&self) -> impl Render<Tui> {
|
||||
//let content: &dyn Render<Tui> = &self.1;
|
||||
//impl<S: BorderStyle, W: Content<Tui>> Content<Tui> for Bordered<S, W> {
|
||||
//fn content (&self) -> impl Content<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