mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
38.54% coverage
This commit is contained in:
parent
f71118613b
commit
77d617f9a0
5 changed files with 68 additions and 11 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue