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

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