-
-
Notifications
You must be signed in to change notification settings - Fork 417
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmatrix.c: Adds Japanese characters support
Adds classic mode which can be invoked with "c", which uses Japanese characters instead of the regular English characters that cmatrix outputed earlier. Done to match up with the original matrix. The starting, ending, and range for randum number (corresponding to the unicode character) is modified to suite the Japanese character range. Requires appropriate Japanese fonts to make it work. Fixes #57 Signed-off-by: Abishek V Ashok <[email protected]>
- Loading branch information
1 parent
8b716ff
commit 80e1c4a
Showing
1 changed file
with
13 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -127,10 +127,11 @@ void c_die(char *msg, ...) { | |
} | ||
|
||
void usage(void) { | ||
printf(" Usage: cmatrix -[abBfhlsmVx] [-u delay] [-C color]\n"); | ||
printf(" Usage: cmatrix -[abBcfhlsmVx] [-u delay] [-C color]\n"); | ||
printf(" -a: Asynchronous scroll\n"); | ||
printf(" -b: Bold characters on\n"); | ||
printf(" -B: All bold characters (overrides -b)\n"); | ||
printf(" -c: Use Japanese characters as seen in the original matrix. Requires appropriate fonts\n"); | ||
printf(" -f: Force the linux $TERM type to be on\n"); | ||
printf(" -l: Linux mode (uses matrix console font)\n"); | ||
printf(" -L: Lock mode (can be closed from another terminal)\n"); | ||
|
@@ -285,13 +286,14 @@ int main(int argc, char *argv[]) { | |
int randnum = 0; | ||
int randmin = 0; | ||
int pause = 0; | ||
int classic = 0; | ||
|
||
srand((unsigned) time(NULL)); | ||
setlocale(LC_ALL, ""); | ||
|
||
/* Many thanks to morph- ([email protected]) for this getopt patch */ | ||
opterr = 0; | ||
while ((optchr = getopt(argc, argv, "abBfhlLnrosmxVu:C:")) != EOF) { | ||
while ((optchr = getopt(argc, argv, "abBcfhlLnrosmxVu:C:")) != EOF) { | ||
switch (optchr) { | ||
case 's': | ||
screensaver = 1; | ||
|
@@ -330,6 +332,9 @@ int main(int argc, char *argv[]) { | |
"white, yellow, cyan, magenta " "and black.\n"); | ||
} | ||
break; | ||
case 'c': | ||
classic = 1; | ||
break; | ||
case 'f': | ||
force = 1; | ||
break; | ||
|
@@ -430,7 +435,12 @@ if (console) { | |
} | ||
|
||
/* Set up values for random number generation */ | ||
if (console || xwindow) { | ||
if(classic) { | ||
/* Japanese character unicode range [they are seen in the original cmatrix] */ | ||
randnum = 63; | ||
randmin = 12288; | ||
highnum = 12351; | ||
} else if (console || xwindow) { | ||
randnum = 51; | ||
randmin = 166; | ||
highnum = 217; | ||
|