mirror of
https://github.com/ocornut/imgui.git
synced 2026-01-09 23:54:20 +00:00
stb_textedit: fixed misleading cursor-1 in STB_TEXTEDIT_K_LINESTART handlers. (#7925)
`state->cursor - 1` in STB_TEXTEDIT_K_LINESTART handlers was technically misleadingly not UTF-8 compliant but things would naturally work anyhow.
This commit is contained in:
parent
aa2f40c3bb
commit
9f969944d5
1 changed files with 12 additions and 4 deletions
|
|
@ -1100,8 +1100,12 @@ retry:
|
||||||
stb_textedit_move_to_first(state);
|
stb_textedit_move_to_first(state);
|
||||||
if (state->single_line)
|
if (state->single_line)
|
||||||
state->cursor = 0;
|
state->cursor = 0;
|
||||||
else while (state->cursor > 0 && STB_TEXTEDIT_GETCHAR(str, state->cursor-1) != STB_TEXTEDIT_NEWLINE)
|
else while (state->cursor > 0) {
|
||||||
state->cursor = IMSTB_TEXTEDIT_GETPREVCHARINDEX(str, state->cursor);
|
int prev = IMSTB_TEXTEDIT_GETPREVCHARINDEX(str, state->cursor);
|
||||||
|
if (STB_TEXTEDIT_GETCHAR(str, prev) == STB_TEXTEDIT_NEWLINE)
|
||||||
|
break;
|
||||||
|
state->cursor = prev;
|
||||||
|
}
|
||||||
state->has_preferred_x = 0;
|
state->has_preferred_x = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -1128,8 +1132,12 @@ retry:
|
||||||
stb_textedit_prep_selection_at_cursor(state);
|
stb_textedit_prep_selection_at_cursor(state);
|
||||||
if (state->single_line)
|
if (state->single_line)
|
||||||
state->cursor = 0;
|
state->cursor = 0;
|
||||||
else while (state->cursor > 0 && STB_TEXTEDIT_GETCHAR(str, state->cursor-1) != STB_TEXTEDIT_NEWLINE)
|
else while (state->cursor > 0) {
|
||||||
state->cursor = IMSTB_TEXTEDIT_GETPREVCHARINDEX(str, state->cursor);
|
int prev = IMSTB_TEXTEDIT_GETPREVCHARINDEX(str, state->cursor);
|
||||||
|
if (STB_TEXTEDIT_GETCHAR(str, prev) == STB_TEXTEDIT_NEWLINE)
|
||||||
|
break;
|
||||||
|
state->cursor = prev;
|
||||||
|
}
|
||||||
state->select_end = state->cursor;
|
state->select_end = state->cursor;
|
||||||
state->has_preferred_x = 0;
|
state->has_preferred_x = 0;
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue