mirror of
https://github.com/alacritty/alacritty.git
synced 2024-11-18 13:55:23 -05:00
Minor improvements
This commit is contained in:
parent
f13685918f
commit
92b11cfa43
2 changed files with 14 additions and 9 deletions
|
@ -179,26 +179,26 @@ impl<T: Copy + Clone> Grid<T> {
|
|||
self.swap_lines(line, line - positions);
|
||||
}
|
||||
|
||||
for i in IndexRange(Line(0)..positions) {
|
||||
self.raw[*(region.start - i - 1)].reset(&self.template_row);
|
||||
for line in IndexRange(region.start .. (region.start + positions)) {
|
||||
self.raw[*line].reset(&self.template_row);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// scroll_up moves lines at the bottom towards the top
|
||||
///
|
||||
/// This is the performance-sensitive part of scrolling.
|
||||
#[inline]
|
||||
pub fn scroll_up(&mut self, region: &Range<index::Line>, positions: index::Line) {
|
||||
if region.start == Line(0) {
|
||||
// Rotate the entire line buffer. If there's a scrolling region
|
||||
// active, the bottom lines are restored in the next step.
|
||||
self.raw.rotate(*positions as isize);
|
||||
self.raw.rotate_up(*positions);
|
||||
|
||||
// Now, restore any lines outside the scroll region
|
||||
let mut i = 0;
|
||||
for _ in IndexRange(region.end .. self.num_lines()) {
|
||||
let idx = *self.num_lines() - i - 1;
|
||||
for idx in (*region.end .. *self.num_lines()).rev() {
|
||||
// First do the swap
|
||||
self.raw.swap(idx, idx - *positions);
|
||||
i += 1;
|
||||
}
|
||||
|
||||
// Finally, reset recycled lines
|
||||
|
@ -214,8 +214,8 @@ impl<T: Copy + Clone> Grid<T> {
|
|||
}
|
||||
|
||||
// Clear reused lines
|
||||
for i in IndexRange(Line(0)..positions) {
|
||||
self.raw[*(region.start - i - 1)].reset(&self.template_row);
|
||||
for line in IndexRange((region.end - positions) .. region.end) {
|
||||
self.raw[*line].reset(&self.template_row);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,6 +68,11 @@ impl<T> Storage<T> {
|
|||
assert!(count.abs() as usize <= len);
|
||||
self.zero += (count + len as isize) as usize % len;
|
||||
}
|
||||
|
||||
// Fast path
|
||||
pub fn rotate_up(&mut self, count: usize) {
|
||||
self.zero = (self.zero + count) % self.len();
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Index<usize> for Storage<T> {
|
||||
|
|
Loading…
Reference in a new issue