blind

suckless command-line video editing utility
git clone git://git.suckless.org/blind
Log | Files | Refs | README | LICENSE

commit 541acb83c081808dc2c19e2cb9a891792462999b
parent 71a9b4ac439c4e354432a8f828632f39c0dd6c29
Author: Mattias Andrée <maandree@kth.se>
Date:   Tue, 10 Jan 2017 07:36:48 +0100

vu-single-colour: add support for infinity repeat

Signed-off-by: Mattias Andrée <maandree@kth.se>

Diffstat:
Msrc/vu-single-colour.c | 14++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/vu-single-colour.c b/src/vu-single-colour.c @@ -3,6 +3,7 @@ #include "util.h" #include <inttypes.h> +#include <string.h> #include <unistd.h> typedef double pixel_t[4]; @@ -10,7 +11,7 @@ typedef double pixel_t[4]; static void usage(void) { - eprintf("usage: %s [-f frames] -w width -h height (X Y Z | Y) [alpha]\n", argv0); + eprintf("usage: %s [-f frames | -f 'inf'] -w width -h height (X Y Z | Y) [alpha]\n", argv0); } int @@ -21,11 +22,16 @@ main(int argc, char *argv[]) size_t x, y, n; pixel_t buf[1024]; ssize_t r; + int inf = 0; + char *arg; ARGBEGIN { case 'f': - if (tozu(EARGF(usage()), 1, SIZE_MAX, &frames)) - eprintf("argument of -f must be an integer in [1, %zu]\n", SIZE_MAX); + arg = EARGF(usage()); + if (!strcmp(arg, "inf")) + inf = 1, frames = 0; + else if (tozu(arg, 1, SIZE_MAX, &frames)) + eprintf("argument of -f must be an integer in [1, %zu] or 'inf'\n", SIZE_MAX); break; case 'w': if (tozu(EARGF(usage()), 1, SIZE_MAX, &width)) @@ -64,7 +70,7 @@ main(int argc, char *argv[]) buf[x][2] = Z; buf[x][3] = alpha; } - while (frames--) { + while (inf || frames--) { for (y = height; y--;) { for (x = width; x;) { x -= n = ELEMENTSOF(buf) < x ? ELEMENTSOF(buf) : x;