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