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

Last change on this file since 2101 was 2101, checked in by Sam Hocevar, 12 years ago
  • Rename "test" to "examples". The former will become a real testsuite.
  • Autodetect zzuf in the configure step. It might become handy.
  • Property svn:keywords set to Id
File size: 2.1 KB
Line 
1/*
2 *  colors        display all possible libcaca colour pairs
3 *  Copyright (c) 2003-2004 Sam Hocevar <sam@zoy.org>
4 *                All Rights Reserved
5 *
6 *  $Id: colors.c 2101 2007-11-30 23:48:39Z 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#include "common.h"
17
18#if !defined(__KERNEL__)
19#   include <stdio.h>
20#endif
21
22#include "cucul.h"
23#include "caca.h"
24
25int main(int argc, char **argv)
26{
27    cucul_canvas_t *cv;
28    caca_display_t *dp;
29    int i, j;
30
31    cv = cucul_create_canvas(80, 24);
32    if(cv == NULL)
33    {
34        printf("Failed to create canvas\n");
35        return 1;
36    }
37
38    dp = caca_create_display(cv);
39    if(dp == NULL)
40    {
41        printf("Failed to create display\n");
42        return 1;
43    }
44
45    cucul_set_color_ansi(cv, CUCUL_LIGHTGRAY, CUCUL_BLACK);
46    cucul_clear_canvas(cv);
47    for(i = 0; i < 16; i++)
48    {
49        cucul_set_color_ansi(cv, CUCUL_LIGHTGRAY, CUCUL_BLACK);
50        cucul_printf(cv, 3, i + (i >= 8 ? 3 : 2), "ANSI %i", i);
51        for(j = 0; j < 16; j++)
52        {
53            cucul_set_color_ansi(cv, i, j);
54            cucul_put_str(cv, (j >= 8 ? 13 : 12) + j * 4, i + (i >= 8 ? 3 : 2),
55                          "Aaホ");
56        }
57    }
58
59    cucul_set_color_ansi(cv, CUCUL_LIGHTGRAY, CUCUL_BLACK);
60    cucul_put_str(cv, 3, 20, "This is bold    This is blink    This is italics    This is underline");
61    cucul_set_attr(cv, CUCUL_BOLD);
62    cucul_put_str(cv, 3 + 8, 20, "bold");
63    cucul_set_attr(cv, CUCUL_BLINK);
64    cucul_put_str(cv, 3 + 24, 20, "blink");
65    cucul_set_attr(cv, CUCUL_ITALICS);
66    cucul_put_str(cv, 3 + 41, 20, "italics");
67    cucul_set_attr(cv, CUCUL_UNDERLINE);
68    cucul_put_str(cv, 3 + 60, 20, "underline");
69
70    caca_refresh_display(dp);
71    caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, -1);
72
73    caca_free_display(dp);
74    cucul_free_canvas(cv);
75
76    return 0;
77}
78
Note: See TracBrowser for help on using the repository browser.