diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 7b08ef3..0000000 --- a/.editorconfig +++ /dev/null @@ -1,3 +0,0 @@ -root = true -[*] -max_line_length = 132 diff --git a/core/src/lib.rs b/core/src/lib.rs index 7bf320e..3a51258 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -35,11 +35,3 @@ pub trait Eval { } }; } - -pub fn wrap_inc (index: usize, count: usize) -> usize { - if count > 0 { (index + 1) % count } else { 0 } -} - -pub fn wrap_dec (index: usize, count: usize) -> usize { - if count > 0 { index.overflowing_sub(1).0.min(count.saturating_sub(1)) } else { 0 } -} diff --git a/output/src/content.rs b/output/src/content.rs index f63e98b..4407023 100644 --- a/output/src/content.rs +++ b/output/src/content.rs @@ -11,7 +11,6 @@ impl Draw for fn(&mut O) { fn draw (&self, to: &mut O) { (*self)(to) impl Draw for Box> { fn draw (&self, to: &mut O) { (**self).draw(to) } } impl> Draw for &D { fn draw (&self, to: &mut O) { (*self).draw(to) } } impl> Draw for &mut D { fn draw (&self, to: &mut O) { (**self).draw(to) } } -impl> Draw for Option { fn draw (&self, to: &mut O) { if let Some(draw) = self { draw.draw(to) } } } /// Drawable area of display. pub trait Layout { fn x (&self, to: O::Area) -> O::Unit { to.x() } diff --git a/output/src/space/space_measure.rs b/output/src/space/space_measure.rs index b785bdb..f508554 100644 --- a/output/src/space/space_measure.rs +++ b/output/src/space/space_measure.rs @@ -2,30 +2,28 @@ use crate::*; /// A widget that tracks its render width and height #[derive(Default)] -pub struct Measure { - _engine: PhantomData, +pub struct Measure { + _engine: PhantomData, pub x: Arc, pub y: Arc, } -impl PartialEq for Measure { +impl PartialEq for Measure { fn eq (&self, other: &Self) -> bool { self.x.load(Relaxed) == other.x.load(Relaxed) && self.y.load(Relaxed) == other.y.load(Relaxed) } } -impl Layout for Measure {} - // TODO: 🡘 🡙 ←🡙→ indicator to expand window when too small -impl Draw for Measure { - fn draw (&self, to: &mut O) { +impl Draw for Measure { + fn draw (&self, to: &mut E) { self.x.store(to.area().w().into(), Relaxed); self.y.store(to.area().h().into(), Relaxed); } } -impl Clone for Measure { +impl Clone for Measure { fn clone (&self) -> Self { Self { _engine: Default::default(), @@ -35,7 +33,7 @@ impl Clone for Measure { } } -impl std::fmt::Debug for Measure { +impl std::fmt::Debug for Measure { fn fmt (&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> { f.debug_struct("Measure") .field("width", &self.x) @@ -44,7 +42,7 @@ impl std::fmt::Debug for Measure { } } -impl Measure { +impl Measure { pub fn new () -> Self { Self { _engine: PhantomData::default(), @@ -77,7 +75,7 @@ impl Measure { pub fn format (&self) -> Arc { format!("{}x{}", self.w(), self.h()).into() } - pub fn of > (&self, item: T) -> Bsp, T> { + pub fn of > (&self, item: T) -> Bsp, T> { Bsp::b(Fill::XY(self), item) } } diff --git a/proc/src/lib.rs b/proc/src/lib.rs index 7ae7699..fa33152 100644 --- a/proc/src/lib.rs +++ b/proc/src/lib.rs @@ -106,7 +106,7 @@ pub(crate) fn write_quote_to (out: &mut TokenStream2, quote: TokenStream2) { //#[tengri_proc::view(SomeOut)] //impl SomeView { //#[tengri::view(":view-1")] - //fn view_1 (&self) -> impl Content + use<'_> { + //fn view_1 (&self) -> impl Draw + use<'_> { //"view-1" //} //} @@ -114,13 +114,13 @@ pub(crate) fn write_quote_to (out: &mut TokenStream2, quote: TokenStream2) { //let written = quote! { #parsed }; //assert_eq!(format!("{written}"), format!("{}", quote! { //impl SomeView { - //fn view_1 (&self) -> impl Content + use<'_> { + //fn view_1 (&self) -> impl Draw + use<'_> { //"view-1" //} //} ///// Generated by [tengri_proc]. //impl ::tengri::output::Content for SomeView { - //fn content (&self) -> impl Content { + //fn content (&self) -> impl Draw { //self.size.of(::tengri::output::View(self, self.config.view)) //} //} diff --git a/tui/examples/tui_01.rs b/tui/examples/tui_01.rs index 9d62bdf..58d505e 100644 --- a/tui/examples/tui_01.rs +++ b/tui/examples/tui_01.rs @@ -12,25 +12,25 @@ fn main () {} //#[tengri_proc::view(TuiOut)] //impl Example { - //pub fn title (&self) -> impl Content + use<'_> { + //pub fn title (&self) -> impl Draw + use<'_> { //Tui::bg(Color::Rgb(60, 10, 10), Push::y(1, Align::n(format!("Example {}/{}:", self.0 + 1, VIEWS.len())))).boxed() //} - //pub fn code (&self) -> impl Content + use<'_> { + //pub fn code (&self) -> impl Draw + use<'_> { //Tui::bg(Color::Rgb(10, 60, 10), Push::y(2, Align::n(format!("{}", VIEWS[self.0])))).boxed() //} - //pub fn hello (&self) -> impl Content + use<'_> { + //pub fn hello (&self) -> impl Draw + use<'_> { //Tui::bg(Color::Rgb(10, 100, 10), "Hello").boxed() //} - //pub fn world (&self) -> impl Content + use<'_> { + //pub fn world (&self) -> impl Draw + use<'_> { //Tui::bg(Color::Rgb(100, 10, 10), "world").boxed() //} - //pub fn hello_world (&self) -> impl Content + use<'_> { + //pub fn hello_world (&self) -> impl Draw + use<'_> { //"Hello world!".boxed() //} - //pub fn map_e (&self) -> impl Content + use<'_> { + //pub fn map_e (&self) -> impl Draw + use<'_> { //Map::east(5u16, ||0..5u16, |n, _i|format!("{n}")).boxed() //} - //pub fn map_s (&self) -> impl Content + use<'_> { + //pub fn map_s (&self) -> impl Draw + use<'_> { //Map::south(5u16, ||0..5u16, |n, _i|format!("{n}")).boxed() //} //} diff --git a/tui/src/tui_content.rs b/tui/src/tui_content.rs index 7c4285d..38cf5ba 100644 --- a/tui/src/tui_content.rs +++ b/tui/src/tui_content.rs @@ -18,31 +18,31 @@ mod tui_scroll; pub use self::tui_scroll::*; mod tui_string; pub use self::tui_string::*; mod tui_number; //pub use self::tui_number::*; mod tui_tryptich; //pub use self::tui_tryptich::*; -impl> Draw for Foreground { - fn draw (&self, to: &mut TuiOut) { - let area = self.layout(to.area()); - to.fill_fg(area, self.0); - to.place_at(area, &self.1); - } -} -impl> Draw for Background { - fn draw (&self, to: &mut TuiOut) { - let area = self.layout(to.area()); - to.fill_bg(area, self.0); - to.place_at(area, &self.1); - } -} pub struct Modify(pub bool, pub Modifier, pub T); -impl> Layout for Modify {} -impl> Draw for Modify { +pub struct Styled(pub Option