Code

release v0.29
[ncmpc.git] / test / run_hscroll.c
1 #include "hscroll.h"
2 #include "config.h"
4 #include <glib.h>
5 #include <stdlib.h>
7 #ifdef ENABLE_LOCALE
8 #include <locale.h>
9 #endif
11 int main(int argc, char **argv)
12 {
13         struct hscroll hscroll;
14         char *p;
15         unsigned width, count;
17         if (argc != 5) {
18                 g_printerr("Usage: %s TEXT SEPARATOR WIDTH COUNT\n", argv[0]);
19                 return 1;
20         }
22 #ifdef ENABLE_LOCALE
23         setlocale(LC_CTYPE,"");
24 #endif
26         hscroll_reset(&hscroll);
28         width = atoi(argv[3]);
29         count = atoi(argv[4]);
31         for (unsigned i = 0; i < count; ++i) {
32                 p = strscroll(&hscroll, argv[1], argv[2], width);
33                 g_print("%s\n", p);
34                 g_free(p);
36                 hscroll_step(&hscroll);
37         }
39         hscroll_reset(&hscroll);
41         return 0;
42 }