mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2026-01-31 10:56:41 +01:00
group tui_engine and tui_content; cargo update
This commit is contained in:
parent
877b344765
commit
71dead5150
13 changed files with 150 additions and 72 deletions
|
|
@ -1,6 +1,10 @@
|
|||
use crate::*;
|
||||
use crate::Color::*;
|
||||
use ratatui::prelude::Position;
|
||||
|
||||
mod tui_color; pub use self::tui_color::*;
|
||||
mod tui_file; pub use self::tui_file::*;
|
||||
|
||||
macro_rules! impl_content_layout_render {
|
||||
($Output:ty: |$self:ident: $Struct:ty, $to:ident| layout = $layout:expr; render = $render:expr) => {
|
||||
impl Content<$Output> for $Struct {
|
||||
|
|
@ -13,19 +17,24 @@ impl_content_layout_render!(TuiOut: |self: &str, to|
|
|||
layout = to.center_xy([self.chars().count() as u16, 1]);
|
||||
render = {let [x, y, ..] = Content::layout(self, to.area());
|
||||
to.blit(self, x, y, None)});
|
||||
|
||||
impl_content_layout_render!(TuiOut: |self: String, to|
|
||||
layout = to.center_xy([self.chars().count() as u16, 1]);
|
||||
render = {let [x, y, ..] = Content::layout(self, to.area());
|
||||
to.blit(self, x, y, None)});
|
||||
|
||||
impl_content_layout_render!(TuiOut: |self: std::sync::RwLock<String>, to|
|
||||
layout = Content::<TuiOut>::layout(&self.read().unwrap(), to);
|
||||
render = Content::<TuiOut>::render(&self.read().unwrap(), to));
|
||||
|
||||
impl_content_layout_render!(TuiOut: |self: std::sync::RwLockReadGuard<'_, String>, to|
|
||||
layout = Content::<TuiOut>::layout(&**self, to);
|
||||
render = Content::<TuiOut>::render(&**self, to));
|
||||
|
||||
impl_content_layout_render!(TuiOut: |self: Arc<str>, to|
|
||||
layout = to.center_xy([self.chars().count() as u16, 1]);
|
||||
render = to.blit(self, to.area.x(), to.area.y(), None));
|
||||
|
||||
impl<T: Content<TuiOut>> Content<TuiOut> for std::sync::Arc<T> {
|
||||
fn layout (&self, to: [u16;4]) -> [u16;4] {
|
||||
Content::<TuiOut>::layout(&**self, to)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue