mirror of
https://github.com/ratatui/ratatui.git
synced 2025-12-29 21:01:16 +00:00
Importing the `WidgetExt` trait allows users to easily get a string
representation of a widget with ANSI escape sequences for the terminal.
This is useful for debugging and testing widgets.
```rust
use ratatui::{prelude::*, widgets::widget_ext::WidgetExt};
fn main() {
let greeting = Text::from(vec![
Line::styled("Hello", Color::Blue),
Line::styled("World ", Color::Green),
]);
println!("{}", greeting.to_ansi_string(5, 2));
}
```
Fixes: https://github.com/ratatui-org/ratatui/issues/1045
10 lines
259 B
Rust
10 lines
259 B
Rust
use ratatui::{prelude::*, widgets::widget_ext::WidgetExt};
|
|
|
|
fn main() {
|
|
let greeting = Text::from(vec![
|
|
Line::styled("Hello", Color::Blue),
|
|
Line::styled("World ", Color::Green),
|
|
]);
|
|
println!("{}", greeting.to_ansi_string(5, 2));
|
|
}
|