raysan5 / raygui

A simple and easy-to-use immediate-mode gui library
zlib License
3.26k stars 280 forks source link

Issue with Unicode input on `GuiTextBox()` #399

Open electrolys opened 3 months ago

electrolys commented 3 months ago

gui textbox doesn't handle adding and removing characters properly and causes an underflow (at adding) and overflow (at removal)

at lines https://github.com/raysan5/raygui/blob/6f532337ff2d6dc14ba3a5f5b7ee63f9d90ff13b/src/raygui.h#L2582 https://github.com/raysan5/raygui/blob/6f532337ff2d6dc14ba3a5f5b7ee63f9d90ff13b/src/raygui.h#L2562C21-L2562C113

you are just comparing the variable i with the text length or cursor when you really need to >= cursor+codepointsize and <= length-codepointsize

raysan5 commented 2 months ago

@electrolys Good catch! Please, could you send a PR with the fix! Thanks!