diff options
author | A-Walrus | 2022-10-26 03:00:13 +0000 |
---|---|---|
committer | GitHub | 2022-10-26 03:00:13 +0000 |
commit | c4d7cde6c8d7f5ca3a9cabd50bdfbda9c3f7bb15 (patch) | |
tree | 0214dc4270da56e5c50fc009e72ae35c4aaf8bf6 /helix-tui/src | |
parent | ac0fe29867012ba0840ee7c8893b41d976d5ab38 (diff) |
Allow the area to be bigger than u16 (width and height remain u16) (#4318)
Now the editor can fill **very** large terminals.
Changed/removed tests which check the truncating behaviour.
Diffstat (limited to 'helix-tui/src')
-rw-r--r-- | helix-tui/src/buffer.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/helix-tui/src/buffer.rs b/helix-tui/src/buffer.rs index 424e6d32..23ba43f1 100644 --- a/helix-tui/src/buffer.rs +++ b/helix-tui/src/buffer.rs @@ -137,7 +137,7 @@ impl Buffer { /// Returns a Buffer with all cells initialized with the attributes of the given Cell pub fn filled(area: Rect, cell: &Cell) -> Buffer { - let size = area.area() as usize; + let size = area.area(); let mut content = Vec::with_capacity(size); for _ in 0..size { content.push(cell.clone()); @@ -239,7 +239,7 @@ impl Buffer { y, self.area ); - ((y - self.area.y) * self.area.width + (x - self.area.x)) as usize + ((y - self.area.y) as usize) * (self.area.width as usize) + ((x - self.area.x) as usize) } /// Returns the index in the Vec<Cell> for the given global (x, y) coordinates, @@ -278,8 +278,8 @@ impl Buffer { self.content.len() ); ( - self.area.x + i as u16 % self.area.width, - self.area.y + i as u16 / self.area.width, + (self.area.x as usize + (i % self.area.width as usize)) as u16, + (self.area.y as usize + (i / self.area.width as usize)) as u16, ) } @@ -480,7 +480,7 @@ impl Buffer { /// Resize the buffer so that the mapped area matches the given area and that the buffer /// length is equal to area.width * area.height pub fn resize(&mut self, area: Rect) { - let length = area.area() as usize; + let length = area.area(); if self.content.len() > length { self.content.truncate(length); } else { @@ -587,8 +587,8 @@ impl Buffer { let mut to_skip: usize = 0; for (i, (current, previous)) in next_buffer.iter().zip(previous_buffer.iter()).enumerate() { if (current != previous || invalidated > 0) && to_skip == 0 { - let x = i as u16 % width; - let y = i as u16 / width; + let x = (i % width as usize) as u16; + let y = (i / width as usize) as u16; updates.push((x, y, &next_buffer[i])); } |