github ratatui/ratatui v0.26.2

latest releases: v0.29.1-alpha.0, v0.29.0, v0.29.0-alpha.0...
7 months ago

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 #968

    This 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 #958

    Introduces 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 #998

    Adds 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) Add FromIterator impls for Line and Text by @joshka in #967

    This 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 and String by @kdheepak in #952

    Currently, `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 #987

    When 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 #949

    An 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.
    
  • b7778e5
    (paragraph) Unit test typo by @joshka in #1022

  • 943c043
    (scrollbar) Dont render on 0 length track by @EdJoPaTo in #964

    Fixes 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 #997

    Previously 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 #992

    Paragraph 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 #959

    When displaying somewhat-long lists, the `Scrollbar` widget sometimes did not display a thumb character, and only the track will be visible.
    

Refactor

  • 6fd5f63
    (lint) Prefer idiomatic for loops by @EdJoPaTo

  • 37b957c
    (lints) Add lints to scrollbar by @EdJoPaTo

  • c12bcfe
    (non-src) Apply pedantic lints by @EdJoPaTo in #976

    Fixes 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 #993

    With 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 #1016

    Simplifies the code, logic stays exactly the same.
    
  • 8e68db9
    (uncategorized) Remove pointless default on internal structs by @EdJoPaTo in #980

    See #978

Also remove other derives. They are unused and just slow down
compilation.

Documentation

Performance

  • e02f476
    (borders) Allow border!() in const by @EdJoPaTo in #977

    This allows more compiler optimizations when the macro is used.
    
  • 541f0f9
    (cell) Use const CompactString::new_inline by @EdJoPaTo in #979

    Some 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 #963

    A 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 #950

    This 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 @EdJoPaTo

    These 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

Full Changelog: v0.26.1...v0.26.2

Don't miss a new ratatui release

NewReleases is sending notifications on new releases.