| 1 |
/* |
| 2 |
* driver libcaca Unicode rendering test program |
| 3 |
* Copyright (c) 2007-2012 Sam Hocevar <[email protected]> |
| 4 |
* All Rights Reserved |
| 5 |
* |
| 6 |
* This program is free software. It comes without any warranty, to |
| 7 |
* the extent permitted by applicable law. You can redistribute it |
| 8 |
* and/or modify it under the terms of the Do What the Fuck You Want |
| 9 |
* to Public License, Version 2, as published by Sam Hocevar. See |
| 10 |
* http://www.wtfpl.net/ for more details. |
| 11 |
*/ |
| 12 |
|
| 13 |
#include "config.h" |
| 14 |
|
| 15 |
#if !defined(__KERNEL__) |
| 16 |
# include <string.h> |
| 17 |
# include <stdio.h> |
| 18 |
#endif |
| 19 |
|
| 20 |
#include "caca.h" |
| 21 |
|
| 22 |
int main(int argc, char *argv[]) |
| 23 |
{ |
| 24 |
char const * const *list; |
| 25 |
caca_display_t *dp; |
| 26 |
caca_canvas_t *cv; |
| 27 |
|
| 28 |
list = caca_get_display_driver_list(); |
| 29 |
|
| 30 |
dp = caca_create_display(NULL); |
| 31 |
if(dp == NULL) |
| 32 |
{ |
| 33 |
printf("cannot create display\n"); |
| 34 |
return -1; |
| 35 |
} |
| 36 |
|
| 37 |
cv = caca_get_canvas(dp); |
| 38 |
caca_set_color_ansi(cv, CACA_WHITE, CACA_BLACK); |
| 39 |
|
| 40 |
while(1) |
| 41 |
{ |
| 42 |
char const *driver; |
| 43 |
int i, cur = 0; |
| 44 |
|
| 45 |
caca_put_str(cv, 1, 0, "Available drivers:"); |
| 46 |
|
| 47 |
driver = caca_get_display_driver(dp); |
| 48 |
|
| 49 |
for(i = 0; list[i]; i += 2) |
| 50 |
{ |
| 51 |
int match = !strcmp(list[i], driver); |
| 52 |
|
| 53 |
if(match) |
| 54 |
cur = i; |
| 55 |
caca_draw_line(cv, 0, i + 2, 9999, i + 2, ' '); |
| 56 |
caca_printf(cv, 2, i + 2, "%c %s (%s)", |
| 57 |
match ? '*' : ' ', list[i], list[i + 1]); |
| 58 |
} |
| 59 |
|
| 60 |
caca_put_str(cv, 1, i + 2, "Switching driver in 5 seconds"); |
| 61 |
|
| 62 |
caca_refresh_display(dp); |
| 63 |
|
| 64 |
if(caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, 5000000)) |
| 65 |
break; |
| 66 |
|
| 67 |
do |
| 68 |
{ |
| 69 |
cur += 2; |
| 70 |
if(list[cur] && !strcmp(list[cur], "raw")) |
| 71 |
cur += 2; |
| 72 |
if(!list[cur]) |
| 73 |
cur = 0; |
| 74 |
} |
| 75 |
while(caca_set_display_driver(dp, list[cur])); |
| 76 |
} |
| 77 |
|
| 78 |
caca_free_display(dp); |
| 79 |
|
| 80 |
return 0; |
| 81 |
} |
| 82 |
|