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

Last change on this file since 627 was 627, checked in by Sam Hocevar, 15 years ago
  • Added support for Unicode characters that fall into CP437 0x01 - 0x1f to the DOS/conio.h driver, and updated the unicode test accordingly.
  • Property svn:keywords set to Id
File size: 3.6 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 627 2006-03-15 22:07:55Z 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    cucul_t *qq;
30    caca_t *kk;
31
32    qq = cucul_init();
33    kk = caca_attach(qq);
34
35    cucul_set_color(qq, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE);
36    cucul_putstr(qq, 1, 1, "Basic Unicode support");
37
38    cucul_set_color(qq, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK);
39    cucul_putstr(qq, 1, 2, "This is ASCII:    | abc DEF 123 !@# |");
40    cucul_putstr(qq, 1, 3, "This is Unicode:  | äßç δεφ ☺♥♀ ╞╬╗ |");
41    cucul_putstr(qq, 1, 4, "And this is, too: | ἀβϛ ΔЗҒ ᚴᛒᛯ ♩♔✈ |");
42
43    cucul_putstr(qq, 1, 5, "If the three lines do not have the same length, there is a bug somewhere.");
44
45    cucul_set_color(qq, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE);
46    cucul_putstr(qq, 1, 7, "Gradient glyphs");
47
48    cucul_set_color(qq, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK);
49    cucul_putstr(qq, 31,  8, "  0%");
50    cucul_putstr(qq, 31,  9, " 25%");
51    cucul_putstr(qq, 31, 10, " 50%");
52    cucul_putstr(qq, 31, 11, " 75%");
53    cucul_putstr(qq, 31, 12, "100%");
54
55    cucul_set_color(qq, CUCUL_COLOR_LIGHTRED, CUCUL_COLOR_LIGHTGREEN);
56    cucul_putstr(qq, 1,  8, "                             ");
57    cucul_putstr(qq, 1,  9, "░░░░░░░░░░░░░░░░░░░░░░░░░░░░░");
58    cucul_putstr(qq, 1, 10, "▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒");
59    cucul_putstr(qq, 1, 11, "▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓");
60    cucul_putstr(qq, 1, 12, "█████████████████████████████");
61
62    cucul_set_color(qq, CUCUL_COLOR_LIGHTGREEN, CUCUL_COLOR_LIGHTRED);
63    cucul_putstr(qq, 36,  8, "█████████████████████████████");
64    cucul_putstr(qq, 36,  9, "▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓");
65    cucul_putstr(qq, 36, 10, "▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒");
66    cucul_putstr(qq, 36, 11, "░░░░░░░░░░░░░░░░░░░░░░░░░░░░░");
67    cucul_putstr(qq, 36, 12, "                             ");
68
69    cucul_set_color(qq, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE);
70    cucul_putstr(qq, 1, 14, "Double width characters");
71
72    cucul_set_color(qq, CUCUL_COLOR_LIGHTRED, CUCUL_COLOR_BLACK);
73    cucul_putstr(qq, 1, 15, "| ドラゴン ボーレ |");
74    cucul_set_color(qq, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK);
75    cucul_putstr(qq, 1, 16, "| ()()()() ()()() |");
76    cucul_set_color(qq, CUCUL_COLOR_YELLOW, CUCUL_COLOR_BLACK);
77    cucul_putstr(qq, 1, 17, "| ドラゴン");
78    cucul_putstr(qq, 10, 17, "ボーレ |");
79
80    cucul_set_color(qq, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK);
81    cucul_putstr(qq, 1, 18, "If the three lines do not have the same length, there is a bug somewhere.");
82
83    caca_display(kk);
84
85    while(!caca_get_event(kk, CACA_EVENT_KEY_PRESS));
86
87    caca_detach(kk);
88    cucul_end(qq);
89
90    return 0;
91}
92
Note: See TracBrowser for help on using the repository browser.