ratatui/examples/demo2
Josh McKinney a23ecd9b45
feat(buffer): add Buffer::cell, cell_mut and index implementations (#1084)
Code which previously called `buf.get(x, y)` or `buf.get_mut(x, y)`
should now use index operators, or be transitioned to `buff.cell()` or
`buf.cell_mut()` for safe access that avoids panics by returning
`Option<&Cell>` and `Option<&mut Cell>`.

The new methods accept `Into<Position>` instead of `x` and `y`
coordinates, which makes them more ergonomic to use.

```rust
let mut buffer = Buffer::empty(Rect::new(0, 0, 10, 10));

let cell = buf[(0, 0)];
let cell = buf[Position::new(0, 0)];

let symbol = buf.cell((0, 0)).map(|cell| cell.symbol());
let symbol = buf.cell(Position::new(0, 0)).map(|cell| cell.symbol());

buf[(0, 0)].set_symbol("🐀");
buf[Position::new(0, 0)].set_symbol("🐀");

buf.cell_mut((0, 0)).map(|cell| cell.set_symbol("🐀"));
buf.cell_mut(Position::new(0, 0)).map(|cell| cell.set_symbol("🐀"));
```

The existing `get()` and `get_mut()` methods are marked as deprecated.
These are fairly widely used and we will leave these methods around on
the buffer for a longer time than our normal deprecation approach (2
major release)

Addresses part of: https://github.com/ratatui-org/ratatui/issues/1011

---------

Co-authored-by: EdJoPaTo <rfc-conform-git-commit-email@funny-long-domain-label-everyone-hates-as-it-is-too-long.edjopato.de>
2024-08-06 00:40:47 -07:00
..
tabs feat(buffer): add Buffer::cell, cell_mut and index implementations (#1084) 2024-08-06 00:40:47 -07:00
app.rs feat(frame): replace Frame::size() with Frame::area() (#1293) 2024-08-05 20:15:14 -07:00
colors.rs feat(buffer): add Buffer::cell, cell_mut and index implementations (#1084) 2024-08-06 00:40:47 -07:00
destroy.rs feat(buffer): add Buffer::cell, cell_mut and index implementations (#1084) 2024-08-06 00:40:47 -07:00
errors.rs refactor(non-src): apply pedantic lints (#976) 2024-03-02 01:06:53 -08:00
main.rs chore: replace big_text with hardcoded logo (#1203) 2024-08-03 16:08:59 -07:00
tabs.rs feat(examples): add demo2 example (#500) 2023-09-21 01:47:23 -07:00
term.rs fix(terminal)!: make terminal module private (#1260) 2024-08-02 04:18:00 -07:00
theme.rs refactor: expand glob imports (#1152) 2024-05-29 04:42:29 -07:00