aboutsummaryrefslogtreecommitdiff
path: root/src/renderer
diff options
context:
space:
mode:
authorJoe Wilm <joe@jwilm.com>2016-06-04 19:40:30 -0700
committerJoe Wilm <joe@jwilm.com>2016-06-04 19:40:30 -0700
commit4fdd5280f1e79ea6575a6a110951c564a7dd235e (patch)
tree89d11f7b903c53e974dca13d9dff227269cd57c1 /src/renderer
parent2f058bd053f52307bdbf3709209418ac26871678 (diff)
downloadalacritty-4fdd5280f1e79ea6575a6a110951c564a7dd235e.tar.gz
alacritty-4fdd5280f1e79ea6575a6a110951c564a7dd235e.zip
Add iterator methods to Grid and Row types
The iterator methods simplify logic in the main grid render function. To disambiguate iterator methods from those returning counts (and to free up names), the `rows()` and `cols()` methods on `Grid` have been renamed to `num_rows()` and `num_cols()`, respectively.
Diffstat (limited to 'src/renderer')
-rw-r--r--src/renderer/mod.rs20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/renderer/mod.rs b/src/renderer/mod.rs
index c983beba..2ba5b94c 100644
--- a/src/renderer/mod.rs
+++ b/src/renderer/mod.rs
@@ -182,17 +182,21 @@ impl QuadRenderer {
pub fn render_grid(&mut self, grid: &Grid, glyph_cache: &GlyphCache, props: &TermProps) {
self.prepare_render(props);
- for i in 0..grid.rows() {
- let row = &grid[i];
- for j in 0..row.cols() {
- let cell = &row[j];
- if cell.c != ' ' {
- if let Some(glyph) = glyph_cache.get(&cell.c) {
- self.render(glyph, i as f32, j as f32, &cell.fg, cell.c);
- }
+
+ for (i, row) in grid.rows().enumerate() {
+ for (j, cell) in row.cells().enumerate() {
+ // Skip empty cells
+ if cell.c == ' ' {
+ continue;
+ }
+
+ // Render if glyph is loaded
+ if let Some(glyph) = glyph_cache.get(&cell.c) {
+ self.render(glyph, i as f32, j as f32, &cell.fg, cell.c);
}
}
}
+
self.finish_render();
}