From 9b9b138bac9353d2d95ce71ec155c3a9b2963491 Mon Sep 17 00:00:00 2001 From: Joe Wilm Date: Thu, 15 Feb 2018 19:34:09 -0800 Subject: [PATCH] Fir cursor not scrolling --- src/grid/mod.rs | 12 ++++++++++-- src/term/mod.rs | 3 ++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/grid/mod.rs b/src/grid/mod.rs index 749012fa..1889d59f 100644 --- a/src/grid/mod.rs +++ b/src/grid/mod.rs @@ -628,6 +628,7 @@ pub struct DisplayIter<'a, T: 'a> { offset: usize, limit: usize, col: Column, + line: Line, } impl<'a, T: 'a> DisplayIter<'a, T> { @@ -635,8 +636,9 @@ impl<'a, T: 'a> DisplayIter<'a, T> { let offset = grid.display_offset + *grid.num_lines() - 1; let limit = grid.display_offset; let col = Column(0); + let line = Line(0); - DisplayIter { grid, offset, col, limit } + DisplayIter { grid, offset, col, limit, line } } pub fn offset(&self) -> usize { @@ -646,6 +648,10 @@ impl<'a, T: 'a> DisplayIter<'a, T> { pub fn column(&self) -> Column { self.col } + + pub fn line(&self) -> Line { + self.line + } } impl<'a, T: Copy + 'a> Iterator for DisplayIter<'a, T> { @@ -660,13 +666,15 @@ impl<'a, T: Copy + 'a> Iterator for DisplayIter<'a, T> { } self.col = Column(0); + self.offset -= 1; + self.line = Line(*self.grid.lines - 1 - (self.offset - self.limit)); } // Return the next item. let item = Some(Indexed { inner: self.grid.raw[self.offset][self.col], - line: Line( *self.grid.lines - 1 - (self.offset - self.limit)), + line: self.line, column: self.col }); diff --git a/src/term/mod.rs b/src/term/mod.rs index e2088413..824577f7 100644 --- a/src/term/mod.rs +++ b/src/term/mod.rs @@ -342,7 +342,8 @@ impl<'a> Iterator for RenderableCellsIter<'a> { self.inner.column() == self.cursor.col { // Cursor cell - let cell = self.cursor_cells.pop_front().unwrap(); + let mut cell = self.cursor_cells.pop_front().unwrap(); + cell.line = self.inner.line(); // Since there may be multiple cursor cells (for a wide // char), only update iteration position after all cursor