mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2025-12-07 12:16:44 +01:00
refactor: extract more tui_content modules
This commit is contained in:
parent
86236b76cd
commit
ea01deb854
6 changed files with 192 additions and 183 deletions
|
|
@ -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].
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue