Преглед на файлове

* Partial Unicode support for the DOS/conio.h driver. Glyphs that have

equivalents in CP437 0x7f - 0xff are translated.
tags/v0.99.beta14
Sam Hocevar sam преди 18 години
родител
ревизия
d651a43041
променени са 1 файла, в които са добавени 56 реда и са изтрити 7 реда
  1. +56
    -7
      caca/driver_conio.c

+ 56
- 7
caca/driver_conio.c Целия файл

@@ -34,6 +34,8 @@
#include "cucul.h"
#include "cucul_internals.h"

static uint8_t conio_utf32_to_cp437(uint32_t);

struct driver_private
{
struct text_info ti;
@@ -104,13 +106,7 @@ static void conio_display(caca_t *kk)

for(n = kk->qq->height * kk->qq->width; n--; )
{
uint32_t c = *chars++;

if(c > 0x00000020 && c < 0x00000080)
*screen++ = (char)c;
else
*screen++ = ' ';

*screen++ = conio_utf32_to_cp437(*chars++);
*screen++ = *attr++;
}
# if defined(SCREENUPDATE_IN_PC_H)
@@ -139,6 +135,59 @@ static unsigned int conio_get_event(caca_t *kk)
return CACA_EVENT_KEY_PRESS | event;
}

/*
* XXX: following functions are local
*/

static uint8_t conio_utf32_to_cp437(uint32_t c)
{
static uint32_t const lookup[] =
{
/* 0x7f */
0x2302,
/* 0x80 - 0x8f */
0xc7, 0xfc, 0xe9, 0xe2, 0xe4, 0xe0, 0xe5, 0xe7,
0xea, 0xeb, 0xe8, 0xef, 0xee, 0xec, 0xc4, 0xc5,
/* 0x90 - 0x9f */
0xc9, 0xe6, 0xc6, 0xf4, 0xf6, 0xf2, 0xfb, 0xf9,
0xff, 0xd6, 0xdc, 0xa2, 0xa3, 0xa5, 0x20a7, 0x192,
/* 0xa0 - 0xaf */
0xe1, 0xed, 0xf3, 0xfa, 0xf1, 0xd1, 0xaa, 0xba,
0xbf, 0x2310, 0xac, 0xbd, 0xbc, 0xa1, 0xab, 0xbb,
/* 0xb0 - 0xbf */
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
0x2555, 0x2563, 0x2551, 0x2557, 0x255d, 0x255c, 0x255b, 0x2510,
/* 0xc0 - 0xcf */
0x2514, 0x2534, 0x252c, 0x251c, 0x2500, 0x253c, 0x255e, 0x255f,
0x255a, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256c, 0x2567,
/* 0xd0 - 0xdf */
0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256b,
0x256a, 0x2518, 0x250c, 0x2588, 0x2584, 0x258c, 0x2590, 0x2580,
/* 0xe0 - 0xef */
0x3b1, 0xdf, 0x393, 0x3c0, 0x3a3, 0x3c3, 0xb5, 0x3c4,
0x3a6, 0x398, 0x3a9, 0x3b4, 0x221e, 0x3c6, 0x3b5, 0x2229,
/* 0xf0 - 0xff */
0x2261, 0xb1, 0x2265, 0x2264, 0x2320, 0x2321, 0xf7, 0x2248,
0xb0, 0x2219, 0xb7, 0x221a, 0x207f, 0xb2, 0x25a0, 0xa0
};

unsigned int i;
if(c < 0x00000020)
return '?';

if(c < 0x00000080)
return c;

for(i = 0; i < sizeof(lookup) / sizeof(*lookup); i++)
{
if(lookup[i] == c)
return 0x7f + i;
}

return '?';
}

/*
* Driver initialisation
*/


Зареждане…
Отказ
Запис