Refactor colors in b_manage

This commit is contained in:
2024-03-15 00:18:30 +01:00
parent 00bb7f4680
commit d7f92c9682
3 changed files with 20 additions and 22 deletions

View File

@@ -3,28 +3,27 @@
#include <string> #include <string>
class Colors { class Colors {
public: 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 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 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 RESET() { return "\033[0m"; }
static std::string BOLD() { return "\033[1m"; } static std::string BOLD() { return "\033[1m"; }
static std::string UNDERLINE() { return "\033[4m"; } static std::string UNDERLINE() { return "\033[4m"; }
static std::string BLINK() { return "\033[5m"; } static std::string BLINK() { return "\033[5m"; }
static std::string REVERSE() { return "\033[7m"; } static std::string REVERSE() { return "\033[7m"; }
static std::string CONCEALED() { return "\033[8m"; } 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"; } static std::string CLRSCR() { return "\033[2J\033[1;1H"; }
}; };

View File

@@ -46,8 +46,7 @@ namespace platform {
auto [index_from, index_to] = paginator.getOffset(page); auto [index_from, index_to] = paginator.getOffset(page);
std::stringstream oss; std::stringstream oss;
oss << index_to - index_from + 1 << " Results on screen - Page " << page << " of " << paginator.getPages(); 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 << Colors::CLRSCR() << Colors::REVERSE() << Colors::BLUE() << oss.str() << std::endl;
std::cout << std::string(oss.str().size(), '-') << std::endl;
if (complete) { if (complete) {
std::cout << Colors::MAGENTA() << "Only listing complete results" << std::endl; std::cout << Colors::MAGENTA() << "Only listing complete results" << std::endl;
} }
@@ -57,8 +56,8 @@ namespace platform {
auto i = 0; auto i = 0;
int maxModel = results.maxModelSize(); int maxModel = results.maxModelSize();
int maxTitle = results.maxTitleSize(); 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 << 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, '=') << std::endl; std::cout << "=== ========== " << std::string(maxModel, '=') << " ========== ========= === ======= " << std::string(maxTitle, '=') << Colors::RESET() << std::endl;
for (int i = index_from; i <= index_to; i++) { for (int i = index_from; i <= index_to; i++) {
auto color = (i % 2) ? Colors::BLUE() : Colors::CYAN(); auto color = (i % 2) ? Colors::BLUE() : Colors::CYAN();
std::cout << color << std::setw(3) << std::fixed << std::right << i << " "; std::cout << color << std::setw(3) << std::fixed << std::right << i << " ";
@@ -181,9 +180,9 @@ namespace platform {
while (!finished) { while (!finished) {
if (indexList) { if (indexList) {
auto [min_index, max_index] = paginator.getOffset(page); 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 { } 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) { switch (option) {
case 'p': case 'p':

View File

@@ -58,7 +58,7 @@ int main(int argc, char** argv)
auto partial = program.get<bool>("partial"); auto partial = program.get<bool>("partial");
auto compare = program.get<bool>("compare"); auto compare = program.get<bool>("compare");
if (number == 0) { 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) if (complete)
partial = false; partial = false;