Changeset 1269


Ignore:
Timestamp:
Oct 31, 2006, 3:04:22 PM (14 years ago)
Author:
Sam Hocevar
Message:
  • Got rid of cucul_ansi_to_str(), it's really useless.
  • Partial update of the C++ bindings.
  • Updated documentation.
Location:
libcaca/trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/caca/caca0.c

    r1257 r1269  
    268268}
    269269
     270char const *__caca0_get_color_name(unsigned char color)
     271{
     272    static char const *color_names[] =
     273    {
     274        "black",
     275        "blue",
     276        "green",
     277        "cyan",
     278        "red",
     279        "magenta",
     280        "brown",
     281        "light gray",
     282        "dark gray",
     283        "light blue",
     284        "light green",
     285        "light cyan",
     286        "light red",
     287        "light magenta",
     288        "yellow",
     289        "white",
     290    };
     291
     292    if(color > 15)
     293        return "unknown";
     294
     295    return color_names[(unsigned int)color];
     296}
     297
  • libcaca/trunk/caca/caca0.h

    r1267 r1269  
    4040          unsigned long int, unsigned long int);
    4141extern void __caca0_free_bitmap(cucul_dither_t *);
     42extern char const *__caca0_get_color_name(unsigned char);
    4243
    4344/* These variables are needed to emulate old non-thread safe behaviour */
     
    134135#define caca_get_fg_color() __caca0_fg
    135136#define caca_get_bg_color() __caca0_bg
    136 #define caca_get_color_name cucul_ansi_to_str
     137#define caca_get_color_name __caca0_get_color_name
    137138#define caca_putchar(x, y, c) cucul_putchar(__caca0_cv, x, y, c)
    138139#define caca_putstr(x, y, s) cucul_putstr(__caca0_cv, x, y, s)
  • libcaca/trunk/cucul/cucul.c

    r1267 r1269  
    177177}
    178178
    179 /** \brief Translate an ANSI colour index into the colour's name.
    180  *
    181  *  Translate an ANSI colour index such as \e CUCUL_RED or \e CUCUL_WHITE
    182  *  into a human-readable string describing the corresponding colour.
    183  *
    184  *  This function never fails.
    185  *
    186  *  \param color The colour value.
    187  *  \return A static string containing the colour's name, or \c "unknown" if
    188  *  the colour is unknown.
    189  */
    190 char const *cucul_ansi_to_str(unsigned char color)
    191 {
    192     static char const *color_names[] =
    193     {
    194         "black",
    195         "blue",
    196         "green",
    197         "cyan",
    198         "red",
    199         "magenta",
    200         "brown",
    201         "light gray",
    202         "dark gray",
    203         "light blue",
    204         "light green",
    205         "light cyan",
    206         "light red",
    207         "light magenta",
    208         "yellow",
    209         "white",
    210     };
    211 
    212     if(color > 15)
    213         return "unknown";
    214 
    215     return color_names[(unsigned int)color];
    216 }
    217 
    218 /* Legacy function for old programs */
    219 char const *cucul_get_color_name(unsigned int color)
    220 {
    221     return cucul_ansi_to_str(color > 15 ? 15 : color);
    222 }
    223 
    224179/** \brief Uninitialise \e libcucul.
    225180 *
  • libcaca/trunk/cucul/cucul.h

    r1267 r1269  
    239239
    240240#if !defined(_DOXYGEN_SKIP_ME)
    241 /* Legacy stuff from beta versions */
     241/* Legacy stuff from beta versions, will probably disappear in 1.0 */
    242242#   ifdef __GNUC__
    243243#       define CUCUL_DEPRECATED __attribute__ ((deprecated))
     
    249249int cucul_set_truecolor(cucul_canvas_t *, unsigned int,
    250250                                          unsigned int) CUCUL_DEPRECATED;
    251 char const *cucul_get_color_name(unsigned int) CUCUL_DEPRECATED;
    252251#   define CUCUL_COLOR_BLACK CUCUL_BLACK
    253252#   define CUCUL_COLOR_BLUE CUCUL_BLUE
  • libcaca/trunk/cxx/cucul++.cpp

    r1156 r1269  
    8888}
    8989
    90 void Cucul::setColor(unsigned int f, unsigned int b)
    91 {
    92     cucul_set_color(cv, f, b);
    93 }
    94 
    95 int  Cucul::setTruecolor(unsigned int f, unsigned int b)
    96 {
    97     return cucul_set_truecolor(cv, f, b);
    98 }
    99 
    100 char const * Cucul::getColorName(unsigned int color)
    101 {
    102     return cucul_get_color_name(color);
     90int Cucul::setColorANSI(unsigned char f, unsigned char b)
     91{
     92    return cucul_set_color_ansi(cv, f, b);
     93}
     94
     95int  Cucul::setColorARGB(unsigned int f, unsigned int b)
     96{
     97    return cucul_set_color_argb(cv, f, b);
    10398}
    10499
     
    236231}
    237232
    238 unsigned long int Cucul::getColor(int x, int y)
    239 {
    240     return cucul_get_color(cv, x, y);
     233int Cucul::setAttr(unsigned long int attr)
     234{
     235    return cucul_set_attr(cv, attr);
     236}
     237
     238unsigned long int Cucul::getAttr(int x, int y)
     239{
     240    return cucul_get_attr(cv, x, y);
    241241}
    242242
  • libcaca/trunk/cxx/cucul++.h

    r1203 r1269  
    121121    unsigned int getWidth(void);
    122122    unsigned int getHeight(void);
    123     void setColor(unsigned int f, unsigned int b);
    124     int  setTruecolor(unsigned int f, unsigned int b);
    125     unsigned long int getColor(int, int);
    126     char const * getColorName(unsigned int color);
     123    unsigned long int getAttr(int, int);
     124    int setAttr(unsigned long int);
     125    int setColorANSI(unsigned char f, unsigned char b);
     126    int setColorARGB(unsigned int f, unsigned int b);
    127127    void Printf(int x , int y , char const * format,...);
    128128    void putChar(int x, int y, char ch);
  • libcaca/trunk/cxx/cxxtest.cpp

    r1268 r1269  
    44 *                All Rights Reserved
    55 *
    6  *  $Id$
     6 *  $Id: cpptest.cpp 784 2006-06-10 11:35:18Z jylam $
    77 *
    88 *  This program is free software; you can redistribute it and/or
     
    7373
    7474        /* Draw pig */
    75         qq->setColor(CUCUL_LIGHTMAGENTA, CUCUL_BLACK);
     75        qq->setColorANSI(CUCUL_LIGHTMAGENTA, CUCUL_BLACK);
    7676
    7777        for(int i = 0; pig[i]; i++)
     
    7979
    8080        /* printf works */
    81         qq->setColor(CUCUL_LIGHTBLUE, CUCUL_BLACK);
     81        qq->setColorANSI(CUCUL_LIGHTBLUE, CUCUL_BLACK);
    8282        qq->Printf(30,15, "Powered by libcaca %s", VERSION);
    8383
  • libcaca/trunk/doc/migrating.dox

    r1017 r1269  
    5454    caca_set_display_title(dp, "Window");
    5555    /* Choose drawing colours */
    56     cucul_set_color(cv, CUCUL_COLOR_BLACK,
    57                         CUCUL_COLOR_WHITE);
     56    cucul_set_color_ansi(cv, CUCUL_BLACK,
     57                             CUCUL_WHITE);
    5858    /* Draw a string at (0, 0) */
    5959    cucul_putstr(cv, 0, 0, "Hello world!");
     
    142142 \subsection bar3 Character printing
    143143
    144  - \b caca_set_color(): use cucul_set_color() or cucul_set_truecolor().
    145  - \b caca_get_fg_color(): deprecated.
    146  - \b caca_get_bg_color(): deprecated.
    147  - \b caca_get_color_name(): use cucul_get_color_name().
     144 - \b caca_set_color(): use cucul_set_color_ansi() or cucul_set_color_argb().
     145 - \b caca_get_fg_color(): use cucul_get_attr().
     146 - \b caca_get_bg_color(): use cucul_get_attr().
     147 - \b caca_get_color_name(): this function is now deprecated due to major
     148   uselessness.
    148149 - \b caca_putchar(): use cucul_putchar().
    149150 - \b caca_putstr(): use cucul_putstr().
  • libcaca/trunk/doc/tutorial.dox

    r923 r1269  
    1818    caca_set_display_title(dp, "Hello!");
    1919    /* Choose drawing colours */
    20     cucul_set_color(cv, CUCUL_COLOR_BLACK, CUCUL_COLOR_WHITE);
     20    cucul_set_color_ansi(cv, CUCUL_BLACK, CUCUL_WHITE);
    2121    /* Draw a string at coordinates (0, 0) */
    2222    cucul_putstr(cv, 0, 0, "This is a message");
  • libcaca/trunk/test/colors.c

    r1267 r1269  
    4141    {
    4242        cucul_set_color_ansi(cv, CUCUL_LIGHTGRAY, CUCUL_BLACK);
    43         cucul_printf(cv, 3, i + (i >= 8 ? 3 : 2), "'%cv': %i (%s)",
    44                      'a' + i, i, cucul_ansi_to_str(i));
     43        cucul_printf(cv, 3, i + (i >= 8 ? 3 : 2), "ANSI %i", i);
    4544        for(j = 0; j < 16; j++)
    4645        {
    4746            cucul_set_color_ansi(cv, i, j);
    48             cucul_putstr(cv, (j >= 8 ? 40 : 39) + j * 2, i + (i >= 8 ? 3 : 2),
    49                          "Aa");
     47            cucul_putstr(cv, (j >= 8 ? 13 : 12) + j * 4, i + (i >= 8 ? 3 : 2),
     48                         "Aa");
    5049        }
    5150    }
  • libcaca/trunk/test/demo.c

    r1267 r1269  
    2525static void demo_all(void);
    2626
    27 static void demo_color(void);
    2827static void demo_dots(void);
    2928static void demo_lines(void);
     
    114113                    break;
    115114#endif
    116                 case 'c':
    117                     demo = demo_color;
    118                     break;
    119115                case 'f':
    120116                case 'F':
     
    364360}
    365361
    366 static void demo_color(void)
    367 {
    368     int i, j;
    369     char buf[BUFSIZ];
    370 
    371     cucul_set_color_ansi(cv, CUCUL_LIGHTGRAY, CUCUL_BLACK);
    372     cucul_clear_canvas(cv);
    373     for(i = 0; i < 16; i++)
    374     {
    375         sprintf(buf, "'%c': %i (%s)", 'a' + i, i, cucul_ansi_to_str(i));
    376         cucul_set_color_ansi(cv, CUCUL_LIGHTGRAY, CUCUL_BLACK);
    377         cucul_putstr(cv, 4, i + (i >= 8 ? 4 : 3), buf);
    378         for(j = 0; j < 16; j++)
    379         {
    380             cucul_set_color_ansi(cv, i, j);
    381             cucul_putstr(cv, (j >= 8 ? 41 : 40) + j * 2, i + (i >= 8 ? 4 : 3), "# ");
    382         }
    383     }
    384 }
    385 
    386362static void demo_lines(void)
    387363{
Note: See TracChangeset for help on using the changeset viewer.