source: libcaca/trunk/test/unicode.c @ 810

Last change on this file since 810 was 810, checked in by Sam Hocevar, 14 years ago
  • Renamed cucul_t into cucul_canvas_t. Eh ouais mon con.
  • Property svn:keywords set to Id
File size: 4.1 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 810 2006-04-18 12:59:07Z sam $
7 *
8 *  This program is free software; you can redistribute it and/or
9 *  modify it under the terms of the Do What The Fuck You Want To
10 *  Public License, Version 2, as published by Sam Hocevar. See
11 *  http://sam.zoy.org/wtfpl/COPYING for more details.
12 */
13
14#include "config.h"
15
16#if defined(HAVE_INTTYPES_H)
17#   include <inttypes.h>
18#else
19typedef unsigned char uint8_t;
20typedef unsigned short uint16_t;
21typedef unsigned int uint32_t;
22#endif
23
24#include "cucul.h"
25#include "caca.h"
26
27int main(void)
28{
29    caca_event_t ev;
30    cucul_canvas_t *c;
31    caca_t *kk;
32
33    c = cucul_create(0, 0);
34    kk = caca_attach(c);
35
36    cucul_set_color(c, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE);
37    cucul_putstr(c, 1, 1, "Basic Unicode support");
38
39    cucul_set_color(c, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK);
40    cucul_putstr(c, 1, 2, "This is ASCII:    | abc DEF 123 !@# |");
41    cucul_putstr(c, 1, 3, "This is Unicode:  | äßç δεφ ☺♥♀ ╞╬╗ |");
42    cucul_putstr(c, 1, 4, "And this is, too: | ἀβϛ ΔЗҒ ᚴᛒᛯ ♩♔✈ |");
43
44    cucul_putstr(c, 1, 5, "If the three lines do not have the same length, there is a bug somewhere.");
45
46    cucul_set_color(c, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE);
47    cucul_putstr(c, 1, 7, "Gradient glyphs");
48
49    cucul_set_color(c, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK);
50    cucul_putstr(c, 31,  8, "  0%");
51    cucul_putstr(c, 31,  9, " 25%");
52    cucul_putstr(c, 31, 10, " 50%");
53    cucul_putstr(c, 31, 11, " 75%");
54    cucul_putstr(c, 31, 12, "100%");
55
56    cucul_set_color(c, CUCUL_COLOR_LIGHTRED, CUCUL_COLOR_LIGHTGREEN);
57    cucul_putstr(c, 1,  8, "                             ");
58    cucul_putstr(c, 1,  9, "░░░░░░░░░░░░░░░░░░░░░░░░░░░░░");
59    cucul_putstr(c, 1, 10, "▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒");
60    cucul_putstr(c, 1, 11, "▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓");
61    cucul_putstr(c, 1, 12, "█████████████████████████████");
62
63    cucul_set_color(c, CUCUL_COLOR_LIGHTGREEN, CUCUL_COLOR_LIGHTRED);
64    cucul_putstr(c, 36,  8, "█████████████████████████████");
65    cucul_putstr(c, 36,  9, "▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓");
66    cucul_putstr(c, 36, 10, "▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒");
67    cucul_putstr(c, 36, 11, "░░░░░░░░░░░░░░░░░░░░░░░░░░░░░");
68    cucul_putstr(c, 36, 12, "                             ");
69
70    cucul_set_color(c, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE);
71    cucul_putstr(c, 1, 14, "Double width characters");
72
73    cucul_set_color(c, CUCUL_COLOR_LIGHTRED, CUCUL_COLOR_BLACK);
74    cucul_putstr(c, 1, 15, "| ドラゴン ボーレ |");
75    cucul_set_color(c, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK);
76    cucul_putstr(c, 1, 16, "| ()()()() ()()() |");
77    cucul_set_color(c, CUCUL_COLOR_YELLOW, CUCUL_COLOR_BLACK);
78    cucul_putstr(c, 1, 17, "| ドラゴン");
79    cucul_putstr(c, 10, 17, "ボーレ |");
80
81    cucul_set_color(c, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK);
82    cucul_putstr(c, 1, 18, "If the three lines do not have the same length, there is a bug somewhere.");
83
84    cucul_putstr(c, 1, 20, "CP437 glyphs: ☺ ☻ ♥ ♦ ♣ ♠ • ◘ ○ ◙ ♂ ♀ ♪ ♫ ☼ ► ◄ ↕ ‼ ¶ § ▬ ↨ ↑ ↓ → ← ∟ ↔ ▲ ▼");
85    cucul_putstr(c, 1, 21, "more CP437: α ß Γ π Σ σ µ τ Φ Θ Ω δ ∞ φ ε ∩ ≡ ± ≥ ≤ ⌠ ⌡ ÷ ≈ ° ∙ · √ ⁿ ² ■");
86    cucul_putstr(c, 1, 22, "drawing blocks: ███ ▓▓▓ ▒▒▒ ░░░ ▀ ▄ ▌ ▐ █ ▖ ▗ ▘ ▝ ▚ ▞ ▙ ▛ ▜ ▟");
87
88    caca_display(kk);
89
90    caca_get_event(kk, CACA_EVENT_KEY_PRESS, &ev, -1);
91
92    caca_detach(kk);
93    cucul_free(c);
94
95    return 0;
96}
97
Note: See TracBrowser for help on using the repository browser.