This commit is contained in:
Your Name
2025-04-21 22:49:10 +12:00
parent 013176dbe5
commit c5ed85c8e9
3 changed files with 56 additions and 53 deletions

View File

@ -130,7 +130,7 @@ std::string width_print_left(std::string str,int width, std::string rowcolor) {
return oss.str();
}
tableprint::tableprint(const std::string title) : title(title) {
tableprint::tableprint(const std::string title, bool compact) : title(title), mCompact(compact) {
// Set locale for wide character support
std::setlocale(LC_ALL, "");
}
@ -176,11 +176,11 @@ void tableprint::print() {
}
// Debug output
std::cerr << "Column widths: ";
for (size_t width : col_widths) {
std::cerr << width << " ";
}
std::cerr << std::endl;
// std::cerr << "Column widths: ";
// for (size_t width : col_widths) {
// std::cerr << width << " ";
// }
// std::cerr << std::endl;
// Calculate total table width
size_t total_width = 0;
@ -240,14 +240,16 @@ void tableprint::print() {
std::cout << std::endl;
// Print header separator
std::cout << "";
for (size_t i = 0; i < rows[0].size(); ++i) {
for (size_t j = 0; j < col_widths[i] + 2; ++j) {
std::cout << "-";
if (!mCompact) {
std::cout << "";
for (size_t i = 0; i < rows[0].size(); ++i) {
for (size_t j = 0; j < col_widths[i] + 2; ++j) {
std::cout << "-";
}
if (i < rows[0].size() - 1) std::cout << "";
}
if (i < rows[0].size() - 1) std::cout << "";
std::cout << "" << std::endl;
}
std::cout << "" << std::endl;
// Print rows
for (size_t row_idx = 1; row_idx < rows.size(); ++row_idx) {
@ -262,7 +264,7 @@ void tableprint::print() {
std::cout << std::endl;
// Print row separator if not the last row
if (row_idx < rows.size() - 1) {
if (row_idx < rows.size() - 1 && !mCompact) {
std::cout << "";
for (size_t i = 0; i < rows[0].size(); ++i) {
for (size_t j = 0; j < col_widths[i] + 2; ++j) {