diff options
author | Joe Wilm <joe@jwilm.com> | 2016-06-04 19:40:30 -0700 |
---|---|---|
committer | Joe Wilm <joe@jwilm.com> | 2016-06-04 19:40:30 -0700 |
commit | 4fdd5280f1e79ea6575a6a110951c564a7dd235e (patch) | |
tree | 89d11f7b903c53e974dca13d9dff227269cd57c1 /src/term.rs | |
parent | 2f058bd053f52307bdbf3709209418ac26871678 (diff) | |
download | r-alacritty-4fdd5280f1e79ea6575a6a110951c564a7dd235e.tar.gz r-alacritty-4fdd5280f1e79ea6575a6a110951c564a7dd235e.tar.bz2 r-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/term.rs')
-rw-r--r-- | src/term.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/term.rs b/src/term.rs index 35088db7..2838c668 100644 --- a/src/term.rs +++ b/src/term.rs @@ -95,7 +95,7 @@ pub struct Term { impl Term { pub fn new(tty: tty::Tty, grid: Grid) -> Term { - let mut tabs = (0..grid.cols()).map(|i| i % TAB_SPACES == 0) + let mut tabs = (0..grid.num_cols()).map(|i| i % TAB_SPACES == 0) .collect::<Vec<bool>>(); tabs[0] = false; @@ -206,10 +206,10 @@ impl ansi::Handler for Term { println!("put_tab: {}", count); let mut x = self.cursor_x(); - while x < self.grid.cols() as u16 && count != 0 { + while x < self.grid.num_cols() as u16 && count != 0 { count -= 1; loop { - if x == self.grid.cols() as u16 || self.tabs[x as usize] { + if x == self.grid.num_cols() as u16 || self.tabs[x as usize] { break; } x += 1; @@ -237,7 +237,7 @@ impl ansi::Handler for Term { fn linefeed(&mut self) { println!("linefeed"); // TODO handle scroll? not clear what parts of this the pty handle - if self.cursor_y() + 1 == self.grid.rows() as u16 { + if self.cursor_y() + 1 == self.grid.num_rows() as u16 { self.grid.feed(); self.clear_line(ansi::LineClearMode::Right); } else { @@ -264,7 +264,7 @@ impl ansi::Handler for Term { println!("clear_line: {:?}", mode); match mode { ansi::LineClearMode::Right => { - let cols = self.grid.cols(); + let cols = self.grid.num_cols(); let row = &mut self.grid[self.cursor.y as usize]; let start = self.cursor.x as usize; for col in start..cols { @@ -279,7 +279,7 @@ impl ansi::Handler for Term { match mode { ansi::ClearMode::Below => { let start = self.cursor_y() as usize; - let end = self.grid.rows(); + let end = self.grid.num_rows(); for i in start..end { let row = &mut self.grid[i]; for cell in row.iter_mut() { |