4 Commits

Author SHA1 Message Date
Josh McKinney
8d60e96b2b
refactor(examples): use crossterm event methods (#1792)
Crossterm 0.29 introduced methods to easily check / extract the event
type. E.g. as_key_press_event() and is_key_press(). This commit
updates the examples to use these methods instead of matching on
the event type. This makes the code cleaner and easier to read.

Also does a general cleanup of the event handling code in the examples.
2025-05-10 10:35:12 -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
Tayfun Bocek
92a19cb604
feat(list)!: highlight symbol styling (#1595)
Allow styling for `List`'s highlight symbol

This change makes it so anything that implements `Into<Line>` can be
used as a highlight symbol.

BREAKING CHANGE: `List::highlight_symbol` can no longer be used in const
context
BREAKING CHANGE: `List::highlight_symbol` accepted `&str`. Conversion
methods that rely on type inference will need to be rewritten as the
compiler cannot infer the type.

closes: https://github.com/ratatui/ratatui/issues/1443

---------

Co-authored-by: Josh McKinney <joshka@users.noreply.github.com>
2025-03-04 14:26:59 -08:00
Orhun Parmaksız
898aef6e2f
docs(widgets): add example for list (#1542)
Related to: #1512
2024-12-08 02:27:19 -08:00