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

Last change on this file since 849 was 849, checked in by Sam Hocevar, 14 years ago
  • Allow the caca_event_t *ev argument for caca_get_event() to be NULL.
  • Property svn:keywords set to Id
File size: 4.2 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 849 2006-04-22 19:46:43Z 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 <stdio.h>
25
26#include "cucul.h"
27#include "caca.h"
28
29int main(void)
30{
31    cucul_canvas_t *cv;
32    caca_display_t *dp;
33
34    cv = cucul_create_canvas(0, 0);
35    dp = caca_create_display(cv);
36
37    cucul_set_color(cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE);
38    cucul_putstr(cv, 1, 1, "Basic Unicode support");
39
40    cucul_set_color(cv, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK);
41    cucul_putstr(cv, 1, 2, "This is ASCII:    | abc DEF 123 !@# |");
42    cucul_putstr(cv, 1, 3, "This is Unicode:  | äßç δεφ ☺♥♀ ╞╬╗ |");
43    cucul_putstr(cv, 1, 4, "And this is, too: | ἀβϛ ΔЗҒ ᚴᛒᛯ ♩♔✈ |");
44
45    cucul_putstr(cv, 1, 5, "If the three lines do not have the same length, there is a bug somewhere.");
46
47    cucul_set_color(cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE);
48    cucul_putstr(cv, 1, 7, "Gradient glyphs");
49
50    cucul_set_color(cv, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK);
51    cucul_putstr(cv, 31,  8, "  0%");
52    cucul_putstr(cv, 31,  9, " 25%");
53    cucul_putstr(cv, 31, 10, " 50%");
54    cucul_putstr(cv, 31, 11, " 75%");
55    cucul_putstr(cv, 31, 12, "100%");
56
57    cucul_set_color(cv, CUCUL_COLOR_LIGHTRED, CUCUL_COLOR_LIGHTGREEN);
58    cucul_putstr(cv, 1,  8, "                             ");
59    cucul_putstr(cv, 1,  9, "░░░░░░░░░░░░░░░░░░░░░░░░░░░░░");
60    cucul_putstr(cv, 1, 10, "▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒");
61    cucul_putstr(cv, 1, 11, "▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓");
62    cucul_putstr(cv, 1, 12, "█████████████████████████████");
63
64    cucul_set_color(cv, CUCUL_COLOR_LIGHTGREEN, CUCUL_COLOR_LIGHTRED);
65    cucul_putstr(cv, 36,  8, "█████████████████████████████");
66    cucul_putstr(cv, 36,  9, "▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓");
67    cucul_putstr(cv, 36, 10, "▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒");
68    cucul_putstr(cv, 36, 11, "░░░░░░░░░░░░░░░░░░░░░░░░░░░░░");
69    cucul_putstr(cv, 36, 12, "                             ");
70
71    cucul_set_color(cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE);
72    cucul_putstr(cv, 1, 14, "Double width characters");
73
74    cucul_set_color(cv, CUCUL_COLOR_LIGHTRED, CUCUL_COLOR_BLACK);
75    cucul_putstr(cv, 1, 15, "| ドラゴン ボーレ |");
76    cucul_set_color(cv, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK);
77    cucul_putstr(cv, 1, 16, "| ()()()() ()()() |");
78    cucul_set_color(cv, CUCUL_COLOR_YELLOW, CUCUL_COLOR_BLACK);
79    cucul_putstr(cv, 1, 17, "| ドラゴン");
80    cucul_putstr(cv, 10, 17, "ボーレ |");
81
82    cucul_set_color(cv, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK);
83    cucul_putstr(cv, 1, 18, "If the three lines do not have the same length, there is a bug somewhere.");
84
85    cucul_putstr(cv, 1, 20, "CP437 glyphs: ☺ ☻ ♥ ♦ ♣ ♠ • ◘ ○ ◙ ♂ ♀ ♪ ♫ ☼ ► ◄ ↕ ‼ ¶ § ▬ ↨ ↑ ↓ → ← ∟ ↔ ▲ ▼");
86    cucul_putstr(cv, 1, 21, "more CP437: α ß Γ π Σ σ µ τ Φ Θ Ω δ ∞ φ ε ∩ ≡ ± ≥ ≤ ⌠ ⌡ ÷ ≈ ° ∙ · √ ⁿ ² ■");
87    cucul_putstr(cv, 1, 22, "drawing blocks: ███ ▓▓▓ ▒▒▒ ░░░ ▀ ▄ ▌ ▐ █ ▖ ▗ ▘ ▝ ▚ ▞ ▙ ▛ ▜ ▟");
88
89    caca_refresh_display(dp);
90
91    caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, -1);
92
93    caca_free_display(dp);
94    cucul_free_canvas(cv);
95
96    return 0;
97}
98
Note: See TracBrowser for help on using the repository browser.