diff --git a/cmatrix.c b/cmatrix.c index 4ace59e..177253f 100644 --- a/cmatrix.c +++ b/cmatrix.c @@ -81,6 +81,8 @@ int xwindow = 0; int lock = 0; cmatrix **matrix = (cmatrix **) NULL; int *length = NULL; /* Length of cols in each line */ +int space = 50; /* vertical density parameter */ +int skip = 2; /* horizontal density parameter */ int *spaces = NULL; /* Spaces left to fill */ int *updates = NULL; /* What does this do again? */ #ifndef _WIN32 @@ -153,6 +155,8 @@ void usage(void) { printf(" -h: Print usage and exit\n"); printf(" -n: No bold characters (overrides -b and -B, default)\n"); printf(" -s: \"Screensaver\" mode, exits on first keystroke\n"); + printf(" -S vertical character density; default 50\n"); + printf(" -T horizontal character density; default 2\n"); printf(" -x: X window mode, use if your xterm is using mtx.pcf\n"); printf(" -V: Print version information and exit\n"); printf(" -M [message]: Prints your message in the center of the screen. Overrides -L's default message.\n"); @@ -162,6 +166,27 @@ 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("\n\n Runtime keys:\n"); + printf(" q: quit\n"); + printf(" a: Asynchronous scroll\n"); + printf(" b: Bold characters on\n"); + printf(" B: All bold characters (overrides -b)\n"); + printf(" n: No bold characters (overrides -b and -B, default)\n"); + printf(" 0-9: Screen update delay\n"); + printf(" !: red\n"); + printf(" @: green\n"); + printf(" #: yellow\n"); + printf(" $: blue\n"); + printf(" %%: magenta\n"); + printf(" ^: cyan\n"); + printf(" &: white\n"); + printf(" m: increase vertical density by 10\n"); + printf(" l: decrease vertical density by 10\n"); + + printf("\n\n Examples:\n"); + printf(" In console try: cmatrix -lab -S 120 -T 1\n"); + printf(" In X try: xterm -bg black -fn mtx -e cmatrix -xab\n"); } void version(void) { @@ -215,14 +240,14 @@ void var_init() { /* Make the matrix */ for (i = 0; i <= LINES; i++) { - for (j = 0; j <= COLS - 1; j += 2) { + for (j = 0; j <= COLS - 1; j += skip) { matrix[i][j].val = -1; } } - for (j = 0; j <= COLS - 1; j += 2) { + for (j = 0; j <= COLS - 1; j += skip) { /* Set up spaces[] array of how many spaces to skip */ - spaces[j] = (int) rand() % LINES + 1; + spaces[j] = (int) rand() % space; /* And length of the stream */ length[j] = (int) rand() % (LINES - 3) + 3; @@ -333,7 +358,7 @@ int main(int argc, char *argv[]) { /* Many thanks to morph- (morph@jmss.com) for this getopt patch */ opterr = 0; - while ((optchr = getopt(argc, argv, "abBcfhlLnrosmxkVM:u:C:t:")) != EOF) { + while ((optchr = getopt(argc, argv, "abBcfhlLnrosmxkVM:S:T:u:C:t:")) != EOF) { switch (optchr) { case 's': screensaver = 1; @@ -407,6 +432,14 @@ int main(int argc, char *argv[]) { case 'x': xwindow = 1; break; + case 'S': + space = atoi(optarg); + if (space <= 0) + space = 1; + break; + case 'T': + skip = atoi(optarg); + break; case 'V': version(); exit(0); @@ -525,7 +558,7 @@ if (console) { highnum = 217; } else { randmin = 33; - highnum = 123; + highnum = 123; /* shouldn't this be 33 + 93 = 126 ?*/ } randnum = highnum - randmin; @@ -606,6 +639,16 @@ if (console) { case '9': update = keypress - 48; break; + case 'm': + space += 10; + if (space <= 0) + space = 1; + break; + case 'l': + space -= 10; + if (space <= 0) + space = 1; + break; case '!': mcolor = COLOR_RED; rainbow = 0; @@ -629,7 +672,7 @@ if (console) { case 'r': rainbow = 1; break; - case 'm': + case 'M': lambda = !lambda; break; case '^': @@ -648,7 +691,7 @@ if (console) { } } } - for (j = 0; j <= COLS - 1; j += 2) { + for (j = 0; j <= COLS - 1; j += skip) { if ((count > updates[j] || asynch == 0) && pause == 0) { /* I don't like old-style scrolling, yuck */ @@ -692,7 +735,7 @@ if (console) { length[j] = (int) rand() % (LINES - 3) + 3; matrix[0][j].val = (int) rand() % randnum + randmin; - spaces[j] = (int) rand() % LINES + 1; + spaces[j] = (int) rand() % space; } i = 0; y = 0;