- Timestamp:
- Nov 11, 2006, 10:10:17 AM (16 years ago)
- Location:
- libcaca/trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/caca/driver_conio.c
r1254 r1333 108 108 { 109 109 *screen++ = '['; 110 *screen++ = _cucul_attr_to_ansi8(*attrs++);110 *screen++ = cucul_attr_to_ansi(*attrs++); 111 111 ch = ']'; 112 112 chars++; … … 114 114 } 115 115 *screen++ = ch; 116 *screen++ = _cucul_attr_to_ansi8(*attrs++);116 *screen++ = cucul_attr_to_ansi(*attrs++); 117 117 } 118 118 # if defined(SCREENUPDATE_IN_PC_H) -
libcaca/trunk/caca/driver_ncurses.c
r1254 r1333 204 204 for(x = dp->cv->width; x--; ) 205 205 { 206 attrset(dp->drv.p->attr[ _cucul_attr_to_ansi8(*attrs++)]);206 attrset(dp->drv.p->attr[cucul_attr_to_ansi(*attrs++)]); 207 207 ncurses_write_utf32(*chars++); 208 208 } -
libcaca/trunk/caca/driver_slang.c
r1332 r1333 243 243 #endif 244 244 { 245 SLsmg_set_color(slang_assoc[ _cucul_attr_to_ansi8(*attrs++)]);245 SLsmg_set_color(slang_assoc[cucul_attr_to_ansi(*attrs++)]); 246 246 slang_write_utf32(ch); 247 247 } 248 248 #else 249 SLsmg_set_color( _cucul_attr_to_ansi8(*attrs++));249 SLsmg_set_color(cucul_attr_to_ansi(*attrs++)); 250 250 slang_write_utf32(ch); 251 251 #endif -
libcaca/trunk/caca/driver_vga.c
r1254 r1333 126 126 { 127 127 *screen++ = '['; 128 *screen++ = _cucul_attr_to_ansi8(*attrs++);128 *screen++ = cucul_attr_to_ansi(*attrs++); 129 129 ch = ']'; 130 130 chars++; … … 132 132 } 133 133 *screen++ = ch; 134 *screen++ = _cucul_attr_to_ansi8(*attrs++);134 *screen++ = cucul_attr_to_ansi(*attrs++); 135 135 } 136 136 } -
libcaca/trunk/cucul/attr.c
r1332 r1333 235 235 } 236 236 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 */ 254 unsigned 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 237 263 /** \brief Get ANSI foreground information from attribute. 238 264 * … … 335 361 336 362 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);351 363 } 352 364 -
libcaca/trunk/cucul/cucul.h
r1331 r1333 122 122 * 123 123 * @{ */ 124 unsigned char cucul_attr_to_ansi(unsigned long int); 124 125 unsigned char cucul_attr_to_ansi_fg(unsigned long int); 125 126 unsigned char cucul_attr_to_ansi_bg(unsigned long int); -
libcaca/trunk/cucul/cucul_internals.h
r1254 r1333 58 58 59 59 /* 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]); 60 extern uint16_t _cucul_attr_to_rgb12fg(uint32_t); 61 extern uint16_t _cucul_attr_to_rgb12bg(uint32_t); 62 extern uint32_t _cucul_attr_to_rgb24fg(uint32_t); 63 extern uint32_t _cucul_attr_to_rgb24bg(uint32_t); 64 extern void _cucul_attr_to_argb4(uint32_t, uint8_t[8]); 68 65 69 66 #endif /* __CUCUL_INTERNALS_H__ */
Note: See TracChangeset
for help on using the changeset viewer.