Commit graph

719 commits

Author SHA1 Message Date
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
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
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
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
EdJoPaTo
bf0923473c
feat(table): make TableState::new const (#1040) 2024-04-21 23:23:56 -06:00
EdJoPaTo
81b96338ea
perf(calendar): use const fn (#1039)
Also, do the comparison without `as u8`. Stays the same at runtime and
is cleaner code.
2024-04-21 11:34:17 -06:00
EdJoPaTo
2e71c1874e
perf(buffer): simplify Buffer::filled with macro (#1036)
The `vec![]` macro is highly optimized by the Rust team and shorter.
Don't do it manually.

This change is mainly cleaner code. The only production code that uses
this is `Terminal::with_options` and `Terminal::insert_before` so it's
not performance relevant on every render.
2024-04-21 11:29:37 -06:00
EdJoPaTo
f3172c59d4
refactor(gauge): fix internal typo (#1048) 2024-04-18 13:47:52 +03:00
dependabot[bot]
b5061c5250
chore(deps): update stability requirement from 0.1.1 to 0.2.0 (#1021)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Josh McKinney <joshka@users.noreply.github.com>
2024-04-08 22:43:04 +03:00
EdJoPaTo
359204c929
refactor: simplify to io::Result (#1016)
Simplifies the code, logic stays exactly the same.
2024-04-03 02:08:42 -07:00
Tadeas Uradnik
0207160784
fix(line): line truncation respects alignment (#987)
When rendering a `Line`, the line will be truncated:
- on the right for left aligned lines
- on the left for right aligned lines
- on bot sides for centered lines

E.g. "Hello World" will be rendered as "Hello", "World", "lo wo" for
left, right, centered lines respectively.

Fixes: https://github.com/ratatui-org/ratatui/issues/932
2024-03-30 18:10:33 -07:00
Josh McKinney
26af65043e
feat(text): add push methods for text and line (#998)
Adds the following methods to the `Text` and `Line` structs:
- Text::push_line
- Text::push_span
- Line::push_span

This allows for adding lines and spans to a text object without having
to call methods on the fields directly, which is usefult for incremental
construction of text objects.
2024-03-28 15:30:21 -07:00
Orhun Parmaksız
125ee929ee
chore(docs): fix typos in crate documentation (#1002) 2024-03-27 16:28:23 +03:00
Josh McKinney
742a5ead06
fix(text): fix panic when rendering out of bounds (#997)
Previously it was possible to cause a panic when rendering to an area
outside of the buffer bounds. Instead this now correctly renders nothing
to the buffer.
2024-03-24 22:06:31 -07:00
EdJoPaTo
8719608bda
refactor(span): rename to_aligned_line into into_aligned_line (#993)
With the Rust method naming conventions these methods are into methods
consuming the Span. Therefore, it's more consistent to use `into_`
instead of `to_`.

```rust
Span::to_centered_line
Span::to_left_aligned_line
Span::to_right_aligned_line
```

Are marked deprecated and replaced with the following

```rust
Span::into_centered_line
Span::into_left_aligned_line
Span::into_right_aligned_line
```
2024-03-22 04:29:29 -07:00
Josh McKinney
f6c4e447e6
fix: ensure that paragraph correctly renders styled text (#992)
Paragraph was ignoring the new `Text::style` field added in 0.26.0

Fixes: https://github.com/ratatui-org/ratatui/issues/990
2024-03-22 02:14:59 -07:00
Jack Wills
c56f49b9fb
fix(list): saturating_sub to fix highlight_symbol overflow (#949)
An overflow (pedantically an underflow) can occur if the
highlight_symbol is a multi-byte char, and area is reduced to a size
less than that char length.
2024-03-16 15:58:39 -07:00
EdJoPaTo
8e68db9e2f
refactor: remove pointless default on internal structs (#980)
See #978

Also remove other derives. They are unused and just slow down
compilation.
2024-03-12 00:33:30 -07:00
EdJoPaTo
541f0f9953
perf(cell): use const CompactString::new_inline (#979)
Some minor find when messing around trying to `const` all the things.

While `reset()` and `default()` can not be `const` it's still a benefit
when their contents are.
2024-03-05 22:05:24 +01:00
Josh McKinney
88bfb5a430
docs(text): update Text and Line docs (#969) 2024-03-05 22:02:07 +01:00
EdJoPaTo
3be189e3c6
refactor: clippy::thread_local_initializer_can_be_made_const (#974)
enabled by default on nightly
2024-03-03 21:41:24 -08:00
EdJoPaTo
5c4efacd1d
refactor: clippy::map_err_ignore (#974) 2024-03-03 21:41:24 -08:00
EdJoPaTo
bbb6d65e06
refactor: clippy::else_if_without_else (#974) 2024-03-03 21:41:24 -08:00
EdJoPaTo
9b3b23ac14
refactor: remove literal suffix (#974)
its not needed and can just be assumed

related: clippy::(un)separated_literal_suffix
2024-03-03 21:41:23 -08:00
EdJoPaTo
58b6e0be0f
refactor: clippy::should_panic_without_expect (#974) 2024-03-03 21:41:23 -08:00
EdJoPaTo
c870a41057
refactor: clippy::many_single_char_names (#974) 2024-03-03 21:41:23 -08:00
EdJoPaTo
a6036ad789
refactor: clippy::similar_names (#974) 2024-03-03 21:41:23 -08:00
EdJoPaTo
060d26b6dc
refactor: clippy::match_same_arms (#974) 2024-03-03 21:41:23 -08:00
EdJoPaTo
fcbea9ee68
refactor: clippy::uninlined_format_args (#974) 2024-03-03 21:41:22 -08:00
EdJoPaTo
14b24e7585
refactor: clippy::if_not_else (#974) 2024-03-03 21:41:22 -08:00
EdJoPaTo
5ed1f43c62
refactor: clippy::redundant_closure_for_method_calls (#974) 2024-03-03 21:41:22 -08:00
EdJoPaTo
c8c7924e0c
refactor: clippy::too_many_lines (#974) 2024-03-03 21:41:22 -08:00
EdJoPaTo
e3afe7c8a1
refactor: clippy::unreadable_literal (#974) 2024-03-03 21:41:22 -08:00
EdJoPaTo
a1f54de7d6
refactor: clippy::bool_to_int_with_if (#974) 2024-03-03 21:41:22 -08:00
EdJoPaTo
b8ea190bf2
refactor: clippy::cast_lossless (#974) 2024-03-03 21:41:21 -08:00
EdJoPaTo
0de5238ed3
refactor: dead_code (#974)
enabled by default, only detected by nightly yet
2024-03-03 21:41:21 -08:00
EdJoPaTo
df5dddfbc9
refactor: unused_imports (#974)
enabled by default, only detected on nightly yet
2024-03-03 21:41:21 -08:00
EdJoPaTo
f1398ae6cb
refactor: clippy::useless_vec (#974)
Lint enabled by default but only nightly finds this yet
2024-03-03 21:41:21 -08:00
EdJoPaTo
525848ff4e
refactor: manually apply clippy::use_self for impl with lifetimes (#974) 2024-03-03 21:41:21 -08:00
EdJoPaTo
660c7183c7
refactor: clippy::empty_line_after_doc_comments (#974) 2024-03-03 21:41:21 -08:00
EdJoPaTo
ab951fae81
refactor: clippy::return_self_not_must_use (#974) 2024-03-03 21:41:21 -08:00
EdJoPaTo
3cd4369176
refactor: clippy::doc_markdown (#974) 2024-03-03 21:41:20 -08:00
EdJoPaTo
9bc014d7f1
refactor: clippy::items_after_statements (#974) 2024-03-03 21:41:20 -08:00
EdJoPaTo
36a0cd56e5
refactor: clippy::deref_by_slicing (#974) 2024-03-03 21:41:20 -08:00
EdJoPaTo
b831c5688c
refactor(widget-ref): clippy::needless_pass_by_value (#974) 2024-03-03 21:41:20 -08:00
EdJoPaTo
8195f526cb
perf: clippy::needless_pass_by_value (#974) 2024-03-03 21:41:20 -08:00