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

Last change on this file since 2300 was 2299, checked in by Sam Hocevar, 13 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.1 KB
RevLine 
[85]1/*
[350]2 *  colors        display all possible libcaca colour pairs
3 *  Copyright (c) 2003-2004 Sam Hocevar <sam@zoy.org>
[268]4 *                All Rights Reserved
[85]5 *
[268]6 *  $Id: colors.c 2299 2008-04-19 12:42:50Z sam $
[85]7 *
[1462]8 *  This program is free software. It comes without any warranty, to
[1452]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
[522]12 *  http://sam.zoy.org/wtfpl/COPYING for more details.
[85]13 */
14
[105]15#include "config.h"
16
[592]17#if !defined(__KERNEL__)
18#   include <stdio.h>
19#endif
[99]20
[524]21#include "cucul.h"
[185]22#include "caca.h"
[85]23
24int main(int argc, char **argv)
25{
[811]26    cucul_canvas_t *cv;
27    caca_display_t *dp;
[350]28    int i, j;
[85]29
[1823]30    cv = cucul_create_canvas(80, 24);
[1753]31    if(cv == NULL)
32    {
33        printf("Failed to create canvas\n");
[85]34        return 1;
[1753]35    }
[85]36
[819]37    dp = caca_create_display(cv);
[1753]38    if(dp == NULL)
39    {
40        printf("Failed to create display\n");
[524]41        return 1;
[1753]42    }
[524]43
[1267]44    cucul_set_color_ansi(cv, CUCUL_LIGHTGRAY, CUCUL_BLACK);
[832]45    cucul_clear_canvas(cv);
[159]46    for(i = 0; i < 16; i++)
47    {
[1267]48        cucul_set_color_ansi(cv, CUCUL_LIGHTGRAY, CUCUL_BLACK);
[1269]49        cucul_printf(cv, 3, i + (i >= 8 ? 3 : 2), "ANSI %i", i);
[226]50        for(j = 0; j < 16; j++)
51        {
[1267]52            cucul_set_color_ansi(cv, i, j);
[1347]53            cucul_put_str(cv, (j >= 8 ? 13 : 12) + j * 4, i + (i >= 8 ? 3 : 2),
54                          "Aaホ");
[226]55        }
[159]56    }
57
[1267]58    cucul_set_color_ansi(cv, CUCUL_LIGHTGRAY, CUCUL_BLACK);
[1347]59    cucul_put_str(cv, 3, 20, "This is bold    This is blink    This is italics    This is underline");
[1266]60    cucul_set_attr(cv, CUCUL_BOLD);
[1347]61    cucul_put_str(cv, 3 + 8, 20, "bold");
[1266]62    cucul_set_attr(cv, CUCUL_BLINK);
[1347]63    cucul_put_str(cv, 3 + 24, 20, "blink");
[1266]64    cucul_set_attr(cv, CUCUL_ITALICS);
[1347]65    cucul_put_str(cv, 3 + 41, 20, "italics");
[1266]66    cucul_set_attr(cv, CUCUL_UNDERLINE);
[1347]67    cucul_put_str(cv, 3 + 60, 20, "underline");
[1263]68
[819]69    caca_refresh_display(dp);
[849]70    caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, -1);
[103]71
[819]72    caca_free_display(dp);
[813]73    cucul_free_canvas(cv);
[524]74
[350]75    return 0;
[103]76}
77
Note: See TracBrowser for help on using the repository browser.