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

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

Large source code cleanup, getting rid of spaces, tabs, and svn keywords.

  • 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 *  This program is free software. It comes without any warranty, to
7 *  the extent permitted by applicable law. You can redistribute it
8 *  and/or modify it under the terms of the Do What The Fuck You Want
9 *  To Public License, Version 2, as published by Sam Hocevar. See
10 *  http://sam.zoy.org/wtfpl/COPYING for more details.
11 */
12
13#include "config.h"
14
15#if !defined(__KERNEL__)
16#   include <stdio.h>
17#endif
18
19#include "caca.h"
20
21int main(int argc, char **argv)
22{
23    caca_canvas_t *cv;
24    caca_display_t *dp;
25    int i, j;
26
27    cv = caca_create_canvas(80, 24);
28    if(cv == NULL)
29    {
30        printf("Failed to create canvas\n");
31        return 1;
32    }
33
34    dp = caca_create_display(cv);
35    if(dp == NULL)
36    {
37        printf("Failed to create display\n");
38        return 1;
39    }
40
41    caca_set_color_ansi(cv, CACA_LIGHTGRAY, CACA_BLACK);
42    caca_clear_canvas(cv);
43    for(i = 0; i < 16; i++)
44    {
45        caca_set_color_ansi(cv, CACA_LIGHTGRAY, CACA_BLACK);
46        caca_printf(cv, 3, i + (i >= 8 ? 3 : 2), "ANSI %i", i);
47        for(j = 0; j < 16; j++)
48        {
49            caca_set_color_ansi(cv, i, j);
50            caca_put_str(cv, (j >= 8 ? 13 : 12) + j * 4, i + (i >= 8 ? 3 : 2),
51                          "Aaホ");
52        }
53    }
54
55    caca_set_color_ansi(cv, CACA_LIGHTGRAY, CACA_BLACK);
56    caca_put_str(cv, 3, 20, "This is bold    This is blink    This is italics    This is underline");
57    caca_set_attr(cv, CACA_BOLD);
58    caca_put_str(cv, 3 + 8, 20, "bold");
59    caca_set_attr(cv, CACA_BLINK);
60    caca_put_str(cv, 3 + 24, 20, "blink");
61    caca_set_attr(cv, CACA_ITALICS);
62    caca_put_str(cv, 3 + 41, 20, "italics");
63    caca_set_attr(cv, CACA_UNDERLINE);
64    caca_put_str(cv, 3 + 60, 20, "underline");
65
66    caca_refresh_display(dp);
67    caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, -1);
68
69    caca_free_display(dp);
70    caca_free_canvas(cv);
71
72    return 0;
73}
74
Note: See TracBrowser for help on using the repository browser.