added zr_input_unicode as another text input method

This commit is contained in:
vurtun 2015-10-14 09:28:15 +02:00
parent bd9eb035fd
commit b0af454098
3 changed files with 18 additions and 2 deletions

View File

@ -348,7 +348,7 @@ draw(XSurface *surf, struct zr_command_queue *queue)
case ZR_COMMAND_TEXT: {
const struct zr_command_text *t = zr_command(text, cmd);
surface_draw_text(surf, t->x, t->y, t->w, t->h, (const char*)t->string,
t->length, (XFont*)t->font->userdata.ptr, t->background, t->foreground);
t->length, (XFont*)t->font->userdata.ptr, t->background, t->foreground);
} break;
case ZR_COMMAND_CURVE:
case ZR_COMMAND_IMAGE:
@ -385,7 +385,8 @@ input_key(struct XWindow *xw, struct zr_input *in, XEvent *evt, zr_bool down)
zr_input_key(in, ZR_KEY_PASTE, down && (evt->xkey.state & ControlMask));
else if (*code == 'x')
zr_input_key(in, ZR_KEY_CUT, down && (evt->xkey.state & ControlMask));
if (!down) zr_input_char(in, (char)*code);
if (!down)
zr_input_unicode(in, (zr_uint)*code);
}
XFree(code);
}

View File

@ -728,6 +728,16 @@ zr_input_char(struct zr_input *in, char c)
zr_input_glyph(in, glyph);
}
void
zr_input_unicode(struct zr_input *in, zr_uint unicode)
{
zr_size len;
zr_glyph rune;
ZR_ASSERT(in);
zr_utf_encode(unicode, rune, ZR_UTF_SIZE);
zr_input_glyph(in, rune);
}
void
zr_input_end(struct zr_input *in)
{

View File

@ -336,6 +336,11 @@ void zr_input_char(struct zr_input*, char);
Input:
- character to add to the text buffer
*/
void zr_input_unicode(struct zr_input *in, zr_uint unicode);
/* this function adds a unicode character into the internal text frame buffer
Input:
- unicode character to add to the text buffer
*/
void zr_input_end(struct zr_input*);
/* this function sets the input state to readable */
zr_bool zr_input_has_mouse_click_in_rect(const struct zr_input*,enum zr_buttons,