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

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