Watch
1
0
Fork
You've already forked cli-flag-collection
0
mirror of synced 2026-11-03 19:27:19 +00:00

Trying around with strings instead of char for future unicode support

This commit is contained in:
MysteryBirb 2026-09-13 21:10:57 +02:00
commit a89bdd4110

View file

@ -1,3 +1,4 @@
#include <clocale>
#include <cstdlib>
#include <iostream>
#include <string>
@ -11,29 +12,31 @@
int flagWidth;
int flagHeight;
char flagChar = ' ';
std::string flagChar(" ");
void drawFlag(const unsigned char flagArray[][3], unsigned char flagStripes) {
short i, y, j;
for (i = 0; i < flagStripes; i++) {
if (flagHeight / flagStripes <= 0) {
std::cerr << "Integer too small!" << std::endl;
break;
}
for (y = 0; y < flagHeight / flagStripes; y++) {
if (flagChar != ' ') {
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; j++) {
std::print("{0}", flagChar);
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) {
@ -41,9 +44,13 @@ int main(int argc, char **argv) {
* TODO:
* - Bi flag handle
* - add more flags for inclusivity
* - Handle Unicode argv
* - 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");
//std::locale::global(std::locale("de_DE.utf8"));
static struct option long_options[] {
{"help", no_argument, nullptr, HELP},
{"list", no_argument, nullptr, LIST},
@ -72,8 +79,6 @@ int main(int argc, char **argv) {
short allFlagsSize = sizeof(allFlags) / sizeof(allFlags[0]);
int opt;
// getopt(argc, argv, "lfh")
while ((opt = getopt_long(argc, argv, "h:c:f:", long_options, nullptr)) != -1) {
switch (opt) {
case '0':
@ -94,7 +99,7 @@ int main(int argc, char **argv) {
return 1;
}
else {
flagChar = *argv[optind - 1];
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':