fix: add ansi_buffer example

This commit is contained in:
Josh McKinney 2024-04-25 20:01:22 -07:00
parent ee85bcfb43
commit 48924e9cb9
No known key found for this signature in database
GPG key ID: 722287396A903BC5
2 changed files with 10 additions and 2 deletions

View file

@ -182,8 +182,8 @@ harness = false
[[example]]
name = "barchart"
required-features = ["crossterm"]
name = "ansi_buffer"
required-features = ["unstable-widget-ext", "unstable-widget-ref"]
doc-scrape-examples = true
[[example]]

8
examples/ansi_buffer.rs Normal file
View file

@ -0,0 +1,8 @@
use ratatui::{prelude::*, widgets::ansi_string_buffer::AnsiStringBuffer};
fn main() {
let mut buf = AnsiStringBuffer::new(5, 2);
buf.render_ref(&Line::styled("Hello", Color::Blue), Rect::new(0, 0, 5, 1));
buf.render_ref(&Line::styled("World", Color::Green), Rect::new(0, 1, 5, 1));
println!("{buf}");
}