summaryrefslogtreecommitdiff
path: root/helix-tui/src/buffer.rs
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-05-09 09:13:50 +0000
committerBlaž Hrastnik2021-05-09 09:13:50 +0000
commitff4c1d05deee2b4b4d85c29a627fb01e60886c7f (patch)
treefb99b0abf84a43ff2280481739a17f5052698ac7 /helix-tui/src/buffer.rs
parent1255bcb8a311c7f382f0bf66bbe791c6dfd77b30 (diff)
Replace the Clear widget with buffer.clear/clear_with.
Diffstat (limited to 'helix-tui/src/buffer.rs')
-rw-r--r--helix-tui/src/buffer.rs20
1 files changed, 20 insertions, 0 deletions
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);