Skip to content
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