Text

Struct Text 

Source
pub struct Text { /* private fields */ }
Expand description

Text component builder.

Implementations§

Source§

impl Text

Source

pub fn new(content: impl Into<String>) -> Self

Create a new text component.

Examples found in repository?
examples/01_counter.rs (line 17)
7fn main() -> std::io::Result<()> {
8    // Create reactive state
9    let (count, set_count) = create_signal(0);
10
11    // Build the UI
12    let ui = Box::new()
13        .column()
14        .padding(1)
15        .border_round()
16        .children([
17            Text::new("🐦 Tuiuiu Counter").cyan().bold().build(),
18            Text::new(format!("Count: {}", count.get())).build(),
19            Text::new("↑/↓: change • Esc: exit").gray().dim().build(),
20        ]);
21
22    // Render and get the output
23    let output = tuiuiu::core::renderer::render_to_string(&ui.build(), 40, 10);
24    
25    println!("{}", output);
26    println!();
27    println!("(Interactive mode not yet implemented)");
28    println!("This example demonstrates the component structure.");
29
30    Ok(())
31}
More examples
Hide additional examples
examples/02_dashboard.rs (line 14)
7fn main() -> std::io::Result<()> {
8    let ui = Box::new()
9        .column()
10        .padding(1)
11        .gap(1)
12        .border_round()
13        .children([
14            Text::new("📊 Dashboard").cyan().bold().build(),
15            
16            Box::new()
17                .row()
18                .gap(2)
19                .children([
20                    Box::new()
21                        .column()
22                        .padding(1)
23                        .border(tuiuiu::utils::border::BorderStyle::Single)
24                        .children([
25                            Text::new("CPU").yellow().build(),
26                            Text::new("45%").green().build(),
27                        ])
28                        .build(),
29                    
30                    Box::new()
31                        .column()
32                        .padding(1)
33                        .border(tuiuiu::utils::border::BorderStyle::Single)
34                        .children([
35                            Text::new("Memory").yellow().build(),
36                            Text::new("2.1 GB").cyan().build(),
37                        ])
38                        .build(),
39                ])
40                .build(),
41            
42            Text::new("Press q to quit").gray().dim().build(),
43        ]);
44
45    let output = tuiuiu::core::renderer::render_to_string(&ui.build(), 50, 15);
46    println!("{}", output);
47
48    Ok(())
49}
Source

pub fn empty() -> Self

Create an empty text.

Source

pub fn content(self, content: impl Into<String>) -> Self

Set the text content.

Source

pub fn color(self, color: Color) -> Self

Set text color.

Source

pub fn fg(self, color: NamedColor) -> Self

Set text color by name.

Source

pub fn rgb(self, r: u8, g: u8, b: u8) -> Self

Set text color as RGB.

Source

pub fn background(self, color: Color) -> Self

Set background color.

Source

pub fn bg(self, color: NamedColor) -> Self

Set background color by name.

Source

pub fn red(self) -> Self

Red text.

Source

pub fn green(self) -> Self

Green text.

Examples found in repository?
examples/02_dashboard.rs (line 26)
7fn main() -> std::io::Result<()> {
8    let ui = Box::new()
9        .column()
10        .padding(1)
11        .gap(1)
12        .border_round()
13        .children([
14            Text::new("📊 Dashboard").cyan().bold().build(),
15            
16            Box::new()
17                .row()
18                .gap(2)
19                .children([
20                    Box::new()
21                        .column()
22                        .padding(1)
23                        .border(tuiuiu::utils::border::BorderStyle::Single)
24                        .children([
25                            Text::new("CPU").yellow().build(),
26                            Text::new("45%").green().build(),
27                        ])
28                        .build(),
29                    
30                    Box::new()
31                        .column()
32                        .padding(1)
33                        .border(tuiuiu::utils::border::BorderStyle::Single)
34                        .children([
35                            Text::new("Memory").yellow().build(),
36                            Text::new("2.1 GB").cyan().build(),
37                        ])
38                        .build(),
39                ])
40                .build(),
41            
42            Text::new("Press q to quit").gray().dim().build(),
43        ]);
44
45    let output = tuiuiu::core::renderer::render_to_string(&ui.build(), 50, 15);
46    println!("{}", output);
47
48    Ok(())
49}
Source

pub fn blue(self) -> Self

Blue text.

Source

pub fn yellow(self) -> Self

Yellow text.

