Changeset 629 for libcaca/trunk/caca
- Timestamp:
- Mar 16, 2006, 1:49:20 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/caca/driver_ncurses.c
r613 r629 22 22 #if defined(USE_NCURSES) 23 23 24 #if defined(HAVE_NCURSES_H) 24 #if defined(HAVE_NCURSESW_NCURSES_H) 25 # include <ncursesw/ncurses.h> 26 #elif defined(HAVE_NCURSES_NCURSES_H) 27 # include <ncurses/ncurses.h> 28 #elif defined(HAVE_NCURSES_H) 25 29 # include <ncurses.h> 26 30 #else … … 54 58 static void ncurses_check_terminal(void); 55 59 #endif 60 static void ncurses_write_utf32(uint32_t); 56 61 57 62 struct driver_private … … 193 198 for(x = kk->qq->width; x--; ) 194 199 { 195 uint32_t c = *chars++;196 197 200 attrset(kk->drv.p->attr[*attr++]); 198 if(c > 0x00000020 && c < 0x00000080) 199 addch((char)c); 200 else 201 addch(' '); 201 ncurses_write_utf32(*chars++); 202 202 } 203 203 } … … 454 454 #endif 455 455 456 static void ncurses_write_utf32(uint32_t c) 457 { 458 #if defined(HAVE_NCURSESW_NCURSES_H) 459 static const uint8_t mark[7] = 460 { 461 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC 462 }; 463 464 char buf[10], *parser; 465 int bytes; 466 #endif 467 468 if(c < 0x80) 469 { 470 addch(c); 471 return; 472 } 473 474 #if defined(HAVE_NCURSESW_NCURSES_H) 475 if(c < 0x10000) 476 { 477 addch(c); /* FIXME: doesn't work either */ 478 return; 479 } 480 481 bytes = (c < 0x800) ? 2 : (c < 0x10000) ? 3 : 4; 482 buf[bytes] = '\0'; 483 parser = buf + bytes; 484 485 switch(bytes) 486 { 487 case 4: *--parser = (c | 0x80) & 0xbf; c >>= 6; 488 case 3: *--parser = (c | 0x80) & 0xbf; c >>= 6; 489 case 2: *--parser = (c | 0x80) & 0xbf; c >>= 6; 490 } 491 *--parser = c | mark[bytes]; 492 493 addstr(buf); 494 #else 495 addch(' '); 496 #endif 497 } 498 456 499 /* 457 500 * Driver initialisation
Note: See TracChangeset
for help on using the changeset viewer.