fixed editbox glyph removing

This commit is contained in:
vurtun 2015-07-09 13:50:10 +02:00
parent 50e3f4deec
commit ca212ed1ab
2 changed files with 15 additions and 2 deletions

15
gui.c
View File

@ -896,8 +896,21 @@ gui_edit_box_buffer_input(struct gui_edit_box *box, const struct gui_input *i)
void
gui_edit_box_remove(struct gui_edit_box *eb)
{
gui_long unicode;
gui_size src_len = 0;
gui_size last_glyph = 0;
gui_size glyph_len = 0;
gui_char *text = gui_edit_box_get(eb);
gui_size text_len = gui_edit_box_len(eb);
GUI_ASSERT(eb);
gui_edit_buffer_remove(&eb->buffer, 1);
glyph_len = gui_utf_decode(text, &unicode, text_len);
while (glyph_len) {
src_len = src_len + glyph_len;
last_glyph = glyph_len;
glyph_len = gui_utf_decode(text + src_len, &unicode, text_len - src_len);
}
gui_edit_buffer_remove(&eb->buffer, last_glyph);
}
gui_char*

2
gui.h
View File

@ -741,7 +741,7 @@ char *gui_edit_buffer_at(gui_edit_buffer*, gui_size pos);
The Editbox first needs to be initialized either with a fixed size
memory block or a allocator. After that it can be used by either the
`gui_editobx` or `gui_panel_editbox` function. In addition symbols can be
added and removed with either `gui_edit_box_add` and `gui_edit_box_remove`.
added and removed with `gui_edit_box_add` and `gui_edit_box_remove`.
Widget function API
gui_edit_box_init() -- initialize a dynamically growing edit box