Examples found in repository?
examples/02_dashboard.rs (line 25)
7fn main() -> std::io::Result<()> {
8    let ui = Box::new()
9        .column()
10        .padding(1)
11        .gap(1)
12        .border_round()
13        .children([
14            Text::new("📊 Dashboard").cyan().bold().build(),
15            
16            Box::new()
17                .row()
18                .gap(2)
19                .children([
20                    Box::new()
21                        .column()
22                        .padding(1)
23                        .border(tuiuiu::utils::border::BorderStyle::Single)
24                        .children([
25                            Text::new("CPU").yellow().build(),
26                            Text::new("45%").green().build(),
27                        ])
28                        .build(),
29                    
30                    Box::new()
31                        .column()
32                        .padding(1)
33                        .border(tuiuiu::utils::border::BorderStyle::Single)
34                        .children([
35                            Text::new("Memory").yellow().build(),
36                            Text::new("2.1 GB").cyan().build(),
37                        ])
38                        .build(),
39                ])
40                .build(),
41            
42            Text::new("Press q to quit").gray().dim().build(),
43        ]);
44
45    let output = tuiuiu::core::renderer::render_to_string(&ui.build(), 50, 15);
46    println!("{}", output);
47
48    Ok(())
49}
Source

pub fn cyan(self) -> Self

Cyan text.

Examples found in repository?
examples/01_counter.rs (line 17)
7fn main() -> std::io::Result<()> {
8    // Create reactive state
9    let (count, set_count) = create_signal(0);
10
11    // Build the UI
12    let ui = Box::new()
13        .column()
14        .padding(1)
15        .border_round()
16        .children([
17            Text::new("🐦 Tuiuiu Counter").cyan().bold().build(),
18            Text::new(format!("Count: {}", count.get())).build(),
19            Text::new("↑/↓: change • Esc: exit").gray().dim().build(),
20        ]);
21
22    // Render and get the output
23    let output = tuiuiu::core::renderer::render_to_string(&ui.build(), 40, 10);
24    
25    println!("{}", output);
26    println!();
27    println!("(Interactive mode not yet implemented)");
28    println!("This example demonstrates the component structure.");
29
30    Ok(())
31}
More examples
Hide additional examples
examples/02_dashboard.rs (line 14)
7fn main() -> std::io::Result<()> {
8    let ui = Box::new()
9        .column()
10        .padding(1)
11        .gap(1)
12        .border_round()
13        .children([
14            Text::new("📊 Dashboard").cyan().bold().build(),
15            
16            Box::new()
17                .row()
18                .gap(2)
19                .children([
20                    Box::new()
21                        .column()
22                        .padding(1)
23                        .border(tuiuiu::utils::border::BorderStyle::Single)
24                        .children([
25                            Text::new("CPU").yellow().build(),
26                            Text::new("45%").green().build(),
27                        ])
28                        .build(),
29                    
30                    Box::new()
31                        .column()
32                        .padding(1)
33                        .border(tuiuiu::utils::border::BorderStyle::Single)
34                        .children([
35                            Text::new("Memory").yellow().build(),
36                            Text::new("2.1 GB").cyan().build(),
37                        ])
38                        .build(),
39                ])
40                .build(),
41            
42            Text::new("Press q to quit").gray().dim().build(),
43        ]);
44
45    let output = tuiuiu::core::renderer::render_to_string(&ui.build(), 50, 15);
46    println!("{}", output);
47
48    Ok(())
49}
Source

pub fn magenta(self) -> Self

Magenta text.

Source

pub fn white(self) -> Self

White text.

Source

pub fn black(self) -> Self

Black text.

Source

pub fn gray(self) -> Self

Gray text.

