Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
archseer committed May 20, 2024
1 parent 8444f52 commit e94735b
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions helix-tui/src/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,22 +130,21 @@ pub struct Buffer {

impl Buffer {
/// Returns a Buffer with all cells set to the default one
#[must_use]
pub fn empty(area: Rect) -> Buffer {
let cell: Cell = Default::default();
Buffer::filled(area, &cell)
Buffer::filled(area, &Cell::default())
}

/// Returns a Buffer with all cells initialized with the attributes of the given Cell
#[must_use]
pub fn filled(area: Rect, cell: &Cell) -> Buffer {
let size = area.area();
let mut content = Vec::with_capacity(size);
for _ in 0..size {
content.push(cell.clone());
}
let content = vec![cell.clone(); size];
Buffer { area, content }
}

/// Returns a Buffer containing the given lines
#[must_use]
pub fn with_lines<S>(lines: Vec<S>) -> Buffer
where
S: AsRef<str>,
Expand Down

0 comments on commit e94735b

Please sign in to comment.