Merge pull request #296 from jonathandturner/polish_on_wrap

Add more polish to table wrap
This commit is contained in:
Jonathan Turner 2019-08-17 04:51:28 +12:00 committed by GitHub
commit 0db77c911d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -54,7 +54,7 @@ impl TableView {
};
if values.len() > 1 {
row.insert(0, format!("{}", Color::Black.bold().paint(idx.to_string())));
row.insert(0, format!("{}", idx.to_string()));
}
entries.push(row);
}
@ -75,7 +75,7 @@ impl TableView {
max_per_column.push(current_row_max);
}
let termwidth = textwrap::termwidth() - 5;
let termwidth = textwrap::termwidth() - 9;
// Make sure we have enough space for the columns we have
let max_num_of_columns = termwidth / 7;
@ -123,6 +123,14 @@ impl TableView {
}
}
// Paint the number column, if it exists
if entries.len() > 1 {
for row in 0..entries.len() {
entries[row][0] =
format!("{}", Color::Black.bold().paint(entries[row][0].to_string()));
}
}
Some(TableView { headers, entries })
}
}