Examples found in repository?
examples/01_counter.rs (line 19)
7fn main() -> std::io::Result<()> {
8    // Create reactive state
9    let (count, set_count) = create_signal(0);
10
11    // Build the UI
12    let ui = Box::new()
13        .column()
14        .padding(1)
15        .border_round()
16        .children([
17            Text::new("🐦 Tuiuiu Counter").cyan().bold().build(),
18            Text::new(format!("Count: {}", count.get())).build(),
19            Text::new("↑/↓: change • Esc: exit").gray().dim().build(),
20        ]);
21
22    // Render and get the output
23    let output = tuiuiu::core::renderer::render_to_string(&ui.build(), 40, 10);
24    
25    println!("{}", output);
26    println!();
27    println!("(Interactive mode not yet implemented)");
28    println!("This example demonstrates the component structure.");
29
30    Ok(())
31}
More examples
Hide additional examples
examples/02_dashboard.rs (line 42)
7fn main() -> std::io::Result<()> {
8    let ui = Box::new()
9        .column()
10        .padding(1)
11        .gap(1)
12        .border_round()
13        .children([
14            Text::new("📊 Dashboard").cyan().bold().build(),
15            
16            Box::new()
17                .row()
18                .gap(2)
19                .children([
20                    Box::new()
21                        .column()
22                        .padding(1)
23                        .border(tuiuiu::utils::border::BorderStyle::Single)
24                        .children([
25                            Text::new("CPU").yellow().build(),
26                            Text::new("45%").green().build(),
27                        ])
28                        .build(),
29                    
30                    Box::new()
31                        .column()
32                        .padding(1)
33                        .border(tuiuiu::utils::border::BorderStyle::Single)
34                        .children([
35                            Text::new("Memory").yellow().build(),
36                            Text::new("2.1 GB").cyan().build(),
37                        ])
38                        .build(),
39                ])
40                .build(),
41            
42            Text::new("Press q to quit").gray().dim().build(),
43        ]);
44
45    let output = tuiuiu::core::renderer::render_to_string(&ui.build(), 50, 15);
46    println!("{}", output);
47
48    Ok(())
49}
Source

pub fn bold(self) -> Self

Make text bold.

Examples found in repository?
examples/01_counter.rs (line 17)
7fn main() -> std::io::Result<()> {
8    // Create reactive state
9    let (count, set_count) = create_signal(0);
10
11    // Build the UI
12    let ui = Box::new()
13        .column()
14        .padding(1)
15        .border_round()
16        .children([
17            Text::new("🐦 Tuiuiu Counter").cyan().bold().build(),
18            Text::new(format!("Count: {}", count.get())).build(),
19            Text::new("↑/↓: change • Esc: exit").gray().dim().build(),
20        ]);
21
22    // Render and get the output
23    let output = tuiuiu::core::renderer::render_to_string(&ui.build(), 40, 10);
24    
25    println!("{}", output);
26    println!();
27    println!("(Interactive mode not yet implemented)");
28    println!("This example demonstrates the component structure.");
29
30    Ok(())
31}
More examples
Hide additional examples
examples/02_dashboard.rs (line 14)
7fn main() -> std::io::Result<()> {
8    let ui = Box::new()
9        .column()
10        .padding(1)
11        .gap(1)
12        .border_round()
13        .children([
14            Text::new("📊 Dashboard").cyan().bold().build(),
15            
16            Box::new()
17                .row()
18                .gap(2)
19                .children([
20                    Box::new()
21                        .column()
22                        .padding(1)
23                        .border(tuiuiu::utils::border::BorderStyle::Single)
24                        .children([
25                            Text::new("CPU").yellow().build(),
26                            Text::new("45%").green().build(),
27                        ])
28                        .build(),
29                    
30                    Box::new()
31                        .column()
32                        .padding(1)
33                        .border(tuiuiu::utils::border::BorderStyle::Single)
34                        .children([
35                            Text::new("Memory").yellow().build(),
36                            Text::new("2.1 GB").cyan().build(),
37                        ])
38                        .build(),
39                ])
40                .build(),
41            
42            Text::new("Press q to quit").gray().dim().build(),
43        ]);
44
45    let output = tuiuiu::core::renderer::render_to_string(&ui.build(), 50, 15);
46    println!("{}", output);
47
48    Ok(())
49}
Source

pub fn italic(self) -> Self

Make text italic.

Source

pub fn underline(self) -> Self

Make text underlined.

Source

pub fn strikethrough(self) -> Self

Make text strikethrough.

Source

pub fn dim(self) -> Self

Make text dim.

