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

Last change on this file since 1823 was 1823, checked in by Sam Hocevar, 13 years ago
  • Minor tuning to the various tests, just so that they’re releasable.
  • 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 1823 2007-09-30 13:32:16Z 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"
[859]16#include "common.h"
[105]17
[592]18#if !defined(__KERNEL__)
19#   include <stdio.h>
20#endif
[99]21
[524]22#include "cucul.h"
[185]23#include "caca.h"
[85]24
25int main(int argc, char **argv)
26{
[811]27    cucul_canvas_t *cv;
28    caca_display_t *dp;
[350]29    int i, j;
[85]30
[1823]31    cv = cucul_create_canvas(80, 24);
[1753]32    if(cv == NULL)
33    {
34        printf("Failed to create canvas\n");
[85]35        return 1;
[1753]36    }
[85]37
[819]38    dp = caca_create_display(cv);
[1753]39    if(dp == NULL)
40    {
41        printf("Failed to create display\n");
[524]42        return 1;
[1753]43    }
[524]44
[1267]45    cucul_set_color_ansi(cv, CUCUL_LIGHTGRAY, CUCUL_BLACK);
[832]46    cucul_clear_canvas(cv);
[159]47    for(i = 0; i < 16; i++)
48    {
[1267]49        cucul_set_color_ansi(cv, CUCUL_LIGHTGRAY, CUCUL_BLACK);
[1269]50        cucul_printf(cv, 3, i + (i >= 8 ? 3 : 2), "ANSI %i", i);
[226]51        for(j = 0; j < 16; j++)
52        {
[1267]53            cucul_set_color_ansi(cv, i, j);
[1347]54            cucul_put_str(cv, (j >= 8 ? 13 : 12) + j * 4, i + (i >= 8 ? 3 : 2),
55                          "Aaホ");
[226]56        }
[159]57    }
58
[1267]59    cucul_set_color_ansi(cv, CUCUL_LIGHTGRAY, CUCUL_BLACK);
[1347]60    cucul_put_str(cv, 3, 20, "This is bold    This is blink    This is italics    This is underline");
[1266]61    cucul_set_attr(cv, CUCUL_BOLD);
[1347]62    cucul_put_str(cv, 3 + 8, 20, "bold");
[1266]63    cucul_set_attr(cv, CUCUL_BLINK);
[1347]64    cucul_put_str(cv, 3 + 24, 20, "blink");
[1266]65    cucul_set_attr(cv, CUCUL_ITALICS);
[1347]66    cucul_put_str(cv, 3 + 41, 20, "italics");
[1266]67    cucul_set_attr(cv, CUCUL_UNDERLINE);
[1347]68    cucul_put_str(cv, 3 + 60, 20, "underline");
[1263]69
[819]70    caca_refresh_display(dp);
[849]71    caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, -1);
[103]72
[819]73    caca_free_display(dp);
[813]74    cucul_free_canvas(cv);
[524]75
[350]76    return 0;
[103]77}
78
Note: See TracBrowser for help on using the repository browser.