commit 90d79c5a47a33f322aa8a376816dde11ce8ff1f7
parent 39c8d624a1306f052a5a57d005ea7046f91028ab
Author: z3bra <willy@mailoo.org>
Date: Wed, 26 Mar 2014 13:39:33 +0100
Can now output a new line after each scroll step
Diffstat:
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/skroll.1 b/skroll.1
@@ -3,20 +3,22 @@
skroll - make a given text scroll
.SH SYNOPSIS
.B skroll
-.RI [\| \-hl\| ]\ [\| -n\ num\| ]\ [\| -d\ delay\| ]
+.RI [\| \-hlr\| ]\ [\| -n\ num\| ]\ [\| -d\ delay\| ]
.SH DESCRIPTION
.PP
.B skroll
reads text on stdin and make it scroll to stdout
.TP
+.B \-d delay
+Make scroll steps last <delay> seconds
.B \-h
Display a help text
.B \-l
Loop text forever
.B \-n num
Show <num> char at a time
-.B \-d delay
-Make scroll steps last <delay> seconds
+.B \-r
+Output a new line after each step
.SH BUGS
.PP
No bugs known actually. Feel free to report them at willy@mailoo.org
diff --git a/skroll.c b/skroll.c
@@ -24,6 +24,7 @@
#define BUFFER_SIZE 512
+static bool newline = false;/* print a new line after each step */
static bool loop = false; /* wether to loop text or not */
static float delay = 1; /* scroll speed, in usec */
static int number = 10; /* number of chars to be shown at the same time */
@@ -60,6 +61,8 @@ void skroll (const char *input)
zero_fill(&buf, number);
printf("\r%s", buf);
+ if (newline) putc('\n', stdout);
+
fflush(stdout);
usleep(delay*1000000);
}
@@ -91,14 +94,15 @@ int main (int argc, char **argv)
char ch;
const char *buf = NULL;
- while ( (ch = getopt(argc, argv, "hd:ln:")) != -1 ) {
+ while ( (ch = getopt(argc, argv, "hd:ln:r")) != -1 ) {
switch (ch) {
case 'h':
- printf("usage: %s [-hl] [-d delay] [-n number]", argv[0]);
+ printf("usage: %s [-hlr] [-d delay] [-n number]", argv[0]);
break;
case 'd': delay = strtof(optarg, NULL); break;
case 'n': number = strtoul(optarg, NULL, 10); break;
case 'l': loop = true; break;
+ case 'r': newline = true; break;
}
}