fix textedit_sample a bit
This commit is contained in:
parent
3557e66362
commit
885b1b7ded
@ -32,16 +32,17 @@ void layout_func(StbTexteditRow *row, STB_TEXTEDIT_STRING *str, int start_i)
|
|||||||
|
|
||||||
int delete_chars(STB_TEXTEDIT_STRING *str, int pos, int num)
|
int delete_chars(STB_TEXTEDIT_STRING *str, int pos, int num)
|
||||||
{
|
{
|
||||||
memmove(&str->string[pos], &str->string[pos+num], str->stringlen - (pos-num));
|
memmove(&str->string[pos], &str->string[pos+num], str->stringlen - pos - num);
|
||||||
str->stringlen -= num;
|
str->stringlen -= num;
|
||||||
return 1; // always succeeds
|
return 1; // always succeeds
|
||||||
}
|
}
|
||||||
|
|
||||||
int insert_chars(STB_TEXTEDIT_STRING *str, int pos, STB_TEXTEDIT_CHARTYPE *newtext, int num)
|
int insert_chars(STB_TEXTEDIT_STRING *str, int pos, STB_TEXTEDIT_CHARTYPE *newtext, int num)
|
||||||
{
|
{
|
||||||
str->string = realloc(str, str->stringlen + num);
|
str->string = realloc(str->string, str->stringlen + num);
|
||||||
memmove(&str->string[pos+num], &str->string[pos], str->stringlen - pos);
|
memmove(&str->string[pos+num], &str->string[pos], str->stringlen - pos);
|
||||||
memcpy(&str->string[pos], newtext, num);
|
memcpy(&str->string[pos], newtext, num);
|
||||||
|
str->stringlen += num;
|
||||||
return 1; // always succeeds
|
return 1; // always succeeds
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user