Changeset 1257


Ignore:
Timestamp:
Oct 29, 2006, 9:54:51 PM (14 years ago)
Author:
Sam Hocevar
Message:
  • Get rid of cucul_set_attr_ansi() and cucul_set_attr_argb and merge the functionality into cucul_set_attr().
  • Add cucul_ansi_to_attr() and cucul_argb_to_attr().
  • Rename CUCUL_COLOR_* to CUCUL_*.
Location:
libcaca/trunk
Files:
32 edited

Legend:

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

    r1015 r1257  
    3030cucul_canvas_t *__caca0_cv = NULL;
    3131caca_display_t *__caca0_dp = NULL;
    32 unsigned char __caca0_fg = CUCUL_COLOR_LIGHTGRAY;
    33 unsigned char __caca0_bg = CUCUL_COLOR_BLACK;
     32unsigned char __caca0_fg = CUCUL_LIGHTGRAY;
     33unsigned char __caca0_bg = CUCUL_BLACK;
    3434char __caca0_utf8[2] = " ";
    3535
     
    6161        return -1;
    6262    }
    63     __caca0_fg = CUCUL_COLOR_LIGHTGRAY;
    64     __caca0_bg = CUCUL_COLOR_BLACK;
     63    __caca0_fg = CUCUL_LIGHTGRAY;
     64    __caca0_bg = CUCUL_BLACK;
    6565    return 0;
    6666}
  • libcaca/trunk/caca/caca0.h

    r1254 r1257  
    5151enum caca_color
    5252{
    53     CACA_COLOR_BLACK = CUCUL_COLOR_BLACK,
    54     CACA_COLOR_BLUE = CUCUL_COLOR_BLUE,
    55     CACA_COLOR_GREEN = CUCUL_COLOR_GREEN,
    56     CACA_COLOR_CYAN = CUCUL_COLOR_CYAN,
    57     CACA_COLOR_RED = CUCUL_COLOR_RED,
    58     CACA_COLOR_MAGENTA = CUCUL_COLOR_MAGENTA,
    59     CACA_COLOR_BROWN = CUCUL_COLOR_BROWN,
    60     CACA_COLOR_LIGHTGRAY = CUCUL_COLOR_LIGHTGRAY,
    61     CACA_COLOR_DARKGRAY = CUCUL_COLOR_DARKGRAY,
    62     CACA_COLOR_LIGHTBLUE = CUCUL_COLOR_LIGHTBLUE,
    63     CACA_COLOR_LIGHTGREEN = CUCUL_COLOR_LIGHTGREEN,
    64     CACA_COLOR_LIGHTCYAN = CUCUL_COLOR_LIGHTCYAN,
    65     CACA_COLOR_LIGHTRED = CUCUL_COLOR_LIGHTRED,
    66     CACA_COLOR_LIGHTMAGENTA = CUCUL_COLOR_LIGHTMAGENTA,
    67     CACA_COLOR_YELLOW = CUCUL_COLOR_YELLOW,
    68     CACA_COLOR_WHITE = CUCUL_COLOR_WHITE,
     53    CACA_COLOR_BLACK = CUCUL_BLACK,
     54    CACA_COLOR_BLUE = CUCUL_BLUE,
     55    CACA_COLOR_GREEN = CUCUL_GREEN,
     56    CACA_COLOR_CYAN = CUCUL_CYAN,
     57    CACA_COLOR_RED = CUCUL_RED,
     58    CACA_COLOR_MAGENTA = CUCUL_MAGENTA,
     59    CACA_COLOR_BROWN = CUCUL_BROWN,
     60    CACA_COLOR_LIGHTGRAY = CUCUL_LIGHTGRAY,
     61    CACA_COLOR_DARKGRAY = CUCUL_DARKGRAY,
     62    CACA_COLOR_LIGHTBLUE = CUCUL_LIGHTBLUE,
     63    CACA_COLOR_LIGHTGREEN = CUCUL_LIGHTGREEN,
     64    CACA_COLOR_LIGHTCYAN = CUCUL_LIGHTCYAN,
     65    CACA_COLOR_LIGHTRED = CUCUL_LIGHTRED,
     66    CACA_COLOR_LIGHTMAGENTA = CUCUL_LIGHTMAGENTA,
     67    CACA_COLOR_YELLOW = CUCUL_YELLOW,
     68    CACA_COLOR_WHITE = CUCUL_WHITE,
    6969};
    7070
     
    132132#define caca_set_color(x, y) \
    133133    (__caca0_fg = (x), __caca0_bg = (y), \
    134      cucul_set_attr_ansi(__caca0_cv, x, y, 0))
     134     cucul_set_attr(__caca0_cv, cucul_ansi_to_attr(x, y)))
    135135#define caca_get_fg_color() __caca0_fg
    136136#define caca_get_bg_color() __caca0_bg
  • libcaca/trunk/caca/driver_gl.c

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

    r1254 r1257  
    223223            if(fgcolor == bgcolor)
    224224            {
    225                 if(fgcolor == CUCUL_COLOR_BLACK)
    226                     fgcolor = CUCUL_COLOR_WHITE;
    227                 else if(fgcolor == CUCUL_COLOR_WHITE
    228                          || fgcolor <= CUCUL_COLOR_LIGHTGRAY)
    229                     fgcolor = CUCUL_COLOR_BLACK;
     225                if(fgcolor == CUCUL_BLACK)
     226                    fgcolor = CUCUL_WHITE;
     227                else if(fgcolor == CUCUL_WHITE
     228                         || fgcolor <= CUCUL_LIGHTGRAY)
     229                    fgcolor = CUCUL_BLACK;
    230230                else
    231                     fgcolor = CUCUL_COLOR_WHITE;
     231                    fgcolor = CUCUL_WHITE;
    232232                SLsmg_set_color(slang_assoc[fgcolor + 16 * bgcolor]);
    233233                SLsmg_write_char(' ');
  • libcaca/trunk/cucul/colour.c

    r1256 r1257  
    3030int cucul_set_color(cucul_canvas_t *, unsigned char, unsigned char);
    3131int cucul_set_truecolor(cucul_canvas_t *, unsigned int, unsigned int);
    32 
    33 /* RGB colours for the ANSI palette. There is no real standard, so we
    34  * use the same values as gnome-terminal. The 7th colour (brown) is a bit
    35  * special: 0xfa50 instead of 0xfaa0. */
    36 static const uint16_t ansitab[16] =
    37 {
    38     0xf000, 0xf00a, 0xf0a0, 0xf0aa, 0xfa00, 0xfa0a, 0xfa50, 0xfaaa,
    39     0xf555, 0xf55f, 0xf5f5, 0xf5ff, 0xff55, 0xff5f, 0xfff5, 0xffff,
    40 };
    4132
    4233/** \brief Set the default character attribute.
     
    4839 *  will use this attribute.
    4940 *
    50  *  The attribute value is a 32-bit integer as returned by cucul_get_attr().
    51  *  For more user-friendly versions of this function, see cucul_set_attr_ansi()
    52  *  and cucul_set_attr_argb().
     41 *  The attribute value is a 32-bit integer as returned by cucul_get_attr()
     42 *  or created using cucul_ansi_to_attr() and cucul_argb_to_attr(), optionally
     43 *  ORed with style values such as CUCUL_UNDERLINE or CUCUL_BLINK.
    5344 *
    5445 *  If an error occurs, -1 is returned and \b errno is set accordingly:
     
    8071 *  caca_draw_line() will use these attributes.
    8172 *
    82  *  Color values are those defined in cucul.h, such as CUCUL_COLOR_RED
    83  *  or CUCUL_COLOR_TRANSPARENT.
    84  *
    85  *  Style values are those defined in cucul.h, such as CUCUL_STYLE_UNDERLINE
    86  *  or CUCUL_STYLE_BLINK. The values can be ORed to set several styles at
     73 *  Color values are those defined in cucul.h, such as CUCUL_RED
     74 *  or CUCUL_TRANSPARENT.
     75 *
     76 *  Style values are those defined in cucul.h, such as CUCUL_UNDERLINE
     77 *  or CUCUL_BLINK. The values can be ORed to set several styles at
    8778 *  the same time.
    8879 *
    89  *  If an error occurs, -1 is returned and \b errno is set accordingly:
     80 *  If an error occurs, 0 is returned and \b errno is set accordingly:
    9081 *  - \c EINVAL The colour values and/or the style mask are invalid.
    9182 *
     
    9687 *  \return 0 in case of success, -1 if an error occurred.
    9788 */
    98 int cucul_set_attr_ansi(cucul_canvas_t *cv, unsigned char fg, unsigned char bg,
    99                         unsigned char style)
    100 {
    101     uint32_t attr;
    102 
    103     if(fg > 0x20 || bg > 0x20 || style > 0x0f)
     89unsigned long int cucul_ansi_to_attr(unsigned char fg, unsigned char bg)
     90{
     91    if(fg > 0x20 || bg > 0x20)
     92    {
     93#if defined(HAVE_ERRNO_H)
     94        errno = EINVAL;
     95#endif
     96        return 0;
     97    }
     98
     99    return ((unsigned long int)bg << 18) | ((unsigned long int)fg << 4);
     100}
     101
     102/* Legacy function for old programs */
     103int cucul_set_color(cucul_canvas_t *cv, unsigned char fg, unsigned char bg)
     104{
     105    return cucul_set_attr(cv, cucul_ansi_to_attr(fg, bg));
     106}
     107
     108/** \brief Set the default colour pair and text style (truecolor version).
     109 *
     110 *  Set the default colour pair and text style for drawing. String
     111 *  functions such as caca_printf() and graphical primitive functions such as
     112 *  caca_draw_line() will use these attributes.
     113 *
     114 *  Colors are 16-bit ARGB values, each component being coded on 4 bits. For
     115 *  instance, 0xf088 is solid dark cyan (A=15 R=0 G=8 B=8), and 0x8fff is
     116 *  white with 50% alpha (A=8 R=15 G=15 B=15).
     117 *
     118 *  If an error occurs, 0 is returned and \b errno is set accordingly:
     119 *  - \c EINVAL At least one of the colour values is invalid.
     120 *
     121 *  \param cv A handle to the libcucul canvas.
     122 *  \param fg The requested foreground colour.
     123 *  \param bg The requested background colour.
     124 *  \param style The requested text styles.
     125 *  \return 0 in case of success, -1 if an error occurred.
     126 */
     127unsigned long int cucul_argb_to_attr(unsigned int fg, unsigned int bg)
     128{
     129    if(fg > 0xffff || bg > 0xffff)
    104130    {
    105131#if defined(HAVE_ERRNO_H)
     
    109135    }
    110136
    111     attr = ((uint32_t)bg << 20) | ((uint32_t)fg << 4);
    112 
    113     if(style)
    114         attr |= (0x02004801 * style) & 0x10011001;
    115 
    116     cv->curattr = attr;
    117 
    118     return 0;
    119 }
    120 
    121 /* Legacy function for old programs */
    122 int cucul_set_color(cucul_canvas_t *cv, unsigned char fg, unsigned char bg)
    123 {
    124     return cucul_set_attr_ansi(cv, fg, bg, 0);
    125 }
    126 
    127 /** \brief Set the default colour pair and text style (truecolor version).
    128  *
    129  *  Set the default colour pair and text style for drawing. String
    130  *  functions such as caca_printf() and graphical primitive functions such as
    131  *  caca_draw_line() will use these attributes.
    132  *
    133  *  Colors are 16-bit ARGB values, each component being coded on 4 bits. For
    134  *  instance, 0xf088 is solid dark cyan (A=15 R=0 G=8 B=8), and 0x8fff is
    135  *  white with 50% alpha (A=8 R=15 G=15 B=15).
    136  *
    137  *  Style values are those defined in cucul.h, such as CUCUL_STYLE_UNDERLINE
    138  *  or CUCUL_STYLE_BLINK. The values can be ORed to set several styles at
    139  *  the same time.
    140  *
    141  *  If an error occurs, -1 is returned and \b errno is set accordingly:
    142  *  - \c EINVAL At least one of the colour values is invalid.
    143  *
    144  *  \param cv A handle to the libcucul canvas.
    145  *  \param fg The requested foreground colour.
    146  *  \param bg The requested background colour.
    147  *  \param style The requested text styles.
    148  *  \return 0 in case of success, -1 if an error occurred.
    149  */
    150 int cucul_set_attr_argb(cucul_canvas_t *cv, unsigned int fg, unsigned int bg,
    151                         unsigned char style)
    152 {
    153     uint32_t attr;
    154 
    155     if(fg > 0xffff || bg > 0xffff || style > 0x0f)
    156     {
    157 #if defined(HAVE_ERRNO_H)
    158         errno = EINVAL;
    159 #endif
    160         return -1;
    161     }
    162 
    163137    if(fg < 0x100)
    164138        fg += 0x100;
     
    167141        bg += 0x100;
    168142
    169     attr = (((uint32_t)bg << 16) | (uint32_t)fg) & 0xeffeeffe;
    170 
    171     if(style)
    172         attr |= (0x02004801 * style) & 0x10011001;
    173 
    174     cv->curattr = attr;
    175 
    176     return 0;
     143    fg = ((fg >> 1) & 0x7ff) | ((fg >> 13) << 11);
     144    bg = ((bg >> 1) & 0x7ff) | ((bg >> 13) << 11);
     145
     146    return ((unsigned long int)bg << 18) | ((unsigned long int)fg << 4);
    177147}
    178148
     
    180150int cucul_set_truecolor(cucul_canvas_t *cv, unsigned int fg, unsigned int bg)
    181151{
    182     return cucul_set_attr_argb(cv, fg, bg, 0);
     152    return cucul_set_attr(cv, cucul_argb_to_attr(fg, bg));
    183153}
    184154
     
    189159 *  organised as follows from MSB to LSB:
    190160 *  - 3 bits for the background alpha
    191  *  - 1 bit for the blink flag
    192161 *  - 4 bits for the background red component
    193162 *  - 4 bits for the background green component
    194163 *  - 3 bits for the background blue component
    195  *  - 1 bit for the underline flag
    196164 *  - 3 bits for the foreground alpha
    197  *  - 1 bit for the italics flag
    198165 *  - 4 bits for the foreground red component
    199166 *  - 4 bits for the foreground green component
    200167 *  - 3 bits for the foreground blue component
    201  *  - 1 bit for the bold flag
     168 *  - 4 bits for the bold, italics, underline and blink flags
    202169 *
    203170 *  If the coordinates are outside the canvas boundaries, the current
     
    223190 */
    224191
    225 static uint8_t nearest_ansi(uint16_t argb16, uint8_t def)
     192/* RGB colours for the ANSI palette. There is no real standard, so we
     193 * use the same values as gnome-terminal. The 7th colour (brown) is a bit
     194 * special: 0xfa50 instead of 0xfaa0. */
     195static const uint16_t ansitab16[16] =
     196{
     197    0xf000, 0xf00a, 0xf0a0, 0xf0aa, 0xfa00, 0xfa0a, 0xfa50, 0xfaaa,
     198    0xf555, 0xf55f, 0xf5f5, 0xf5ff, 0xff55, 0xff5f, 0xfff5, 0xffff,
     199};
     200
     201/* Same table, except on 14 bits (3-4-4-3) */
     202static const uint16_t ansitab14[16] =
     203{
     204    0x3800, 0x3805, 0x3850, 0x3855, 0x3d00, 0x3d05, 0x3d28, 0x3d55,
     205    0x3aaa, 0x3aaf, 0x3afa, 0x3aff, 0x3faa, 0x3faf, 0x3ffa, 0x3fff,
     206};
     207
     208static uint8_t nearest_ansi(uint16_t argb14, uint8_t def)
    226209{
    227210    unsigned int i, best, dist;
    228211
    229     if(argb16 == (argb16 & 0x00f0))
    230         return argb16 >> 4;
    231 
    232     if(argb16 == (CUCUL_COLOR_DEFAULT << 4)
    233        || argb16 == (CUCUL_COLOR_TRANSPARENT << 4))
     212    if(argb14 < 0x0010)
     213        return argb14;
     214
     215    if(argb14 == CUCUL_DEFAULT || argb14 == CUCUL_TRANSPARENT)
    234216        return def;
    235217
    236     if(argb16 < 0x6fff) /* too transparent, return default colour */
     218    if(argb14 < 0x0fff) /* too transparent, return default colour */
    237219        return def;
    238220
    239221    best = def;
    240     dist = 0xffff;
     222    dist = 0x3fff;
    241223    for(i = 0; i < 16; i++)
    242224    {
     
    244226        int a, b;
    245227
    246         a = (ansitab[i] >> 8) & 0xf;
    247         b = (argb16 >> 8) & 0xf;
     228        a = (ansitab14[i] >> 7) & 0xf;
     229        b = (argb14 >> 7) & 0xf;
    248230        d += (a - b) * (a - b);
    249231
    250         a = (ansitab[i] >> 4) & 0xf;
    251         b = (argb16 >> 4) & 0xf;
     232        a = (ansitab14[i] >> 3) & 0xf;
     233        b = (argb14 >> 3) & 0xf;
    252234        d += (a - b) * (a - b);
    253235
    254         a = ansitab[i] & 0xf;
    255         b = argb16 & 0xf;
     236        a = (ansitab14[i] << 1) & 0xf;
     237        b = (argb14 << 1) & 0xf;
    256238        d += (a - b) * (a - b);
    257239
     
    268250uint8_t _cucul_attr_to_ansi8(uint32_t attr)
    269251{
    270     uint16_t fg = attr & 0xeffe;
    271     uint16_t bg = (attr >> 16) & 0xeffe;
    272 
    273     return nearest_ansi(fg, CUCUL_COLOR_LIGHTGRAY)
    274             | (nearest_ansi(bg, CUCUL_COLOR_BLACK) << 4);
     252    uint16_t fg = (attr >> 4) & 0x3fff;
     253    uint16_t bg = attr >> 18;
     254
     255    return nearest_ansi(fg, CUCUL_LIGHTGRAY)
     256            | (nearest_ansi(bg, CUCUL_BLACK) << 4);
    275257}
    276258
    277259uint8_t _cucul_attr_to_ansi4fg(uint32_t attr)
    278260{
    279     return nearest_ansi(attr & 0xeffe, CUCUL_COLOR_LIGHTGRAY);
     261    return nearest_ansi((attr >> 4) & 0x3fff, CUCUL_LIGHTGRAY);
    280262}
    281263
    282264uint8_t _cucul_attr_to_ansi4bg(uint32_t attr)
    283265{
    284     return nearest_ansi((attr >> 16) & 0xeffe, CUCUL_COLOR_BLACK);
     266    return nearest_ansi(attr >> 18, CUCUL_BLACK);
    285267}
    286268
    287269uint16_t _cucul_attr_to_rgb12fg(uint32_t attr)
    288270{
    289     uint16_t fg = attr & 0xeffe;
    290 
    291     if(fg == (fg & 0x00f0))
    292         return ansitab[fg >> 4] & 0x0fff;
    293 
    294     if(fg == (CUCUL_COLOR_DEFAULT << 4))
    295         return ansitab[CUCUL_COLOR_LIGHTGRAY] & 0x0fff;
    296 
    297     if(fg == (CUCUL_COLOR_TRANSPARENT << 4))
    298         return ansitab[CUCUL_COLOR_LIGHTGRAY] & 0x0fff;
    299 
    300     return fg & 0x0fff;
     271    uint16_t fg = (attr >> 4) & 0x3fff;
     272
     273    if(fg < 0x0010)
     274        return ansitab16[fg] & 0x0fff;
     275
     276    if(fg == CUCUL_DEFAULT)
     277        return ansitab16[CUCUL_LIGHTGRAY] & 0x0fff;
     278
     279    if(fg == CUCUL_TRANSPARENT)
     280        return ansitab16[CUCUL_LIGHTGRAY] & 0x0fff;
     281
     282    return (fg << 1) & 0x0fff;
    301283}
    302284
    303285uint16_t _cucul_attr_to_rgb12bg(uint32_t attr)
    304286{
    305     uint16_t bg = (attr >> 16) & 0xeffe;
    306 
    307     if(bg == (bg & 0x00f0))
    308         return ansitab[bg >> 4] & 0x0fff;
    309 
    310     if(bg == (CUCUL_COLOR_DEFAULT << 4))
    311         return ansitab[CUCUL_COLOR_BLACK] & 0x0fff;
    312 
    313     if(bg == (CUCUL_COLOR_TRANSPARENT << 4))
    314         return ansitab[CUCUL_COLOR_BLACK] & 0x0fff;
    315 
    316     return bg & 0x0fff;
     287    uint16_t bg = attr >> 18;
     288
     289    if(bg < 0x0010)
     290        return ansitab16[bg] & 0x0fff;
     291
     292    if(bg == CUCUL_DEFAULT)
     293        return ansitab16[CUCUL_BLACK] & 0x0fff;
     294
     295    if(bg == CUCUL_TRANSPARENT)
     296        return ansitab16[CUCUL_BLACK] & 0x0fff;
     297
     298    return (bg << 1) & 0x0fff;
    317299}
    318300
     
    334316void _cucul_attr_to_argb4(uint32_t attr, uint8_t argb[8])
    335317{
    336     uint16_t fg = attr & 0xeffe;
    337     uint16_t bg = (attr >> 16) & 0xeffe;
    338 
    339     if(fg == (fg & 0x00f0))
    340         fg = ansitab[fg >> 4];
    341     else if(fg == (CUCUL_COLOR_DEFAULT << 4))
    342         fg = ansitab[CUCUL_COLOR_LIGHTGRAY];
    343     else if(fg == (CUCUL_COLOR_TRANSPARENT << 4))
    344         fg = 0x0fff;
    345 
    346     if(bg == (bg & 0x00f0))
    347         bg = ansitab[bg >> 4];
    348     else if(bg == (CUCUL_COLOR_DEFAULT << 4))
    349         bg = ansitab[CUCUL_COLOR_BLACK];
    350     else if(bg == (CUCUL_COLOR_TRANSPARENT << 4))
     318    uint16_t fg = (attr >> 4) & 0x3fff;
     319    uint16_t bg = attr >> 18;
     320
     321    if(bg < 0x0010)
     322        bg = ansitab16[bg];
     323    else if(bg == CUCUL_DEFAULT)
     324        bg = ansitab16[CUCUL_BLACK];
     325    else if(bg == CUCUL_TRANSPARENT)
    351326        bg = 0x0fff;
     327    else
     328        bg = ((bg << 2) & 0xf000) | ((bg << 1) & 0x0fff);
    352329
    353330    argb[0] = bg >> 12;
     
    356333    argb[3] = bg & 0xf;
    357334
     335    if(fg < 0x0010)
     336        fg = ansitab16[fg];
     337    else if(fg == CUCUL_DEFAULT)
     338        fg = ansitab16[CUCUL_LIGHTGRAY];
     339    else if(fg == CUCUL_TRANSPARENT)
     340        fg = 0x0fff;
     341    else
     342        fg = ((fg << 2) & 0xf000) | ((fg << 1) & 0x0fff);
     343
    358344    argb[4] = fg >> 12;
    359345    argb[5] = (fg >> 8) & 0xf;
  • libcaca/trunk/cucul/cucul.c

    r1254 r1257  
    6060    cv->refcount = 0;
    6161
    62     cv->curattr = (CUCUL_COLOR_DEFAULT << 20) | (CUCUL_COLOR_TRANSPARENT < 4);
     62    cv->curattr = (CUCUL_DEFAULT << 20) | (CUCUL_TRANSPARENT < 4);
    6363
    6464    cv->width = cv->height = 0;
  • libcaca/trunk/cucul/cucul.h

    r1256 r1257  
    4343/** \defgroup attributes libcucul attribute definitions
    4444 *
    45  *  Colours and styles that can be used with cucul_set_attr_ansi() and
    46  *  cucul_set_attr_argb().
    47  *
    48  *  @{ */
    49 #define CUCUL_COLOR_BLACK 0x00 /**< The colour index for black. */
    50 #define CUCUL_COLOR_BLUE 0x01 /**< The colour index for blue. */
    51 #define CUCUL_COLOR_GREEN 0x02 /**< The colour index for green. */
    52 #define CUCUL_COLOR_CYAN 0x03 /**< The colour index for cyan. */
    53 #define CUCUL_COLOR_RED 0x04 /**< The colour index for red. */
    54 #define CUCUL_COLOR_MAGENTA 0x05 /**< The colour index for magenta. */
    55 #define CUCUL_COLOR_BROWN 0x06 /**< The colour index for brown. */
    56 #define CUCUL_COLOR_LIGHTGRAY 0x07 /**< The colour index for light gray. */
    57 #define CUCUL_COLOR_DARKGRAY 0x08 /**< The colour index for dark gray. */
    58 #define CUCUL_COLOR_LIGHTBLUE 0x09 /**< The colour index for blue. */
    59 #define CUCUL_COLOR_LIGHTGREEN 0x0a /**< The colour index for light green. */
    60 #define CUCUL_COLOR_LIGHTCYAN 0x0b /**< The colour index for light cyan. */
    61 #define CUCUL_COLOR_LIGHTRED 0x0c /**< The colour index for light red. */
    62 #define CUCUL_COLOR_LIGHTMAGENTA 0x0d /**< The colour index for light magenta. */
    63 #define CUCUL_COLOR_YELLOW 0x0e /**< The colour index for yellow. */
    64 #define CUCUL_COLOR_WHITE 0x0f /**< The colour index for white. */
    65 #define CUCUL_COLOR_DEFAULT 0x10 /**< The output driver's default colour. */
    66 #define CUCUL_COLOR_TRANSPARENT 0x20 /**< The transparent colour. */
    67 
    68 #define CUCUL_STYLE_BOLD 0x01 /**< The style mask for bold. */
    69 #define CUCUL_STYLE_ITALICS 0x02 /**< The style mask for italics. */
    70 #define CUCUL_STYLE_UNDERLINE 0x04 /**< The style mask for underline. */
    71 #define CUCUL_STYLE_BLINK 0x08 /**< The style mask for blink. */
     45 *  Colours and styles that can be used with cucul_set_attr().
     46 *
     47 *  @{ */
     48#define CUCUL_BLACK 0x00 /**< The colour index for black. */
     49#define CUCUL_BLUE 0x01 /**< The colour index for blue. */
     50#define CUCUL_GREEN 0x02 /**< The colour index for green. */
     51#define CUCUL_CYAN 0x03 /**< The colour index for cyan. */
     52#define CUCUL_RED 0x04 /**< The colour index for red. */
     53#define CUCUL_MAGENTA 0x05 /**< The colour index for magenta. */
     54#define CUCUL_BROWN 0x06 /**< The colour index for brown. */
     55#define CUCUL_LIGHTGRAY 0x07 /**< The colour index for light gray. */
     56#define CUCUL_DARKGRAY 0x08 /**< The colour index for dark gray. */
     57#define CUCUL_LIGHTBLUE 0x09 /**< The colour index for blue. */
     58#define CUCUL_LIGHTGREEN 0x0a /**< The colour index for light green. */
     59#define CUCUL_LIGHTCYAN 0x0b /**< The colour index for light cyan. */
     60#define CUCUL_LIGHTRED 0x0c /**< The colour index for light red. */
     61#define CUCUL_LIGHTMAGENTA 0x0d /**< The colour index for light magenta. */
     62#define CUCUL_YELLOW 0x0e /**< The colour index for yellow. */
     63#define CUCUL_WHITE 0x0f /**< The colour index for white. */
     64#define CUCUL_DEFAULT 0x10 /**< The output driver's default colour. */
     65#define CUCUL_TRANSPARENT 0x20 /**< The transparent colour. */
     66
     67#define CUCUL_BOLD 0x01 /**< The style mask for bold. */
     68#define CUCUL_ITALICS 0x02 /**< The style mask for italics. */
     69#define CUCUL_UNDERLINE 0x04 /**< The style mask for underline. */
     70#define CUCUL_BLINK 0x08 /**< The style mask for blink. */
    7271/*  @} */
    7372
     
    106105#define CUCUL_MAGIC_FULLWIDTH 0x000ffffe /**< Used to indicate that the previous character was a fullwidth glyph. */
    107106int cucul_set_attr(cucul_canvas_t *, unsigned long int);
    108 int cucul_set_attr_ansi(cucul_canvas_t *, unsigned char, unsigned char,
    109                         unsigned char);
    110 int cucul_set_attr_argb(cucul_canvas_t *, unsigned int, unsigned int,
    111                         unsigned char);
    112107unsigned long int cucul_get_attr(cucul_canvas_t *, int, int);
     108unsigned long int cucul_ansi_to_attr(unsigned char, unsigned char);
     109unsigned long int cucul_argb_to_attr(unsigned int, unsigned int);
    113110char const *cucul_get_color_name(unsigned int);
    114111int cucul_putchar(cucul_canvas_t *, int, int, unsigned long int);
     
    241238/*  @} */
    242239
     240/* Legacy macros */
     241#define CUCUL_COLOR_BLACK CUCUL_BLACK
     242#define CUCUL_COLOR_BLUE CUCUL_BLUE
     243#define CUCUL_COLOR_GREEN CUCUL_GREEN
     244#define CUCUL_COLOR_CYAN CUCUL_CYAN
     245#define CUCUL_COLOR_RED CUCUL_RED
     246#define CUCUL_COLOR_MAGENTA CUCUL_MAGENTA
     247#define CUCUL_COLOR_BROWN CUCUL_BROWN
     248#define CUCUL_COLOR_LIGHTGRAY CUCUL_LIGHTGRAY
     249#define CUCUL_COLOR_DARKGRAY CUCUL_DARKGRAY
     250#define CUCUL_COLOR_LIGHTBLUE CUCUL_LIGHTBLUE
     251#define CUCUL_COLOR_LIGHTGREEN CUCUL_LIGHTGREEN
     252#define CUCUL_COLOR_LIGHTCYAN CUCUL_LIGHTCYAN
     253#define CUCUL_COLOR_LIGHTRED CUCUL_LIGHTRED
     254#define CUCUL_COLOR_LIGHTMAGENTA CUCUL_LIGHTMAGENTA
     255#define CUCUL_COLOR_YELLOW CUCUL_YELLOW
     256#define CUCUL_COLOR_WHITE CUCUL_YELLOW
     257#define CUCUL_COLOR_DEFAULT CUCUL_DEFAULT
     258#define CUCUL_COLOR_TRANSPARENT CUCUL_TRANSPARENT
     259
    243260#ifdef __cplusplus
    244261}
  • libcaca/trunk/cucul/dither.c

    r1256 r1257  
    10011001            if(rgba[2] > lum) lum = rgba[2];
    10021002            outfg = outbg;
    1003             outbg = CUCUL_COLOR_BLACK;
     1003            outbg = CUCUL_BLACK;
    10041004
    10051005            ch = lum * dchmax / 0x1000;
     
    10431043
    10441044        /* Now output the character */
    1045         cucul_set_attr_ansi(cv, outfg, outbg, 0);
     1045        cucul_set_attr(cv, cucul_ansi_to_attr(outfg, outbg));
    10461046        cucul_putchar(cv, x, y, outch);
    10471047
     
    13791379
    13801380    /* These ones are constant */
    1381     lookup_colors[0] = CUCUL_COLOR_BLACK;
    1382     lookup_colors[1] = CUCUL_COLOR_DARKGRAY;
    1383     lookup_colors[2] = CUCUL_COLOR_LIGHTGRAY;
    1384     lookup_colors[3] = CUCUL_COLOR_WHITE;
     1381    lookup_colors[0] = CUCUL_BLACK;
     1382    lookup_colors[1] = CUCUL_DARKGRAY;
     1383    lookup_colors[2] = CUCUL_LIGHTGRAY;
     1384    lookup_colors[3] = CUCUL_WHITE;
    13851385
    13861386    /* These ones will be overwritten */
    1387     lookup_colors[4] = CUCUL_COLOR_MAGENTA;
    1388     lookup_colors[5] = CUCUL_COLOR_LIGHTMAGENTA;
    1389     lookup_colors[6] = CUCUL_COLOR_RED;
    1390     lookup_colors[7] = CUCUL_COLOR_LIGHTRED;
     1387    lookup_colors[4] = CUCUL_MAGENTA;
     1388    lookup_colors[5] = CUCUL_LIGHTMAGENTA;
     1389    lookup_colors[6] = CUCUL_RED;
     1390    lookup_colors[7] = CUCUL_LIGHTRED;
    13911391
    13921392    for(v = 0; v < LOOKUP_VAL; v++)
  • libcaca/trunk/cucul/export.c

    r1254 r1257  
    231231                continue;
    232232
    233             fg = ((attr & 0xeffe) == (CUCUL_COLOR_DEFAULT << 4)) ?
     233            fg = (((attr >> 4) & 0x7ffe) == (CUCUL_DEFAULT << 4)) ?
    234234                     0x10 : palette[_cucul_attr_to_ansi4fg(attr)];
    235             bg = (((attr >> 16) & 0xeffe) == (CUCUL_COLOR_TRANSPARENT << 4)) ?
     235            bg = (((attr >> 18) & 0x7ffe) == (CUCUL_TRANSPARENT << 4)) ?
    236236                     0x10 : palette[_cucul_attr_to_ansi4bg(attr)];
    237237
     
    538538                continue;
    539539
    540             if((attr & 0xeffe) == (CUCUL_COLOR_DEFAULT << 4))
     540            if(((attr >> 4) & 0x7ffe) == (CUCUL_DEFAULT << 4))
    541541                fg = 0x10;
    542542
    543             if(((attr >> 16) & 0xeffe) == (CUCUL_COLOR_TRANSPARENT << 4))
     543            if(((attr >> 18) & 0x7ffe) == (CUCUL_TRANSPARENT << 4))
    544544                bg = 0x10;
    545545
  • libcaca/trunk/cucul/import.c

    r1256 r1257  
    203203    }
    204204
    205     cucul_set_attr_ansi(cv, CUCUL_COLOR_DEFAULT, CUCUL_COLOR_TRANSPARENT, 0);
     205    cucul_set_attr(cv, cucul_ansi_to_attr(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_ansi(cv, CUCUL_COLOR_DEFAULT,
    388                                         CUCUL_COLOR_TRANSPARENT, 0);
     387                    cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_DEFAULT,
     388                                                          CUCUL_TRANSPARENT));
    389389                    cucul_set_canvas_size(cv, width = 80, height);
    390390                for(j = x; j < 80; j++)
     
    436436        if((unsigned int)x + wch > width)
    437437        {
    438             cucul_set_attr_ansi(cv, CUCUL_COLOR_DEFAULT,
    439                                 CUCUL_COLOR_TRANSPARENT, 0);
     438            cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_DEFAULT,
     439                                                  CUCUL_TRANSPARENT));
    440440            cucul_set_canvas_size(cv, width = x + wch, height);
    441441        }
     
    443443        if((unsigned int)y >= height)
    444444        {
    445             cucul_set_attr_ansi(cv, CUCUL_COLOR_DEFAULT,
    446                                 CUCUL_COLOR_TRANSPARENT, 0);
     445            cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_DEFAULT,
     446                                                  CUCUL_TRANSPARENT));
    447447            cucul_set_canvas_size(cv, width, height = y + 1);
    448448        }
    449449
    450450        /* Now paste our character */
    451         cucul_set_attr_ansi(cv, grcm.efg, grcm.ebg, 0);
     451        cucul_set_attr(cv, cucul_ansi_to_attr(grcm.efg, grcm.ebg));
    452452        cucul_putchar(cv, x, y, ch);
    453453        x += wch;
     
    456456    if((unsigned int)y > height)
    457457    {
    458         cucul_set_attr_ansi(cv, CUCUL_COLOR_DEFAULT,
    459                             CUCUL_COLOR_TRANSPARENT, 0);
     458        cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_DEFAULT,
     459                                              CUCUL_TRANSPARENT));
    460460        cucul_set_canvas_size(cv, width, height = y);
    461461    }
     
    471471    static uint8_t const ansi2cucul[] =
    472472    {
    473         CUCUL_COLOR_BLACK, CUCUL_COLOR_RED,
    474         CUCUL_COLOR_GREEN, CUCUL_COLOR_BROWN,
    475         CUCUL_COLOR_BLUE, CUCUL_COLOR_MAGENTA,
    476         CUCUL_COLOR_CYAN, CUCUL_COLOR_LIGHTGRAY
     473        CUCUL_BLACK, CUCUL_RED, CUCUL_GREEN, CUCUL_BROWN,
     474        CUCUL_BLUE, CUCUL_MAGENTA, CUCUL_CYAN, CUCUL_LIGHTGRAY
    477475    };
    478476
     
    493491        {
    494492        case 0: /* default rendition */
    495             g->fg = CUCUL_COLOR_DEFAULT;
    496             g->bg = CUCUL_COLOR_TRANSPARENT;
     493            g->fg = CUCUL_DEFAULT;
     494            g->bg = CUCUL_TRANSPARENT;
    497495            g->bold = g->negative = g->concealed = 0;
    498496            break;
     
    517515            break;
    518516        case 39: /* default display colour (implementation-defined) */
    519             g->fg = CUCUL_COLOR_DEFAULT;
     517            g->fg = CUCUL_DEFAULT;
    520518            break;
    521519        case 49: /* default background colour (implementation-defined) */
    522             g->bg = CUCUL_COLOR_TRANSPARENT;
     520            g->bg = CUCUL_TRANSPARENT;
    523521            break;
    524522        default:
     
    530528    if(g->concealed)
    531529    {
    532         g->efg = g->ebg = CUCUL_COLOR_TRANSPARENT;
     530        g->efg = g->ebg = CUCUL_TRANSPARENT;
    533531    }
    534532    else
     
    541539            if(g->efg < 8)
    542540                g->efg += 8;
    543             else if(g->efg == CUCUL_COLOR_DEFAULT)
    544                 g->efg = CUCUL_COLOR_WHITE;
     541            else if(g->efg == CUCUL_DEFAULT)
     542                g->efg = CUCUL_WHITE;
    545543        }
    546544    }
  • libcaca/trunk/cucul/sprite.c

    r1256 r1257  
    4949 *  Set the active canvas frame. All subsequent drawing operations will
    5050 *  be performed on that frame. The current painting context set by
    51  *  cucul_set_attr_ansi() or cucul_set_attr_argb() is inherited.
     51 *  cucul_set_attr() is inherited.
    5252 *
    5353 *  If the frame index is outside the canvas' frame range, nothing happens.
  • libcaca/trunk/src/aafire.c

    r1256 r1257  
    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_ansi(cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE, 0);
     243  cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_BLUE));
    244244  if (sloop < 100)
    245245    cucul_putstr(cv, cucul_get_canvas_width(cv) - 30,
  • libcaca/trunk/src/cacademo.c

    r1256 r1257  
    162162        {
    163163            fn[next](RENDER, backcv);
    164             cucul_set_attr_ansi(mask, CUCUL_COLOR_LIGHTGRAY,
    165                                       CUCUL_COLOR_BLACK, 0);
     164            cucul_set_attr(mask, cucul_ansi_to_attr(CUCUL_LIGHTGRAY,
     165                                                    CUCUL_BLACK));
    166166            cucul_clear_canvas(mask);
    167             cucul_set_attr_ansi(mask, CUCUL_COLOR_WHITE,
    168                                       CUCUL_COLOR_WHITE, 0);
     167            cucul_set_attr(mask, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_WHITE));
    169168            transition(mask, tmode,
    170169                       100 * (frame - next_transition) / TRANSITION_FRAMES);
     
    172171        }
    173172
    174         cucul_set_attr_ansi(frontcv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE, 0);
     173        cucul_set_attr(frontcv, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_BLUE));
    175174        if(frame < 100)
    176175            cucul_putstr(frontcv, cucul_get_canvas_width(frontcv) - 30,
     
    695694
    696695                if(p & 0x0f)
    697                     cucul_set_attr_ansi(cv, CUCUL_COLOR_WHITE, p >> 4, 0);
     696                    cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_WHITE, p >> 4));
    698697                else
    699                     cucul_set_attr_ansi(cv, CUCUL_COLOR_BLACK,
    700                                             CUCUL_COLOR_BLACK, 0);
     698                    cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_BLACK,
     699                                                          CUCUL_BLACK));
    701700                cucul_putchar(cv, x, y, gradient[p & 0x0f]);
    702701            }
     
    762761        h = cucul_get_canvas_height(cv);
    763762
    764         cucul_set_attr_ansi(cv, CUCUL_COLOR_BLACK, CUCUL_COLOR_BLACK, 0);
     763        cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_BLACK, CUCUL_BLACK));
    765764        cucul_clear_canvas(cv);
    766765
     
    777776
    778777                if(j < 2)
    779                     fg = CUCUL_COLOR_WHITE;
     778                    fg = CUCUL_WHITE;
    780779                else if(j < drop[i].len / 4)
    781                     fg = CUCUL_COLOR_LIGHTGREEN;
     780                    fg = CUCUL_LIGHTGREEN;
    782781                else if(j < drop[i].len * 4 / 5)
    783                     fg = CUCUL_COLOR_GREEN;
     782                    fg = CUCUL_GREEN;
    784783                else
    785                     fg = CUCUL_COLOR_DARKGRAY;
    786                 cucul_set_attr_ansi(cv, fg, CUCUL_COLOR_BLACK, 0);
     784                    fg = CUCUL_DARKGRAY;
     785                cucul_set_attr(cv, cucul_ansi_to_attr(fg, CUCUL_BLACK));
    787786
    788787                cucul_putchar(cv, x, y - j,
  • libcaca/trunk/src/cacadraw.c

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

    r1256 r1257  
    305305            sprintf(buffer, " Loading `%s'... ", list[current]);
    306306            buffer[ww] = '\0';
    307             cucul_set_attr_ansi(cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE, 0);
     307            cucul_set_attr(cv, cucul_ansi_to_attr(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_ansi(cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLACK, 0);
     327        cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_BLACK));
    328328        cucul_clear_canvas(cv);
    329329
    330330        if(!items)
    331331        {
    332             cucul_set_attr_ansi(cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE, 0);
     332            cucul_set_attr(cv, cucul_ansi_to_attr(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_ansi(cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE, 0);
     352            cucul_set_attr(cv, cucul_ansi_to_attr(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_ansi(cv, CUCUL_COLOR_LIGHTGRAY,
    383                                     CUCUL_COLOR_BLACK, 0);
     382            cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_LIGHTGRAY,
     383                                                  CUCUL_BLACK));
    384384            switch(status)
    385385            {
     
    420420static void print_status(void)
    421421{
    422     cucul_set_attr_ansi(cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE, 0);
     422    cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_BLUE));
    423423    cucul_draw_line(cv, 0, 0, ww - 1, 0, " ");
    424424    cucul_draw_line(cv, 0, wh - 2, ww - 1, wh - 2, "-");
     
    430430    cucul_printf(cv, ww - 14, wh - 2, "(zoom: %s%i)", zoom > 0 ? "+" : "", zoom);
    431431
    432     cucul_set_attr_ansi(cv, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK, 0);
     432    cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_LIGHTGRAY, CUCUL_BLACK));
    433433    cucul_draw_line(cv, 0, wh - 1, ww - 1, wh - 1, " ");
    434434}
     
    458458    int i;
    459459
    460     cucul_set_attr_ansi(cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE, 0);
     460    cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_BLUE));
    461461
    462462    for(i = 0; help[i]; i++)
     
    519519    {
    520520        if((((xn - x) / 5) ^ ((yn - y) / 3)) & 1)
    521             cucul_set_attr_ansi(cv, CUCUL_COLOR_LIGHTGRAY,
    522                                     CUCUL_COLOR_DARKGRAY, 0);
     521            cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_LIGHTGRAY,
     522                                                  CUCUL_DARKGRAY));
    523523        else
    524             cucul_set_attr_ansi(cv, CUCUL_COLOR_DARKGRAY,
    525                                     CUCUL_COLOR_LIGHTGRAY, 0);
     524            cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_DARKGRAY,
     525                                                  CUCUL_LIGHTGRAY));
    526526        cucul_putchar(cv, xn, yn, ' ');
    527527    }
  • libcaca/trunk/src/img2irc.c

    r1256 r1257  
    5757
    5858    cucul_set_canvas_size(cv, cols, lines);
    59     cucul_set_attr_ansi(cv, CUCUL_COLOR_DEFAULT, CUCUL_COLOR_TRANSPARENT, 0);
     59    cucul_set_attr(cv, cucul_ansi_to_attr(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

    r1256 r1257  
    3636        return 1;
    3737
    38     cucul_set_attr_ansi(cv, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK, 0);
     38    cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_LIGHTGRAY, CUCUL_BLACK));
    3939    cucul_clear_canvas(cv);
    4040    for(i = 0; i < 16; i++)
    4141    {
    42         cucul_set_attr_ansi(cv, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK, 0);
     42        cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_LIGHTGRAY, CUCUL_BLACK));
    4343        cucul_printf(cv, 4, i + (i >= 8 ? 4 : 3), "'%cv': %i (%s)",
    4444                     'a' + i, i, cucul_get_color_name(i));
    4545        for(j = 0; j < 16; j++)
    4646        {
    47             cucul_set_attr_ansi(cv, i, j, 0);
     47            cucul_set_attr(cv, cucul_ansi_to_attr(i, j));
    4848            cucul_putstr(cv, (j >= 8 ? 41 : 40) + j * 2, i + (i >= 8 ? 4 : 3),
    4949                         "Aa");
  • libcaca/trunk/test/demo.c

    r1256 r1257  
    151151                if(demo)
    152152                {
    153                     cucul_set_attr_ansi(cv, CUCUL_COLOR_LIGHTGRAY,
    154                                             CUCUL_COLOR_BLACK, 0);
     153                    cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_LIGHTGRAY,
     154                                                          CUCUL_BLACK));
    155155                    cucul_clear_canvas(cv);
    156156                }
     
    173173            if(mouse && !demo)
    174174            {
    175                 cucul_set_attr_ansi(cv, CUCUL_COLOR_RED, CUCUL_COLOR_BLACK, 0);
     175                cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_RED, CUCUL_BLACK));
    176176                cucul_putstr(cv, xmouse, ymouse,     ".");
    177177                cucul_putstr(cv, xmouse, ymouse + 1, "|\\");
     
    185185            demo();
    186186
    187             cucul_set_attr_ansi(cv, CUCUL_COLOR_LIGHTGRAY,
    188                                     CUCUL_COLOR_BLACK, 0);
     187            cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_LIGHTGRAY,
     188                                                  CUCUL_BLACK));
    189189            cucul_draw_thin_box(cv, 1, 1, cucul_get_canvas_width(cv) - 2,
    190190                                          cucul_get_canvas_height(cv) - 2);
     
    211211    int yo = cucul_get_canvas_height(cv) - 2;
    212212
    213     cucul_set_attr_ansi(cv, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK, 0);
     213    cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_LIGHTGRAY, CUCUL_BLACK));
    214214    cucul_clear_canvas(cv);
    215215    cucul_draw_thin_box(cv, 1, 1, xo, yo);
     
    253253    i++;
    254254
    255     cucul_set_attr_ansi(cv, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK, 0);
     255    cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_LIGHTGRAY, CUCUL_BLACK));
    256256    cucul_clear_canvas(cv);
    257257
    258258    /* Draw the sun */
    259     cucul_set_attr_ansi(cv, CUCUL_COLOR_YELLOW, CUCUL_COLOR_BLACK, 0);
     259    cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_YELLOW, CUCUL_BLACK));
    260260    xo = cucul_get_canvas_width(cv) / 4;
    261261    yo = cucul_get_canvas_height(cv) / 4 + 5 * sin(0.03*i);
     
    269269
    270270    j = 15 + sin(0.03*i) * 8;
    271     cucul_set_attr_ansi(cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLACK, 0);
     271    cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_BLACK));
    272272    cucul_fill_ellipse(cv, xo, yo, j, j / 2, "#");
    273     cucul_set_attr_ansi(cv, CUCUL_COLOR_YELLOW, CUCUL_COLOR_BLACK, 0);
     273    cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_YELLOW, CUCUL_BLACK));
    274274    cucul_draw_ellipse(cv, xo, yo, j, j / 2, "#");
    275275
     
    287287    yc = cucul_get_canvas_height(cv) * 3 / 4 + cos(0.02*i) * 5;
    288288
    289     cucul_set_attr_ansi(cv, CUCUL_COLOR_GREEN, CUCUL_COLOR_BLACK, 0);
     289    cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_GREEN, CUCUL_BLACK));
    290290    cucul_fill_triangle(cv, xo, yo, xb, yb, xa, ya, "%");
    291     cucul_set_attr_ansi(cv, CUCUL_COLOR_YELLOW, CUCUL_COLOR_BLACK, 0);
     291    cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_YELLOW, CUCUL_BLACK));
    292292    cucul_draw_thin_triangle(cv, xo, yo, xb, yb, xa, ya);
    293293
    294     cucul_set_attr_ansi(cv, CUCUL_COLOR_RED, CUCUL_COLOR_BLACK, 0);
     294    cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_RED, CUCUL_BLACK));
    295295    cucul_fill_triangle(cv, xa, ya, xb, yb, xc, yc, "#");
    296     cucul_set_attr_ansi(cv, CUCUL_COLOR_YELLOW, CUCUL_COLOR_BLACK, 0);
     296    cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_YELLOW, CUCUL_BLACK));
    297297    cucul_draw_thin_triangle(cv, xa, ya, xb, yb, xc, yc);
    298298
    299     cucul_set_attr_ansi(cv, CUCUL_COLOR_BLUE, CUCUL_COLOR_BLACK, 0);
     299    cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_BLUE, CUCUL_BLACK));
    300300    cucul_fill_triangle(cv, xo, yo, xb, yb, xc, yc, "%");
    301     cucul_set_attr_ansi(cv, CUCUL_COLOR_YELLOW, CUCUL_COLOR_BLACK, 0);
     301    cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_YELLOW, CUCUL_BLACK));
    302302    cucul_draw_thin_triangle(cv, xo, yo, xb, yb, xc, yc);
    303303
     
    312312    yc = cucul_get_canvas_height(cv) - 3;
    313313
    314     cucul_set_attr_ansi(cv, CUCUL_COLOR_CYAN, CUCUL_COLOR_BLACK, 0);
     314    cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_CYAN, CUCUL_BLACK));
    315315    cucul_draw_thin_triangle(cv, xa, ya, xb, yb, xc, yc);
    316316
     
    331331    {
    332332        int delta = cucul_rand(-5, 6);
    333         cucul_set_attr_ansi(cv, cucul_rand(0, 16), cucul_rand(0, 16), 0);
     333        cucul_set_attr(cv, cucul_ansi_to_attr(cucul_rand(0, 16),
     334                                              cucul_rand(0, 16)));
    334335        cucul_putchar(cv, cucul_get_canvas_width(cv) / 2
    335336                    + cos(0.02*j) * (delta + cucul_get_canvas_width(cv) / 4),
     
    360361    {
    361362        /* Putpixel */
    362         cucul_set_attr_ansi(cv, cucul_rand(0, 16), cucul_rand(0, 16), 0);
     363        cucul_set_attr(cv, cucul_ansi_to_attr(cucul_rand(0, 16),
     364                                              cucul_rand(0, 16)));
    363365        cucul_putchar(cv, cucul_rand(0, xmax), cucul_rand(0, ymax),
    364366                      chars[cucul_rand(0, 9)]);
     
    371373    char buf[BUFSIZ];
    372374
    373     cucul_set_attr_ansi(cv, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK, 0);
     375    cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_LIGHTGRAY, CUCUL_BLACK));
    374376    cucul_clear_canvas(cv);
    375377    for(i = 0; i < 16; i++)
    376378    {
    377379        sprintf(buf, "'%c': %i (%s)", 'a' + i, i, cucul_get_color_name(i));
    378         cucul_set_attr_ansi(cv, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK, 0);
     380        cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_LIGHTGRAY, CUCUL_BLACK));
    379381        cucul_putstr(cv, 4, i + (i >= 8 ? 4 : 3), buf);
    380382        for(j = 0; j < 16; j++)
    381383        {
    382             cucul_set_attr_ansi(cv, i, j, 0);
     384            cucul_set_attr(cv, cucul_ansi_to_attr(i, j));
    383385            cucul_putstr(cv, (j >= 8 ? 41 : 40) + j * 2, i + (i >= 8 ? 4 : 3), "# ");
    384386        }
     
    403405    }
    404406
    405     cucul_set_attr_ansi(cv, cucul_rand(0, 16), CUCUL_COLOR_BLACK, 0);
     407    cucul_set_attr(cv, cucul_ansi_to_attr(cucul_rand(0, 16), CUCUL_BLACK));
    406408    if(outline > 1)
    407409        cucul_draw_thin_line(cv, xa, ya, xb, yb);
     
    427429    }
    428430
    429     cucul_set_attr_ansi(cv, cucul_rand(0, 16), cucul_rand(0, 16), 0);
     431    cucul_set_attr(cv, cucul_ansi_to_attr(cucul_rand(0, 16),
     432                                          cucul_rand(0, 16)));
    430433    cucul_fill_box(cv, xa, ya, xb, yb, "#");
    431434
    432     cucul_set_attr_ansi(cv, cucul_rand(0, 16), CUCUL_COLOR_BLACK, 0);
     435    cucul_set_attr(cv, cucul_ansi_to_attr(cucul_rand(0, 16), CUCUL_BLACK));
    433436    if(outline == 2)
    434437        cucul_draw_thin_box(cv, xa, ya, xb, yb);
     
    458461    }
    459462
    460     cucul_set_attr_ansi(cv, cucul_rand(0, 16), cucul_rand(0, 16), 0);
     463    cucul_set_attr(cv, cucul_ansi_to_attr(cucul_rand(0, 16),
     464                                          cucul_rand(0, 16)));
    461465    cucul_fill_ellipse(cv, x, y, a, b, "#");
    462466
    463     cucul_set_attr_ansi(cv, cucul_rand(0, 16), CUCUL_COLOR_BLACK, 0);
     467    cucul_set_attr(cv, cucul_ansi_to_attr(cucul_rand(0, 16), CUCUL_BLACK));
    464468    if(outline == 2)
    465469        cucul_draw_thin_ellipse(cv, x, y, a, b);
     
    488492    }
    489493
    490     cucul_set_attr_ansi(cv, cucul_rand(0, 16), cucul_rand(0, 16), 0);
     494    cucul_set_attr(cv, cucul_ansi_to_attr(cucul_rand(0, 16),
     495                                          cucul_rand(0, 16)));
    491496    cucul_fill_triangle(cv, xa, ya, xb, yb, xc, yc, "#");
    492497
    493     cucul_set_attr_ansi(cv, cucul_rand(0, 16), CUCUL_COLOR_BLACK, 0);
     498    cucul_set_attr(cv, cucul_ansi_to_attr(cucul_rand(0, 16), CUCUL_BLACK));
    494499    if(outline == 2)
    495500        cucul_draw_thin_triangle(cv, xa, ya, xb, yb, xc, yc);
  • libcaca/trunk/test/dithering.c

    r1256 r1257  
    2828unsigned int points[] =
    2929{
    30     CUCUL_COLOR_BLACK,
    31     CUCUL_COLOR_DARKGRAY,
    32     CUCUL_COLOR_LIGHTGRAY,
    33     CUCUL_COLOR_WHITE,
    34     CUCUL_COLOR_RED,
    35     CUCUL_COLOR_LIGHTRED
     30    CUCUL_BLACK, CUCUL_DARKGRAY, CUCUL_LIGHTGRAY,
     31    CUCUL_WHITE, CUCUL_RED, CUCUL_LIGHTRED
    3632};
    3733
     
    121117        else
    122118            ch = density[dista * 2 * 13 / (dista + distb)];
    123         cucul_set_attr_ansi(cv, points[nearb], points[neara], 0);
     119        cucul_set_attr(cv, cucul_ansi_to_attr(points[nearb], points[neara]));
    124120
    125121        cucul_putchar(cv, x * cucul_get_canvas_width(cv) / 100,
  • libcaca/trunk/test/event.c

    r1256 r1257  
    4242    h = cucul_get_canvas_height(cv) - 1;
    4343
    44     cucul_set_attr_ansi(cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE, 0);
     44    cucul_set_attr(cv, cucul_ansi_to_attr(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_ansi(cv, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK, 0);
     86        cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_LIGHTGRAY, CUCUL_BLACK));
    8787        cucul_clear_canvas(cv);
    8888
    8989        /* Print current event */
    90         cucul_set_attr_ansi(cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE, 0);
     90        cucul_set_attr(cv, cucul_ansi_to_attr(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_ansi(cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLACK, 0);
     98        cucul_set_attr(cv, cucul_ansi_to_attr(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

    r1256 r1257  
    116116        cucul_free_dither(dither);
    117117
    118         cucul_set_attr_ansi(cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLACK, 0);
     118        cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_BLACK));
    119119        cucul_draw_thin_box(cv, 0, 0, WIDTH - 1, HEIGHT - 1);
    120120
    121         cucul_set_attr_ansi(cv, CUCUL_COLOR_BLACK, CUCUL_COLOR_WHITE, 0);
     121        cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_BLACK, CUCUL_WHITE));
    122122        cucul_fill_ellipse(cv, WIDTH / 2, HEIGHT / 2,
    123123                               WIDTH / 4, HEIGHT / 4, " ");
     
    127127        cucul_putstr(cv, WIDTH / 2 - 7, HEIGHT / 2 + 2, "äβç ░▒▓█▓▒░ ΔЗҒ");
    128128
    129         cucul_set_attr_ansi(cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_LIGHTBLUE, 0);
     129        cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_LIGHTBLUE));
    130130        cucul_putstr(cv, WIDTH / 2 - 7, HEIGHT / 2, "    LIBCACA    ");
    131131
    132132        for(x = 0; x < 16; x++)
    133133        {
    134             cucul_set_attr_argb(cv, 0xff00 | x, 0xf00f | (x << 4), 0);
     134            cucul_set_attr(cv, cucul_argb_to_attr(0xff00 | x,
     135                                                  0xf00f | (x << 4)));
    135136            cucul_putstr(cv, WIDTH / 2 - 7 + x, HEIGHT / 2 + 5, "#");
    136137        }
  • libcaca/trunk/test/font.c

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

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

    r1256 r1257  
    4949    {
    5050        cucul_set_canvas_frame(cv, frame);
    51         cucul_set_attr_ansi(cv, CUCUL_COLOR_WHITE, frame, 0);
     51        cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_WHITE, frame));
    5252        cucul_fill_box(cv, 0, 0, 40, 15, ":");
    53         cucul_set_attr_ansi(cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE, 0);
     53        cucul_set_attr(cv, cucul_ansi_to_attr(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_ansi(cv, CUCUL_COLOR_DEFAULT, CUCUL_COLOR_TRANSPARENT, 0);
     63    cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_DEFAULT, CUCUL_TRANSPARENT));
    6464    dp = caca_create_display(cv);
    6565    caca_set_display_time(dp, 50000);
  • libcaca/trunk/test/fullwidth.c

    r1256 r1257  
    4343    for(i = 0; i < 10; i++)
    4444    {
    45         cucul_set_attr_ansi(caca, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE, 0);
     45        cucul_set_attr(caca, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_BLUE));
    4646        cucul_putstr(caca, 0, i, CACA);
    47         cucul_set_attr_ansi(caca, CUCUL_COLOR_WHITE, CUCUL_COLOR_RED, 0);
     47        cucul_set_attr(caca, cucul_ansi_to_attr(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_ansi(caca, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE, 0);
     56        cucul_set_attr(caca, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_BLUE));
    5757        cucul_putstr(caca, 0, i, CACA);
    58         cucul_set_attr_ansi(caca, CUCUL_COLOR_WHITE, CUCUL_COLOR_GREEN, 0);
     58        cucul_set_attr(caca, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_GREEN));
    5959        cucul_putstr(caca, i - 2, i, "ホ");
    6060    }
     
    6363
    6464    /* Line of canvas */
    65     cucul_set_attr_ansi(line, CUCUL_COLOR_WHITE, CUCUL_COLOR_MAGENTA, 0);
     65    cucul_set_attr(line, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_MAGENTA));
    6666    cucul_putstr(line, 0, 0, "ほ");
    6767    for(i = 0; i < 10; i++)
    6868    {
    69         cucul_set_attr_ansi(caca, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE, 0);
     69        cucul_set_attr(caca, cucul_ansi_to_attr(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

    r1256 r1257  
    8787
    8888        /* Draw something on the mask */
    89         cucul_set_attr_ansi(mask, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK, 0);
     89        cucul_set_attr(mask, cucul_ansi_to_attr(CUCUL_LIGHTGRAY, CUCUL_BLACK));
    9090        cucul_clear_canvas(mask);
    91         cucul_set_attr_ansi(mask, CUCUL_COLOR_WHITE, CUCUL_COLOR_WHITE, 0);
     91        cucul_set_attr(mask, cucul_ansi_to_attr(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_ansi(cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE, 0);
     102        cucul_set_attr(cv, cucul_ansi_to_attr(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

    r1256 r1257  
    4444    dp = caca_create_display(cv);
    4545
    46     cucul_set_attr_ansi(cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE, 0);
     46    cucul_set_attr(cv, cucul_ansi_to_attr(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_ansi(cv, CUCUL_COLOR_BLACK,
    65                                     CUCUL_COLOR_LIGHTGRAY, 0);
     64            cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_BLACK,
     65                                                  CUCUL_LIGHTGRAY));
    6666            cucul_fill_box(cv, 2, 3 * i + 4, 2 + BUFFER_SIZE, 3 * i + 4, " ");
    6767
     
    7777
    7878        /* Put the cursor on the active textentry */
    79         cucul_set_attr_ansi(cv, CUCUL_COLOR_LIGHTRED, CUCUL_COLOR_LIGHTRED, 0);
     79        cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_LIGHTRED, CUCUL_LIGHTRED));
    8080        cucul_putchar(cv, 2 + entries[e].cursor, 3 * e + 4, ' ');
    8181
  • libcaca/trunk/test/spritedit.c

    r1256 r1257  
    103103
    104104
    105         cucul_set_attr_ansi(cv, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK, 0);
     105        cucul_set_attr(cv, cucul_ansi_to_attr(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_ansi(cv, CUCUL_COLOR_BLACK, CUCUL_COLOR_BLACK, 0);
     128        cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_BLACK, CUCUL_BLACK));
    129129        cucul_fill_box(cv, 57 + xa, 10 + ya, 57 + xb, 10 + yb, " ");
    130         cucul_set_attr_ansi(cv, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK, 0);
     130        cucul_set_attr(cv, cucul_ansi_to_attr(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

    r1256 r1257  
    5959    rotate = cucul_create_canvas(70, 6);
    6060
    61     cucul_set_attr_ansi(normal, CUCUL_COLOR_LIGHTMAGENTA, CUCUL_COLOR_BLACK, 0);
     61    cucul_set_attr(normal, cucul_ansi_to_attr(CUCUL_LIGHTMAGENTA, CUCUL_BLACK));
    6262    for(i = 0; pig[i]; i++)
    6363        cucul_putstr(normal, 55, i, pig[i]);
    6464
    65     cucul_set_attr_ansi(normal, CUCUL_COLOR_LIGHTGREEN, CUCUL_COLOR_BLACK, 0);
     65    cucul_set_attr(normal, cucul_ansi_to_attr(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_ansi(normal, CUCUL_COLOR_LIGHTCYAN, CUCUL_COLOR_BLACK, 0);
     69    cucul_set_attr(normal, cucul_ansi_to_attr(CUCUL_LIGHTCYAN, CUCUL_BLACK));
    7070    cucul_putstr(normal, 1, 1, "hahaha mais vieux porc immonde !! [⽼ ⾗]");
    71     cucul_set_attr_ansi(normal, CUCUL_COLOR_LIGHTRED, CUCUL_COLOR_BLACK, 0);
     71    cucul_set_attr(normal, cucul_ansi_to_attr(CUCUL_LIGHTRED, CUCUL_BLACK));
    7272    cucul_putchar(normal, 38, 1, '|');
    7373
    74     cucul_set_attr_ansi(normal, CUCUL_COLOR_YELLOW, CUCUL_COLOR_BLACK, 0);
     74    cucul_set_attr(normal, cucul_ansi_to_attr(CUCUL_YELLOW, CUCUL_BLACK));
    7575    cucul_putstr(normal, 4, 2, "\\o\\ \\o| _o/ \\o_ |o/ /o/");
    7676
    77     cucul_set_attr_ansi(normal, CUCUL_COLOR_WHITE, CUCUL_COLOR_LIGHTRED, 0);
     77    cucul_set_attr(normal, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_LIGHTRED));
    7878    cucul_putstr(normal, 7, 3, "▙▘▌▙▘▞▖▞▖▌ ▞▖▌ ▌▌");
    7979    cucul_putstr(normal, 7, 4, "▛▖▌▛▖▚▘▚▘▚▖▚▘▚▖▖▖");
    80     cucul_set_attr_ansi(normal, CUCUL_COLOR_BLACK, CUCUL_COLOR_LIGHTRED, 0);
     80    cucul_set_attr(normal, cucul_ansi_to_attr(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_ansi(cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE, 0);
     97    cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_WHITE, CUCUL_BLUE));
    9898    cucul_putstr(cv, 0, 0, "normal");
    9999    cucul_blit(cv, 10, 0, normal, NULL);
  • libcaca/trunk/test/truecolor.c

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

    r1256 r1257  
    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
    2730int main(int argc, char *argv[])
    2831{
     
    3336    dp = caca_create_display(cv);
    3437
    35     cucul_set_attr_ansi(cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE, 0);
     38    cucul_set_attr(cv, ATTR_WHITE_ON_BLUE);
    3639    cucul_putstr(cv, 1, 1, "Basic Unicode support");
    3740
    38     cucul_set_attr_ansi(cv, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK, 0);
     41    cucul_set_attr(cv, ATTR_DEFAULT);
    3942    cucul_putstr(cv, 1, 2, "This is ASCII:    | abc DEF 123 !@# |");
    4043    cucul_putstr(cv, 1, 3, "This is Unicode:  | äßç δεφ ☺♥♀ ╞╬╗ |");
     
    4346    cucul_putstr(cv, 1, 5, "If the three lines do not have the same length, there is a bug somewhere.");
    4447
    45     cucul_set_attr_ansi(cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE, 0);
     48    cucul_set_attr(cv, ATTR_WHITE_ON_BLUE);
    4649    cucul_putstr(cv, 1, 7, "Gradient glyphs");
    4750
    48     cucul_set_attr_ansi(cv, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK, 0);
     51    cucul_set_attr(cv, ATTR_DEFAULT);
    4952    cucul_putstr(cv, 31,  8, "  0%");
    5053    cucul_putstr(cv, 31,  9, " 25%");
     
    5356    cucul_putstr(cv, 31, 12, "100%");
    5457
    55     cucul_set_attr_ansi(cv, CUCUL_COLOR_LIGHTRED, CUCUL_COLOR_LIGHTGREEN, 0);
     58    cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_LIGHTRED, CUCUL_LIGHTGREEN));
    5659    cucul_putstr(cv, 1,  8, "                             ");
    5760    cucul_putstr(cv, 1,  9, "░░░░░░░░░░░░░░░░░░░░░░░░░░░░░");
     
    6063    cucul_putstr(cv, 1, 12, "█████████████████████████████");
    6164
    62     cucul_set_attr_ansi(cv, CUCUL_COLOR_LIGHTGREEN, CUCUL_COLOR_LIGHTRED, 0);
     65    cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_LIGHTGREEN, CUCUL_LIGHTRED));
    6366    cucul_putstr(cv, 36,  8, "█████████████████████████████");
    6467    cucul_putstr(cv, 36,  9, "▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓");
     
    6770    cucul_putstr(cv, 36, 12, "                             ");
    6871
    69     cucul_set_attr_ansi(cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE, 0);
     72    cucul_set_attr(cv, ATTR_WHITE_ON_BLUE);
    7073    cucul_putstr(cv, 1, 14, "Double width characters");
    7174
    72     cucul_set_attr_ansi(cv, CUCUL_COLOR_LIGHTRED, CUCUL_COLOR_BLACK, 0);
     75    cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_LIGHTRED, CUCUL_TRANSPARENT));
    7376    cucul_putstr(cv, 1, 15, "| ドラゴン ボーレ |");
    74     cucul_set_attr_ansi(cv, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK, 0);
     77    cucul_set_attr(cv, ATTR_DEFAULT);
    7578    cucul_putstr(cv, 1, 16, "| ()()()() ()()() |");
    76     cucul_set_attr_ansi(cv, CUCUL_COLOR_YELLOW, CUCUL_COLOR_BLACK, 0);
     79    cucul_set_attr(cv, cucul_ansi_to_attr(CUCUL_YELLOW, CUCUL_TRANSPARENT));
    7780    cucul_putstr(cv, 1, 17, "| ドラゴン");
    7881    cucul_putstr(cv, 12, 17, "ボーレ |");
    7982
    80     cucul_set_attr_ansi(cv, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK, 0);
     83    cucul_set_attr(cv, ATTR_DEFAULT);
    8184    cucul_putstr(cv, 1, 18, "If the three lines do not have the same length, there is a bug somewhere.");
    8285
  • libcaca/trunk/tools/optipal.c

    r1048 r1257  
    3030static unsigned int const hue_list[] =
    3131{
    32     CUCUL_COLOR_RED,
    33     CUCUL_COLOR_BROWN,
    34     CUCUL_COLOR_GREEN,
    35     CUCUL_COLOR_CYAN,
    36     CUCUL_COLOR_BLUE,
    37     CUCUL_COLOR_MAGENTA
     32    CUCUL_RED, CUCUL_BROWN, CUCUL_GREEN,
     33    CUCUL_CYAN, CUCUL_BLUE, CUCUL_MAGENTA
    3834};
    3935
     
    172168    /* black background colour pairs that are needed for the old renderer */
    173169    for(i = 1; i < 16; i++)
    174         SETPAIR(i, CUCUL_COLOR_BLACK, cur++);
     170        SETPAIR(i, CUCUL_BLACK, cur++);
    175171
    176172    /* gray combinations used for grayscale dithering */
    177     SETPAIR(CUCUL_COLOR_BLACK, CUCUL_COLOR_DARKGRAY, cur++);
    178     SETPAIR(CUCUL_COLOR_DARKGRAY, CUCUL_COLOR_LIGHTGRAY, cur++);
    179     SETPAIR(CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_DARKGRAY, cur++);
    180     SETPAIR(CUCUL_COLOR_WHITE, CUCUL_COLOR_LIGHTGRAY, cur++);
    181     SETPAIR(CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_WHITE, cur++);
     173    SETPAIR(CUCUL_BLACK, CUCUL_DARKGRAY, cur++);
     174    SETPAIR(CUCUL_DARKGRAY, CUCUL_LIGHTGRAY, cur++);
     175    SETPAIR(CUCUL_LIGHTGRAY, CUCUL_DARKGRAY, cur++);
     176    SETPAIR(CUCUL_WHITE, CUCUL_LIGHTGRAY, cur++);
     177    SETPAIR(CUCUL_LIGHTGRAY, CUCUL_WHITE, cur++);
    182178
    183179    /* white/light, light/dark, lightgray/light, darkgray/dark, dark/black
     
    187183    for(i = 1; i < 7; i++)
    188184    {
    189         SETPAIR(CUCUL_COLOR_WHITE, i + 8, cur++);
    190         SETPAIR(i + 8, CUCUL_COLOR_WHITE, cur++);
     185        SETPAIR(CUCUL_WHITE, i + 8, cur++);
     186        SETPAIR(i + 8, CUCUL_WHITE, cur++);
    191187        SETPAIR(i, i + 8, cur++);
    192188        SETPAIR(i + 8, i, cur++);
    193         SETPAIR(CUCUL_COLOR_LIGHTGRAY, i + 8, cur++);
    194         SETPAIR(i + 8, CUCUL_COLOR_LIGHTGRAY, cur++);
    195         SETPAIR(CUCUL_COLOR_DARKGRAY, i, cur++);
    196         SETPAIR(i, CUCUL_COLOR_DARKGRAY, cur++);
    197         SETPAIR(CUCUL_COLOR_BLACK, i, cur++);
     189        SETPAIR(CUCUL_LIGHTGRAY, i + 8, cur++);
     190        SETPAIR(i + 8, CUCUL_LIGHTGRAY, cur++);
     191        SETPAIR(CUCUL_DARKGRAY, i, cur++);
     192        SETPAIR(i, CUCUL_DARKGRAY, cur++);
     193        SETPAIR(CUCUL_BLACK, i, cur++);
    198194    }
    199195
     
    220216    /* black on light gray, black on white, white on dark gray, dark gray
    221217     * on white, white on blue, light gray on blue (chosen arbitrarily) */
    222     SETPAIR(CUCUL_COLOR_BLACK, CUCUL_COLOR_LIGHTGRAY, cur++);
    223     SETPAIR(CUCUL_COLOR_BLACK, CUCUL_COLOR_WHITE, cur++);
    224     SETPAIR(CUCUL_COLOR_WHITE, CUCUL_COLOR_DARKGRAY, cur++);
    225     SETPAIR(CUCUL_COLOR_DARKGRAY, CUCUL_COLOR_WHITE, cur++);
    226     SETPAIR(CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE, cur++);
    227     SETPAIR(CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLUE, cur++);
     218    SETPAIR(CUCUL_BLACK, CUCUL_LIGHTGRAY, cur++);
     219    SETPAIR(CUCUL_BLACK, CUCUL_WHITE, cur++);
     220    SETPAIR(CUCUL_WHITE, CUCUL_DARKGRAY, cur++);
     221    SETPAIR(CUCUL_DARKGRAY, CUCUL_WHITE, cur++);
     222    SETPAIR(CUCUL_WHITE, CUCUL_BLUE, cur++);
     223    SETPAIR(CUCUL_LIGHTGRAY, CUCUL_BLUE, cur++);
    228224}
    229225
     
    241237    for(i = 1; i < 7; i++)
    242238    {
    243         if(i != CUCUL_COLOR_BLUE)
     239        if(i != CUCUL_BLUE)
    244240        {
    245             SETPAIR(CUCUL_COLOR_LIGHTGRAY, i, 128 +
     241            SETPAIR(CUCUL_LIGHTGRAY, i, 128 +
    246242                    slang_assoc[i + 8 + 16 * i]);
    247             SETPAIR(CUCUL_COLOR_WHITE, i, 128 +
    248                     slang_assoc[CUCUL_COLOR_LIGHTGRAY + 16 * (i + 8)]);
     243            SETPAIR(CUCUL_WHITE, i, 128 +
     244                    slang_assoc[CUCUL_LIGHTGRAY + 16 * (i + 8)]);
    249245        }
    250         SETPAIR(CUCUL_COLOR_BLACK, i + 8,
    251                 128 + slang_assoc[CUCUL_COLOR_DARKGRAY + 16 * i]);
    252         SETPAIR(CUCUL_COLOR_DARKGRAY, i + 8,
     246        SETPAIR(CUCUL_BLACK, i + 8,
     247                128 + slang_assoc[CUCUL_DARKGRAY + 16 * i]);
     248        SETPAIR(CUCUL_DARKGRAY, i + 8,
    253249                128 + slang_assoc[i + 16 * (i + 8)]);
    254         SETPAIR(i + 8, CUCUL_COLOR_DARKGRAY,
    255                 128 + slang_assoc[i + 16 * CUCUL_COLOR_DARKGRAY]);
    256         SETPAIR(i, CUCUL_COLOR_LIGHTGRAY,
    257                 128 + slang_assoc[i + 8 + 16 * CUCUL_COLOR_LIGHTGRAY]);
    258         SETPAIR(i, CUCUL_COLOR_WHITE,
    259                 128 + slang_assoc[i + 8 + 16 * CUCUL_COLOR_WHITE]);
     250        SETPAIR(i + 8, CUCUL_DARKGRAY,
     251                128 + slang_assoc[i + 16 * CUCUL_DARKGRAY]);
     252        SETPAIR(i, CUCUL_LIGHTGRAY,
     253                128 + slang_assoc[i + 8 + 16 * CUCUL_LIGHTGRAY]);
     254        SETPAIR(i, CUCUL_WHITE,
     255                128 + slang_assoc[i + 8 + 16 * CUCUL_WHITE]);
    260256    }
    261257
     
    291287    {
    292288        SETPAIR(hue_list[i], hue_list[(i + 3) % 6],
    293                 128 + slang_assoc[hue_list[i] + 16 * CUCUL_COLOR_BLACK]);
     289                128 + slang_assoc[hue_list[i] + 16 * CUCUL_BLACK]);
    294290        SETPAIR(hue_list[i] + 8, hue_list[(i + 3) % 6],
    295                 128 + slang_assoc[hue_list[i] + 8 + 16 * CUCUL_COLOR_BLACK]);
     291                128 + slang_assoc[hue_list[i] + 8 + 16 * CUCUL_BLACK]);
    296292        SETPAIR(hue_list[(i + 3) % 6], hue_list[i] + 8,
    297                 128 + slang_assoc[CUCUL_COLOR_BLACK + 16 * hue_list[i]]);
     293                128 + slang_assoc[CUCUL_BLACK + 16 * hue_list[i]]);
    298294        SETPAIR(hue_list[(i + 3) % 6] + 8, hue_list[i] + 8,
    299                 128 + slang_assoc[CUCUL_COLOR_WHITE + 16 * (hue_list[i] + 8)]);
     295                128 + slang_assoc[CUCUL_WHITE + 16 * (hue_list[i] + 8)]);
    300296    }
    301297}
Note: See TracChangeset for help on using the changeset viewer.