0.26.2 - 2024-04-15
This is a patch release that fixes bugs and adds enhancements, including new iterator constructors, List scroll padding, and various rendering improvements. ✨
✨ Release highlights: https://ratatui.rs/highlights/v0262/
Features
-
11b452d
(layout) Mark various functions as const by @EdJoPaTo in #951 -
1cff511
(line) Impl Styled for Line by @joshka in #968This adds `FromIterator` impls for `Line` and `Text` that allow creating `Line` and `Text` instances from iterators of `Span` and `Line` instances, respectively. ```rust let line = Line::from_iter(vec!["Hello".blue(), " world!".green()]); let line: Line = iter::once("Hello".blue()) .chain(iter::once(" world!".green())) .collect(); let text = Text::from_iter(vec!["The first line", "The second line"]); let text: Text = iter::once("The first line") .chain(iter::once("The second line")) .collect(); ```
-
654949b
(list) Add Scroll Padding to Lists by @CameronBarnes in #958Introduces scroll padding, which allows the api user to request that a certain number of ListItems be kept visible above and below the currently selected item while scrolling. ```rust let list = List::new(items).scroll_padding(1); ```
Fixes:#955
-
26af650
(text) Add push methods for text and line by @joshka in #998Adds the following methods to the `Text` and `Line` structs: - Text::push_line - Text::push_span - Line::push_span This allows for adding lines and spans to a text object without having to call methods on the fields directly, which is useful for incremental construction of text objects.
-
b5bdde0
(text) AddFromIterator
impls forLine
andText
by @joshka in #967This adds `FromIterator` impls for `Line` and `Text` that allow creating `Line` and `Text` instances from iterators of `Span` and `Line` instances, respectively. ```rust let line = Line::from_iter(vec!["Hello".blue(), " world!".green()]); let line: Line = iter::once("Hello".blue()) .chain(iter::once(" world!".green())) .collect(); let text = Text::from_iter(vec!["The first line", "The second line"]); let text: Text = iter::once("The first line") .chain(iter::once("The second line")) .collect(); ```
-
12f67e8
(uncategorized) Impl Widget for&str
andString
by @kdheepak in #952Currently, `f.render_widget("hello world".bold(), area)` works but `f.render_widget("hello world", area)` doesn't. This PR changes that my implementing `Widget` for `&str` and `String`. This makes it easier to render strings with no styles as widgets. Example usage: ```rust terminal.draw(|f| f.render_widget("Hello World!", f.size()))?; ``` ---------
Bug Fixes
-
0207160
(line) Line truncation respects alignment by @TadoTheMiner in #987When rendering a `Line`, the line will be truncated: - on the right for left aligned lines - on the left for right aligned lines - on bot sides for centered lines E.g. "Hello World" will be rendered as "Hello", "World", "lo wo" for left, right, centered lines respectively.
Fixes:#932
-
c56f49b
(list) Saturating_sub to fix highlight_symbol overflow by @mrjackwills in #949An overflow (pedantically an underflow) can occur if the highlight_symbol is a multi-byte char, and area is reduced to a size less than that char length.
-
943c043
(scrollbar) Dont render on 0 length track by @EdJoPaTo in #964Fixes a panic when `track_length - 1` is used. (clamp panics on `-1.0` being smaller than `0.0`)
-
742a5ea
(text) Fix panic when rendering out of bounds by @joshka in #997Previously it was possible to cause a panic when rendering to an area outside of the buffer bounds. Instead this now correctly renders nothing to the buffer.
-
f6c4e44
(uncategorized) Ensure that paragraph correctly renders styled text by @joshka in #992Paragraph was ignoring the new `Text::style` field added in 0.26.0
Fixes:#990
-
35e971f
(uncategorized) Scrollbar thumb not visible on long lists by @ThomasMiz in #959When displaying somewhat-long lists, the `Scrollbar` widget sometimes did not display a thumb character, and only the track will be visible.
Refactor
-
c12bcfe
(non-src) Apply pedantic lints by @EdJoPaTo in #976Fixes many not yet enabled lints (mostly pedantic) on everything that is not the lib (examples, benches, tests). Therefore, this is not containing anything that can be a breaking change. Lints are not enabled as that should be the job of #974. I created this as a separate PR as its mostly independent and would only clutter up the diff of #974 even more. Also see https://github.com/ratatui-org/ratatui/pull/974#discussion_r1506458743 ---------
-
8719608
(span) Rename to_aligned_line into into_aligned_line by @EdJoPaTo in #993With the Rust method naming conventions these methods are into methods consuming the Span. Therefore, it's more consistent to use `into_` instead of `to_`. ```rust Span::to_centered_line Span::to_left_aligned_line Span::to_right_aligned_line ``` Are marked deprecated and replaced with the following ```rust Span::into_centered_line Span::into_left_aligned_line Span::into_right_aligned_line ```
-
b831c56
(widget-ref) Clippy::needless_pass_by_value by @EdJoPaTo -
359204c
(uncategorized) Simplify to io::Result by @EdJoPaTo in #1016Simplifies the code, logic stays exactly the same.
-
8e68db9
(uncategorized) Remove pointless default on internal structs by @EdJoPaTo in #980See #978
Also remove other derives. They are unused and just slow down
compilation.
-
3be189e
(uncategorized) Clippy::thread_local_initializer_can_be_made_const by @EdJoPaToenabled by default on nightly
-
bbb6d65
(uncategorized) Clippy::else_if_without_else by @EdJoPaTo -
fdb14dc
(uncategorized) Clippy::redundant_type_annotations by @EdJoPaTo -
9b3b23a
(uncategorized) Remove literal suffix by @EdJoPaToits not needed and can just be assumed
related:clippy::(un)separated_literal_suffix
-
58b6e0b
(uncategorized) Clippy::should_panic_without_expect by @EdJoPaTo -
c870a41
(uncategorized) Clippy::many_single_char_names by @EdJoPaTo -
060d26b
(uncategorized) Clippy::match_same_arms by @EdJoPaTo -
fcbea9e
(uncategorized) Clippy::uninlined_format_args by @EdJoPaTo -
5ed1f43
(uncategorized) Clippy::redundant_closure_for_method_calls by @EdJoPaTo -
e3afe7c
(uncategorized) Clippy::unreadable_literal by @EdJoPaTo -
a1f54de
(uncategorized) Clippy::bool_to_int_with_if by @EdJoPaTo -
0de5238
(uncategorized) Dead_code by @EdJoPaToenabled by default, only detected by nightly yet
-
df5dddf
(uncategorized) Unused_imports by @EdJoPaToenabled by default, only detected on nightly yet
-
f1398ae
(uncategorized) Clippy::useless_vec by @EdJoPaToLint enabled by default but only nightly finds this yet
-
525848f
(uncategorized) Manually apply clippy::use_self for impl with lifetimes by @EdJoPaTo -
660c718
(uncategorized) Clippy::empty_line_after_doc_comments by @EdJoPaTo -
ab951fa
(uncategorized) Clippy::return_self_not_must_use by @EdJoPaTo -
9bc014d
(uncategorized) Clippy::items_after_statements by @EdJoPaTo -
36a0cd5
(uncategorized) Clippy::deref_by_slicing by @EdJoPaTo -
f7f6692
(uncategorized) Clippy::equatable_if_let by @EdJoPaTo -
01418eb
(uncategorized) Clippy::default_trait_access by @EdJoPaTo -
8536760
(uncategorized) Clippy::inefficient_to_string by @EdJoPaTo -
27680c0
(uncategorized) Clippy::semicolon_if_nothing_returned by @EdJoPaTo
Documentation
-
14461c3
(breaking-changes) Typos and markdownlint by @EdJoPaTo in #1009 -
3b002fd
(uncategorized) Update incompatible code warning in examples readme by @joshka in #1013
Performance
-
e02f476
(borders) Allow border!() in const by @EdJoPaTo in #977This allows more compiler optimizations when the macro is used.
-
541f0f9
(cell) Use const CompactString::new_inline by @EdJoPaTo in #979Some minor find when messing around trying to `const` all the things. While `reset()` and `default()` can not be `const` it's still a benefit when their contents are.
-
65e7923
(scrollbar) Const creation by @EdJoPaTo in #963A bunch of `const fn` allow for more performance and `Default` now uses the `const` new implementations.
-
8195f52
(uncategorized) Clippy::needless_pass_by_value by @EdJoPaTo -
183c07e
(uncategorized) Clippy::trivially_copy_pass_by_ref by @EdJoPaTo -
a13867f
(uncategorized) Clippy::cloned_instead_of_copied by @EdJoPaTo -
3834374
(uncategorized) Clippy::missing_const_for_fn by @EdJoPaTo
Miscellaneous Tasks
-
125ee92
(docs) Fix: fix typos in crate documentation by @orhun in #1002 -
38c17e0
(editorconfig) Set and apply some defaults by @EdJoPaTo -
07da90a
(funding) Add eth address for receiving funds from drips.network by @BenJam in #994 -
078e97e
(github) Add EdJoPaTo as a maintainer by @orhun in #986 -
b0314c5
(uncategorized) Remove conventional commit check for PR by @Valentin271 in #950This removes conventional commit check for PRs. Since we use the PR title and description this is useless. It fails a lot of time and we ignore it. IMPORTANT NOTE: This does **not** mean Ratatui abandons conventional commits. This only relates to commits in PRs.
Build
-
6e6ba27
(lint) Warn on pedantic and allow the rest by @EdJoPaTo -
c4ce7e8
(uncategorized) Enable more satisfied lints by @EdJoPaToThese lints dont generate warnings and therefore dont need refactoring. I think they are useful in the future.
-
a4e84a6
(uncategorized) Increase msrv to 1.74.0 by @EdJoPaTo [breaking]configure lints in Cargo.toml requires 1.74.0
BREAKING CHANGE:rust 1.74 is required now
New Contributors
- @TadoTheMiner made their first contribution in #987
- @BenJam made their first contribution in #994
- @CameronBarnes made their first contribution in #958
- @ThomasMiz made their first contribution in #959
Full Changelog: v0.26.1...v0.26.2