fix delete key for text editing

This commit is contained in:
hippoz 2023-05-21 20:10:47 +03:00
parent 1d7c2c6f92
commit 2a07dc1061
Signed by: hippoz
GPG key ID: 56C4E02A85F2FBED

View file

@ -43,10 +43,10 @@ int text_input_handle(UINode *node, enum UIEvent ev, size_t d, void *p)
break;
}
case XKB_KEY_Delete: {
if (n->text_cursor_index > 0 && n->text_cursor_index + 1 <= n->text.size) {
ui_string_delete(&n->text, n->text_cursor_index + 1, 1);
if (n->text.size > 0 && n->text_cursor_index < n->text.size) {
ui_string_delete(&n->text, n->text_cursor_index, 1);
}
if (n->text_cursor_index > n->text.size) {
if (n->text_cursor_index > 0 && n->text_cursor_index > n->text.size) {
n->text_cursor_index = n->text.size - 1;
}
break;