From c5cffcaea378ad8346bab19c14b495c769dbde9d Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 21 Apr 2025 22:33:44 +1200 Subject: [PATCH] Close --- src/tableprint.cpp | 44 ++++++++++++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/src/tableprint.cpp b/src/tableprint.cpp index 5cfa66a..e71a20c 100644 --- a/src/tableprint.cpp +++ b/src/tableprint.cpp @@ -103,6 +103,32 @@ std::string process_cell(std::string str,std::string rowcolor) { return result; } +std::string width_print_centered(std::string str,int width, std::string rowcolor) { + size_t padding = (width - get_visible_length(str)) / 2; + std::ostringstream oss; + oss << rowcolor << std::string(padding, ' ') << process_cell(str, rowcolor) << + std::string(width - get_codepoints(str) - padding, ' ') << "\033[0m"; + + // std::cout << "str = "<