Fix unicode pasting in DoEditBox

This commit is contained in:
TsFreddie 2020-09-04 18:03:08 +01:00
parent a3a363f665
commit 44c699b812

View file

@ -249,12 +249,16 @@ int CMenus::DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrS
{ {
int Offset = str_length(pStr); int Offset = str_length(pStr);
int CharsLeft = StrSize - Offset - 1; int CharsLeft = StrSize - Offset - 1;
for(int i = 0; i < str_length(Text) && i < CharsLeft; i++) char *pCur = pStr + Offset;
str_utf8_copy(pCur, Text, CharsLeft);
for(int i = 0; i < CharsLeft; i++)
{ {
if(Text[i] == '\n') if(pCur[i] == 0)
pStr[i + Offset] = ' '; break;
else else if(pCur[i] == '\r')
pStr[i + Offset] = Text[i]; pCur[i] = ' ';
else if(pCur[i] == '\n')
pCur[i] = ' ';
} }
s_AtIndex = str_length(pStr); s_AtIndex = str_length(pStr);
ReturnValue = true; ReturnValue = true;