38.54% coverage

This commit is contained in:
🪞👃🪞 2025-02-17 23:51:26 +02:00
parent f71118613b
commit 77d617f9a0
5 changed files with 68 additions and 11 deletions

View file

@ -43,13 +43,6 @@ impl<E: Output> std::fmt::Debug for Measure<E> {
}
}
impl<E: Output> Measure<E> {
pub fn w (&self) -> usize { self.x.load(Relaxed) }
pub fn h (&self) -> usize { self.y.load(Relaxed) }
pub fn wh (&self) -> [usize;2] { [self.w(), self.h()] }
pub fn set_w (&self, w: impl Into<usize>) { self.x.store(w.into(), Relaxed) }
pub fn set_h (&self, h: impl Into<usize>) { self.y.store(h.into(), Relaxed) }
pub fn set_wh (&self, w: impl Into<usize>, h: impl Into<usize>) { self.set_w(w); self.set_h(h); }
pub fn format (&self) -> Arc<str> { format!("{}x{}", self.w(), self.h()).into() }
pub fn new () -> Self {
Self {
_engine: PhantomData::default(),
@ -57,10 +50,45 @@ impl<E: Output> Measure<E> {
y: Arc::new(0.into()),
}
}
pub fn set_w (&self, w: impl Into<usize>) -> &Self {
self.x.store(w.into(), Relaxed);
self
}
pub fn set_h (&self, h: impl Into<usize>) -> &Self {
self.y.store(h.into(), Relaxed);
self
}
pub fn set_wh (&self, w: impl Into<usize>, h: impl Into<usize>) -> &Self {
self.set_w(w);
self.set_h(h);
self
}
pub fn w (&self) -> usize {
self.x.load(Relaxed)
}
pub fn h (&self) -> usize {
self.y.load(Relaxed)
}
pub fn wh (&self) -> [usize;2] {
[self.w(), self.h()]
}
pub fn format (&self) -> Arc<str> {
format!("{}x{}", self.w(), self.h()).into()
}
pub fn of <T: Content<E>> (&self, item: T) -> Bsp<Fill<&Self>, T> {
Bsp::b(Fill::xy(self), item)
}
}
//#[cfg(test)] #[test] fn test_measure () {
//use tek_tui::*;
//let size: Measure<TuiOut> = Measure::default().set_w(1usize).set_h(1usize).clone();
//let size: Measure<TuiOut> = (&Measure::new().set_wh(2usize, 1usize)).clone();
//let _ = format!("{:?}", &size);
//let _ = size.wh();
//let _ = size.format();
//let _ = size.of(());
//}
///// A scrollable area.
//pub struct Scroll<E, F>(pub F, pub Direction, pub u64, PhantomData<E>)
//where