Tags: joshka/ratatui
Tags
Make ratatui dev-dependecy in ratatui-termwiz just a path ref
fix(buffer): buffer::get_pos() now correctly handles index > u16::MAX (… …ratatui#1447) Previously this function wrapped the index pass u16::MAX which caused problems rendering. Fixes: <ratatui#1441>
feat!: Add overlap to layout (ratatui#1398) This PR adds a new feature for the existing `Layout::spacing` method, and introducing a `Spacing` enum. Now `Layout::spacing` is generic and can take - zero or positive numbers, e.g. `Layout::spacing(1)` (current functionality) - negative number, e.g. `Layout::spacing(-1)` (new) - variant of the `Spacing` (new) This allows creating layouts with a shared pixel for segments. When `spacing(negative_value)` is used, spacing is ignored and all segments will be adjacent and have pixels overlapping. `spacing(zero_or_positive_value)` behaves the same as before. These are internally converted to `Spacing::Overlap` or `Spacing::Space`. Here's an example output to illustrate the layout solve from this PR: ```rust #[test] fn test_layout() { use crate::layout::Constraint::*; let mut terminal = crate::Terminal::new(crate::backend::TestBackend::new(50, 4)).unwrap(); terminal .draw(|frame| { let [upper, lower] = Layout::vertical([Fill(1), Fill(1)]).areas(frame.area()); let (segments, spacers) = Layout::horizontal([Length(10), Length(10), Length(10)]) .flex(Flex::Center) .split_with_spacers(upper); for segment in segments.iter() { frame.render_widget( crate::widgets::Block::bordered() .border_set(crate::symbols::border::DOUBLE), *segment, ); } for spacer in spacers.iter() { frame.render_widget(crate::widgets::Block::bordered(), *spacer); } let (segments, spacers) = Layout::horizontal([Length(10), Length(10), Length(10)]) .flex(Flex::Center) .spacing(-1) // new feature .split_with_spacers(lower); for segment in segments.iter() { frame.render_widget( crate::widgets::Block::bordered() .border_set(crate::symbols::border::DOUBLE), *segment, ); } for spacer in spacers.iter() { frame.render_widget(crate::widgets::Block::bordered(), *spacer); } }) .unwrap(); dbg!(terminal.backend()); } ``` ```plain ┌────────┐╔════════╗╔════════╗╔════════╗┌────────┐ └────────┘╚════════╝╚════════╝╚════════╝└────────┘ ┌─────────┐╔════════╔════════╔════════╗┌─────────┐ └─────────┘╚════════╚════════╚════════╝└─────────┘ ``` Currently drawing a border on top of an existing border overwrites it. Future PRs will allow for making the border drawing handle overlaps better. --------- Co-authored-by: Josh McKinney <joshka@users.noreply.github.com>
feat(text): improve concise debug view for Span,Line,Text,Style (rata… …tui#1410) Improves ratatui#1383 The following now round trips when formatted for debug. This will make it easier to use insta when testing text related views of widgets. ```rust Text::from_iter([ Line::from("Hello, world!"), Line::from("How are you?").bold().left_aligned(), Line::from_iter([ Span::from("I'm "), Span::from("doing ").italic(), Span::from("great!").bold(), ]), ]).on_blue().italic().centered() ```
refactor(layout): rename element to segment in layout (ratatui#1397) This PR renames `element` to `segment` in a couple of functions in the layout calculations for clarity. `element` can refer to `segment`s or `spacer`s and functions that take only `segment`s should use `segment` as the variable names.
chore(style): make Debug output for Text/Line/Span/Style more concise (… …ratatui#1383) Given: ```rust Text::from_iter([ Line::from("without line fields"), Line::from("with line fields").bold().centered(), Line::from_iter([ Span::from("without span fields"), Span::from("with span fields") .green() .on_black() .italic() .not_dim(), ]), ]) ``` Debug: ``` Text [Line [Span("without line fields")], Line { style: Style::new().add_modifier(Modifier::BOLD), alignment: Some(Center), spans: [Span("with line fields")] }, Line [Span("without span fields"), Span { style: Style::new().green().on_black().add_modifier(Modifier::ITALIC).remove_modifier(Modifier::DIM), content: "with span fields" }]] ``` Fixes: ratatui#1382 --------- Co-authored-by: Orhun Parmaksız <orhun@archlinux.org> Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
chore(block): deprecate block::Title (ratatui#1372) `ratatui::widgets::block::Title` is deprecated in favor of using `Line` to represent titles. This removes an unnecessary layer of wrapping (string -> Span -> Line -> Title). This struct will be removed in a future release of Ratatui (likely 0.31). For more information see: <ratatui#738> To update your code: ```rust Block::new().title(Title::from("foo")); // becomes any of Block::new().title("foo"); Block::new().title(Line::from("foo")); Block::new().title(Title::from("foo").position(Position::TOP)); // becomes any of Block::new().title_top("foo"); Block::new().title_top(Line::from("foo")); Block::new().title(Title::from("foo").position(Position::BOTTOM)); // becomes any of Block::new().title_bottom("foo"); Block::new().title_bottom(Line::from("foo")); ```
docs(constraint): add note about percentages (ratatui#1368) Co-authored-by: Orhun Parmaksız <orhun@archlinux.org>
fix: add `unstable-backend-writer` feature (ratatui#1352) ratatui#991 created a new unstable feature, but forgot to add it to Cargo.toml, making it impossible to use on newer versions of rustc - this commit fixes it.
PreviousNext