source: libcaca/trunk/test/colors.c @ 524

Last change on this file since 524 was 524, checked in by Sam Hocevar, 15 years ago

A new low-level text management library (canvas for ultrafast compositing

of unicode letters) is now separated from the higher level rendering and I/O
(that is, libcaca). This commit totally breaks the API, but once everything
is polished I will think about source-level backward compatibility. Most
drivers are broken, but X11 still sorta works.

The new design is much more object-oriented and allows having several

active renderers at the same time, changing renderers on the fly, and more
important, having no renderer at all (useful for converters, or when you
want to do your own renderer).

And in case you are still wondering, the libcucul acronym has "Unicode"

because I want to support at least a subset of Unicode. There are awesome
glyphs in it, including the ones inherited from Codepage 437 such as
"gray 25%" that are used in DOS and Win32 ANSI art.

  • Property svn:keywords set to Id
File size: 1.3 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 524 2006-03-05 18:43:13Z 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#include <stdio.h>
17
18#include "cucul.h"
19#include "caca.h"
20
21int main(int argc, char **argv)
22{
23    cucul_t *qq;
24    caca_t *kk;
25    int i, j;
26
27    qq = cucul_init();
28    if(!qq)
29        return 1;
30
31    kk = caca_attach(qq);
32    if(!kk)
33        return 1;
34
35    cucul_clear(qq);
36    for(i = 0; i < 16; i++)
37    {
38        cucul_set_color(qq, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK);
39        cucul_printf(qq, 4, i + (i >= 8 ? 4 : 3), "'%c': %i (%s)",
40                     'a' + i, i, cucul_get_color_name(i));
41        for(j = 0; j < 16; j++)
42        {
43            cucul_set_color(qq, i, j);
44            cucul_putstr(qq, (j >= 8 ? 41 : 40) + j * 2, i + (i >= 8 ? 4 : 3),
45                         "# ");
46        }
47    }
48
49    caca_refresh(kk);
50    caca_wait_event(kk, CACA_EVENT_KEY_PRESS);
51
52    caca_detach(kk);
53    cucul_end(qq);
54
55    return 0;
56}
57
Note: See TracBrowser for help on using the repository browser.