Examples found in repository?
examples/01_counter.rs (line 19)
7fn main() -> std::io::Result<()> {
8    // Create reactive state
9    let (count, set_count) = create_signal(0);
10
11    // Build the UI
12    let ui = Box::new()
13        .column()
14        .padding(1)
15        .border_round()
16        .children([
17            Text::new("🐦 Tuiuiu Counter").cyan().bold().build(),
18            Text::new(format!("Count: {}", count.get())).build(),
19            Text::new("↑/↓: change • Esc: exit").gray().dim().build(),
20        ]);
21
22    // Render and get the output
23    let output = tuiuiu::core::renderer::render_to_string(&ui.build(), 40, 10);
24    
25    println!("{}", output);
26    println!();
27    println!("(Interactive mode not yet implemented)");
28    println!("This example demonstrates the component structure.");
29
30    Ok(())
31}
More examples
Hide additional examples
examples/02_dashboard.rs (line 42)
7fn main() -> std::io::Result<()> {
8    let ui = Box::new()
9        .column()
10        .padding(1)
11        .gap(1)
12        .border_round()
13        .children([
14            Text::new("📊 Dashboard").cyan().bold().build(),
15            
16            Box::new()
17                .row()
18                .gap(2)
19                .children([
20                    Box::new()
21                        .column()
22                        .padding(1)
23                        .border(tuiuiu::utils::border::BorderStyle::Single)
24                        .children([
25                            Text::new("CPU").yellow().build(),
26                            Text::new("45%").green().build(),
27                        ])
28                        .build(),
29                    
30                    Box::new()
31                        .column()
32                        .padding(1)
33                        .border(tuiuiu::utils::border::BorderStyle::Single)
34                        .children([
35                            Text::new("Memory").yellow().build(),
36                            Text::new("2.1 GB").cyan().build(),
37                        ])
38                        .build(),
39                ])
40                .build(),
41            
42            Text::new("Press q to quit").gray().dim().build(),
43        ]);
44
45    let output = tuiuiu::core::renderer::render_to_string(&ui.build(), 50, 15);
46    println!("{}", output);
47
48    Ok(())
49}
Source

pub fn inverse(self) -> Self

Inverse colors.

Source

pub fn wrap(self, mode: WrapMode) -> Self

Set wrap mode.

Source

pub fn wrap_word(self) -> Self

Wrap at word boundaries.

Source

pub fn wrap_char(self) -> Self

Wrap at character boundaries.

Source

pub fn truncate(self) -> Self

Truncate with ellipsis.

Source

pub fn build(self) -> VNode

Build into a VNode.

Examples found in repository?
examples/01_counter.rs (line 17)
7fn main() -> std::io::Result<()> {
8    // Create reactive state
9    let (count, set_count) = create_signal(0);
10
11    // Build the UI
12    let ui = Box::new()
13        .column()
14        .padding(1)
15        .border_round()
16        .children([
17            Text::new("🐦 Tuiuiu Counter").cyan().bold().build(),
18            Text::new(format!("Count: {}", count.get())).build(),
19            Text::new("↑/↓: change • Esc: exit").gray().dim().build(),
20        ]);
21
22    // Render and get the output
23    let output = tuiuiu::core::renderer::render_to_string(&ui.build(), 40, 10);
24    
25    println!("{}", output);
26    println!();
27    println!("(Interactive mode not yet implemented)");
28    println!("This example demonstrates the component structure.");
29
30    Ok(())
31}
More examples
Hide additional examples
examples/02_dashboard.rs (line 14)
7fn main() -> std::io::Result<()> {
8    let ui = Box::new()
9        .column()
10        .padding(1)
11        .gap(1)
12        .border_round()
13        .children([
14            Text::new("📊 Dashboard").cyan().bold().build(),
15            
16            Box::new()
17                .row()
18                .gap(2)
19                .children([
20                    Box::new()
21                        .column()
22                        .padding(1)
23                        .border(tuiuiu::utils::border::BorderStyle::Single)
24                        .children([
25                            Text::new("CPU").yellow().build(),
26                            Text::new("45%").green().build(),
27                        ])
28                        .build(),
29                    
30                    Box::new()
31                        .column()
32                        .padding(1)
33                        .border(tuiuiu::utils::border::BorderStyle::Single)
34                        .children([
35                            Text::new("Memory").yellow().build(),
36                            Text::new("2.1 GB").cyan().build(),
37                        ])
38                        .build(),
39                ])
40                .build(),
41            
42            Text::new("Press q to quit").gray().dim().build(),
43        ]);
44
45    let output = tuiuiu::core::renderer::render_to_string(&ui.build(), 50, 15);
46    println!("{}", output);
47
48    Ok(())
49}

Trait Implementations§

Source§

impl Clone for Text

Source§

fn clone(&self) -> Text

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Text

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Text

Source§

fn default() -> Text

Returns the “default value” for a type. Read more
Source§

impl From<&str> for Text

Source§

fn from(s: &str) -> Self

Converts to this type from the input type.
Source§

impl From<String> for Text

Source§

fn from(s: String) -> Self

Converts to this type from the input type.
Source§

impl From<Text> for VNode

Source§

fn from(t: Text) -> VNode

Converts to this type from the input type.

Auto Trait Implementations§

§

impl Freeze for Text

§

impl RefUnwindSafe for Text

§

impl Send for Text

§

impl Sync for Text

§

impl Unpin for Text

§

impl UnwindSafe for Text

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.