Skip to content

Commit 9a920e8

Browse files
tyler-cromwellklange
authored andcommitted
Converted spaces to tabs, and changed to setting a delay instead of a speed up amount
1 parent b81aac9 commit 9a920e8

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

nyancat.1

+4-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ Do not set the titlebar text.
3030
.B \-e, \-\-no\-clear
3131
Do not clear the display between frames.
3232
.TP
33-
.B \-u, \-\-usleep
34-
Set how frequently the image refreshes (1 <= t <= 10).
33+
.B \-d, \-\-delay
34+
Delay image rendering by anywhere between 10ms and 1000ms.
35+
.br
36+
Default (90ms) is used if amount is out of range.
3537
.TP
3638
.B \-f, \-\-frames
3739
Display the requested number of frames, then quit.

src/nyancat.c

+10-10
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ void usage(char * argv[]) {
335335
" -n --no-counter \033[3mDo not display the timer\033[0m\n"
336336
" -s --no-title \033[3mDo not set the titlebar text\033[0m\n"
337337
" -e --no-clear \033[3mDo not clear the display between frames\033[0m\n"
338-
" -u --usleep \033[3mSet how frequently the image refreshes (1 <= t <= 10)\033[0m\n"
338+
" -d --delay \033[3mDelay image rendering by anywhere between 10ms and 1000ms\n"
339339
" -f --frames \033[3mDisplay the requested number of frames, then quit\033[0m\n"
340340
" -r --min-rows \033[3mCrop the animation from the top\033[0m\n"
341341
" -R --max-rows \033[3mCrop the animation from the bottom\033[0m\n"
@@ -370,7 +370,7 @@ int main(int argc, char ** argv) {
370370
{"no-counter", no_argument, 0, 'n'},
371371
{"no-title", no_argument, 0, 's'},
372372
{"no-clear", no_argument, 0, 'e'},
373-
{"usleep", required_argument, 0, 'u'},
373+
{"delay", required_argument, 0, 'd'},
374374
{"frames", required_argument, 0, 'f'},
375375
{"min-rows", required_argument, 0, 'r'},
376376
{"max-rows", required_argument, 0, 'R'},
@@ -381,12 +381,12 @@ int main(int argc, char ** argv) {
381381
{0,0,0,0}
382382
};
383383

384-
/* Determine the usleep time */
385-
useconds_t speed_divisor = 1;
384+
/* Time delay in milliseconds */
385+
int delay_ms = 90; // Default to original value
386386

387387
/* Process arguments */
388388
int index, c;
389-
while ((c = getopt_long(argc, argv, "eshiItnu:f:r:R:c:C:W:H:", long_opts, &index)) != -1) {
389+
while ((c = getopt_long(argc, argv, "eshiItnd:f:r:R:c:C:W:H:", long_opts, &index)) != -1) {
390390
if (!c) {
391391
if (long_opts[index].flag == 0) {
392392
c = long_opts[index].val;
@@ -415,10 +415,10 @@ int main(int argc, char ** argv) {
415415
case 'n':
416416
show_counter = 0;
417417
break;
418-
case 'u':
419-
if (1 <= atoi(optarg) && atoi(optarg) <= 10)
420-
speed_divisor = atoi(optarg);
421-
break;
418+
case 'd':
419+
if (10 <= atoi(optarg) && atoi(optarg) <= 1000)
420+
delay_ms = atoi(optarg);
421+
break;
422422
case 'f':
423423
frame_count = atoi(optarg);
424424
break;
@@ -916,7 +916,7 @@ int main(int argc, char ** argv) {
916916
i = 0;
917917
}
918918
/* Wait */
919-
usleep(90000 / speed_divisor);
919+
usleep(1000 * delay_ms);
920920
}
921921
return 0;
922922
}

0 commit comments

Comments
 (0)