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

Last change on this file since 2821 was 2821, checked in by Sam Hocevar, 11 years ago

Starting refactoring to get rid of libcucul. The initial reason for the
split is rendered moot by the plugin system: when enabled, binaries do
not link directly with libX11 or libGL. I hope this is a step towards
more consisteny and clarity.

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