diff options
author | Jesse Luehrs <doy@tozt.net> | 2019-10-30 01:57:39 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2019-10-30 01:57:39 -0400 |
commit | b3cf6eb46847b881ad8edac8acceaefb79e37cb7 (patch) | |
tree | fbf07f19f2f48329d9f1297efbf9212443c9235c /src/row.rs | |
parent | 95d757f2643d7451973c121d775ff1bae4ee26e9 (diff) | |
download | vt100-rust-b3cf6eb46847b881ad8edac8acceaefb79e37cb7.tar.gz vt100-rust-b3cf6eb46847b881ad8edac8acceaefb79e37cb7.zip |
more passing tests
Diffstat (limited to 'src/row.rs')
-rw-r--r-- | src/row.rs | 17 |
1 files changed, 13 insertions, 4 deletions
@@ -22,15 +22,24 @@ impl Row { pub fn contents(&self, col_start: u16, col_end: u16) -> String { // XXX very inefficient - let mut max_col = 0; + let mut max_col = None; for (col, cell) in self.cells.iter().enumerate() { if cell.has_contents() { - max_col = col; + max_col = Some(col); } } + let mut contents = String::new(); - for col in col_start..=(col_end.min(max_col as u16)) { - contents += self.cells[col as usize].contents(); + if let Some(max_col) = max_col { + for col in col_start..=(col_end.min(max_col as u16)) { + let cell_contents = self.cells[col as usize].contents(); + let cell_contents = if cell_contents == "" { + " " + } else { + cell_contents + }; + contents += cell_contents; + } } if !self.wrapped { contents += "\n"; |