ratatui/tests
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
..
backend_termion.rs feat: re-export backends from the ratatui crate (#1151) 2024-05-28 13:23:39 -07:00
state_serde.rs feat(frame): replace Frame::size() with Frame::area() (#1293) 2024-08-05 20:15:14 -07:00
stylize.rs feat(buffer): add Buffer::cell, cell_mut and index implementations (#1084) 2024-08-06 00:40:47 -07:00
terminal.rs feat(buffer): add Buffer::cell, cell_mut and index implementations (#1084) 2024-08-06 00:40:47 -07:00
widgets_barchart.rs feat(buffer): add Buffer::cell, cell_mut and index implementations (#1084) 2024-08-06 00:40:47 -07:00
widgets_block.rs feat(buffer): add Buffer::cell, cell_mut and index implementations (#1084) 2024-08-06 00:40:47 -07:00
widgets_calendar.rs feat(frame): replace Frame::size() with Frame::area() (#1293) 2024-08-05 20:15:14 -07:00
widgets_canvas.rs feat(buffer): add Buffer::cell, cell_mut and index implementations (#1084) 2024-08-06 00:40:47 -07:00
widgets_chart.rs feat(buffer): add Buffer::cell, cell_mut and index implementations (#1084) 2024-08-06 00:40:47 -07:00
widgets_gauge.rs feat(buffer): add Buffer::cell, cell_mut and index implementations (#1084) 2024-08-06 00:40:47 -07:00
widgets_list.rs feat(buffer): add Buffer::cell, cell_mut and index implementations (#1084) 2024-08-06 00:40:47 -07:00
widgets_paragraph.rs feat(frame): replace Frame::size() with Frame::area() (#1293) 2024-08-05 20:15:14 -07:00
widgets_table.rs feat(buffer): add Buffer::cell, cell_mut and index implementations (#1084) 2024-08-06 00:40:47 -07:00
widgets_tabs.rs refactor(buffer): deprecate assert_buffer_eq! in favor of assert_eq! (#1007) 2024-05-13 18:13:46 -07:00