aboutsummaryrefslogtreecommitdiffstats
path: root/src/row.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2019-10-30 01:57:39 -0400
committerJesse Luehrs <doy@tozt.net>2019-10-30 01:57:39 -0400
commitb3cf6eb46847b881ad8edac8acceaefb79e37cb7 (patch)
treefbf07f19f2f48329d9f1297efbf9212443c9235c /src/row.rs
parent95d757f2643d7451973c121d775ff1bae4ee26e9 (diff)
downloadvt100-rust-b3cf6eb46847b881ad8edac8acceaefb79e37cb7.tar.gz
vt100-rust-b3cf6eb46847b881ad8edac8acceaefb79e37cb7.zip
more passing tests
Diffstat (limited to 'src/row.rs')
-rw-r--r--src/row.rs17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/row.rs b/src/row.rs
index f9c4e77..1526ebc 100644
--- a/src/row.rs
+++ b/src/row.rs
@@ -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";