diff --git a/src/color.rs b/src/color.rs index 13caf71..50f1eed 100644 --- a/src/color.rs +++ b/src/color.rs @@ -6,10 +6,7 @@ pub(crate) use ::palette::{ }; use rand::distributions::uniform::UniformSampler; -pub fn rgb (r: u8, g: u8, b: u8) -> ItemColor { - let term = Color::Rgb(r, g, b); - ItemColor { okhsl: rgb_to_okhsl(term), term } -} +pub fn rgb (r: u8, g: u8, b: u8) -> ItemColor { todo!(); } pub fn okhsl_to_rgb (color: Okhsl) -> Color { let Srgb { red, green, blue, .. }: Srgb = Srgb::from_color_unclamped(color); @@ -33,10 +30,10 @@ pub trait HasColor { fn color (&self) -> ItemColor; } } } -#[derive(Copy, Clone, Debug, Default, PartialEq)] +#[derive(Copy, Clone, Debug, Default)] pub struct ItemColor { - pub term: Color, - pub okhsl: Okhsl + term: Color, + okhsl: Okhsl } impl_from!(ItemColor: |term: Color| Self { term, okhsl: rgb_to_okhsl(term) }); impl_from!(ItemColor: |okhsl: Okhsl| Self { okhsl, term: okhsl_to_rgb(okhsl) }); @@ -66,7 +63,6 @@ impl ItemColor { } } -#[derive(Copy, Clone, Debug, Default, PartialEq)] pub struct ItemTheme { pub base: ItemColor, pub light: ItemColor, diff --git a/src/draw.rs b/src/draw.rs index b33a155..dd252db 100644 --- a/src/draw.rs +++ b/src/draw.rs @@ -90,14 +90,11 @@ pub const fn either (condition: bool, a: impl Draw, b: impl Draw< /// ``` pub trait Screen: Space + Send + Sync + Sized { type Unit: Coord; - /// Render drawable in area. - fn place <'t, T: Draw + ?Sized> (&mut self, content: &'t T) { - self.place_at(self.xywh(), content) - } - /// Render drawable in subarea specified by `area` - fn place_at <'t, T: Draw + ?Sized> ( - &mut self, area: XYWH, content: &'t T + /// Render drawable in area specified by `area` + fn place <'t, T: Draw + ?Sized> ( + &mut self, content: &'t T, area: Option> ) { + let area = area.unwrap_or_else(||self.xywh()); unimplemented!() } } diff --git a/src/play.rs b/src/play.rs index f07a4f7..28c4795 100644 --- a/src/play.rs +++ b/src/play.rs @@ -71,11 +71,11 @@ impl Thread { // FIXME: support attrs (docstrings) $($Variant $({ $($arg: $Arg),* })?),* } - impl ::tengri::dizzle::Act<$State> for $Command { - fn act (&self, $state: &mut $State) -> Perhaps { + impl ::tengri::Command<$State> for $Command { + fn execute (&self, $state: &mut $State) -> Perhaps { match self { $(Self::$Variant $({ $($arg),* })? => $body,)* - _ => unimplemented!("Act<{}>: {self:?}", stringify!($State)), + _ => unimplemented!("Command<{}>: {self:?}", stringify!($State)), } } } diff --git a/src/space.rs b/src/space.rs index 78b90fa..b7c7e96 100644 --- a/src/space.rs +++ b/src/space.rs @@ -201,12 +201,12 @@ impl Split { let b = origin_b.align(b); match self { Self::Below => { - to.place_at(area_b, &b); - to.place_at(area_b, &a); + to.place(&b, Some(area_b)); + to.place(&a, Some(area_b)); }, _ => { - to.place_at(area_a, &a); - to.place_at(area_a, &b); + to.place(&a, Some(area_a)); + to.place(&b, Some(area_a)); } } Ok(to.xywh()) // FIXME: compute and return actually used area diff --git a/src/term.rs b/src/term.rs index b59edbd..b06c0b3 100644 --- a/src/term.rs +++ b/src/term.rs @@ -35,7 +35,7 @@ impl Y for Tui { fn h (&self) -> u16 { self.1.3 } } impl Tui { - pub fn update (&mut self, callback: &impl Fn(&mut Cell, u16, u16)) -> XYWH { + fn update (&mut self, callback: &impl Fn(&mut Cell, u16, u16)) -> XYWH { for row in 0..self.h() { let y = self.y() + row; for col in 0..self.w() { @@ -49,14 +49,14 @@ impl Tui { } self.xywh() } - pub fn tint_all (&mut self, fg: Color, bg: Color, modifier: Modifier) { + fn tint_all (&mut self, fg: Color, bg: Color, modifier: Modifier) { for cell in self.0.content.iter_mut() { cell.fg = fg; cell.bg = bg; cell.modifier = modifier; } } - pub fn blit (&mut self, text: &impl AsRef, x: u16, y: u16, style: Option