wip: text drawing impls

This commit is contained in:
facile pop culture reference 2026-06-19 10:17:04 +03:00
parent 29035d0b36
commit 9c5bfafb7a
2 changed files with 15 additions and 8 deletions

View file

@ -46,21 +46,26 @@ pub use self::screen::*;
/// }
/// }
/// ```
pub trait Draw<T: Screen> {
fn draw (self, to: &mut T) -> Usually<XYWH<T::Unit>>;
pub trait Draw<S: Screen> {
fn draw (self, to: &mut S) -> Usually<XYWH<S::Unit>>;
}
impl<T: Screen> Draw<T> for () {
fn draw (self, __: &mut T) -> Usually<XYWH<T::Unit>> {
impl<S: Screen> Draw<S> for () {
fn draw (self, __: &mut S) -> Usually<XYWH<S::Unit>> {
Ok(Default::default())
}
}
impl<T: Screen, D: Draw<T>> Draw<T> for &D {
fn draw (self, __: &mut T) -> Usually<XYWH<T::Unit>> {
impl<S: Screen, D: Draw<S>> Draw<S> for &D {
fn draw (self, __: &mut S) -> Usually<XYWH<S::Unit>> {
todo!()
}
}
impl<T: Screen, D: Draw<T>> Draw<T> for Option<D> {
fn draw (self, __: &mut T) -> Usually<XYWH<T::Unit>> {
impl<S: Screen, D: Draw<S>> Draw<S> for Option<D> {
fn draw (self, __: &mut S) -> Usually<XYWH<S::Unit>> {
todo!()
}
}
impl<S: Screen, D: Draw<S>> Draw<S> for RwLock<D> {
fn draw (self, __: &mut S) -> Usually<XYWH<S::Unit>> {
todo!()
}
}

View file

@ -12,11 +12,13 @@ pub(crate) use ::unicode_width::*;
to.text(&self, x, y, w)
}
}
impl Draw<Tui> for String {
fn draw (self, to: &mut Tui) -> Usually<XYWH<u16>> {
self.as_str().draw(to)
}
}
impl Draw<Tui> for &std::sync::Arc<str> {
fn draw (self, to: &mut Tui) -> Usually<XYWH<u16>> {
self.as_ref().draw(to)