source: libcaca/trunk/examples/colors.c @ 4148

Last change on this file since 4148 was 4148, checked in by Sam Hocevar, 10 years ago

Update my e-mail address everywhere.

  • Property svn:keywords set to Id
File size: 2.0 KB
Line 
1/*
2 *  colors        display all possible libcaca colour pairs
3 *  Copyright (c) 2003-2004 Sam Hocevar <sam@hocevar.net>
4 *                All Rights Reserved
5 *
6 *  $Id: colors.c 4148 2009-12-19 14:38:38Z 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 "caca.h"
22
23int main(int argc, char **argv)
24{
25    caca_canvas_t *cv;
26    caca_display_t *dp;
27    int i, j;
28
29    cv = caca_create_canvas(80, 24);
30    if(cv == NULL)
31    {
32        printf("Failed to create canvas\n");
33        return 1;
34    }
35
36    dp = caca_create_display(cv);
37    if(dp == NULL)
38    {
39        printf("Failed to create display\n");
40        return 1;
41    }
42
43    caca_set_color_ansi(cv, CACA_LIGHTGRAY, CACA_BLACK);
44    caca_clear_canvas(cv);
45    for(i = 0; i < 16; i++)
46    {
47        caca_set_color_ansi(cv, CACA_LIGHTGRAY, CACA_BLACK);
48        caca_printf(cv, 3, i + (i >= 8 ? 3 : 2), "ANSI %i", i);
49        for(j = 0; j < 16; j++)
50        {
51            caca_set_color_ansi(cv, i, j);
52            caca_put_str(cv, (j >= 8 ? 13 : 12) + j * 4, i + (i >= 8 ? 3 : 2),
53                          "Aaホ");
54        }
55    }
56
57    caca_set_color_ansi(cv, CACA_LIGHTGRAY, CACA_BLACK);
58    caca_put_str(cv, 3, 20, "This is bold    This is blink    This is italics    This is underline");
59    caca_set_attr(cv, CACA_BOLD);
60    caca_put_str(cv, 3 + 8, 20, "bold");
61    caca_set_attr(cv, CACA_BLINK);
62    caca_put_str(cv, 3 + 24, 20, "blink");
63    caca_set_attr(cv, CACA_ITALICS);
64    caca_put_str(cv, 3 + 41, 20, "italics");
65    caca_set_attr(cv, CACA_UNDERLINE);
66    caca_put_str(cv, 3 + 60, 20, "underline");
67
68    caca_refresh_display(dp);
69    caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, -1);
70
71    caca_free_display(dp);
72    caca_free_canvas(cv);
73
74    return 0;
75}
76
Note: See TracBrowser for help on using the repository browser.