10 Commits

Author SHA1 Message Date
John T. Wodder II
08b21fa55c
fix: Fix panic when rendering a Paragraph out of bounds (#1670)
Fixes #1667.
2025-07-09 17:37:20 -07:00
Josh McKinney
4c86513790
chore: remove block::Title (#1926)
The title alignment is better expressed in the `Line` as this fits more
coherently with the rest of the library.

BREAKING CHANGES:
- `widgets::block` is no longer exported
- `widgets::block::Title` no longer exists
- `widgets::block::Position` is now `widgets::TitlePosition`
- `Block::title()` now accepts `Into::<Line>` instead of `Into<Title>`
- `BlockExt` is now exported at widgets::`BlockExt`

Closes: https://github.com/ratatui/ratatui/issues/738
2025-06-25 15:36:50 -07:00
Jagoda Estera Ślązak
a42a17e184
feat(no_std): make ratatui-widgets no_std (#1779)
Resolves #1776
2025-04-15 09:16:06 -07:00
Josh McKinney
2739391950
style: use Module imports_granularity (#1728)
I was swayed by the arguments about this made by the compiler team In
<https://github.com/rust-lang/compiler-team/issues/750> and decided to
look at how this organization affects ratatui. I found this reduces the
number of lines across the codebase by about 350 and makes the imports
more readable and definitely more greppable as you usually only have
to read a single line. I've found in the past that maintaining imports
regularly leads to merge conflicts which have to be resolved by hand
and this change should reduce the likelihood of that happening.

Main change is in rustfmt.toml, and the rest is just the result of
running `cargo xtask format`.

While implementing this, cargo machete brings up that the various
backend crates are unused by the example crates.

The re-export of each backend crate under ratatui is to make it possible
for libs that rely on a specific version of ratatui to use the same
version of the backend crate. Apps in general should use the backend
crate directly rather than through ratatui as this is less confusing.

- Removes all usages of `ratatui::{crossterm, termion, termwiz}`` in the
  examples.
- Adds the backend crate to the dependencies of the examples that use
  the backend crate directly.
2025-03-19 16:48:02 -07:00
Orhun Parmaksız
bb94d1c0fa
docs(examples): move minimal example to examples folder (#1649) 2025-02-05 10:11:57 -08:00
Björn Steinbrink
f5fc8197ff
fix: avoid extra line break on whitespace only lines when wrapping paragraphs (#1636)
Currently whitespace only lines produces an extra line break when
trimming is disabled, because both the trimmed as well as the
non-trimmed line get inserted. Fix this by only inserting the
non-trimmed one.

Co-authored-by: Björn Steinbrink <b.steinbrink@demv.de>
2025-02-04 17:02:50 -08:00
Alex Pasmantier
1f41a61008
perf(paragraph): avoid unnecessary work when rendering (#1622)
Improve render times for paragraphs that are scrolled.

Currently all `LineComposer`s are considered to be state machines which
means rendering a paragraph with a given Y offset requires computing the
entire state up to Y before being able to render from Y onwards.

While this makes sense for Composers such as the `WordWrapper` (where
one needs to consider all previous lines to determine where a given line
will end up), it means it also penalizes Composers which can render a
given line "statelessely" (such as the `LineTruncator`) which actually
end up doing a lot of unnecessary work (and on the critical rendering
path) when the offset gets high.

Co-authored-by: Josh McKinney <joshka@users.noreply.github.com>
2025-01-23 13:52:52 -08:00
Josh McKinney
2892bddce6
fix: rust 1.83 clippy lints (#1527)
https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes
2024-11-29 10:49:12 +03:00
Josh McKinney
a41c97b413
chore: move unstable widget refs to ratatui (#1491)
These are less stable than the non-ref traits as we have not yet
committed to the exact API. This change moves them to ratatui from
ratatui-core.

To facilitate this:
- implementations of WidgetRef for all internal widgets are removed and
  replaced with implementations of Widget for references to those
  widgets.
- Widget is now implemented for Option<W> where W: Widget, allowing for
  rendering of optional widgets.
- The blanket implementation of Widget for WidgetRef is reversed, to be
  a blanket implementation of WidgetRef for all &W where W: Widget.

BREAKING CHANGE: implementations of WidgetRef no longer have a blanket
implementation of Widget, so Widgets should generally implement the
Widget trait on a reference to the widget rather than implementing
WidgetRef directly. This has the advantage of not requiring unstable
features to be enabled.

Part of: https://github.com/ratatui/ratatui/issues/1388

Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
2024-11-18 14:19:21 -08:00
Josh McKinney
e7085e3a3e
chore: move widgets into ratatui-widgets crate (#1474)
All the widgets now live in their own ratatui-widgets crate, but are re-exported in the main ratatui crate.
This makes it easier to use portions of the ratatui library and is part of the effort to modularize

Part of: #1388

---------

Co-authored-by: Orhun Parmaksız <orhun@archlinux.org>
Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
2024-11-15 19:42:07 -08:00