From ff4c1d05deee2b4b4d85c29a627fb01e60886c7f Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Sun, 9 May 2021 18:13:50 +0900 Subject: Replace the Clear widget with buffer.clear/clear_with. --- helix-tui/src/buffer.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'helix-tui/src/buffer.rs') diff --git a/helix-tui/src/buffer.rs b/helix-tui/src/buffer.rs index 8a227ce7..c584ee7f 100644 --- a/helix-tui/src/buffer.rs +++ b/helix-tui/src/buffer.rs @@ -379,6 +379,26 @@ impl Buffer { } } + /// Clear an area in the buffer + pub fn clear(&mut self, area: Rect) { + for x in area.left()..area.right() { + for y in area.top()..area.bottom() { + self.get_mut(x, y).reset(); + } + } + } + + /// Clear an area in the buffer with a default style. + pub fn clear_with(&mut self, area: Rect, style: Style) { + for x in area.left()..area.right() { + for y in area.top()..area.bottom() { + let cell = self.get_mut(x, y); + cell.reset(); + cell.set_style(style); + } + } + } + /// Merge an other buffer into this one pub fn merge(&mut self, other: &Buffer) { let area = self.area.union(other.area); -- cgit v1.2.3-70-g09d2