refactor: extract more tui_content modules

This commit is contained in:
🪞👃🪞 2025-04-04 20:59:17 +03:00
parent 86236b76cd
commit ea01deb854
6 changed files with 192 additions and 183 deletions

View file

@ -2,6 +2,24 @@ use crate::*;
use crate::ratatui::prelude::Position;
use unicode_width::{UnicodeWidthStr, UnicodeWidthChar};
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));
/// Displays an owned [str]-like with fixed maximum width.
///
/// Width is computed using [unicode_width].