Skip to content

Commit

Permalink
refactor!: remove items deprecated since 0.10 (#691)
Browse files Browse the repository at this point in the history
Remove `Axis::title_style` and `Buffer::set_background` which are deprecated since 0.10
  • Loading branch information
Valentin271 authored Dec 15, 2023
1 parent b8f71c0 commit b282a06
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 45 deletions.
29 changes: 9 additions & 20 deletions BREAKING-CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ github with a [breaking change] label.
This is a quick summary of the sections below:

- Unreleased (0.24.1)
- `List::start_corner` is renamed to `List::direction`
- Removed `Axis::title_style` and `Buffer::set_background`
- `List::new()` now accepts `IntoIterator<Item = Into<ListItem<'a>>>`
- `Table::new()` now requires specifying the widths
- `Table::widths()` now accepts `IntoIterator<Item = AsRef<Constraint>>`
Expand Down Expand Up @@ -42,28 +42,17 @@ This is a quick summary of the sections below:

## Unreleased (v0.24.1)

### `List::start_corner` is renamed to `List::direction` ([#673])
### Removed `Axis::title_style` and `Buffer::set_background`

[#673]: https://github.com/ratatui-org/ratatui/pull/673
These items were deprecated since 0.10.

Previously `List::start_corner` didn't communicate the intent of the method. It also used an
inadequate `Corner` enum. The method is now renamed `direction` and a new enum
`ListDirection` has been added.
- You should use styling capabilities of [`text::Line`] given as argument of [`Axis::title`]
instead of `Axis::title_style`
- You should use styling capabilities of [`Buffer::set_style`] instead of `Buffer::set_background`

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

```diff
- List::new(/* items */).start_corner(Corner::BottomLeft);
// becomes
+ List::new(/* items */).direction(ListDirection::BottomToTop);
```
[`text::Line`]: https://docs.rs/ratatui/latest/ratatui/text/struct.Line.html
[`Axis::title`]: https://docs.rs/ratatui/latest/ratatui/widgets/struct.Axis.html#method.title
[`Buffer::set_style`]: https://docs.rs/ratatui/latest/ratatui/buffer/struct.Buffer.html#method.set_style

### `List::new()` now accepts `IntoIterator<Item = Into<ListItem<'a>>>` ([#672])

Expand Down
12 changes: 0 additions & 12 deletions src/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,18 +367,6 @@ impl Buffer {
self.set_stringn(x, y, span.content.as_ref(), width as usize, span.style)
}

#[deprecated(
since = "0.10.0",
note = "You should use styling capabilities of `Buffer::set_style`"
)]
pub fn set_background(&mut self, area: Rect, color: Color) {
for y in area.top()..area.bottom() {
for x in area.left()..area.right() {
self.get_mut(x, y).set_bg(color);
}
}
}

pub fn set_style(&mut self, area: Rect, style: Style) {
for y in area.top()..area.bottom() {
for x in area.left()..area.right() {
Expand Down
13 changes: 0 additions & 13 deletions src/widgets/chart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,6 @@ impl<'a> Axis<'a> {
self
}

#[deprecated(
since = "0.10.0",
note = "You should use styling capabilities of `text::Line` given as argument of the `title` method to apply styling to the title."
)]
#[must_use = "method moves the value of self and returns the modified value"]
pub fn title_style(mut self, style: Style) -> Axis<'a> {
if let Some(t) = self.title {
let title = String::from(t);
self.title = Some(TextLine::from(Span::styled(title, style)));
}
self
}

#[must_use = "method moves the value of self and returns the modified value"]
pub fn bounds(mut self, bounds: [f64; 2]) -> Axis<'a> {
self.bounds = bounds;
Expand Down

0 comments on commit b282a06

Please sign in to comment.