Changeset 1136 for libcaca/trunk/cucul/import.c
- Timestamp:
- Sep 30, 2006, 1:34:03 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/cucul/import.c
r1104 r1136 41 41 static cucul_canvas_t *import_caca(void const *, unsigned int); 42 42 static cucul_canvas_t *import_text(void const *, unsigned int); 43 static cucul_canvas_t *import_ansi(void const *, unsigned int );43 static cucul_canvas_t *import_ansi(void const *, unsigned int, int); 44 44 45 45 static void ansi_parse_grcm(cucul_canvas_t *, struct ansi_grcm *, … … 53 53 * Valid values for \c format are: 54 54 * - \c "": attempt to autodetect the file format. 55 * - \c "text": import ASCII text files. 55 56 * - \c "ansi": import ANSI files. 57 * - \c "utf8": import UTF-8 files with ANSI colour files. 56 58 * - \c "caca": import native libcaca files. 57 59 * … … 71 73 if(!strcasecmp("caca", format)) 72 74 return import_caca(buffer->data, buffer->size); 75 if(!strcasecmp("utf8", format)) 76 return import_ansi(buffer->data, buffer->size, 1); 73 77 if(!strcasecmp("text", format)) 74 78 return import_text(buffer->data, buffer->size); 75 79 if(!strcasecmp("ansi", format)) 76 return import_ansi(buffer->data, buffer->size );80 return import_ansi(buffer->data, buffer->size, 0); 77 81 78 82 /* Autodetection */ … … 89 93 for(i = 0; i < buffer->size - 1; i++) 90 94 if((buf[i] == 0x1b) && (buf[i + 1] == '[')) 91 return import_ansi(buffer->data, buffer->size );95 return import_ansi(buffer->data, buffer->size, 0); 92 96 93 97 /* Otherwise, import it as text */ … … 236 240 } 237 241 238 static cucul_canvas_t *import_ansi(void const *data, unsigned int size) 242 static cucul_canvas_t *import_ansi(void const *data, unsigned int size, 243 int utf8) 239 244 { 240 245 struct ansi_grcm grcm; … … 243 248 unsigned int i, j, skip, dummy = 0; 244 249 unsigned int width = 1, height = 1; 250 unsigned long int ch; 245 251 int x = 0, y = 0, save_x = 0, save_y = 0; 246 252 … … 412 418 413 419 /* Now paste our character */ 420 if(utf8) 421 { 422 unsigned int bytes; 423 ch = cucul_utf8_to_utf32((char const *)(buffer + i), &bytes); 424 skip += bytes - 1; 425 } 426 else 427 { 428 ch = cucul_cp437_to_utf32(buffer[i]); 429 } 414 430 cucul_set_color(cv, grcm.efg, grcm.ebg); 415 cucul_putchar(cv, x, y, c ucul_cp437_to_utf32(buffer[i]));431 cucul_putchar(cv, x, y, ch); 416 432 x++; 417 433 }
Note: See TracChangeset
for help on using the changeset viewer.