- More flexible listbuilder lifetimes by @nmandrus1
- Bump ratatui to v0.29.0
-
ListView::scroll_padding added. Allows to keep a specified number of cells above/below the selected widget visibile while scrolling.
-
ListState::circular got removed. Use ListView::infinite_scrolling instead.
- Change scroll up behaviour - keep first element truncated if possible
- Bump ratatui to v0.28
- Introduces
ListView
,ListBuilder
andListBuildContext
as replacement forList
,PreRender
andPreRenderContext
. List
,PreRender
andPreRenderContext
are marked as deprecated.
// Builder provides the ListBuildContext.
// Return the widget and the widget's size along its main-axis.
let builder = ListBuilder::new(|context| {
let mut item = Line::from(format!("Item {0}", context.index));
if context.index % 2 == 0 {
item.style = Style::default().bg(Color::Rgb(28, 28, 32))
} else {
item.style = Style::default().bg(Color::Rgb(0, 0, 0))
};
if context.is_selected {
item.style = Style::default()
.bg(Color::Rgb(255, 153, 0))
.fg(Color::Rgb(28, 28, 32));
};
return (item, 1);
});
// Construct the list. ListView takes in the builder and an item count.
let list = ListView::new(builder, 20);
// Render the list
list.render(area, &mut buf, &mut state);
- Implement Styled for List (contributor: airblast-dev)
- Bump ratatui to v0.27
- Introduced
PreRender
trait as a replacement forListableWidget
. - This change is non-breaking
- It provides a more concise and clearer interface. Migration Guide
- Update trait implementations to use the new
pre_render
signature:
fn pre_render(&mut self, context: &PreRenderContext) -> u16 {
let main_axis_size = // The widgets size in the main axis
if context.is_selected {
self = // You can modify the selected item here
}
main_axis_size
}
- Deprecated ListState::selected(). Use the struct field selected instead.
- Updated examples
- Add example for long lists
- Fix: Missing base style on truncated items
- Truncate last element correctly
- Add tests
- Add support for horizontal scroll
- Remove
truncate
option
Breaking Change The ListableWidgets trait method main_axis_size() was renamed to size with an additional scroll_direction parameter. This parameter can be ignored if the ListItem is only used in vertical or horizontal scroll mode, and not in both.
- Deprecate Listable trait in favor of ListableWidget
- Migration: height() becomes main_axis_size()
- Listable got deprectated, but old apps still compile
- ListableWidget is more descriptive and using main_axis_size allows for reusing the trait in horizontal lists, which will come in the future
- Bugfix: Some cases paniced when the truncated element had a size 0
Bump ratatui to version 0.26
Bugfix
- Correct truncation of the top element, see issues/6
- Bump ratatui to version 0.25
- Move crossterm from dependency to dev-dependency
Breaking Changes
- Change of Listable trait Interface returning Self instead of Option
Bugfix
- Selected widgets height is correctly calculated
The api should be more stable from now on.
Breaking Changes
- Renamed WidgetList to List
- Renamed WidgetListState to ListState
- Renamed trait WidgetItem to Listable
- Interface change of Listable
Api improvement to make the crate more reusable and idiomatic in the ratatui ecosystem.