From 8a66a000e4961a334af93070666300f7ab486f0c Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Sat, 17 Aug 2019 04:32:35 +1200 Subject: [PATCH] Add more polish to table wrap --- src/format/table.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/format/table.rs b/src/format/table.rs index 76ea37ee9a..6321d71893 100644 --- a/src/format/table.rs +++ b/src/format/table.rs @@ -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 }) } }