mirror of
https://github.com/raysan5/raygui.git
synced 2026-01-29 02:09:17 -05:00
GuiTextBox(): Do not get previous code point when at start of string (#420)
Co-authored-by: segcore <segcore@github.com>
This commit is contained in:
15
src/raygui.h
15
src/raygui.h
@ -2611,16 +2611,17 @@ int GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
|
|||||||
if (IsKeyPressed(KEY_BACKSPACE) || (autoCursorDelayCounter%RAYGUI_TEXTBOX_AUTO_CURSOR_DELAY) == 0) // Delay every movement some frames
|
if (IsKeyPressed(KEY_BACKSPACE) || (autoCursorDelayCounter%RAYGUI_TEXTBOX_AUTO_CURSOR_DELAY) == 0) // Delay every movement some frames
|
||||||
{
|
{
|
||||||
int prevCodepointSize = 0;
|
int prevCodepointSize = 0;
|
||||||
GetCodepointPrevious(text + textBoxCursorIndex, &prevCodepointSize);
|
|
||||||
|
|
||||||
// Move backward text from cursor position
|
|
||||||
for (int i = (textBoxCursorIndex - prevCodepointSize); i < textLength; i++) text[i] = text[i + prevCodepointSize];
|
|
||||||
|
|
||||||
// TODO Check: >= cursor+codepointsize and <= length-codepointsize
|
|
||||||
|
|
||||||
// Prevent cursor index from decrementing past 0
|
// Prevent cursor index from decrementing past 0
|
||||||
if (textBoxCursorIndex > 0)
|
if (textBoxCursorIndex > 0)
|
||||||
{
|
{
|
||||||
|
GetCodepointPrevious(text + textBoxCursorIndex, &prevCodepointSize);
|
||||||
|
|
||||||
|
// Move backward text from cursor position
|
||||||
|
for (int i = (textBoxCursorIndex - prevCodepointSize); i < textLength; i++) text[i] = text[i + prevCodepointSize];
|
||||||
|
|
||||||
|
// TODO Check: >= cursor+codepointsize and <= length-codepointsize
|
||||||
|
|
||||||
textBoxCursorIndex -= codepointSize;
|
textBoxCursorIndex -= codepointSize;
|
||||||
textLength -= codepointSize;
|
textLength -= codepointSize;
|
||||||
}
|
}
|
||||||
@ -2638,7 +2639,7 @@ int GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
|
|||||||
if (IsKeyPressed(KEY_LEFT) || (autoCursorDelayCounter%RAYGUI_TEXTBOX_AUTO_CURSOR_DELAY) == 0) // Delay every movement some frames
|
if (IsKeyPressed(KEY_LEFT) || (autoCursorDelayCounter%RAYGUI_TEXTBOX_AUTO_CURSOR_DELAY) == 0) // Delay every movement some frames
|
||||||
{
|
{
|
||||||
int prevCodepointSize = 0;
|
int prevCodepointSize = 0;
|
||||||
GetCodepointPrevious(text + textBoxCursorIndex, &prevCodepointSize);
|
if (textBoxCursorIndex > 0) GetCodepointPrevious(text + textBoxCursorIndex, &prevCodepointSize);
|
||||||
|
|
||||||
if (textBoxCursorIndex >= prevCodepointSize) textBoxCursorIndex -= prevCodepointSize;
|
if (textBoxCursorIndex >= prevCodepointSize) textBoxCursorIndex -= prevCodepointSize;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user