Changeset 1333


Ignore:
Timestamp:
Nov 11, 2006, 10:10:17 AM (13 years ago)
Author:
Sam Hocevar
Message:
  • Replace _cucul_attr_to_ansi8() with a now documented cucul_attr_to_ansi() function.
Location:
libcaca/trunk
Files:
7 edited

Legend:

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

    r1254 r1333  
    108108        {
    109109            *screen++ = '[';
    110             *screen++ = _cucul_attr_to_ansi8(*attrs++);
     110            *screen++ = cucul_attr_to_ansi(*attrs++);
    111111            ch = ']';
    112112            chars++;
     
    114114        }
    115115        *screen++ = ch;
    116         *screen++ = _cucul_attr_to_ansi8(*attrs++);
     116        *screen++ = cucul_attr_to_ansi(*attrs++);
    117117    }
    118118#   if defined(SCREENUPDATE_IN_PC_H)
  • libcaca/trunk/caca/driver_ncurses.c

    r1254 r1333  
    204204        for(x = dp->cv->width; x--; )
    205205        {
    206             attrset(dp->drv.p->attr[_cucul_attr_to_ansi8(*attrs++)]);
     206            attrset(dp->drv.p->attr[cucul_attr_to_ansi(*attrs++)]);
    207207            ncurses_write_utf32(*chars++);
    208208        }
  • libcaca/trunk/caca/driver_slang.c

    r1332 r1333  
    243243#endif
    244244            {
    245                 SLsmg_set_color(slang_assoc[_cucul_attr_to_ansi8(*attrs++)]);
     245                SLsmg_set_color(slang_assoc[cucul_attr_to_ansi(*attrs++)]);
    246246                slang_write_utf32(ch);
    247247            }
    248248#else
    249             SLsmg_set_color(_cucul_attr_to_ansi8(*attrs++));
     249            SLsmg_set_color(cucul_attr_to_ansi(*attrs++));
    250250            slang_write_utf32(ch);
    251251#endif
  • libcaca/trunk/caca/driver_vga.c

    r1254 r1333  
    126126        {
    127127            *screen++ = '[';
    128             *screen++ = _cucul_attr_to_ansi8(*attrs++);
     128            *screen++ = cucul_attr_to_ansi(*attrs++);
    129129            ch = ']';
    130130            chars++;
     
    132132        }
    133133        *screen++ = ch;
    134         *screen++ = _cucul_attr_to_ansi8(*attrs++);
     134        *screen++ = cucul_attr_to_ansi(*attrs++);
    135135    }
    136136}
  • libcaca/trunk/cucul/attr.c

    r1332 r1333  
    235235}
    236236
     237/** \brief Get DOS ANSI information from attribute.
     238 *
     239 *  Get the ANSI colour pair for a given attribute. The returned value is
     240 *  an 8-bit value whose higher 4 bits are the background colour and lower
     241 *  4 bits are the foreground colour.
     242 *
     243 *  If the attribute has ARGB colours, the nearest colour is used. Special
     244 *  attributes such as \e CUCUL_DEFAULT and \e CUCUL_TRANSPARENT are not
     245 *  handled and are both replaced with \e CUCUL_LIGHTGRAY for the foreground
     246 *  colour and \e CUCUL_BLACK for the background colour.
     247 *
     248 *  This function never fails. If the attribute value is outside the expected
     249 *  32-bit range, higher order bits are simply ignored.
     250 *
     251 *  \param attr The requested attribute value.
     252 *  \return The corresponding DOS ANSI value.
     253 */
     254unsigned char cucul_attr_to_ansi(unsigned long int attr)
     255{
     256    uint8_t fg = nearest_ansi((attr >> 4) & 0x3fff);
     257    uint8_t bg = nearest_ansi(attr >> 18);
     258
     259    return (fg < 0x10 ? fg : CUCUL_LIGHTGRAY)
     260            | ((bg < 0x10 ? bg : CUCUL_BLACK) << 4);
     261}
     262
    237263/** \brief Get ANSI foreground information from attribute.
    238264 *
     
    335361
    336362    return best;
    337 }
    338 
    339 uint8_t _cucul_attr_to_ansi8(uint32_t attr)
    340 {
    341     uint8_t fg = nearest_ansi((attr >> 4) & 0x3fff);
    342     uint8_t bg = nearest_ansi(attr >> 18);
    343 
    344     if(fg == CUCUL_DEFAULT || fg == CUCUL_TRANSPARENT)
    345         fg = CUCUL_LIGHTGRAY;
    346 
    347     if(bg == CUCUL_DEFAULT || bg == CUCUL_TRANSPARENT)
    348         bg = CUCUL_BLACK;
    349 
    350     return fg | (bg << 4);
    351363}
    352364
  • libcaca/trunk/cucul/cucul.h

    r1331 r1333  
    122122 *
    123123 *  @{ */
     124unsigned char cucul_attr_to_ansi(unsigned long int);
    124125unsigned char cucul_attr_to_ansi_fg(unsigned long int);
    125126unsigned char cucul_attr_to_ansi_bg(unsigned long int);
  • libcaca/trunk/cucul/cucul_internals.h

    r1254 r1333  
    5858
    5959/* Colour functions */
    60 uint8_t _cucul_attr_to_ansi8(uint32_t);
    61 uint8_t _cucul_attr_to_ansi4fg(uint32_t);
    62 uint8_t _cucul_attr_to_ansi4bg(uint32_t);
    63 uint16_t _cucul_attr_to_rgb12fg(uint32_t);
    64 uint16_t _cucul_attr_to_rgb12bg(uint32_t);
    65 uint32_t _cucul_attr_to_rgb24fg(uint32_t);
    66 uint32_t _cucul_attr_to_rgb24bg(uint32_t);
    67 void _cucul_attr_to_argb4(uint32_t, uint8_t[8]);
     60extern uint16_t _cucul_attr_to_rgb12fg(uint32_t);
     61extern uint16_t _cucul_attr_to_rgb12bg(uint32_t);
     62extern uint32_t _cucul_attr_to_rgb24fg(uint32_t);
     63extern uint32_t _cucul_attr_to_rgb24bg(uint32_t);
     64extern void _cucul_attr_to_argb4(uint32_t, uint8_t[8]);
    6865
    6966#endif /* __CUCUL_INTERNALS_H__ */
Note: See TracChangeset for help on using the changeset viewer.