diff --git a/README.md b/README.md index cc0f412..0e2d90d 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ Usage: ./cfc-cli [OPTION] [ARGUMENT] -f [FLAG] All options: -f, --flag [FLAG] Prints the chosen flag -h, --height [Integer] Prints the flag with the chosen positive integer - -s, --string '[String]' Print the chosen flag with the given string (Flag width is not yet perfectly variable) + -c, --character '[Char]' Print the chosen flag with the given character (Only supports ASCII for now) --list List all available flags --help Prints out the help screen ``` diff --git a/cli-flag-collection.cpp b/cli-flag-collection.cpp index 8c87549..5216ff7 100644 --- a/cli-flag-collection.cpp +++ b/cli-flag-collection.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -11,23 +12,10 @@ int flagWidth; int flagHeight; -std::string flagStr(" "); +std::string flagChar(" "); void drawFlag(const unsigned char flagArray[][3], unsigned char flagStripes) { - short i, y, j, uni = 0; - short divLen = flagStr.size(); - - // Hopefully will handle all unicode things in a string - for (int k : flagStr) { - if (k < 0 && uni != 2) { - uni++; - } - if (uni == 2) { - divLen -= 1; - uni = 0; - } - } - //std::println("Divided length: {0} ({1} / {2})", (flagWidth / divLen), flagWidth, divLen); + short i, y, j; for (i = 0; i < flagStripes; i++) { if (flagHeight / flagStripes <= 0) { @@ -35,19 +23,20 @@ void drawFlag(const unsigned char flagArray[][3], unsigned char flagStripes) { break; } for (y = 0; y < flagHeight / flagStripes; y++) { - if (flagStr != " ") { - flagStr.shrink_to_fit(); + if (flagChar != " ") { + flagChar.shrink_to_fit(); std::print("\x1b[38;2;{0};{1};{2}m", flagArray[i][0], flagArray[i][1], flagArray[i][2]); } else { std::print("\x1b[48;2;{0};{1};{2}m", flagArray[i][0], flagArray[i][1], flagArray[i][2]); } - for (j = 0; j < flagWidth / divLen; j++) { - std::print("{0}", flagStr); + for (j = 0; j < flagWidth; j++) { + std::print("{0}", flagChar.at(0)); // Imma leave this how it is before i deal with bs letters like 'รค' } } std::println("\x1b[0m"); } + //std::println("Divided length: {0}\nflagWidth: {1}", (flagWidth / flagChar.size()), flagWidth); } int main(int argc, char **argv) { @@ -55,6 +44,8 @@ int main(int argc, char **argv) { * TODO: * - Bi flag handle * - add more flags for inclusivity + * - Handle Unicode argv (This fucking bitch is driving me insane I can't take it anymore) + * - ^ Handle strings(?) */ //std::setlocale(LC_CTYPE, "de_DE.utf8"); @@ -65,7 +56,7 @@ int main(int argc, char **argv) { {"list", no_argument, nullptr, LIST}, {"flag", required_argument, nullptr, 'f'}, {"height", required_argument, nullptr, 'h'}, - {"string", required_argument, nullptr, 's'}, + {"character", required_argument, nullptr, 'c'}, {nullptr, 0, nullptr, 0}, }; @@ -88,7 +79,7 @@ int main(int argc, char **argv) { short allFlagsSize = sizeof(allFlags) / sizeof(allFlags[0]); int opt; - while ((opt = getopt_long(argc, argv, "h:s:f:", long_options, nullptr)) != -1) { + while ((opt = getopt_long(argc, argv, "h:c:f:", long_options, nullptr)) != -1) { switch (opt) { case '0': std::print("{}", opt); @@ -102,13 +93,13 @@ int main(int argc, char **argv) { flagHeight = atoi(argv[optind - 1]); } break; - case 's': + case 'c': if (argc == 3 || argc == 2) { std::cerr << "You can't run '" << argv[1] << "' alone!\n"; return 1; } else { - flagStr = argv[optind - 1]; // I will keep this at index 0 so it can't even break it for now + flagChar.insert(0, argv[optind - 1]); // I will keep this at index 0 so it can't even break it for now } break; case 'f': @@ -158,8 +149,8 @@ int main(int argc, char **argv) { << "All options:\n" << "\t-f, --flag [FLAG]\t\tPrints the chosen flag\n" << "\t-h, --height [Integer]\t\tPrints the flag with the chosen positive integer\n" - << "\t-s, --string \'[String]\'\t\tPrint the chosen flag with the given string (Flag width is not yet perfectly variable)\n" - << "\t--list\t\t\t\tList all available flags\n" + << "\t-c, --character \'[Char]\'\tPrint the chosen flag with the given character (Only supports ASCII for now)\n" + << "\t--list\t\t\tList all available flags\n" << "\t--help\t\t\t\tPrints out the help screen\n"; return 0; case '?':