diff --git a/src/xwin.rs b/src/xwin.rs index cdeb08351..34abb0f7e 100644 --- a/src/xwin.rs +++ b/src/xwin.rs @@ -494,6 +494,12 @@ impl<'a> TerminalWindow<'a> { self.host.window.show(); } + /// Compute a vertex buffer to hold the quads that comprise the visible + /// portion of the screen. We recreate this when the screen is resized. + /// The idea is that we want to minimize and heavy lifting and computation + /// and instead just poke some attributes into the offset that corresponds + /// to a changed cell when we need to repaint the screen, and then just + /// let the GPU figure out the rest. fn compute_vertices( host: &Host, cell_width: f32, @@ -558,8 +564,8 @@ impl<'a> TerminalWindow<'a> { )) } + /// The projection corrects for the aspect ratio and flips the y-axis fn compute_projection(width: f32, height: f32) -> Transform3D { - // The projection corrects for the aspect ratio and flips the y-axis Transform3D::ortho( -width / 2.0, width / 2.0, @@ -786,6 +792,10 @@ impl<'a> TerminalWindow<'a> { font.shape(0, s) } + /// "Render" a line of the terminal screen into the vertex buffer. + /// This is nominally a matter of setting the fg/bg color and the + /// texture coordinates for a given glyph. There's a little bit + /// of extra complexity to deal with multi-cell glyphs. fn render_screen_line( &self, line_idx: usize, @@ -1014,7 +1024,7 @@ impl<'a> TerminalWindow<'a> { let cursor = self.terminal.cursor_pos(); { - let dirty_lines = self.terminal.get_dirty_lines(false); + let dirty_lines = self.terminal.get_dirty_lines(); for (line_idx, line, selrange) in dirty_lines { self.render_screen_line(line_idx, line, selrange, &cursor)?; diff --git a/term/src/terminalstate.rs b/term/src/terminalstate.rs index fdad1590b..a3a2023b4 100644 --- a/term/src/terminalstate.rs +++ b/term/src/terminalstate.rs @@ -640,7 +640,7 @@ impl TerminalState { /// line_idx is relative to the top of the viewport. /// The selrange value is the column range representing the selected /// columns on this line. - pub fn get_dirty_lines(&self, get_all: bool) -> Vec<(usize, &Line, Range)> { + pub fn get_dirty_lines(&self) -> Vec<(usize, &Line, Range)> { let mut res = Vec::new(); let screen = self.screen(); @@ -650,7 +650,7 @@ impl TerminalState { let selection = self.selection_range.map(|r| r.normalize()); for (i, mut line) in screen.lines.iter().skip(len - height).enumerate() { - if get_all || line.is_dirty() { + if line.is_dirty() { let selrange = match selection { None => 0..0, Some(sel) => { diff --git a/term/src/test/mod.rs b/term/src/test/mod.rs index c4a03aea8..a7fffde60 100644 --- a/term/src/test/mod.rs +++ b/term/src/test/mod.rs @@ -191,10 +191,7 @@ impl TestTerm { } fn assert_dirty_lines(&self, expected: &[usize], reason: Option<&str>) { - let dirty_indices: Vec = self.get_dirty_lines(false) - .iter() - .map(|&(i, ..)| i) - .collect(); + let dirty_indices: Vec = self.get_dirty_lines().iter().map(|&(i, ..)| i).collect(); assert_eq!( &dirty_indices, &expected,