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

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