Skip to content

Allow user to set start and end of unicode chars #196

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion cmatrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ void usage(void) {
printf(" -m: lambda mode\n");
printf(" -k: Characters change while scrolling. (Works without -o opt.)\n");
printf(" -t [tty]: Set tty to use\n");
printf(" -A [Unicode]: Set minimum Unicode (use 0x16A0 for runes)\n");
printf(" -Z [Unicode]: Set maximum Unicode (0x16FF for runes)\n");
}

void version(void) {
Expand Down Expand Up @@ -333,13 +335,15 @@ int main(int argc, char *argv[]) {
int changes = 0;
char *msg = "";
char *tty = NULL;
int userrandmin = 33;
int userhighnum = 123;

srand((unsigned) time(NULL));
setlocale(LC_ALL, "");

/* Many thanks to morph- ([email protected]) for this getopt patch */
opterr = 0;
while ((optchr = getopt(argc, argv, "abBcfhlLnrosmxkVM:u:C:t:")) != EOF) {
while ((optchr = getopt(argc, argv, "abBcfhlLnrosmxkVM:u:C:t:A:Z:")) != EOF) {
switch (optchr) {
case 's':
screensaver = 1;
Expand All @@ -355,6 +359,13 @@ int main(int argc, char *argv[]) {
case 'B':
bold = 2;
break;
case 'A':
if (optarg)
userrandmin = (int)strtol(optarg, NULL, 16);
break;
case 'Z':
userhighnum = (int)strtol(optarg, NULL, 16);
break;
case 'C':
if (!strcasecmp(optarg, "green")) {
mcolor = COLOR_GREEN;
Expand Down Expand Up @@ -444,6 +455,10 @@ int main(int argc, char *argv[]) {
setenv("TERM", "linux", 1);
#endif
}
if ((userrandmin!=33 || userhighnum!=123) && (userhighnum - userrandmin<1)) {
fprintf(stderr, "%d is not enough letters between Minimum and Maximum unicode.\n", userhighnum - userrandmin);
exit(EXIT_FAILURE);
}
if (tty) {
FILE *ftty = fopen(tty, "r+");
if (!ftty) {
Expand Down Expand Up @@ -532,6 +547,9 @@ if (console) {
} else if (console || xwindow) {
randmin = 166;
highnum = 217;
} else if (userrandmin!=33 || userhighnum!=123) {
randmin = userrandmin;
highnum = userhighnum;
} else {
randmin = 33;
highnum = 123;
Expand Down