@@ 1,4 1,3 @@
-
use crossterm::{
cursor,
style::{self, Print},
@@ 26,8 25,8 @@ impl Span {
Self { lines: lines }
}
- pub fn line_iter(&self) -> impl Iterator<Item = &String> {
- self.lines.iter().rev()
+ pub fn line_iter(&self) -> impl DoubleEndedIterator<Item = &String> {
+ self.lines.iter()
}
}
/// The `Buffer` stores a list of lines which need to be displayed
@@ 103,11 102,13 @@ impl Buffer {
.map(|line| Span::new(line, self.cols))
.collect::<Vec<_>>();
+ // grab at most a buffer's worth of lines
let viewport_lines = self.viewport_spans
.iter()
- .flat_map(|span| span.line_iter())
+ .flat_map(|span| span.line_iter().rev())
.take(self.rows as usize);
+ // blit lines to the viewport
let mut rows_drawn = 0;
for line in viewport_lines {
rows_drawn += 1;