Browse Source

* pipi.c: implement --roll, RPL-style.

git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libpipi/trunk@2752 92316355-f0b4-4df1-b90c-862c8a59935f
remotes/tiles
sam 16 years ago
parent
commit
10baf86103
2 changed files with 29 additions and 0 deletions
  1. +21
    -0
      pipi/context.c
  2. +8
    -0
      src/pipi.c

+ 21
- 0
pipi/context.c View File

@@ -594,6 +594,27 @@ int pipi_command(pipi_context_t *ctx, char const *cmd, ...)
ctx->images[ctx->nimages - 1] = ctx->images[ctx->nimages - 2];
ctx->images[ctx->nimages - 2] = tmp;
}
else if(!strcmp(cmd, "roll"))
{
pipi_image_t *tmp;
char const *arg;
va_list ap;
int val;

va_start(ap, cmd);
arg = va_arg(ap, char const *);
va_end(ap);
val = atoi(arg);
if(val <= 0 || ctx->nimages < val)
return -1;
if(val == 1)
return 0;
tmp = ctx->images[ctx->nimages - val];
memmove(ctx->images + ctx->nimages - val,
ctx->images + ctx->nimages - val + 1,
(val - 1) * sizeof(*ctx->images));
ctx->images[ctx->nimages - 1] = tmp;
}
else
{
return -1;


+ 8
- 0
src/pipi.c View File

@@ -25,6 +25,14 @@ int main(int argc, char *argv[])
if(pipi_command(ctx, "swap") != 0)
return EXIT_FAILURE;
}
else if(!strcmp(argv[0], "--roll"))
{
if(argv[1] == NULL)
return EXIT_FAILURE;
if(pipi_command(ctx, "roll", argv[1]) != 0)
return EXIT_FAILURE;
argv++;
}
else if(!strcmp(argv[0], "--scale"))
{
if(argv[1] == NULL)


Loading…
Cancel
Save