From d7f92c968219623a518e57bb5e00dc6842a341c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Monta=C3=B1ana=20G=C3=B3mez?= Date: Fri, 15 Mar 2024 00:18:30 +0100 Subject: [PATCH] Refactor colors in b_manage --- src/common/Colors.h | 29 ++++++++++++++--------------- src/manage/ManageResults.cpp | 11 +++++------ src/manage/b_manage.cpp | 2 +- 3 files changed, 20 insertions(+), 22 deletions(-) diff --git a/src/common/Colors.h b/src/common/Colors.h index 9c8da43..95cc494 100644 --- a/src/common/Colors.h +++ b/src/common/Colors.h @@ -3,28 +3,27 @@ #include class Colors { public: - static std::string MAGENTA() { return "\033[1;35m"; } + static std::string BLACK() { return "\033[1;30m"; } + static std::string IBLACK() { return "\033[0;90m"; } static std::string BLUE() { return "\033[1;34m"; } - static std::string CYAN() { return "\033[1;36m"; } - static std::string GREEN() { return "\033[1;32m"; } - static std::string YELLOW() { return "\033[1;33m"; } - static std::string RED() { return "\033[1;31m"; } - static std::string WHITE() { return "\033[1;37m"; } static std::string IBLUE() { return "\033[0;94m"; } + static std::string CYAN() { return "\033[1;36m"; } + static std::string ICYAN() { return "\033[0;96m"; } + static std::string GREEN() { return "\033[1;32m"; } + static std::string IGREEN() { return "\033[0;92m"; } + static std::string MAGENTA() { return "\033[1;35m"; } + static std::string IMAGENTA() { return "\033[0;95m"; } + static std::string RED() { return "\033[1;31m"; } + static std::string IRED() { return "\033[0;91m"; } + static std::string YELLOW() { return "\033[1;33m"; } + static std::string IYELLOW() { return "\033[0;93m"; } + static std::string WHITE() { return "\033[1;37m"; } + static std::string IWHITE() { return "\033[0;97m"; } static std::string RESET() { return "\033[0m"; } static std::string BOLD() { return "\033[1m"; } static std::string UNDERLINE() { return "\033[4m"; } static std::string BLINK() { return "\033[5m"; } static std::string REVERSE() { return "\033[7m"; } static std::string CONCEALED() { return "\033[8m"; } - static std::string BLACK() { return "\033[1;30m"; } - static std::string IBROWN() { return "\033[0;93m"; } - static std::string IRED() { return "\033[0;91m"; } - static std::string IWHITE() { return "\033[0;97m"; } - static std::string IGREEN() { return "\033[0;92m"; } - static std::string IYELLOW() { return "\033[0;93m"; } - static std::string ICYAN() { return "\033[0;96m"; } - static std::string IBLACK() { return "\033[0;90m"; } - static std::string IMAGENTA() { return "\033[0;95m"; } static std::string CLRSCR() { return "\033[2J\033[1;1H"; } }; diff --git a/src/manage/ManageResults.cpp b/src/manage/ManageResults.cpp index 7fdd31c..3f02a21 100644 --- a/src/manage/ManageResults.cpp +++ b/src/manage/ManageResults.cpp @@ -46,8 +46,7 @@ namespace platform { auto [index_from, index_to] = paginator.getOffset(page); std::stringstream oss; oss << index_to - index_from + 1 << " Results on screen - Page " << page << " of " << paginator.getPages(); - std::cout << Colors::CLRSCR() << Colors::GREEN() << oss.str() << std::endl; - std::cout << std::string(oss.str().size(), '-') << std::endl; + std::cout << Colors::CLRSCR() << Colors::REVERSE() << Colors::BLUE() << oss.str() << std::endl; if (complete) { std::cout << Colors::MAGENTA() << "Only listing complete results" << std::endl; } @@ -57,8 +56,8 @@ namespace platform { auto i = 0; int maxModel = results.maxModelSize(); int maxTitle = results.maxTitleSize(); - std::cout << Colors::GREEN() << " # Date " << std::setw(maxModel) << std::left << "Model" << " Score Name Score C/P Time Title" << std::endl; - std::cout << "=== ========== " << std::string(maxModel, '=') << " ========== ========= === ======= " << std::string(maxTitle, '=') << std::endl; + std::cout << Colors::IGREEN() << " # Date " << std::setw(maxModel) << std::left << "Model" << " Score Name Score C/P Time Title" << std::endl; + std::cout << "=== ========== " << std::string(maxModel, '=') << " ========== ========= === ======= " << std::string(maxTitle, '=') << Colors::RESET() << std::endl; for (int i = index_from; i <= index_to; i++) { auto color = (i % 2) ? Colors::BLUE() : Colors::CYAN(); std::cout << color << std::setw(3) << std::fixed << std::right << i << " "; @@ -181,9 +180,9 @@ namespace platform { while (!finished) { if (indexList) { auto [min_index, max_index] = paginator.getOffset(page); - std::tie(option, index) = parser.parse(Colors::GREEN(), mainOptions, 'r', min_index, max_index); + std::tie(option, index) = parser.parse(Colors::IGREEN(), mainOptions, 'r', min_index, max_index); } else { - std::tie(option, subIndex) = parser.parse(Colors::BLUE(), listOptions, 'r', 0, results.at(index).getJson()["results"].size() - 1); + std::tie(option, subIndex) = parser.parse(Colors::IBLUE(), listOptions, 'r', 0, results.at(index).getJson()["results"].size() - 1); } switch (option) { case 'p': diff --git a/src/manage/b_manage.cpp b/src/manage/b_manage.cpp index a35eb13..258bfaf 100644 --- a/src/manage/b_manage.cpp +++ b/src/manage/b_manage.cpp @@ -58,7 +58,7 @@ int main(int argc, char** argv) auto partial = program.get("partial"); auto compare = program.get("compare"); if (number == 0) { - number = std::max(0, numRows() - 5); // 5 is the number of lines used by the menu & header + number = std::max(0, numRows() - 4); // 4 is the number of lines used by the menu & header } if (complete) partial = false;