Debian Codegraph @

examples/unicode.c

raw
1 /*
2 * unicode libcaca Unicode rendering test program
3 * Copyright (c) 2006-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 <stdio.h>
17 #endif
18
19 #include "caca.h"
20
21 int main(int argc, char *argv[])
22 {
23 caca_canvas_t *cv;
24 caca_display_t *dp;
25
26 cv = caca_create_canvas(0, 0);
27 if(cv == NULL)
28 {
29 printf("Can't created canvas\n");
30 return -1;
31 }
32 dp = caca_create_display(cv);
33 if(dp == NULL)
34 {
35 printf("Can't create display\n");
36 return -1;
37 }
38 caca_set_color_ansi(cv, CACA_WHITE, CACA_BLUE);
39 caca_put_str(cv, 1, 1, "Basic Unicode support");
40
41 caca_set_color_ansi(cv, CACA_DEFAULT, CACA_TRANSPARENT);
42 caca_put_str(cv, 1, 2, "This is ASCII: | abc DEF 123 !@# |");
43 caca_put_str(cv, 1, 3, "This is Unicode: | äßç δεφ ☺♥♀ ╞╬╗ |");
44 caca_put_str(cv, 1, 4, "And this is, too: | ἀβϛ ΔЗҒ ᚴᛒᛯ ♩♔✈ |");
45 caca_put_str(cv, 41, 4, "Size test: 018adxmygWX'_ÍçÕĔŷ ﻙ が本");
46
47 caca_put_str(cv, 1, 5, "If the three lines do not have the same length, there is a bug somewhere.");
48
49 caca_set_color_ansi(cv, CACA_WHITE, CACA_BLUE);
50 caca_put_str(cv, 1, 7, "Gradient glyphs");
51
52 caca_set_color_ansi(cv, CACA_DEFAULT, CACA_TRANSPARENT);
53 caca_put_str(cv, 31, 8, " 0%");
54 caca_put_str(cv, 31, 9, " 25%");
55 caca_put_str(cv, 31, 10, " 50%");
56 caca_put_str(cv, 31, 11, " 75%");
57 caca_put_str(cv, 31, 12, "100%");
58
59 caca_set_color_ansi(cv, CACA_LIGHTRED, CACA_LIGHTGREEN);
60 caca_put_str(cv, 1, 8, " ");
61 caca_put_str(cv, 1, 9, "░░░░░░░░░░░░░░░░░░░░░░░░░░░░░");
62 caca_put_str(cv, 1, 10, "▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒");
63 caca_put_str(cv, 1, 11, "▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓");
64 caca_put_str(cv, 1, 12, "█████████████████████████████");
65
66 caca_set_color_ansi(cv, CACA_LIGHTGREEN, CACA_LIGHTRED);
67 caca_put_str(cv, 36, 8, "█████████████████████████████");
68 caca_put_str(cv, 36, 9, "▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓");
69 caca_put_str(cv, 36, 10, "▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒");
70 caca_put_str(cv, 36, 11, "░░░░░░░░░░░░░░░░░░░░░░░░░░░░░");
71 caca_put_str(cv, 36, 12, " ");
72
73 caca_set_color_ansi(cv, CACA_WHITE, CACA_BLUE);
74 caca_put_str(cv, 1, 14, "Double width characters");
75
76 caca_set_color_ansi(cv, CACA_LIGHTRED, CACA_TRANSPARENT);
77 caca_put_str(cv, 1, 15, "| ドラゴン ボーレ |");
78 caca_set_color_ansi(cv, CACA_DEFAULT, CACA_TRANSPARENT);
79 caca_put_str(cv, 1, 16, "| ()()()() ()()() |");
80 caca_set_color_ansi(cv, CACA_YELLOW, CACA_TRANSPARENT);
81 caca_put_str(cv, 1, 17, "| ドラゴン");
82 caca_put_str(cv, 12, 17, "ボーレ |");
83
84 caca_set_color_ansi(cv, CACA_DEFAULT, CACA_TRANSPARENT);
85 caca_put_str(cv, 1, 18, "If the three lines do not have the same length, there is a bug somewhere.");
86
87 caca_put_str(cv, 1, 20, "CP437 glyphs: ☺ ☻ ♥ ♦ ♣ ♠ • ◘ ○ ◙ ♂ ♀ ♪ ♫ ☼ ► ◄ ↕ ‼ ¶ § ▬ ↨ ↑ ↓ → ← ∟ ↔ ▲ ▼");
88 caca_put_str(cv, 1, 21, "more CP437: α ß Γ π Σ σ µ τ Φ Θ Ω δ ∞ φ ε ∩ ≡ ± ≥ ≤ ⌠ ⌡ ÷ ≈ ° ∙ · √ ⁿ ² ■");
89 caca_put_str(cv, 1, 22, "drawing blocks: ███ ▓▓▓ ▒▒▒ ░░░ ▀ ▄ ▌ ▐ █ ▖ ▗ ▘ ▝ ▚ ▞ ▙ ▛ ▜ ▟ ─ │ ┌ ┐ └ ┘ ├ ┤");
90 caca_put_str(cv, 1, 23, "more drawing: ┬ ┴ ┼ ═ ║ ╒ ╓ ╔ ╕ ╖ ╗ ╘ ╙ ╚ ╛ ╜ ╝ ╞ ╟ ╠ ╡ ╢ ╣ ╤ ╥ ╦ ╧ ╨ ╩ ╪ ╫ ╬");
91 caca_put_str(cv, 1, 24, "misc Unicode: ● ☭ ☮ ☯ ♔ ♛ ♙ ♞ ⚒ ⚓ ⚠");
92
93 caca_refresh_display(dp);
94
95 caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, -1);
96
97 caca_free_display(dp);
98 caca_free_canvas(cv);
99
100 return 0;
101 }
102