Changeset 1267


Ignore:
Timestamp:
Oct 31, 2006, 2:29:48 PM (13 years ago)
Author:
Sam Hocevar
Message:
  • Got rid of cucul_ansi_to_attr() and cucul_argb_to_attr() and restored cucul_set_color() and cucul_set_truecolor() under the new names cucul_set_color_ansi() and cucul_set_color_argb().
  • Renamed cucul_get_color_name() into cucul_ansi_to_str().
Location:
libcaca/trunk
Files:
27 edited

Legend:

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

    r1257 r1267  
    131131
    132132#define caca_set_color(x, y) \
    133     (__caca0_fg = (x), __caca0_bg = (y), \
    134      cucul_set_attr(__caca0_cv, cucul_ansi_to_attr(x, y)))
     133    (__caca0_fg = (x), __caca0_bg = (y), cucul_set_color_ansi(__caca0_cv, x, y))
    135134#define caca_get_fg_color() __caca0_fg
    136135#define caca_get_bg_color() __caca0_bg
    137 #define caca_get_color_name cucul_get_color_name
     136#define caca_get_color_name cucul_ansi_to_str
    138137#define caca_putchar(x, y, c) cucul_putchar(__caca0_cv, x, y, c)
    139138#define caca_putstr(x, y, s) cucul_putstr(__caca0_cv, x, y, s)
  • libcaca/trunk/caca/driver_gl.c

    r1257 r1267  
    513513    /* Allocate a libcucul canvas and print all the glyphs on it */
    514514    cv = cucul_create_canvas(1, b);
    515     cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_BLACK));
     515    cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLACK);
    516516
    517517    for(b = 0, i = 0; dp->drv.p->blocks[i + 1]; i += 2)
  • libcaca/trunk/cucul/colour.c

    r1266 r1267  
    2626#include "cucul.h"
    2727#include "cucul_internals.h"
    28 
    29 /** \brief Set the default character attribute.
    30  *
    31  *  Set the default character attribute for drawing. Attributes define
    32  *  foreground and background colour, transparency, bold, italics and
    33  *  underline styles, as well as blink. String functions such as
    34  *  caca_printf() and graphical primitive functions such as caca_draw_line()
    35  *  will use this attribute.
    36  *
    37  *  The attribute value is a 32-bit integer as returned by cucul_get_attr()
    38  *  or created using cucul_ansi_to_attr() and cucul_argb_to_attr(), optionally
    39  *  ORed with style values such as CUCUL_UNDERLINE or CUCUL_BLINK.
    40  *
    41  *  Only changing the style does not affect the current colour value.
    42  *
    43  *  If an error occurs, -1 is returned and \b errno is set accordingly:
    44  *  - \c EINVAL The attribute value is out of the 32-bit range.
    45  *
    46  *  \param cv A handle to the libcucul canvas.
    47  *  \param attr The requested attribute value.
    48  *  \return 0 in case of success, -1 if an error occurred.
    49  */
    50 int cucul_set_attr(cucul_canvas_t *cv, unsigned long int attr)
    51 {
    52     if(sizeof(unsigned long int) > sizeof(uint32_t) && attr > 0xffffffff)
    53     {
    54 #if defined(HAVE_ERRNO_H)
    55         errno = EINVAL;
    56 #endif
    57         return -1;
    58     }
    59 
    60     if(attr < 0x00000010)
    61         attr = (cv->curattr & 0xfffffff0) | attr;
    62 
    63     cv->curattr = attr;
    64 
    65     return 0;
    66 }
    6728
    6829/** \brief Get the text attribute at the given coordinates.
     
    9960}
    10061
    101 /** \brief Set the default colour pair and text style (ANSI version).
    102  *
    103  *  Set the default ANSI colour pair and text style for drawing. String
    104  *  functions such as caca_printf() and graphical primitive functions such as
    105  *  caca_draw_line() will use these attributes.
     62/** \brief Set the default character attribute.
     63 *
     64 *  Set the default character attribute for drawing. Attributes define
     65 *  foreground and background colour, transparency, bold, italics and
     66 *  underline styles, as well as blink. String functions such as
     67 *  caca_printf() and graphical primitive functions such as caca_draw_line()
     68 *  will use this attribute.
     69 *
     70 *  The value of \e attr is either:
     71 *  - a 32-bit integer as returned by cucul_get_attr(), in which case it
     72 *    also contains colour information,
     73 *  - a combination (bitwise OR) of style values (\e CUCUL_UNDERLINE,
     74 *    \e CUCUL_BLINK, \e CUCUL_BOLD and \e CUCUL_ITALICS), in which case
     75 *    setting the attribute does not modify the current colour information.
     76 *
     77 *  If an error occurs, -1 is returned and \b errno is set accordingly:
     78 *  - \c EINVAL The attribute value is out of the 32-bit range.
     79 *
     80 *  \param cv A handle to the libcucul canvas.
     81 *  \param attr The requested attribute value.
     82 *  \return 0 in case of success, -1 if an error occurred.
     83 */
     84int cucul_set_attr(cucul_canvas_t *cv, unsigned long int attr)
     85{
     86    if(sizeof(unsigned long int) > sizeof(uint32_t) && attr > 0xffffffff)
     87    {
     88#if defined(HAVE_ERRNO_H)
     89        errno = EINVAL;
     90#endif
     91        return -1;
     92    }
     93
     94    if(attr < 0x00000010)
     95        attr = (cv->curattr & 0xfffffff0) | attr;
     96
     97    cv->curattr = attr;
     98
     99    return 0;
     100}
     101
     102/** \brief Set the default colour pair for text (ANSI version).
     103 *
     104 *  Set the default ANSI colour pair for text drawing. String functions such
     105 *  as caca_printf() and graphical primitive functions such as caca_draw_line()
     106 *  will use these attributes.
    106107 *
    107108 *  Color values are those defined in cucul.h, such as CUCUL_RED
    108109 *  or CUCUL_TRANSPARENT.
    109110 *
    110  *  Style values are those defined in cucul.h, such as CUCUL_UNDERLINE
    111  *  or CUCUL_BLINK. The values can be ORed to set several styles at
    112  *  the same time.
    113  *
    114111 *  If an error occurs, 0 is returned and \b errno is set accordingly:
    115  *  - \c EINVAL The colour values and/or the style mask are invalid.
     112 *  - \c EINVAL At least one of the colour values is invalid.
    116113 *
    117114 *  \param cv A handle to the libcucul canvas.
    118  *  \param fg The requested foreground colour.
    119  *  \param bg The requested background colour.
    120  *  \param style The requested text styles.
     115 *  \param fg The requested ANSI foreground colour.
     116 *  \param bg The requested ANSI background colour.
    121117 *  \return 0 in case of success, -1 if an error occurred.
    122118 */
    123 unsigned long int cucul_ansi_to_attr(unsigned char fg, unsigned char bg)
    124 {
     119int cucul_set_color_ansi(cucul_canvas_t *cv, unsigned char fg, unsigned char bg)
     120{
     121    uint32_t attr;
     122
    125123    if(fg > 0x20 || bg > 0x20)
    126124    {
     
    128126        errno = EINVAL;
    129127#endif
    130         return 0;
     128        return -1;
    131129    }
    132130
    133     fg |= 0x40;
    134     bg |= 0x40;
    135 
    136     return ((unsigned long int)bg << 18) | ((unsigned long int)fg << 4);
     131    attr = ((uint32_t)(bg | 0x40) << 18) | ((uint32_t)(fg | 0x40) << 4);
     132    cv->curattr = (cv->curattr & 0x0000000f) | attr;
     133
     134    return 0;
    137135}
    138136
     
    140138int cucul_set_color(cucul_canvas_t *cv, unsigned char fg, unsigned char bg)
    141139{
    142     return cucul_set_attr(cv, cucul_ansi_to_attr(fg, bg));
    143 }
    144 
    145 /** \brief Set the default colour pair and text style (truecolor version).
    146  *
    147  *  Set the default colour pair and text style for drawing. String
    148  *  functions such as caca_printf() and graphical primitive functions such as
    149  *  caca_draw_line() will use these attributes.
     140    return cucul_set_color_ansi(cv, fg, bg);
     141}
     142
     143/** \brief Set the default colour pair for text (truecolor version).
     144 *
     145 *  Set the default ARGB colour pair for text drawing. String functions such
     146 *  as caca_printf() and graphical primitive functions such as caca_draw_line()
     147 *  will use these attributes.
    150148 *
    151149 *  Colors are 16-bit ARGB values, each component being coded on 4 bits. For
     
    157155 *
    158156 *  \param cv A handle to the libcucul canvas.
    159  *  \param fg The requested foreground colour.
    160  *  \param bg The requested background colour.
    161  *  \param style The requested text styles.
     157 *  \param fg The requested ARGB foreground colour.
     158 *  \param bg The requested ARGB background colour.
    162159 *  \return 0 in case of success, -1 if an error occurred.
    163160 */
    164 unsigned long int cucul_argb_to_attr(unsigned int fg, unsigned int bg)
    165 {
     161int cucul_set_color_argb(cucul_canvas_t *cv, unsigned int fg, unsigned int bg)
     162{
     163    uint32_t attr;
     164
    166165    if(fg > 0xffff || bg > 0xffff)
    167166    {
     
    181180    bg = ((bg >> 1) & 0x7ff) | ((bg >> 13) << 11);
    182181
    183     return ((unsigned long int)bg << 18) | ((unsigned long int)fg << 4);
     182    attr = ((uint32_t)bg << 18) | ((uint32_t)fg << 4);
     183    cv->curattr = (cv->curattr & 0x0000000f) | attr;
     184
     185    return 0;
    184186}
    185187
     
    187189int cucul_set_truecolor(cucul_canvas_t *cv, unsigned int fg, unsigned int bg)
    188190{
    189     return cucul_set_attr(cv, cucul_argb_to_attr(fg, bg));
     191    return cucul_set_color_argb(cv, fg, bg);
    190192}
    191193
  • libcaca/trunk/cucul/cucul.c

    r1257 r1267  
    177177}
    178178
    179 /** \brief Translate a colour index into the colour's name.
    180  *
    181  *  Translate a cucul_color enum into a human-readable string describing
    182  *  the corresponding colour.
     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.
    183183 *
    184184 *  This function never fails.
     
    188188 *  the colour is unknown.
    189189 */
    190 char const *cucul_get_color_name(unsigned int color)
     190char const *cucul_ansi_to_str(unsigned char color)
    191191{
    192192    static char const *color_names[] =
     
    210210    };
    211211
    212     if(color < 0 || color > 15)
     212    if(color > 15)
    213213        return "unknown";
    214214
    215     return color_names[color];
     215    return color_names[(unsigned int)color];
     216}
     217
     218/* Legacy function for old programs */
     219char const *cucul_get_color_name(unsigned int color)
     220{
     221    return cucul_ansi_to_str(color > 15 ? 15 : color);
    216222}
    217223
  • libcaca/trunk/cucul/cucul.h

    r1258 r1267  
    104104 *  @{ */
    105105#define CUCUL_MAGIC_FULLWIDTH 0x000ffffe /**< Used to indicate that the previous character was a fullwidth glyph. */
     106unsigned long int cucul_get_attr(cucul_canvas_t *, int, int);
    106107int cucul_set_attr(cucul_canvas_t *, unsigned long int);
    107 unsigned long int cucul_get_attr(cucul_canvas_t *, int, int);
    108 unsigned long int cucul_ansi_to_attr(unsigned char, unsigned char);
    109 unsigned long int cucul_argb_to_attr(unsigned int, unsigned int);
    110 char const *cucul_get_color_name(unsigned int);
     108int cucul_set_color_ansi(cucul_canvas_t *, unsigned char, unsigned char);
     109int cucul_set_color_argb(cucul_canvas_t *, unsigned int, unsigned int);
     110char const *cucul_ansi_to_str(unsigned char);
    111111int cucul_putchar(cucul_canvas_t *, int, int, unsigned long int);
    112112unsigned long int cucul_getchar(cucul_canvas_t *, int, int);
     
    249249int cucul_set_truecolor(cucul_canvas_t *, unsigned int,
    250250                                          unsigned int) CUCUL_DEPRECATED;
     251char const *cucul_get_color_name(unsigned int) CUCUL_DEPRECATED;
    251252#   define CUCUL_COLOR_BLACK CUCUL_BLACK
    252253#   define CUCUL_COLOR_BLUE CUCUL_BLUE
  • libcaca/trunk/cucul/dither.c

    r1257 r1267  
    10431043
    10441044        /* Now output the character */
    1045         cucul_set_attr(cv, cucul_ansi_to_attr(outfg, outbg));
     1045        cucul_set_color_ansi(cv, outfg, outbg);
    10461046        cucul_putchar(cv, x, y, outch);
    10471047
  • libcaca/trunk/cucul/import.c

    r1257 r1267  
    203203    }
    204204
    205     cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_DEFAULT, CUCUL_TRANSPARENT));
     205    cucul_set_color_ansi(cv, CUCUL_DEFAULT, CUCUL_TRANSPARENT);
    206206
    207207    for(i = 0; i < size; i++)
     
    385385            case 'K': /* EL - Erase In Line */
    386386                if(width < 80)
    387                     cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_DEFAULT,
    388                                                           CUCUL_TRANSPARENT));
     387                    cucul_set_color_ansi(cv, CUCUL_DEFAULT, CUCUL_TRANSPARENT);
    389388                    cucul_set_canvas_size(cv, width = 80, height);
    390389                for(j = x; j < 80; j++)
     
    436435        if((unsigned int)x + wch > width)
    437436        {
    438             cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_DEFAULT,
    439                                                   CUCUL_TRANSPARENT));
     437            cucul_set_color_ansi(cv, CUCUL_DEFAULT, CUCUL_TRANSPARENT);
    440438            cucul_set_canvas_size(cv, width = x + wch, height);
    441439        }
     
    443441        if((unsigned int)y >= height)
    444442        {
    445             cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_DEFAULT,
    446                                                   CUCUL_TRANSPARENT));
     443            cucul_set_color_ansi(cv, CUCUL_DEFAULT, CUCUL_TRANSPARENT);
    447444            cucul_set_canvas_size(cv, width, height = y + 1);
    448445        }
    449446
    450447        /* Now paste our character */
    451         cucul_set_attr(cv, cucul_ansi_to_attr(grcm.efg, grcm.ebg));
     448        cucul_set_color_ansi(cv, grcm.efg, grcm.ebg);
    452449        cucul_putchar(cv, x, y, ch);
    453450        x += wch;
     
    456453    if((unsigned int)y > height)
    457454    {
    458         cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_DEFAULT,
    459                                               CUCUL_TRANSPARENT));
     455        cucul_set_color_ansi(cv, CUCUL_DEFAULT, CUCUL_TRANSPARENT);
    460456        cucul_set_canvas_size(cv, width, height = y);
    461457    }
  • libcaca/trunk/src/aafire.c

    r1257 r1267  
    241241  cucul_dither_bitmap(cv, 0, 0, cucul_get_canvas_width(cv),
    242242                      cucul_get_canvas_height(cv), cucul_dither, bitmap);
    243   cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_BLUE));
     243  cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE);
    244244  if (sloop < 100)
    245245    cucul_putstr(cv, cucul_get_canvas_width(cv) - 30,
  • libcaca/trunk/src/cacademo.c

    r1257 r1267  
    162162        {
    163163            fn[next](RENDER, backcv);
    164             cucul_set_attr(mask, cucul_ansi_to_attr(CUCUL_LIGHTGRAY,
    165                                                     CUCUL_BLACK));
     164            cucul_set_color_ansi(mask, CUCUL_LIGHTGRAY, CUCUL_BLACK);
    166165            cucul_clear_canvas(mask);
    167             cucul_set_attr(mask, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_WHITE));
     166            cucul_set_color_ansi(mask, CUCUL_WHITE, CUCUL_WHITE);
    168167            transition(mask, tmode,
    169168                       100 * (frame - next_transition) / TRANSITION_FRAMES);
     
    171170        }
    172171
    173         cucul_set_attr(frontcv, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_BLUE));
     172        cucul_set_color_ansi(frontcv, CUCUL_WHITE, CUCUL_BLUE);
    174173        if(frame < 100)
    175174            cucul_putstr(frontcv, cucul_get_canvas_width(frontcv) - 30,
     
    694693
    695694                if(p & 0x0f)
    696                     cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_WHITE, p >> 4));
     695                    cucul_set_color_ansi(cv, CUCUL_WHITE, p >> 4);
    697696                else
    698                     cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_BLACK,
    699                                                           CUCUL_BLACK));
     697                    cucul_set_color_ansi(cv, CUCUL_BLACK, CUCUL_BLACK);
    700698                cucul_putchar(cv, x, y, gradient[p & 0x0f]);
    701699            }
     
    761759        h = cucul_get_canvas_height(cv);
    762760
    763         cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_BLACK, CUCUL_BLACK));
     761        cucul_set_color_ansi(cv, CUCUL_BLACK, CUCUL_BLACK);
    764762        cucul_clear_canvas(cv);
    765763
     
    783781                else
    784782                    fg = CUCUL_DARKGRAY;
    785                 cucul_set_attr(cv, cucul_ansi_to_attr(fg, CUCUL_BLACK));
     783                cucul_set_color_ansi(cv, fg, CUCUL_BLACK);
    786784
    787785                cucul_putchar(cv, x, y - j,
  • libcaca/trunk/src/cacadraw.c

    r1257 r1267  
    152152static int refresh_screen(void)
    153153{
    154     cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_DEFAULT, CUCUL_DEFAULT));
     154    cucul_set_color_ansi(cv, CUCUL_DEFAULT, CUCUL_DEFAULT);
    155155    cucul_clear_canvas(cv);
    156156
  • libcaca/trunk/src/cacaview.c

    r1257 r1267  
    305305            sprintf(buffer, " Loading `%s'... ", list[current]);
    306306            buffer[ww] = '\0';
    307             cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_BLUE));
     307            cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE);
    308308            cucul_putstr(cv, (ww - strlen(buffer)) / 2, wh / 2, buffer);
    309309            caca_refresh_display(dp);
     
    325325        }
    326326
    327         cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_BLACK));
     327        cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLACK);
    328328        cucul_clear_canvas(cv);
    329329
    330330        if(!items)
    331331        {
    332             cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_BLUE));
     332            cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE);
    333333            cucul_printf(cv, ww / 2 - 5, wh / 2, " No image. ");
    334334        }
     
    350350            sprintf(buffer, ERROR_STRING, list[current]);
    351351            buffer[ww] = '\0';
    352             cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_BLUE));
     352            cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE);
    353353            cucul_putstr(cv, (ww - strlen(buffer)) / 2, wh / 2, buffer);
    354354            free(buffer);
     
    380380
    381381#if 0 /* FIXME */
    382             cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_LIGHTGRAY,
    383                                                   CUCUL_BLACK));
     382            cucul_set_color_ansi(cv, CUCUL_LIGHTGRAY, CUCUL_BLACK);
    384383            switch(status)
    385384            {
     
    420419static void print_status(void)
    421420{
    422     cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_BLUE));
     421    cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE);
    423422    cucul_draw_line(cv, 0, 0, ww - 1, 0, " ");
    424423    cucul_draw_line(cv, 0, wh - 2, ww - 1, wh - 2, "-");
     
    430429    cucul_printf(cv, ww - 14, wh - 2, "(zoom: %s%i)", zoom > 0 ? "+" : "", zoom);
    431430
    432     cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_LIGHTGRAY, CUCUL_BLACK));
     431    cucul_set_color_ansi(cv, CUCUL_LIGHTGRAY, CUCUL_BLACK);
    433432    cucul_draw_line(cv, 0, wh - 1, ww - 1, wh - 1, " ");
    434433}
     
    458457    int i;
    459458
    460     cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_BLUE));
     459    cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE);
    461460
    462461    for(i = 0; help[i]; i++)
     
    519518    {
    520519        if((((xn - x) / 5) ^ ((yn - y) / 3)) & 1)
    521             cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_LIGHTGRAY,
    522                                                   CUCUL_DARKGRAY));
     520            cucul_set_color_ansi(cv, CUCUL_LIGHTGRAY, CUCUL_DARKGRAY);
    523521        else
    524             cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_DARKGRAY,
    525                                                   CUCUL_LIGHTGRAY));
     522            cucul_set_color_ansi(cv, CUCUL_DARKGRAY, CUCUL_LIGHTGRAY);
    526523        cucul_putchar(cv, xn, yn, ' ');
    527524    }
  • libcaca/trunk/src/img2irc.c

    r1257 r1267  
    5757
    5858    cucul_set_canvas_size(cv, cols, lines);
    59     cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_DEFAULT, CUCUL_TRANSPARENT));
     59    cucul_set_color_ansi(cv, CUCUL_DEFAULT, CUCUL_TRANSPARENT);
    6060    cucul_clear_canvas(cv);
    6161    cucul_dither_bitmap(cv, 0, 0, cols, lines, i->dither, i->pixels);
  • libcaca/trunk/test/colors.c

    r1266 r1267  
    3636        return 1;
    3737
    38     cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_LIGHTGRAY, CUCUL_BLACK));
     38    cucul_set_color_ansi(cv, CUCUL_LIGHTGRAY, CUCUL_BLACK);
    3939    cucul_clear_canvas(cv);
    4040    for(i = 0; i < 16; i++)
    4141    {
    42         cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_LIGHTGRAY, CUCUL_BLACK));
     42        cucul_set_color_ansi(cv, CUCUL_LIGHTGRAY, CUCUL_BLACK);
    4343        cucul_printf(cv, 3, i + (i >= 8 ? 3 : 2), "'%cv': %i (%s)",
    44                      'a' + i, i, cucul_get_color_name(i));
     44                     'a' + i, i, cucul_ansi_to_str(i));
    4545        for(j = 0; j < 16; j++)
    4646        {
    47             cucul_set_attr(cv, cucul_ansi_to_attr(i, j));
     47            cucul_set_color_ansi(cv, i, j);
    4848            cucul_putstr(cv, (j >= 8 ? 40 : 39) + j * 2, i + (i >= 8 ? 3 : 2),
    4949                         "Aa");
     
    5151    }
    5252
    53     cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_LIGHTGRAY, CUCUL_BLACK));
     53    cucul_set_color_ansi(cv, CUCUL_LIGHTGRAY, CUCUL_BLACK);
    5454    cucul_putstr(cv, 3, 20, "This is bold    This is blink    This is italics    This is underline");
    5555    cucul_set_attr(cv, CUCUL_BOLD);
  • libcaca/trunk/test/demo.c

    r1257 r1267  
    151151                if(demo)
    152152                {
    153                     cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_LIGHTGRAY,
    154                                                           CUCUL_BLACK));
     153                    cucul_set_color_ansi(cv, CUCUL_LIGHTGRAY, CUCUL_BLACK);
    155154                    cucul_clear_canvas(cv);
    156155                }
     
    173172            if(mouse && !demo)
    174173            {
    175                 cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_RED, CUCUL_BLACK));
     174                cucul_set_color_ansi(cv, CUCUL_RED, CUCUL_BLACK);
    176175                cucul_putstr(cv, xmouse, ymouse,     ".");
    177176                cucul_putstr(cv, xmouse, ymouse + 1, "|\\");
     
    185184            demo();
    186185
    187             cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_LIGHTGRAY,
    188                                                   CUCUL_BLACK));
     186            cucul_set_color_ansi(cv, CUCUL_LIGHTGRAY, CUCUL_BLACK);
    189187            cucul_draw_thin_box(cv, 1, 1, cucul_get_canvas_width(cv) - 2,
    190188                                          cucul_get_canvas_height(cv) - 2);
     
    211209    int yo = cucul_get_canvas_height(cv) - 2;
    212210
    213     cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_LIGHTGRAY, CUCUL_BLACK));
     211    cucul_set_color_ansi(cv, CUCUL_LIGHTGRAY, CUCUL_BLACK);
    214212    cucul_clear_canvas(cv);
    215213    cucul_draw_thin_box(cv, 1, 1, xo, yo);
     
    253251    i++;
    254252
    255     cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_LIGHTGRAY, CUCUL_BLACK));
     253    cucul_set_color_ansi(cv, CUCUL_LIGHTGRAY, CUCUL_BLACK);
    256254    cucul_clear_canvas(cv);
    257255
    258256    /* Draw the sun */
    259     cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_YELLOW, CUCUL_BLACK));
     257    cucul_set_color_ansi(cv, CUCUL_YELLOW, CUCUL_BLACK);
    260258    xo = cucul_get_canvas_width(cv) / 4;
    261259    yo = cucul_get_canvas_height(cv) / 4 + 5 * sin(0.03*i);
     
    269267
    270268    j = 15 + sin(0.03*i) * 8;
    271     cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_BLACK));
     269    cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLACK);
    272270    cucul_fill_ellipse(cv, xo, yo, j, j / 2, "#");
    273     cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_YELLOW, CUCUL_BLACK));
     271    cucul_set_color_ansi(cv, CUCUL_YELLOW, CUCUL_BLACK);
    274272    cucul_draw_ellipse(cv, xo, yo, j, j / 2, "#");
    275273
     
    287285    yc = cucul_get_canvas_height(cv) * 3 / 4 + cos(0.02*i) * 5;
    288286
    289     cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_GREEN, CUCUL_BLACK));
     287    cucul_set_color_ansi(cv, CUCUL_GREEN, CUCUL_BLACK);
    290288    cucul_fill_triangle(cv, xo, yo, xb, yb, xa, ya, "%");
    291     cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_YELLOW, CUCUL_BLACK));
     289    cucul_set_color_ansi(cv, CUCUL_YELLOW, CUCUL_BLACK);
    292290    cucul_draw_thin_triangle(cv, xo, yo, xb, yb, xa, ya);
    293291
    294     cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_RED, CUCUL_BLACK));
     292    cucul_set_color_ansi(cv, CUCUL_RED, CUCUL_BLACK);
    295293    cucul_fill_triangle(cv, xa, ya, xb, yb, xc, yc, "#");
    296     cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_YELLOW, CUCUL_BLACK));
     294    cucul_set_color_ansi(cv, CUCUL_YELLOW, CUCUL_BLACK);
    297295    cucul_draw_thin_triangle(cv, xa, ya, xb, yb, xc, yc);
    298296
    299     cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_BLUE, CUCUL_BLACK));
     297    cucul_set_color_ansi(cv, CUCUL_BLUE, CUCUL_BLACK);
    300298    cucul_fill_triangle(cv, xo, yo, xb, yb, xc, yc, "%");
    301     cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_YELLOW, CUCUL_BLACK));
     299    cucul_set_color_ansi(cv, CUCUL_YELLOW, CUCUL_BLACK);
    302300    cucul_draw_thin_triangle(cv, xo, yo, xb, yb, xc, yc);
    303301
     
    312310    yc = cucul_get_canvas_height(cv) - 3;
    313311
    314     cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_CYAN, CUCUL_BLACK));
     312    cucul_set_color_ansi(cv, CUCUL_CYAN, CUCUL_BLACK);
    315313    cucul_draw_thin_triangle(cv, xa, ya, xb, yb, xc, yc);
    316314
     
    331329    {
    332330        int delta = cucul_rand(-5, 6);
    333         cucul_set_attr(cv, cucul_ansi_to_attr(cucul_rand(0, 16),
    334                                               cucul_rand(0, 16)));
     331        cucul_set_color_ansi(cv, cucul_rand(0, 16), cucul_rand(0, 16));
    335332        cucul_putchar(cv, cucul_get_canvas_width(cv) / 2
    336333                    + cos(0.02*j) * (delta + cucul_get_canvas_width(cv) / 4),
     
    361358    {
    362359        /* Putpixel */
    363         cucul_set_attr(cv, cucul_ansi_to_attr(cucul_rand(0, 16),
    364                                               cucul_rand(0, 16)));
     360        cucul_set_color_ansi(cv, cucul_rand(0, 16), cucul_rand(0, 16));
    365361        cucul_putchar(cv, cucul_rand(0, xmax), cucul_rand(0, ymax),
    366362                      chars[cucul_rand(0, 9)]);
     
    373369    char buf[BUFSIZ];
    374370
    375     cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_LIGHTGRAY, CUCUL_BLACK));
     371    cucul_set_color_ansi(cv, CUCUL_LIGHTGRAY, CUCUL_BLACK);
    376372    cucul_clear_canvas(cv);
    377373    for(i = 0; i < 16; i++)
    378374    {
    379         sprintf(buf, "'%c': %i (%s)", 'a' + i, i, cucul_get_color_name(i));
    380         cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_LIGHTGRAY, CUCUL_BLACK));
     375        sprintf(buf, "'%c': %i (%s)", 'a' + i, i, cucul_ansi_to_str(i));
     376        cucul_set_color_ansi(cv, CUCUL_LIGHTGRAY, CUCUL_BLACK);
    381377        cucul_putstr(cv, 4, i + (i >= 8 ? 4 : 3), buf);
    382378        for(j = 0; j < 16; j++)
    383379        {
    384             cucul_set_attr(cv, cucul_ansi_to_attr(i, j));
     380            cucul_set_color_ansi(cv, i, j);
    385381            cucul_putstr(cv, (j >= 8 ? 41 : 40) + j * 2, i + (i >= 8 ? 4 : 3), "# ");
    386382        }
     
    405401    }
    406402
    407     cucul_set_attr(cv, cucul_ansi_to_attr(cucul_rand(0, 16), CUCUL_BLACK));
     403    cucul_set_color_ansi(cv, cucul_rand(0, 16), CUCUL_BLACK);
    408404    if(outline > 1)
    409405        cucul_draw_thin_line(cv, xa, ya, xb, yb);
     
    429425    }
    430426
    431     cucul_set_attr(cv, cucul_ansi_to_attr(cucul_rand(0, 16),
    432                                           cucul_rand(0, 16)));
     427    cucul_set_color_ansi(cv, cucul_rand(0, 16), cucul_rand(0, 16));
    433428    cucul_fill_box(cv, xa, ya, xb, yb, "#");
    434429
    435     cucul_set_attr(cv, cucul_ansi_to_attr(cucul_rand(0, 16), CUCUL_BLACK));
     430    cucul_set_color_ansi(cv, cucul_rand(0, 16), CUCUL_BLACK);
    436431    if(outline == 2)
    437432        cucul_draw_thin_box(cv, xa, ya, xb, yb);
     
    461456    }
    462457
    463     cucul_set_attr(cv, cucul_ansi_to_attr(cucul_rand(0, 16),
    464                                           cucul_rand(0, 16)));
     458    cucul_set_color_ansi(cv, cucul_rand(0, 16), cucul_rand(0, 16));
    465459    cucul_fill_ellipse(cv, x, y, a, b, "#");
    466460
    467     cucul_set_attr(cv, cucul_ansi_to_attr(cucul_rand(0, 16), CUCUL_BLACK));
     461    cucul_set_color_ansi(cv, cucul_rand(0, 16), CUCUL_BLACK);
    468462    if(outline == 2)
    469463        cucul_draw_thin_ellipse(cv, x, y, a, b);
     
    492486    }
    493487
    494     cucul_set_attr(cv, cucul_ansi_to_attr(cucul_rand(0, 16),
    495                                           cucul_rand(0, 16)));
     488    cucul_set_color_ansi(cv, cucul_rand(0, 16), cucul_rand(0, 16));
    496489    cucul_fill_triangle(cv, xa, ya, xb, yb, xc, yc, "#");
    497490
    498     cucul_set_attr(cv, cucul_ansi_to_attr(cucul_rand(0, 16), CUCUL_BLACK));
     491    cucul_set_color_ansi(cv, cucul_rand(0, 16), CUCUL_BLACK);
    499492    if(outline == 2)
    500493        cucul_draw_thin_triangle(cv, xa, ya, xb, yb, xc, yc);
  • libcaca/trunk/test/dithering.c

    r1257 r1267  
    117117        else
    118118            ch = density[dista * 2 * 13 / (dista + distb)];
    119         cucul_set_attr(cv, cucul_ansi_to_attr(points[nearb], points[neara]));
     119        cucul_set_color_ansi(cv, points[nearb], points[neara]);
    120120
    121121        cucul_putchar(cv, x * cucul_get_canvas_width(cv) / 100,
  • libcaca/trunk/test/event.c

    r1257 r1267  
    4242    h = cucul_get_canvas_height(cv) - 1;
    4343
    44     cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_BLUE));
     44    cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE);
    4545    cucul_draw_line(cv, 0, 0, cucul_get_canvas_width(cv) - 1, 0, " ");
    4646
     
    8484        while(ret);
    8585
    86         cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_LIGHTGRAY, CUCUL_BLACK));
     86        cucul_set_color_ansi(cv, CUCUL_LIGHTGRAY, CUCUL_BLACK);
    8787        cucul_clear_canvas(cv);
    8888
    8989        /* Print current event */
    90         cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_BLUE));
     90        cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE);
    9191        cucul_draw_line(cv, 0, 0, cucul_get_canvas_width(cv) - 1, 0, " ");
    9292        print_event(0, 0, events);
     
    9696
    9797        /* Print previous events */
    98         cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_BLACK));
     98        cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLACK);
    9999        for(i = 1; i < h && events[i].type; i++)
    100100            print_event(0, i, events + i);
  • libcaca/trunk/test/export.c

    r1266 r1267  
    116116        cucul_free_dither(dither);
    117117
    118         cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_BLACK));
     118        cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLACK);
    119119        cucul_draw_thin_box(cv, 0, 0, WIDTH - 1, HEIGHT - 1);
    120120
    121         cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_BLACK, CUCUL_WHITE));
     121        cucul_set_color_ansi(cv, CUCUL_BLACK, CUCUL_WHITE);
    122122        cucul_fill_ellipse(cv, WIDTH / 2, HEIGHT / 2,
    123123                               WIDTH / 4, HEIGHT / 4, " ");
     
    135135        cucul_set_attr(cv, CUCUL_UNDERLINE);
    136136        cucul_putstr(cv, WIDTH / 2 + 8, HEIGHT / 2 + 3, "Underline");
     137        cucul_set_attr(cv, 0);
    137138
    138         cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_LIGHTBLUE));
     139        cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_LIGHTBLUE);
    139140        cucul_putstr(cv, WIDTH / 2 - 7, HEIGHT / 2, "    LIBCACA    ");
    140141
    141142        for(x = 0; x < 16; x++)
    142143        {
    143             cucul_set_attr(cv, cucul_argb_to_attr(0xff00 | x,
    144                                                   0xf00f | (x << 4)));
     144            cucul_set_color_argb(cv, 0xff00 | x, 0xf00f | (x << 4));
    145145            cucul_putstr(cv, WIDTH / 2 - 7 + x, HEIGHT / 2 + 5, "#");
    146146        }
  • libcaca/trunk/test/font.c

    r1257 r1267  
    4646
    4747    /* Draw stuff on our canvas */
    48     cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_BLACK));
     48    cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLACK);
    4949    cucul_putstr(cv, 0, 0, "ABcde");
    50     cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_LIGHTRED, CUCUL_BLACK));
     50    cucul_set_color_ansi(cv, CUCUL_LIGHTRED, CUCUL_BLACK);
    5151    cucul_putstr(cv, 5, 0, "\\o/");
    52     cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_BLUE));
     52    cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE);
    5353    cucul_putstr(cv, 0, 1, "&$âøÿØ?!");
    5454
  • libcaca/trunk/test/font2tga.c

    r1257 r1267  
    5959    /* Create a canvas */
    6060    cv = cucul_create_canvas(WIDTH, (glyphs + WIDTH - 1) / WIDTH);
    61     cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_BLACK, CUCUL_WHITE));
     61    cucul_set_color_ansi(cv, CUCUL_BLACK, CUCUL_WHITE);
    6262
    6363    /* Put all glyphs on the canvas */
  • libcaca/trunk/test/frames.c

    r1257 r1267  
    4949    {
    5050        cucul_set_canvas_frame(cv, frame);
    51         cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_WHITE, frame));
     51        cucul_set_color_ansi(cv, CUCUL_WHITE, frame);
    5252        cucul_fill_box(cv, 0, 0, 40, 15, ":");
    53         cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_BLUE));
     53        cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE);
    5454        cucul_putstr(cv, frame * 5 / 2, frame, "カカ");
    5555    }
     
    6161            cucul_get_canvas_width(cv), cucul_get_canvas_height(cv));
    6262
    63     cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_DEFAULT, CUCUL_TRANSPARENT));
     63    cucul_set_color_ansi(cv, CUCUL_DEFAULT, CUCUL_TRANSPARENT);
    6464    dp = caca_create_display(cv);
    6565    caca_set_display_time(dp, 50000);
  • libcaca/trunk/test/fullwidth.c

    r1257 r1267  
    4343    for(i = 0; i < 10; i++)
    4444    {
    45         cucul_set_attr(caca, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_BLUE));
     45        cucul_set_color_ansi(caca, CUCUL_WHITE, CUCUL_BLUE);
    4646        cucul_putstr(caca, 0, i, CACA);
    47         cucul_set_attr(caca, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_RED));
     47        cucul_set_color_ansi(caca, CUCUL_WHITE, CUCUL_RED);
    4848        cucul_putchar(caca, i - 2, i, 'x');
    4949    }
     
    5454    for(i = 0; i < 10; i++)
    5555    {
    56         cucul_set_attr(caca, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_BLUE));
     56        cucul_set_color_ansi(caca, CUCUL_WHITE, CUCUL_BLUE);
    5757        cucul_putstr(caca, 0, i, CACA);
    58         cucul_set_attr(caca, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_GREEN));
     58        cucul_set_color_ansi(caca, CUCUL_WHITE, CUCUL_GREEN);
    5959        cucul_putstr(caca, i - 2, i, "ホ");
    6060    }
     
    6363
    6464    /* Line of canvas */
    65     cucul_set_attr(line, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_MAGENTA));
     65    cucul_set_color_ansi(line, CUCUL_WHITE, CUCUL_MAGENTA);
    6666    cucul_putstr(line, 0, 0, "ほ");
    6767    for(i = 0; i < 10; i++)
    6868    {
    69         cucul_set_attr(caca, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_BLUE));
     69        cucul_set_color_ansi(caca, CUCUL_WHITE, CUCUL_BLUE);
    7070        cucul_putstr(caca, 0, i, CACA);
    7171        cucul_blit(caca, i - 2, i, line, NULL);
  • libcaca/trunk/test/gamma.c

    r1257 r1267  
    8787
    8888        /* Draw something on the mask */
    89         cucul_set_attr(mask, cucul_ansi_to_attr(CUCUL_LIGHTGRAY, CUCUL_BLACK));
     89        cucul_set_color_ansi(mask, CUCUL_LIGHTGRAY, CUCUL_BLACK);
    9090        cucul_clear_canvas(mask);
    91         cucul_set_attr(mask, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_WHITE));
     91        cucul_set_color_ansi(mask, CUCUL_WHITE, CUCUL_WHITE);
    9292        cucul_fill_ellipse(mask, (1.0 + sin(0.05 * (float)x))
    9393                                   * 0.5 * cucul_get_canvas_width(mask),
     
    100100        cucul_blit(cv, 0, 0, cw, mask);
    101101
    102         cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_BLUE));
     102        cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE);
    103103        cucul_printf(cv, 2, 1,
    104104                     "gamma=%g - use arrows to change, Esc to quit", gam);
  • libcaca/trunk/test/input.c

    r1257 r1267  
    4444    dp = caca_create_display(cv);
    4545
    46     cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_BLUE));
     46    cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE);
    4747    cucul_putstr(cv, 1, 1, "Text entries - press tab to cycle");
    4848
     
    6262            unsigned int j, start, size;
    6363
    64             cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_BLACK,
    65                                                   CUCUL_LIGHTGRAY));
     64            cucul_set_color_ansi(cv, CUCUL_BLACK, CUCUL_LIGHTGRAY);
    6665            cucul_fill_box(cv, 2, 3 * i + 4, 2 + BUFFER_SIZE, 3 * i + 4, " ");
    6766
     
    7776
    7877        /* Put the cursor on the active textentry */
    79         cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_LIGHTRED, CUCUL_LIGHTRED));
     78        cucul_set_color_ansi(cv, CUCUL_LIGHTRED, CUCUL_LIGHTRED);
    8079        cucul_putchar(cv, 2 + entries[e].cursor, 3 * e + 4, ' ');
    8180
  • libcaca/trunk/test/spritedit.c

    r1257 r1267  
    103103
    104104
    105         cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_LIGHTGRAY, CUCUL_BLACK));
     105        cucul_set_color_ansi(cv, CUCUL_LIGHTGRAY, CUCUL_BLACK);
    106106        cucul_clear_canvas(cv);
    107107
     
    126126        xb = xa + 1 + cucul_get_sprite_width(sprite, frame);
    127127        yb = ya + 1 + cucul_get_sprite_height(sprite, frame);
    128         cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_BLACK, CUCUL_BLACK));
     128        cucul_set_color_ansi(cv, CUCUL_BLACK, CUCUL_BLACK);
    129129        cucul_fill_box(cv, 57 + xa, 10 + ya, 57 + xb, 10 + yb, " ");
    130         cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_LIGHTGRAY, CUCUL_BLACK));
     130        cucul_set_color_ansi(cv, CUCUL_LIGHTGRAY, CUCUL_BLACK);
    131131        cucul_draw_thin_box(cv, 57 + xa, 10 + ya, 57 + xb, 10 + yb);
    132132        cucul_draw_sprite(cv, 57, 10, sprite, frame);
  • libcaca/trunk/test/transform.c

    r1257 r1267  
    5959    rotate = cucul_create_canvas(70, 6);
    6060
    61     cucul_set_attr(normal, cucul_ansi_to_attr(CUCUL_LIGHTMAGENTA, CUCUL_BLACK));
     61    cucul_set_color_ansi(normal, CUCUL_LIGHTMAGENTA, CUCUL_BLACK);
    6262    for(i = 0; pig[i]; i++)
    6363        cucul_putstr(normal, 55, i, pig[i]);
    6464
    65     cucul_set_attr(normal, cucul_ansi_to_attr(CUCUL_LIGHTGREEN, CUCUL_BLACK));
     65    cucul_set_color_ansi(normal, CUCUL_LIGHTGREEN, CUCUL_BLACK);
    6666    for(i = 0; duck[i]; i++)
    6767        cucul_putstr(normal, 30, 1 + i, duck[i]);
    6868
    69     cucul_set_attr(normal, cucul_ansi_to_attr(CUCUL_LIGHTCYAN, CUCUL_BLACK));
     69    cucul_set_color_ansi(normal, CUCUL_LIGHTCYAN, CUCUL_BLACK);
    7070    cucul_putstr(normal, 1, 1, "hahaha mais vieux porc immonde !! [⽼ ⾗]");
    71     cucul_set_attr(normal, cucul_ansi_to_attr(CUCUL_LIGHTRED, CUCUL_BLACK));
     71    cucul_set_color_ansi(normal, CUCUL_LIGHTRED, CUCUL_BLACK);
    7272    cucul_putchar(normal, 38, 1, '|');
    7373
    74     cucul_set_attr(normal, cucul_ansi_to_attr(CUCUL_YELLOW, CUCUL_BLACK));
     74    cucul_set_color_ansi(normal, CUCUL_YELLOW, CUCUL_BLACK);
    7575    cucul_putstr(normal, 4, 2, "\\o\\ \\o| _o/ \\o_ |o/ /o/");
    7676
    77     cucul_set_attr(normal, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_LIGHTRED));
     77    cucul_set_color_ansi(normal, CUCUL_WHITE, CUCUL_LIGHTRED);
    7878    cucul_putstr(normal, 7, 3, "▙▘▌▙▘▞▖▞▖▌ ▞▖▌ ▌▌");
    7979    cucul_putstr(normal, 7, 4, "▛▖▌▛▖▚▘▚▘▚▖▚▘▚▖▖▖");
    80     cucul_set_attr(normal, cucul_ansi_to_attr(CUCUL_BLACK, CUCUL_LIGHTRED));
     80    cucul_set_color_ansi(normal, CUCUL_BLACK, CUCUL_LIGHTRED);
    8181    cucul_putstr(normal, 4, 3, "▓▒░");
    8282    cucul_putstr(normal, 4, 4, "▓▒░");
     
    9595
    9696    /* Blit the transformed canvas onto the main canvas */
    97     cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_BLUE));
     97    cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE);
    9898    cucul_putstr(cv, 0, 0, "normal");
    9999    cucul_blit(cv, 10, 0, normal, NULL);
  • libcaca/trunk/test/truecolor.c

    r1257 r1267  
    4141        uint16_t fgcolor = 0xf000 | ((15 - y) << 4) | ((15 - x) << 8);
    4242
    43         cucul_set_attr(cv, cucul_argb_to_attr(fgcolor, bgcolor));
     43        cucul_set_color_argb(cv, fgcolor, bgcolor);
    4444        cucul_putstr(cv, x * 2, y, "CA");
    4545    }
    4646
    47     cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_LIGHTBLUE));
     47    cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_LIGHTBLUE);
    4848    cucul_putstr(cv, 2, 1, " truecolor libcaca ");
    4949
  • libcaca/trunk/test/unicode.c

    r1257 r1267  
    2525#include "caca.h"
    2626
    27 #define ATTR_WHITE_ON_BLUE cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_BLUE)
    28 #define ATTR_DEFAULT cucul_ansi_to_attr(CUCUL_DEFAULT, CUCUL_TRANSPARENT)
    29 
    3027int main(int argc, char *argv[])
    3128{
     
    3633    dp = caca_create_display(cv);
    3734
    38     cucul_set_attr(cv, ATTR_WHITE_ON_BLUE);
     35    cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE);
    3936    cucul_putstr(cv, 1, 1, "Basic Unicode support");
    4037
    41     cucul_set_attr(cv, ATTR_DEFAULT);
     38    cucul_set_color_ansi(cv, CUCUL_DEFAULT, CUCUL_TRANSPARENT);
    4239    cucul_putstr(cv, 1, 2, "This is ASCII:    | abc DEF 123 !@# |");
    4340    cucul_putstr(cv, 1, 3, "This is Unicode:  | äßç δεφ ☺♥♀ ╞╬╗ |");
     
    4643    cucul_putstr(cv, 1, 5, "If the three lines do not have the same length, there is a bug somewhere.");
    4744
    48     cucul_set_attr(cv, ATTR_WHITE_ON_BLUE);
     45    cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE);
    4946    cucul_putstr(cv, 1, 7, "Gradient glyphs");
    5047
    51     cucul_set_attr(cv, ATTR_DEFAULT);
     48    cucul_set_color_ansi(cv, CUCUL_DEFAULT, CUCUL_TRANSPARENT);
    5249    cucul_putstr(cv, 31,  8, "  0%");
    5350    cucul_putstr(cv, 31,  9, " 25%");
     
    5653    cucul_putstr(cv, 31, 12, "100%");
    5754
    58     cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_LIGHTRED, CUCUL_LIGHTGREEN));
     55    cucul_set_color_ansi(cv, CUCUL_LIGHTRED, CUCUL_LIGHTGREEN);
    5956    cucul_putstr(cv, 1,  8, "                             ");
    6057    cucul_putstr(cv, 1,  9, "░░░░░░░░░░░░░░░░░░░░░░░░░░░░░");
     
    6360    cucul_putstr(cv, 1, 12, "█████████████████████████████");
    6461
    65     cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_LIGHTGREEN, CUCUL_LIGHTRED));
     62    cucul_set_color_ansi(cv, CUCUL_LIGHTGREEN, CUCUL_LIGHTRED);
    6663    cucul_putstr(cv, 36,  8, "█████████████████████████████");
    6764    cucul_putstr(cv, 36,  9, "▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓");
     
    7067    cucul_putstr(cv, 36, 12, "                             ");
    7168
    72     cucul_set_attr(cv, ATTR_WHITE_ON_BLUE);
     69    cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE);
    7370    cucul_putstr(cv, 1, 14, "Double width characters");
    7471
    75     cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_LIGHTRED, CUCUL_TRANSPARENT));
     72    cucul_set_color_ansi(cv, CUCUL_LIGHTRED, CUCUL_TRANSPARENT);
    7673    cucul_putstr(cv, 1, 15, "| ドラゴン ボーレ |");
    77     cucul_set_attr(cv, ATTR_DEFAULT);
     74    cucul_set_color_ansi(cv, CUCUL_DEFAULT, CUCUL_TRANSPARENT);
    7875    cucul_putstr(cv, 1, 16, "| ()()()() ()()() |");
    79     cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_YELLOW, CUCUL_TRANSPARENT));
     76    cucul_set_color_ansi(cv, CUCUL_YELLOW, CUCUL_TRANSPARENT);
    8077    cucul_putstr(cv, 1, 17, "| ドラゴン");
    8178    cucul_putstr(cv, 12, 17, "ボーレ |");
    8279
    83     cucul_set_attr(cv, ATTR_DEFAULT);
     80    cucul_set_color_ansi(cv, CUCUL_DEFAULT, CUCUL_TRANSPARENT);
    8481    cucul_putstr(cv, 1, 18, "If the three lines do not have the same length, there is a bug somewhere.");
    8582
Note: See TracChangeset for help on using the changeset viewer.