From a515b06bcb556c1be2d0fc3095cd778d413fe40d Mon Sep 17 00:00:00 2001 From: Ellie Huxtable Date: Fri, 31 Mar 2023 22:57:37 +0100 Subject: 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 --- src/ratatui/widgets/canvas/points.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/ratatui/widgets/canvas/points.rs (limited to 'src/ratatui/widgets/canvas/points.rs') 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, + } + } +} -- cgit v1.3.1