Commit graph

993 commits

Author SHA1 Message Date
hasezoey
f63ac72305
feat(widgets::table): add option to always allocate the "selection" constraint (#375)
* feat(table): add option to configure selection layout changes

Before this option was available, selecting a row in the table when no row was selected
previously made the tables layout change (the same applies to unselecting) by adding the width
of the "highlight symbol" in the front of the first column, this option allows to configure this
behavior.

* refactor(table): refactor "get_columns_widths" to return (x, width)

and "render" to make use of that

* refactor(table): refactor "get_columns_widths" to take in a selection_width instead of a boolean

also refactor "render" to make use of this change

* fix(table): rename "highlight_set_selection_space" to "highlight_spacing"

* style(table): apply doc-comment suggestions from code review

Co-authored-by: Dheepak Krishnamurthy <me@kdheepak.com>

---------

Co-authored-by: Dheepak Krishnamurthy <me@kdheepak.com>
2023-08-11 14:15:46 +00:00
Valentin271
3293c6b80b
test(sparkline): added benchmark (#384)
Added benchmark for the `sparkline` widget testing a basic render with different amout of data
2023-08-11 02:17:32 +00:00
Valentin271
149d48919d
perf(bench): Used iter_batched to clone widgets in setup function (#383)
Replaced `Bencher::iter` by `Bencher::iter_batched` to clone the widget in the setup function instead of in the benchmark timing.
2023-08-11 02:17:14 +00:00
tieway59
8c4a2e0fbf
chore: implement Hash common traits (#381)
Reorder the derive fields to be more consistent:

    Debug, Default, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Hash

Hash trait won't be impl in this PR due to rust std design.
If we need hash trait for f64 related structs in the future,
we should consider wrap f64 into a new type.

see: https://github.com/ratatui-org/ratatui/issues/307
2023-08-11 02:16:48 +00:00
Valentin271
664fb4cffd
test(list): Added benchmarks (#377)
Added benchmarks for the list widget (render and render half scrolled)
2023-08-11 02:11:41 +00:00
Josh McKinney
6ad4bd4cf2
docs(examples): Add color and modifiers examples (#345)
The intent of these examples is to show the available colors and
modifiers.

- added impl Display for Color

![colors](https://vhs.charm.sh/vhs-2ZCqYbTbXAaASncUeWkt1z.gif)
![modifiers](https://vhs.charm.sh/vhs-2ovGBz5l3tfRGdZ7FCw0am.gif)
2023-08-11 01:36:12 +00:00
a-kenji
37fa6abe9d
build(deps): upgrade crossterm to 0.27 (#380) 2023-08-07 13:30:11 +00:00
a-kenji
8b28672131
chore(docs): add doc comment bump to release documentation (#382) 2023-08-07 13:30:03 +00:00
a-kenji
de9f52ff2c
ci(coverage): exclude examples directory from coverage (#373) 2023-08-07 12:34:04 +00:00
hasezoey
c8ddc164c7
docs(layout::Constraint): add doc-comments for all variants (#371)
fixes #354
2023-08-05 22:40:25 +00:00
Valentin271
e18393dbc6
test(block): add benchmarks (#368)
Added benchmarks to the block widget to uncover eventual performance issues
2023-08-05 14:47:06 +00:00
Orhun Parmaksız
aad164a531
feat(release): add automated nightly releases (#359)
* feat(release): add automated nightly releases

* refactor(release): rename the alpha workflow

* refactor(release): simplify the release calculation
2023-08-05 14:41:07 +00:00
Valentin271
3a37d2f6ed
docs(readme): use the correct version for MSRV (#369) 2023-08-05 10:20:30 +00:00
a-kenji
8cd3205d70
chore(toolchain)!: bump msrv to 1.67 (#361)
* chore(toolchain)!: bump msrv to 1.67

BREAKING_CHANGE: The msrv is now `1.67`

* docs(readme): update the MSRV notice

---------

Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
2023-08-04 23:23:22 +00:00
Josh McKinney
e82521ea79
docs(examples): regen block.gif in readme (#365) 2023-08-04 10:12:13 +00:00
Josh McKinney
9191ad60fd
ci: don't fail fast (#364)
Run all the tests rather than canceling when one test fails. This allows
us to see all the failures, rather than just the first one if there are
multiple. Specifically this is useful when we have an issue in one
toolchain or backend.
2023-08-04 09:56:05 +00:00
Valentin271
49a82e062f
fix(block): Fixed title_style not rendered (#349) (#363)
Fixes #349
2023-08-04 09:47:55 +00:00
tieway59
181706c564
chore: implement Eq & PartialEq common traits (#357)
Reorder the derive fields to be more consistent:

    Debug, Default, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Hash

see: https://github.com/ratatui-org/ratatui/issues/307
2023-08-04 08:23:26 +00:00
Josh McKinney
554805d6cb
docs(examples): Update block example (#351)
![Block example](https://vhs.charm.sh/vhs-5X6hpReuDBKjD6hLxmDQ6F.gif)
2023-08-04 07:46:37 +00:00
a-kenji
1727fa5120
feat(scrollbar)!: add optional track symbol (#360)
The track symbol is now optional, simplifying composition with other
widgets.

BREAKING_CHANGE: The `track_symbol` needs to be set in the following way
now:

```
let scrollbar = Scrollbar::default().track_symbol(Some("-"));
```
2023-08-03 15:42:54 +00:00
tieway59
440f62ff54
Chore: implement Clone & Copy common traits (#350)
Implement `Clone & Copy` common traits for most structs in src.

Only implement `Copy` for structs that are simple and trivial to copy.

Reorder the derive fields to be more consistent:

    Debug, Default, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Hash

see: https://github.com/ratatui-org/ratatui/issues/307
2023-07-28 11:04:29 +00:00
Josh McKinney
6f659cfb07
ci: add coverage token (#352) 2023-07-28 06:57:53 +00:00
tieway59
bf4944683d
Chore: implement Debug & Default common traits (#339)
Implement `Debug & Default` common traits for most structs in src.

Reorder the derive fields to be more consistent:

    Debug, Default, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Hash

see: https://github.com/ratatui-org/ratatui/issues/307
2023-07-27 01:40:07 +00:00
Josh McKinney
7539f775fe
fix(scrollbar)!: move symbols to symbols module (#330)
The symbols and sets are moved from `widgets::scrollbar` to
`symbols::scrollbar`. This makes it consistent with the other symbol
sets and allows us to make the scrollbar module private rather than
re-exporting it.

BREAKING CHANGE: The symbols are now in the `symbols` module. To update
your code, add an import for `ratatui:🔣:scrollbar::*` (or the
specific symbols you need). The scrollbar module is no longer public. To
update your code, remove any `widgets::scrollbar` imports and replace it
with `ratatui::widgets::Scrollbar`.
2023-07-26 11:33:39 +00:00
nathan
8db9fb4aeb
fix(cargo): adjust minimum paste version (#348)
ratatui is using features that are currently only available in paste 1.0.2; specifying the minimum version to be 1.0 will consequently cause a compilation error if cargo is only able to use a version less than 1.0.2.
2023-07-26 07:05:12 +00:00
Florian Meißner
d05ab6fb70
fix(readme): fix typo in readme (#344)
Co-authored-by: josh rotenberg <joshrotenberg@users.noreply.github.com>
2023-07-25 21:47:28 +00:00
Josh McKinney
2920e045ba
docs(readme): fix widget docs links (#346)
Add scrollbar, clear. Fix Block link. Sort
2023-07-25 21:44:50 +00:00
Josh McKinney
add578a7d6
docs(examples): Add examples readme with gifs (#303)
This commit adds a readme to the examples directory with gifs of each
example. This should make it easier to see what each example does
without having to run it.

I modified the examples to fit better in the gifs. Mostly this was just
removing the margins, but for the block example I cleaned up the code a
bit to make it more readable and changed it so the background bug is not
triggered.

For the table example, the combination of Min, Length, and Percent
constraints was causing the table to panic when the terminal was too
small. I changed the example to use the Max constraint instead of the
Length constraint.

The layout example now shows information about how the layout is
constrained on each block (which is now a paragraph with a block).
2023-07-24 19:05:37 +00:00
Orhun Parmaksız
60a4131384
chore(github): add kdheepak as a maintainer (#343) 2023-07-22 22:12:08 +00:00
Orhun Parmaksız
964190a859
chore(github): rename tui-rs-revival references to ratatui-org (#340) 2023-07-22 10:34:11 +00:00
josh rotenberg
b9290b35d1
fix(readme): fix incorrect template link (#338) 2023-07-20 21:36:15 +00:00
josh rotenberg
daf5890152
fix(example): Fix typo (#337)
the existential feels
2023-07-20 20:00:42 +00:00
josh rotenberg
7e37a96678
fix(readme): fix typo in readme (#336) 2023-07-20 04:39:46 +00:00
josh rotenberg
bcb7417785
update version in README.md (#335) 2023-07-20 04:29:08 +00:00
Hichem
9c956733f7
fix(barchart): empty groups causes panic (#333)
This unlikely to happen, since nobody wants to add an empty group.
Even we fix the panic, things will not render correctly.
So it is better to just not add them to the BarChart.

Signed-off-by: Ben Fekih, Hichem <hichem.f@live.de>
2023-07-19 09:37:59 +00:00
Markus
13fb11a62c
fix: Correct minor typos in documentation (#331) 2023-07-18 10:06:59 +00:00
EdJoPaTo
0fb1ed85c6
build: forbid unsafe code (#332)
This indicates good (high level) code and is used by tools like cargo-geiger.
2023-07-18 10:03:00 +00:00
Josh McKinney
e2cb11cc30
build(examples): fix cargo make run-examples (#327)
Enables the all-widgets feature so that the calendar example runs correctly
2023-07-17 15:59:56 +00:00
a-kenji
c3f87f245a
docs: improve scrollbar doc comment (#329) 2023-07-17 12:05:28 +00:00
Orhun Parmaksız
df90982632
chore(release): prepare for 0.22.0 (#326) 2023-07-17 10:41:45 +00:00
Josh McKinney
bb061fdab6
ci: parallelize CI jobs (#318)
* ci: parallelize CI jobs

- remove the dependency on the lint job from all other jobs
- implement workflow concurrency
- reorder the workflow so that the lint, clippy and coverage jobs are
  scheduled before the test jobs
- run jobs which run for each backend in parallel by calling e.g.
  cargo make test-termion, instead of cargo make test
- add a coverage task to the makefile
- change "cargo-make check" to check all features valid for OS in
  parallel
- run clippy only on the ubuntu-latest runner and check all features
  valid in parallel
- tidy up the workflow file

* ci: simplify Makefile OS detection

Use platform overrides to significantly simplify the Makefile logic
See https://github.com/sagiegurari/cargo-make\#platform-override

* fix(termwiz): skip doc test that requires stdout
2023-07-17 10:31:31 +00:00
Orhun Parmaksız
1ff85535c8
fix(title): remove default alignment and position (#323)
* fix(title): remove default alignment and position

* test(block): add test cases for alignment

* test(block): extend the unit tests for block title alignment
2023-07-17 10:27:58 +00:00
Josh McKinney
33f3212cbf
fix: rust-tui-template became a revival project (#320)
Changed the URL https://github.com/orhun/rust-tui-template
into https://github.com/rust-tui-revival/rust-tui-template

Co-authored-by: Geert Stappers <stappers@stappers.it>
2023-07-17 06:31:26 +00:00
Josh McKinney
fb6d4b2f51
refactor(text): simplify reflow implementation (#290)
* refactor(text): split text::* into separate files

* feat(text): expose graphemes on Line

- add `Line::styled()`
- add `Line::styled_graphemes()`
- add `StyledGrapheme::new()`

---------

Co-authored-by: Eyesonjune18 <lowellashton@gmail.com>
2023-07-17 06:27:45 +00:00
Josh McKinney
446efae185
fix(prelude): remove widgets module from prelude (#317)
This helps to keep the prelude small and less likely to conflict with
other crates.

- remove widgets module from prelude as the entire module can be just as
  easily imported with `use ratatui::widgets::*;`
- move prelude module into its own file
- update examples to import widgets module instead of just prelude
- added several modules to prelude to make it possible to qualify
  imports that collide with other types that have similar names
2023-07-16 09:11:59 +00:00
Mano Ségransan
b347201b9f
feat(style): Enable setting the underline color for crossterm (#308) (#310)
This commit adds the underline_color() function to the Style and Cell
structs. This enables setting the underline color of text on the
crossterm backend. This is a no-op for the termion and termwiz backends
as they do not support this feature.
2023-07-15 09:57:15 +00:00
Josh McKinney
9f1f59a51c
feat(stylize): allow all widgets to be styled (#289)
* feat(stylize): allow all widgets to be styled

- Add styled impl to:
  - Barchart
  - Chart (including Axis and Dataset),
  - Guage and LineGuage
  - List and ListItem
  - Sparkline
  - Table, Row, and Cell
  - Tabs
  - Style
- Allow modifiers to be removed (e.g. .not_italic())
- Allow .bg() to recieve Into<Color>
- Made shorthand methods consistent with modifier names (e.g. dim() not
  dimmed() and underlined() not underline())
- Simplify integration tests
- Add doc comments
- Simplified stylize macros with https://crates.io/crates/paste

* build: run clippy before tests

Runny clippy first means that we fail fast when there is an issue that
can easily be fixed rather than having to wait 30-40s for the failure
2023-07-14 08:37:30 +00:00
Josh McKinney
6f6c355c5c
chore(tests): add coverage job to bacon (#312)
- Add two jobs to bacon.toml (one for unit tests, one for all tests)
- Remove "run" job as it doesn't work well with bacon due to no stdin
- Document coverage tooling in CONTRIBUTING.md
2023-07-14 08:37:00 +00:00
Hichem
60150f6236
feat(barchart): set custom text value in the bar (#309)
for now the value is converted to a string and then printed. in many
cases the values are too wide or double values. so it make sense
to set a custom value text instead of the default behavior.

this patch suggests to add a method
"fn text_value(mut self, text_value: String)"
to the Bar, which allows to override the value printed in the bar

Signed-off-by: Ben Fekih, Hichem <hichem.f@live.de>
2023-07-14 04:38:54 +00:00
Josh McKinney
2889c7d084
fix(lint): suspicious_double_ref_op is new in 1.71 (#311)
Fixed tests and completed coverage for `Masked` type.
2023-07-14 02:18:07 +00:00