with "utf8".tags/v0.99.beta14
@@ -49,8 +49,8 @@ typedef struct caca_event caca_event_t; | |||||
* \li \b CACA_EVENT_KEY_PRESS, \b CACA_EVENT_KEY_RELEASE: the \e data.key.ch | * \li \b CACA_EVENT_KEY_PRESS, \b CACA_EVENT_KEY_RELEASE: the \e data.key.ch | ||||
* field is valid and contains either the ASCII value for the key, or | * field is valid and contains either the ASCII value for the key, or | ||||
* an \e enum \e caca_key value. If the value is a printable ASCII | * an \e enum \e caca_key value. If the value is a printable ASCII | ||||
* character, the \e data.key.ucs4 and \e data.key.utf8 fields are | |||||
* also filled and contain respectively the UCS-4/UTF-32 and the UTF-8 | |||||
* character, the \e data.key.utf32 and \e data.key.utf8 fields are | |||||
* also filled and contain respectively the UTF-32/UCS-4 and the UTF-8 | |||||
* representations of the character. Otherwise, their content is | * representations of the character. Otherwise, their content is | ||||
* undefined. | * undefined. | ||||
* | * | ||||
@@ -92,7 +92,7 @@ struct caca_event | |||||
{ | { | ||||
struct { unsigned int x, y, button; } mouse; | struct { unsigned int x, y, button; } mouse; | ||||
struct { unsigned int w, h; } resize; | struct { unsigned int w, h; } resize; | ||||
struct { unsigned int ch; unsigned long int ucs4; char utf8[8]; } key; | |||||
struct { unsigned int ch; unsigned long int utf32; char utf8[8]; } key; | |||||
} data; | } data; | ||||
}; | }; | ||||
@@ -135,7 +135,7 @@ static int conio_get_event(caca_display_t *dp, caca_event_t *ev) | |||||
ev->type = CACA_EVENT_KEY_PRESS; | ev->type = CACA_EVENT_KEY_PRESS; | ||||
ev->data.key.ch = ch; | ev->data.key.ch = ch; | ||||
ev->data.key.ucs4 = (uint32_t)ch; | |||||
ev->data.key.utf32 = (uint32_t)ch; | |||||
ev->data.key.utf8[0] = ch; | ev->data.key.utf8[0] = ch; | ||||
ev->data.key.utf8[1] = '\0'; | ev->data.key.utf8[1] = '\0'; | ||||
@@ -476,7 +476,7 @@ static int gl_get_event(caca_display_t *dp, caca_event_t *ev) | |||||
{ | { | ||||
ev->type = CACA_EVENT_KEY_PRESS; | ev->type = CACA_EVENT_KEY_PRESS; | ||||
ev->data.key.ch = dp->drv.p->key; | ev->data.key.ch = dp->drv.p->key; | ||||
ev->data.key.ucs4 = (uint32_t)dp->drv.p->key; | |||||
ev->data.key.utf32 = (uint32_t)dp->drv.p->key; | |||||
ev->data.key.utf8[0] = dp->drv.p->key; | ev->data.key.utf8[0] = dp->drv.p->key; | ||||
ev->data.key.utf8[1] = '\0'; | ev->data.key.utf8[1] = '\0'; | ||||
dp->drv.p->key = 0; | dp->drv.p->key = 0; | ||||
@@ -514,7 +514,7 @@ static int gl_get_event(caca_display_t *dp, caca_event_t *ev) | |||||
} | } | ||||
ev->type = CACA_EVENT_KEY_PRESS; | ev->type = CACA_EVENT_KEY_PRESS; | ||||
ev->data.key.ucs4 = 0; | |||||
ev->data.key.utf32 = 0; | |||||
ev->data.key.utf8[0] = '\0'; | ev->data.key.utf8[0] = '\0'; | ||||
dp->drv.p->special_key = 0; | dp->drv.p->special_key = 0; | ||||
@@ -428,7 +428,7 @@ static int ncurses_get_event(caca_display_t *dp, caca_event_t *ev) | |||||
} | } | ||||
ev->type = CACA_EVENT_KEY_PRESS; | ev->type = CACA_EVENT_KEY_PRESS; | ||||
ev->data.key.ucs4 = 0; | |||||
ev->data.key.utf32 = 0; | |||||
ev->data.key.utf8[0] = '\0'; | ev->data.key.utf8[0] = '\0'; | ||||
return 1; | return 1; | ||||
} | } | ||||
@@ -337,7 +337,7 @@ static int slang_get_event(caca_display_t *dp, caca_event_t *ev) | |||||
} | } | ||||
ev->type = CACA_EVENT_KEY_PRESS; | ev->type = CACA_EVENT_KEY_PRESS; | ||||
ev->data.key.ucs4 = 0; | |||||
ev->data.key.utf32 = 0; | |||||
ev->data.key.utf8[0] = '\0'; | ev->data.key.utf8[0] = '\0'; | ||||
return 1; | return 1; | ||||
} | } | ||||
@@ -256,7 +256,7 @@ static int win32_get_event(caca_display_t *dp, caca_event_t *ev) | |||||
if(rec.Event.KeyEvent.uChar.AsciiChar) | if(rec.Event.KeyEvent.uChar.AsciiChar) | ||||
{ | { | ||||
ev->data.key.ch = rec.Event.KeyEvent.uChar.AsciiChar; | ev->data.key.ch = rec.Event.KeyEvent.uChar.AsciiChar; | ||||
ev->data.key.ucs4 = (uint32_t)ev->data.key.ch; | |||||
ev->data.key.utf32 = (uint32_t)ev->data.key.ch; | |||||
ev->data.key.utf8[0] = ev->data.key.ch; | ev->data.key.utf8[0] = ev->data.key.ch; | ||||
ev->data.key.utf8[1] = '\0'; | ev->data.key.utf8[1] = '\0'; | ||||
@@ -508,7 +508,7 @@ static int x11_get_event(caca_display_t *dp, caca_event_t *ev) | |||||
if(XLookupString(&xevent.xkey, &key, 1, NULL, NULL)) | if(XLookupString(&xevent.xkey, &key, 1, NULL, NULL)) | ||||
{ | { | ||||
ev->data.key.ch = key; | ev->data.key.ch = key; | ||||
ev->data.key.ucs4 = key; | |||||
ev->data.key.utf32 = key; | |||||
ev->data.key.utf8[0] = key; | ev->data.key.utf8[0] = key; | ||||
ev->data.key.utf8[1] = '\0'; | ev->data.key.utf8[1] = '\0'; | ||||
return 1; | return 1; | ||||
@@ -548,7 +548,7 @@ static int x11_get_event(caca_display_t *dp, caca_event_t *ev) | |||||
default: ev->type = CACA_EVENT_NONE; return 0; | default: ev->type = CACA_EVENT_NONE; return 0; | ||||
} | } | ||||
ev->data.key.ucs4 = 0; | |||||
ev->data.key.utf32 = 0; | |||||
ev->data.key.utf8[0] = '\0'; | ev->data.key.utf8[0] = '\0'; | ||||
return 1; | return 1; | ||||
} | } | ||||
@@ -201,7 +201,7 @@ static int _get_next_event(caca_display_t *dp, caca_event_t *ev) | |||||
if(ev->type == CACA_EVENT_KEY_PRESS | if(ev->type == CACA_EVENT_KEY_PRESS | ||||
&& dp->events.last_key_event.type | && dp->events.last_key_event.type | ||||
&& ev->data.key.ch == dp->events.last_key_event.data.key.ch | && ev->data.key.ch == dp->events.last_key_event.data.key.ch | ||||
&& ev->data.key.ucs4 == dp->events.last_key_event.data.key.ucs4) | |||||
&& ev->data.key.utf32 == dp->events.last_key_event.data.key.utf32) | |||||
{ | { | ||||
dp->events.last_key_ticks = 0; | dp->events.last_key_ticks = 0; | ||||
return _get_next_event(dp, ev); | return _get_next_event(dp, ev); | ||||
@@ -130,7 +130,7 @@ int main(void) | |||||
memmove(entries[e].buffer + entries[e].cursor + 1, | memmove(entries[e].buffer + entries[e].cursor + 1, | ||||
entries[e].buffer + entries[e].cursor, | entries[e].buffer + entries[e].cursor, | ||||
(entries[e].size - entries[e].cursor) * 4); | (entries[e].size - entries[e].cursor) * 4); | ||||
entries[e].buffer[entries[e].cursor] = ev.data.key.ucs4; | |||||
entries[e].buffer[entries[e].cursor] = ev.data.key.utf32; | |||||
entries[e].size++; | entries[e].size++; | ||||
entries[e].cursor++; | entries[e].cursor++; | ||||
} | } | ||||