diff options
| author | Ellie Huxtable <ellie@elliehuxtable.com> | 2023-03-31 22:57:37 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-31 22:57:37 +0100 |
| commit | a515b06bcb556c1be2d0fc3095cd778d413fe40d (patch) | |
| tree | 4b544de9aa53d6976177c08b91aa3943ef4d9e92 /src/ratatui/widgets/canvas/points.rs | |
| parent | feat: add github action to test the nix builds (#833) (diff) | |
| download | atuin-a515b06bcb556c1be2d0fc3095cd778d413fe40d.zip | |
Vendor ratatui temporarily (#835)
* Vendor ratatui temporarily
Once https://github.com/tui-rs-revival/ratatui/pull/114 has been merged,
we can undo this! But otherwise we can't publish to crates.io with a git
dependency.
* make tests pass
* Shush.
* these literally just fail in nix, nowhere else
idk how to work with nix properly, and they're also not our tests
Diffstat (limited to 'src/ratatui/widgets/canvas/points.rs')
| -rw-r--r-- | src/ratatui/widgets/canvas/points.rs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/ratatui/widgets/canvas/points.rs b/src/ratatui/widgets/canvas/points.rs new file mode 100644 index 00000000..d9f97522 --- /dev/null +++ b/src/ratatui/widgets/canvas/points.rs @@ -0,0 +1,30 @@ +use crate::ratatui::{ + style::Color, + widgets::canvas::{Painter, Shape}, +}; + +/// A shape to draw a group of points with the given color +#[derive(Debug, Clone)] +pub struct Points<'a> { + pub coords: &'a [(f64, f64)], + pub color: Color, +} + +impl<'a> Shape for Points<'a> { + fn draw(&self, painter: &mut Painter) { + for (x, y) in self.coords { + if let Some((x, y)) = painter.get_point(*x, *y) { + painter.paint(x, y, self.color); + } + } + } +} + +impl<'a> Default for Points<'a> { + fn default() -> Points<'a> { + Points { + coords: &[], + color: Color::Reset, + } + } +} |
