source: libcaca/trunk/examples/fullwidth.c @ 2299

Last change on this file since 2299 was 2299, checked in by Sam Hocevar, 12 years ago
  • Remove #include <stdint.h> etc. from "common.h". Instead, make sure that <cucul.h> will provide the C99 types, even if libcaca has been installed.
  • Rename what's left of "common.h" to "stubs.h".
  • Remove all references to erroneous <inttypes.h> from source files.
  • Property svn:keywords set to Id
File size: 2.3 KB
Line 
1/*
2 *  fullwidth     libcaca fullwidth Unicode characters test program
3 *  Copyright (c) 2006 Sam Hocevar <sam@zoy.org>
4 *                All Rights Reserved
5 *
6 *  $Id: fullwidth.c 2299 2008-04-19 12:42:50Z sam $
7 *
8 *  This program is free software. It comes without any warranty, to
9 *  the extent permitted by applicable law. You can redistribute it
10 *  and/or modify it under the terms of the Do What The Fuck You Want
11 *  To Public License, Version 2, as published by Sam Hocevar. See
12 *  http://sam.zoy.org/wtfpl/COPYING for more details.
13 */
14
15#include "config.h"
16
17#if !defined(__KERNEL__)
18#   include <stdio.h>
19#endif
20
21#include "cucul.h"
22#include "caca.h"
23
24#define CACA "쫊쫊쫊쫊쫊쫊쫊쫊쫊쫊쫊쫊쫊쫊쫊"
25
26int main(int argc, char *argv[])
27{
28    cucul_canvas_t *cv, *caca, *line;
29    caca_display_t *dp;
30
31    unsigned int i;
32
33    cv = cucul_create_canvas(0, 0);
34    if(cv == NULL)
35    {
36        printf("Can't created canvas\n");
37        return -1;
38    }
39    dp = caca_create_display(cv);
40    if(dp == NULL)
41    {
42        printf("Can't create display\n");
43        return -1;
44    }
45
46    caca = cucul_create_canvas(6, 10);
47    line = cucul_create_canvas(2, 1);
48
49    /* Line of x's */
50    for(i = 0; i < 10; i++)
51    {
52        cucul_set_color_ansi(caca, CUCUL_WHITE, CUCUL_BLUE);
53        cucul_put_str(caca, 0, i, CACA);
54        cucul_set_color_ansi(caca, CUCUL_WHITE, CUCUL_RED);
55        cucul_put_char(caca, i - 2, i, 'x');
56    }
57
58    cucul_blit(cv, 1, 1, caca, NULL);
59
60    /* Line of ホ's */
61    for(i = 0; i < 10; i++)
62    {
63        cucul_set_color_ansi(caca, CUCUL_WHITE, CUCUL_BLUE);
64        cucul_put_str(caca, 0, i, CACA);
65        cucul_set_color_ansi(caca, CUCUL_WHITE, CUCUL_GREEN);
66        cucul_put_str(caca, i - 2, i, "ホ");
67    }
68
69    cucul_blit(cv, 15, 1, caca, NULL);
70
71    /* Line of canvas */
72    cucul_set_color_ansi(line, CUCUL_WHITE, CUCUL_MAGENTA);
73    cucul_put_str(line, 0, 0, "ほ");
74    for(i = 0; i < 10; i++)
75    {
76        cucul_set_color_ansi(caca, CUCUL_WHITE, CUCUL_BLUE);
77        cucul_put_str(caca, 0, i, CACA);
78        cucul_blit(caca, i - 2, i, line, NULL);
79    }
80
81    cucul_blit(cv, 29, 1, caca, NULL);
82
83    caca_refresh_display(dp);
84
85    caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, -1);
86
87    caca_free_display(dp);
88
89    cucul_free_canvas(line);
90    cucul_free_canvas(caca);
91    cucul_free_canvas(cv);
92
93    return 0;
94}
95
Note: See TracBrowser for help on using the repository browser.