source: libcaca/trunk/examples/unicode.c @ 2299

Last change on this file since 2299 was 2299, checked in by Sam Hocevar, 12 years ago
  • Remove #include <stdint.h> etc. from "common.h". Instead, make sure that <cucul.h> will provide the C99 types, even if libcaca has been installed.
  • Rename what's left of "common.h" to "stubs.h".
  • Remove all references to erroneous <inttypes.h> from source files.
  • Property svn:keywords set to Id
File size: 4.6 KB
Line 
1/*
2 *  unicode       libcaca Unicode rendering test program
3 *  Copyright (c) 2006 Sam Hocevar <sam@zoy.org>
4 *                All Rights Reserved
5 *
6 *  $Id: unicode.c 2299 2008-04-19 12:42:50Z sam $
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 <stdio.h>
19#endif
20
21#include "cucul.h"
22#include "caca.h"
23
24int main(int argc, char *argv[])
25{
26    cucul_canvas_t *cv;
27    caca_display_t *dp;
28
29    cv = cucul_create_canvas(0, 0);
30    if(cv == NULL)
31    {
32        printf("Can't created canvas\n");
33        return -1;
34    }
35    dp = caca_create_display(cv);
36    if(dp == NULL)
37    {
38        printf("Can't create display\n");
39        return -1;
40    }
41    cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE);
42    cucul_put_str(cv, 1, 1, "Basic Unicode support");
43
44    cucul_set_color_ansi(cv, CUCUL_DEFAULT, CUCUL_TRANSPARENT);
45    cucul_put_str(cv, 1, 2, "This is ASCII:    | abc DEF 123 !@# |");
46    cucul_put_str(cv, 1, 3, "This is Unicode:  | äßç δεφ ☺♥♀ ╞╬╗ |");
47    cucul_put_str(cv, 1, 4, "And this is, too: | ἀβϛ ΔЗҒ ᚴᛒᛯ ♩♔✈ |");
48
49    cucul_put_str(cv, 1, 5, "If the three lines do not have the same length, there is a bug somewhere.");
50
51    cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE);
52    cucul_put_str(cv, 1, 7, "Gradient glyphs");
53
54    cucul_set_color_ansi(cv, CUCUL_DEFAULT, CUCUL_TRANSPARENT);
55    cucul_put_str(cv, 31,  8, "  0%");
56    cucul_put_str(cv, 31,  9, " 25%");
57    cucul_put_str(cv, 31, 10, " 50%");
58    cucul_put_str(cv, 31, 11, " 75%");
59    cucul_put_str(cv, 31, 12, "100%");
60
61    cucul_set_color_ansi(cv, CUCUL_LIGHTRED, CUCUL_LIGHTGREEN);
62    cucul_put_str(cv, 1,  8, "                             ");
63    cucul_put_str(cv, 1,  9, "░░░░░░░░░░░░░░░░░░░░░░░░░░░░░");
64    cucul_put_str(cv, 1, 10, "▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒");
65    cucul_put_str(cv, 1, 11, "▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓");
66    cucul_put_str(cv, 1, 12, "█████████████████████████████");
67
68    cucul_set_color_ansi(cv, CUCUL_LIGHTGREEN, CUCUL_LIGHTRED);
69    cucul_put_str(cv, 36,  8, "█████████████████████████████");
70    cucul_put_str(cv, 36,  9, "▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓");
71    cucul_put_str(cv, 36, 10, "▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒");
72    cucul_put_str(cv, 36, 11, "░░░░░░░░░░░░░░░░░░░░░░░░░░░░░");
73    cucul_put_str(cv, 36, 12, "                             ");
74
75    cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE);
76    cucul_put_str(cv, 1, 14, "Double width characters");
77
78    cucul_set_color_ansi(cv, CUCUL_LIGHTRED, CUCUL_TRANSPARENT);
79    cucul_put_str(cv, 1, 15, "| ドラゴン ボーレ |");
80    cucul_set_color_ansi(cv, CUCUL_DEFAULT, CUCUL_TRANSPARENT);
81    cucul_put_str(cv, 1, 16, "| ()()()() ()()() |");
82    cucul_set_color_ansi(cv, CUCUL_YELLOW, CUCUL_TRANSPARENT);
83    cucul_put_str(cv, 1, 17, "| ドラゴン");
84    cucul_put_str(cv, 12, 17, "ボーレ |");
85
86    cucul_set_color_ansi(cv, CUCUL_DEFAULT, CUCUL_TRANSPARENT);
87    cucul_put_str(cv, 1, 18, "If the three lines do not have the same length, there is a bug somewhere.");
88
89    cucul_put_str(cv, 1, 20, "CP437 glyphs: ☺ ☻ ♥ ♦ ♣ ♠ • ◘ ○ ◙ ♂ ♀ ♪ ♫ ☼ ► ◄ ↕ ‼ ¶ § ▬ ↨ ↑ ↓ → ← ∟ ↔ ▲ ▼");
90    cucul_put_str(cv, 1, 21, "more CP437: α ß Γ π Σ σ µ τ Φ Θ Ω δ ∞ φ ε ∩ ≡ ± ≥ ≤ ⌠ ⌡ ÷ ≈ ° ∙ · √ ⁿ ² ■");
91    cucul_put_str(cv, 1, 22, "drawing blocks: ███ ▓▓▓ ▒▒▒ ░░░ ▀ ▄ ▌ ▐ █ ▖ ▗ ▘ ▝ ▚ ▞ ▙ ▛ ▜ ▟ ─ │ ┌ ┐ └ ┘ ├ ┤");
92    cucul_put_str(cv, 1, 23, "more drawing: ┬ ┴ ┼ ═ ║ ╒ ╓ ╔ ╕ ╖ ╗ ╘ ╙ ╚ ╛ ╜ ╝ ╞ ╟ ╠ ╡ ╢ ╣ ╤ ╥ ╦ ╧ ╨ ╩ ╪ ╫ ╬");
93    cucul_put_str(cv, 1, 24, "misc Unicode: ● ☭ ☮ ☯ ♔ ♛ ♙ ♞ ⚒ ⚓ ⚠");
94
95    caca_refresh_display(dp);
96
97    caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, -1);
98
99    caca_free_display(dp);
100    cucul_free_canvas(cv);
101
102    return 0;
103}
104
Note: See TracBrowser for help on using the repository browser.