src/content/docs/highlights/v0.26.3.md
https://github.com/ratatui/ratatui/releases/tag/v0.26.3
We are happy to announce a brand new Ratatui Forum ๐ญ for Rust & TUI enthusiasts.
<center>Join here: https://forum.ratatui.rs
</center>Here you can get help with your Rust/Ratatui questions and share your projects!
If you are using Ratatui 0.26.2 you might have hit this bug:
panic occurred at
ratatui-0.26.2/src/text/line.rs:477:59byte index 51 is not a char boundary; it is inside 'ใง' (bytes 49..52) of๐ฆ RFC8628 OAuth 2.0 Device Authorization GrantใงCLIใใGithubใฎaccess tokenใๅๅพใใ
This issue was introduced in this PR and now fixed
with 0.26.3!
#[test]
fn truncation_works_with_emoji() {
let line = Line::raw( "123456789๐ฆ");
let mut buf = Buffer::empty(Rect::new(0, 0, 10, 1));
line.render(buf.area, &mut buf);
assert_buffer_eq!(buf, Buffer::with_lines(vec!["123456789 "]));
}
Color::Rgb will now be serialized as the hex representation of their value.
For example, Color::Rgb(255, 0, 255) would be serialized as "#FF00FF" rather than
{"Rgb": [255, 0, 255]}:
let json_rgb = serde_json::to_string(&Color::Rgb(255, 0, 255))?;
assert_eq!(json_rgb, r##""#FF00FF""##);
assert_eq!(
serde_json::from_str::<Color>(&json_rgb)?,
Color::Rgb(255, 0, 255)
);
Similarly, Color::Indexed will now be serialized as just the string of the index.
For example, with serde_json, Color::Indexed(10) would be serialized as "10" rather than
{"Indexed": 10}:
let json_indexed = serde_json::to_string(&Color::Indexed(10))?;
assert_eq!(json_indexed, r#""10""#);
assert_eq!(
serde_json::from_str::<Color>(&json_indexed)?,
Color::Indexed(10)
);
We sped up combined foreground and background color changes for the crossterm backend by up to
20%! ๐ฅ
For more information, see:
I changed the SetColors command to write both colors at once with a single write instead of multiple writes that more bytes. This led to a 15-25% fps increase when testing the colors_rgb example on iTerm2 on an M2 Macbook Pro.
assert_buffer_eq macro ๐ซassert_buffer_eq is now
deprecated in favor of the standard assert_eq macro:
-assert_buffer_eq!(actual, expected);
+assert_eq!(actual, expected);
We also introduced TestBackend::assert_buffer_lines for checking if TestBackend's buffer is
equal to the expected lines.
Here is an example usage:
#[test]
fn buffer() {
let backend = TestBackend::new(10, 2);
backend.assert_buffer_lines([" "; 2]);
}
So the usage can be simplified as follows:
-backend.assert_buffer(&Buffer::with_lines([" "; 2]));
+backend.assert_buffer_lines([" "; 2]);
Block::bordered ๐ฆThroughout the codebase we switched to the new way of creating bordered Blocks: Block::bordered
- Block::default().borders(Borders::ALL);
+ Block::bordered();
This was added in 0.26 and it requires one less import!
Have you ever tried to wrap ParseColorError in your custom error implementation?
9 | ParseColor(ratatui::style::color::ParseColorError),
| ^^^^^ --------------- struct `ParseColorError` is not publicly re-exported
| |
| private module
This is now possible since ParseColorError is re-exported as ratatui::style::ParseColorError!
We made improvements in some widgets to make use of constant functions and types:
TableState::new constant (#1040)rstest
(#1095)clippy::cargo_common_metadata and clippy::cargo)