Changeset 982
- Timestamp:
- May 25, 2006, 10:01:10 PM (15 years ago)
- Location:
- libcaca/trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/caca/driver_slang.c
r974 r982 212 212 213 213 #if defined(OPTIMISE_SLANG_PALETTE) 214 /* If foreground == background, just don't use this colour 215 * pair, and print a space instead of the real character. 216 * XXX: disabled, because I can't remember what it was 217 * here for, and in cases where SLang does not render 218 * bright backgrounds, it's just fucked up. */ 219 #if 0 214 220 uint8_t fgcolor = _cucul_argb32_to_ansi4fg(*attr); 215 221 uint8_t bgcolor = _cucul_argb32_to_ansi4bg(*attr); 216 222 217 /* If foreground == background, just don't use this colour 218 * pair, and print a space instead of the real character. */ 219 if(fgcolor != bgcolor) 220 { 221 SLsmg_set_color(slang_assoc[_cucul_argb32_to_ansi8(*attr++)]); 222 slang_write_utf32(ch); 223 } 224 else 223 if(fgcolor == bgcolor) 225 224 { 226 225 if(fgcolor == CUCUL_COLOR_BLACK) … … 235 234 attr++; 236 235 } 236 else 237 #endif 238 { 239 SLsmg_set_color(slang_assoc[_cucul_argb32_to_ansi8(*attr++)]); 240 slang_write_utf32(ch); 241 } 237 242 #else 238 243 SLsmg_set_color(_cucul_argb32_to_ansi8(*attr++)); … … 284 289 ev->data.key.utf8[1] = '\0'; 285 290 return 1; 291 } 292 293 /* If the key was UTF-8, parse the whole sequence */ 294 if(intkey >= 0x80 && intkey < 0x100) 295 { 296 int keys[7]; /* Necessary for ungetkey(); */ 297 char utf8[7]; 298 uint32_t utf32; 299 unsigned int i, bytes = 0; 300 301 keys[0] = intkey; 302 utf8[0] = intkey; 303 304 for(i = 1; i < 6; i++) 305 { 306 if(!SLang_input_pending(0)) 307 break; 308 keys[i] = SLang_getkey(); 309 utf8[i] = (unsigned char)keys[i]; 310 } 311 312 utf8[i] = '\0'; 313 utf32 = cucul_utf8_to_utf32(utf8, &bytes); 314 315 while(i > bytes) 316 SLang_ungetkey(keys[--i]); 317 318 if(bytes) 319 { 320 ev->type = CACA_EVENT_KEY_PRESS; 321 ev->data.key.ch = 0; 322 ev->data.key.utf32 = utf32; 323 strcpy(ev->data.key.utf8, utf8); 324 return 1; 325 } 286 326 } 287 327 … … 339 379 case SL_KEY_F(12): ev->data.key.ch = CACA_KEY_F12; break; 340 380 341 default: ev->type = CACA_EVENT_NONE; return 0; 381 default: 382 /* Unknown key */ 383 ev->type = CACA_EVENT_NONE; return 0; 342 384 } 343 385 -
libcaca/trunk/cucul/box.c
r962 r982 156 156 if(y2 > ymax) y2 = ymax; 157 157 158 ch = cucul_utf8_to_utf32(str );158 ch = cucul_utf8_to_utf32(str, NULL); 159 159 160 160 for(y = y1; y <= y2; y++) -
libcaca/trunk/cucul/canvas.c
r962 r982 117 117 while(len) 118 118 { 119 *chars++ = cucul_utf8_to_utf32(s );119 *chars++ = cucul_utf8_to_utf32(s, NULL); 120 120 *attr++ = (cv->bgcolor << 16) | cv->fgcolor; 121 121 -
libcaca/trunk/cucul/charset.c
r963 r982 96 96 * 97 97 * This function converts a UTF-8 character read from a string and returns 98 * its value in the UTF-32 character set. 98 * its value in the UTF-32 character set. If the second argument is not null, 99 * the total number of read bytes is written in it. 100 * 101 * If a null byte was reached before the expected end of the UTF-8 sequence, 102 * this function returns zero and the number of read bytes is set to zero. 99 103 * 100 104 * This function never fails, but its behaviour with illegal UTF-8 sequences … … 102 106 * 103 107 * \param s A string containing the UTF-8 character. 104 * \return The corresponding UTF-32 character. 105 */ 106 unsigned long int cucul_utf8_to_utf32(char const *s) 107 { 108 int bytes = trailing[(int)(unsigned char)*s]; 108 * \param read A pointer to an unsigned integer to store the number of 109 * bytes in the character, or NULL. 110 * \return The corresponding UTF-32 character, or zero if the character 111 * is incomplete. 112 */ 113 unsigned long int cucul_utf8_to_utf32(char const *s, unsigned int *read) 114 { 115 unsigned int bytes = trailing[(int)(unsigned char)*s]; 116 unsigned int i = 0; 109 117 uint32_t ret = 0; 110 118 111 switch(bytes) 112 { 113 /* FIXME: do something for invalid sequences (4 and 5) */ 114 case 3: ret += (uint8_t)*s++; ret <<= 6; 115 case 2: ret += (uint8_t)*s++; ret <<= 6; 116 case 1: ret += (uint8_t)*s++; ret <<= 6; 117 case 0: ret += (uint8_t)*s++; 118 } 119 120 ret -= offsets[bytes]; 121 122 return ret; 119 for(;;) 120 { 121 if(!*s) 122 { 123 if(read) 124 *read = 0; 125 return 0; 126 } 127 128 ret += ((uint32_t)(unsigned char)*s++) << (6 * (bytes - i)); 129 130 if(bytes == i++) 131 { 132 if(read) 133 *read = i; 134 return ret - offsets[bytes]; 135 } 136 } 123 137 } 124 138 -
libcaca/trunk/cucul/conic.c
r962 r982 44 44 { 45 45 int test, dx, dy; 46 uint32_t ch = cucul_utf8_to_utf32(str );46 uint32_t ch = cucul_utf8_to_utf32(str, NULL); 47 47 48 48 /* Optimized Bresenham. Kick ass. */ … … 139 139 int y = b; 140 140 int d1 = b*b - (a*a*b) + (a*a/4); 141 uint32_t ch = cucul_utf8_to_utf32(str );141 uint32_t ch = cucul_utf8_to_utf32(str, NULL); 142 142 143 143 ellipsepoints(cv, xo, yo, x, y, ch); -
libcaca/trunk/cucul/cucul.h
r962 r982 124 124 * 125 125 * @{ */ 126 extern unsigned long int cucul_utf8_to_utf32(char const * );126 extern unsigned long int cucul_utf8_to_utf32(char const *, unsigned int *); 127 127 extern unsigned int cucul_utf32_to_utf8(char *, unsigned long int); 128 128 extern unsigned char cucul_utf32_to_cp437(unsigned long int); -
libcaca/trunk/cucul/line.c
r962 r982 62 62 s.x2 = x2; 63 63 s.y2 = y2; 64 s.ch = cucul_utf8_to_utf32(str );64 s.ch = cucul_utf8_to_utf32(str, NULL); 65 65 s.draw = draw_solid_line; 66 66 clip_line(cv, &s); … … 90 90 int i; 91 91 struct line s; 92 s.ch = cucul_utf8_to_utf32(str );92 s.ch = cucul_utf8_to_utf32(str, NULL); 93 93 s.draw = draw_solid_line; 94 94 -
libcaca/trunk/cucul/triangle.c
r962 r982 110 110 ymax = cv->height - 1; 111 111 112 ch = cucul_utf8_to_utf32(str );112 ch = cucul_utf8_to_utf32(str, NULL); 113 113 114 114 /* Rasterize our triangle */
Note: See TracChangeset
for help on using the changeset viewer.