Commit graph

1230 commits

Author SHA1 Message Date
EdJoPaTo
4f7791079e
refactor(padding): Add Padding::ZERO as a constant (#1133)
Deprecate Padding::zero()
2024-05-24 23:48:05 -07:00
EdJoPaTo
cf67ed9b88
refactor(lint): use clippy::or_fun_call (#1138)
<https://rust-lang.github.io/rust-clippy/master/index.html#or_fun_call>
2024-05-24 18:33:19 -07:00
EdJoPaTo
8a60a561c9
refactor: needless_pass_by_ref_mut (#1137)
<https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut>
2024-05-24 18:32:22 -07:00
Dheepak Krishnamurthy
35941809e1
feat!: Make Stylize's .bg(color) generic (#1103) 2024-05-24 18:05:45 -07:00
EdJoPaTo
73fd367a74
refactor(block): group builder pattern methods (#1134) 2024-05-24 18:04:35 -07:00
EdJoPaTo
1de9a82b7a
refactor: simplify if let (#1135)
While looking through lints
[`clippy::option_if_let_else`](https://rust-lang.github.io/rust-clippy/master/index.html#option_if_let_else)
found these. Other findings are more complex so I skipped them.
2024-05-24 18:03:51 -07:00
EdJoPaTo
d6587bc6b0
test(style): use rstest (#1136)
<!-- Please read CONTRIBUTING.md before submitting any pull request. -->
2024-05-24 18:02:59 -07:00
Matt Armstrong
f429f688da
docs(examples): Remove lifetimes from the List example (#1132)
Simplify the List example by removing lifetimes not strictly necessary
to demonstrate how Ratatui lists work. Instead, the sample strings are
copied into each `TodoItem`. To further simplify, I changed the code to
use a new TodoItem::new function, rather than an implementation of the
`From` trait.
2024-05-24 15:09:24 -07:00
Valentin271
4770e71581
refactor(list)!: remove deprecated start_corner and Corner (#759)
`List::start_corner` was deprecated in v0.25. Use `List::direction` and
`ListDirection` instead.

```diff
- list.start_corner(Corner::TopLeft);
- list.start_corner(Corner::TopRight);
// This is not an error, BottomRight rendered top to bottom previously
- list.start_corner(Corner::BottomRight);
// all becomes
+ list.direction(ListDirection::TopToBottom);
```

```diff
- list.start_corner(Corner::BottomLeft);
// becomes
+ list.direction(ListDirection::BottomToTop);
```

`layout::Corner` is removed entirely.

Co-authored-by: Josh McKinney <joshka@users.noreply.github.com>
2024-05-24 11:52:01 -07:00
Mikołaj Nowak
eef1afe915
feat(LineGauge): allow LineGauge background styles (#565)
This PR deprecates `gauge_style` in favor of `filled_style` and
`unfilled_style` which can have it's foreground and background styled.

`cargo run --example=line_gauge --features=crossterm`

https://github.com/ratatui-org/ratatui/assets/5149215/5fb2ce65-8607-478f-8be4-092e08612f5b

Implements: <https://github.com/ratatui-org/ratatui/issues/424>

Co-authored-by: Josh McKinney <joshka@users.noreply.github.com>
2024-05-24 11:42:52 -07:00
EdJoPaTo
257db6257f
refactor(cell): must_use and simplify style() (#1124)
<!-- Please read CONTRIBUTING.md before submitting any pull request. -->
2024-05-21 23:26:32 -07:00
EdJoPaTo
70df102de0
build(bench): improve benchmark consistency (#1126)
Codegen units are optimized on their own. Per default bench / release
have 16 codegen units. What ends up in a codeget unit is rather random
and can influence a benchmark result as a code change can move stuff
into a different codegen unit → prevent / allow LLVM optimizations
unrelated to the actual change.

More details: https://doc.rust-lang.org/cargo/reference/profiles.html
2024-05-21 23:12:31 -07:00
EdJoPaTo
bf2036987f
refactor(cell): reset instead of applying default (#1127)
Using reset is clearer to me what actually happens. On the other case a
struct is created to override the old one completely which basically
does the same in a less clear way.
2024-05-21 22:11:45 -07:00
Enrico Borba
0b5fd6bf8e
feat: add writer() and writer_mut() to termion and crossterm backends (#991)
It is sometimes useful to obtain access to the writer if we want to see
what has been written so far. For example, when using &mut [u8] as a
writer.

Co-authored-by: Josh McKinney <joshka@users.noreply.github.com>
2024-05-21 10:34:07 -07:00
Orhun Parmaksız
fadc73d62e
chore(release): prepare for 0.26.3 (#1118)
🧀

---------

Co-authored-by: Josh McKinney <joshka@users.noreply.github.com>
2024-05-20 15:20:29 +03:00
Josh McKinney
fcb5d589bb
fix: make cargo test --doc work with unstable-widget-ref examples (#1117) 2024-05-19 16:18:45 -07:00
Josh McKinney
4955380932
build: remove pre-push hooks (#1115) 2024-05-18 22:09:15 -07:00
Josh McKinney
828d17a3f5
docs: add minimal example (#1114) 2024-05-18 21:18:59 -07:00
EdJoPaTo
9bd89c218a
refactor(clippy): enable breaking lint checks (#988)
We need to make sure to not change existing methods without a notice.
But at the same time this also finds public additions with mistakes
before they are even released which is what I would like to have.

This renames a method and deprecated the old name hinting to a new name.
Should this be mentioned somewhere, so it's added to the release notes?
It's not breaking because the old method is still there.
2024-05-13 18:16:09 -07:00
EdJoPaTo
2cfe82a47e
refactor(buffer): deprecate assert_buffer_eq! in favor of assert_eq! (#1007)
- Simplify `assert_buffer_eq!` logic.
- Deprecate `assert_buffer_eq!`.
- Introduce `TestBackend::assert_buffer_lines`.

Also simplify many tests involving buffer comparisons.

For the deprecation, just use `assert_eq` instead of `assert_buffer_eq`:

```diff
-assert_buffer_eq!(actual, expected);
+assert_eq!(actual, expected);
```

---

I noticed `assert_buffer_eq!` creating no test coverage reports and
looked into this macro. First I simplified it. Then I noticed a bunch of
`assert_eq!(buffer, …)` and other indirect usages of this macro (like
`TestBackend::assert_buffer`).

The good thing here is that it's mainly used in tests so not many
changes to the library code.
2024-05-13 18:13:46 -07:00
tranzystorekk
1a4bb1cbb8
perf(layout): avoid allocating memory when using split ergonomic utils (#1105)
Don't create intermediate vec in `Layout::areas` and
`Layout::spacers` when there's no need for one.
2024-05-13 16:54:34 -07:00
Dheepak Krishnamurthy
839cca20bf
docs(table): Fix typo in docs for highlight_symbol (#1108) 2024-05-13 16:38:34 -04:00
Orhun Parmaksız
f945a0bcff
docs(test): fix typo in TestBackend documentation (#1107) 2024-05-13 23:15:09 +03:00
EdJoPaTo
eb281df974
feat: use inner Display implementation (#1097) 2024-05-13 01:36:39 -07:00
Josh McKinney
28e81c0714
build: add underline-color to all features flag in makefile (#1100) 2024-05-13 01:34:52 -07:00
Dheepak Krishnamurthy
76e5fe5a9a
chore: Revert "Make Stylize's .bg(color) generic" (#1102)
This reverts commit ec763af851 from #1099
2024-05-12 19:05:00 -04:00
EdJoPaTo
366cbae09f
fix(buffer): fix Debug panic and fix formatting of overridden parts (#1098)
Fix panic in `Debug for Buffer` when `width == 0`.
Also corrects the output when symbols are overridden.
2024-05-12 14:57:40 -07:00
Dheepak Krishnamurthy
ec763af851
feat: Make Stylize's .bg(color) generic (#1099)
This PR makes `.bg(color)` generic accepting anything that can be
converted into `Color`; similar to the `.fg(color)` method on the same
trait
2024-05-12 13:23:08 -04:00
Josh McKinney
699c2d7c8d
fix: unicode truncation bug (#1089)
- Rewrote the line / span rendering code to take into account how
multi-byte / wide emoji characters are truncated when rendering into
areas that cannot accommodate them in the available space
- Added comprehensive coverage over the edge cases
- Adds a benchmark to ensure perf

Fixes: https://github.com/ratatui-org/ratatui/issues/1032
Co-authored-by: EdJoPaTo <rfc-conform-git-commit-email@funny-long-domain-label-everyone-hates-as-it-is-too-long.edjopato.de>
Co-authored-by: EdJoPaTo <github@edjopato.de>
2024-05-11 19:28:38 -07:00
EdJoPaTo
3cc29bdada
test(block): use rstest to simplify test cases (#1095) 2024-05-11 11:03:02 -07:00
Josh McKinney
8de3d52469
chore(changelog): put commit id on the same line as the message (#1093) 2024-05-11 15:30:08 +03:00
Josh McKinney
b30411d1c7
fix: termwiz underline color test (#1094)
Fixes code that doesn't compile in the termwiz tests when
underline-color feature is enabled.
2024-05-10 20:04:58 -07:00
Josh McKinney
aa4260f92c
style: use std::fmt instead of importing Debug and Display (#1087)
This is a small universal style change to avoid making this change a
part of other PRs.

[rationale](https://github.com/ratatui-org/ratatui/pull/1083#discussion_r1588466060)
2024-05-04 23:51:24 -07:00
Josh McKinney
5f1e119563
fix: correct feature flag typo for termwiz (#1088)
underline-color was incorrectly spelt as underline_color
2024-05-04 23:43:24 -07:00
Josh McKinney
4d1784f2de
feat: re-export ParseColorError as style::ParseColorError (#1086)
Fixes: https://github.com/ratatui-org/ratatui/issues/1085
2024-05-04 14:22:51 -07:00
EdJoPaTo
baedc39494
refactor(buffer): simplify set_stringn logic (#1083) 2024-05-02 16:32:52 -07:00
EdJoPaTo
366c2a0e6d
perf(block): use Block::bordered (#1041)
`Block::bordered()` is shorter than
`Block::new().borders(Borders::ALL)`, requires one less import
(`Borders`) and in case `Block::default()` was used before can even be
`const`.
2024-05-02 03:09:48 -07:00
Josh McKinney
bef2bc1e7c
chore(cargo): add homepage to Cargo.toml (#1080) 2024-05-02 12:47:10 +03:00
Josh McKinney
64eb3913a4
chore: fixup cargo lint for windows targets (#1071)
Crossterm brings in multiple versions of the same dep
2024-05-01 05:59:09 -07:00
May
e95230beda
docs: add note about scrollbar state content length (#1077) 2024-04-30 23:37:43 -07:00
Levi Zim
f4637d40c3
fix(reflow): allow wrapping at zero width whitespace (#1074) 2024-04-28 01:58:28 -07:00
Orhun Parmaksız
da1ade7b2e
docs(github): update code owners about past maintainers (#1073)
As per suggestion in
https://github.com/ratatui-org/ratatui/pull/1067#issuecomment-2079766990

It's good for historical purposes!
2024-04-27 16:06:29 -07:00
Josh McKinney
1706b0a3e4
perf(crossterm): Speed up combined fg and bg color changes by up to 20% (#1072) 2024-04-27 14:34:52 -07:00
Eiko Thomas
4392759501
fix(examples): changed user_input example to work with multi-byte unicode chars (#1069)
This is the proposed solution for issue #1068. It solves the bug in the
user_input example with multi-byte UTF-8 characters as input.

Fixes: #1068

---------

Co-authored-by: Josh McKinney <joshka@users.noreply.github.com>
2024-04-26 22:36:36 -07:00
Paul Sobolik
20fc0ddfca
fix(examples): fix key handling in constraints (#1066)
Add check for `KeyEventKind::Press` to constraints example's event
handler to eliminate double keys
on Windows.

Fixes: #1062

---------

Co-authored-by: Josh McKinney <joshka@users.noreply.github.com>
2024-04-26 21:20:30 -07:00
Orhun Parmaksız
3687f78f6a
docs(github): update code owners (#1067)
Removes the team members that are not able to review PRs recently (with
their approval ofc)
2024-04-26 20:51:06 -07:00
Tadeas Uradnik
5fbb77ad20
chore(README): use terminal theme for badges (#1026)
The badges in the readme were all the default theme. Giving them
prettier colors that match the terminal gif is better. I've used the
colors from the VHS repo.
2024-04-25 20:27:28 -07:00
EdJoPaTo
97ee102f17
feat(buffer): track_caller for index_of (#1046)
The caller put in the wrong x/y -> the caller is the cause.
2024-04-25 16:23:09 -07:00
EdJoPaTo
c442dfd1ad
perf(canvas): change map data to const instead of static (#1037) 2024-04-24 01:49:57 -07:00
Ibby
0a164965ea
fix: use to_string to serialize Color (#934)
Since deserialize now uses `FromStr` to deserialize color, serializing
`Color` RGB values, as well as index values, would produce an output
that would no longer be able to be deserialized without causing an
error.


Color::Rgb will now be serialized as the hex representation of their
value.
For example, with serde_json, `Color::Rgb(255, 0, 255)` would be
serialized as `"#FF00FF"` rather than `{"Rgb": [255, 0, 255]}`.

Color::Indexed will now be serialized as just the string of the index.
For example, with serde_json, `Color::Indexed(10)` would be serialized
as `"10"` rather than `{"Indexed": 10}`.

Other color variants remain the same.
2024-04-23 23:30:00 -07:00