InputText: stb_textedit.h tentative fix for End key on multi-line fields (#275)
diff --git a/stb_textedit.h b/stb_textedit.h
index 5aa79f0..3972c0f 100644
--- a/stb_textedit.h
+++ b/stb_textedit.h
@@ -1,3 +1,6 @@
+// [ImGui] this is a slightly modified version of stb_truetype.h 1.4
+// [ImGui] we made a fix for using the END key on multi-line text edit, see https://github.com/ocornut/imgui/issues/275
+
// stb_textedit.h - v1.4 - public domain - Sean Barrett
// Development of this library was sponsored by RAD Game Tools
//
@@ -957,6 +960,8 @@
stb_textedit_move_to_first(state);
stb_textedit_find_charpos(&find, str, state->cursor, state->single_line);
state->cursor = find.first_char + find.length;
+ if (find.length > 0 && STB_TEXTEDIT_GETCHAR(str, state->cursor-1) == STB_TEXTEDIT_NEWLINE)
+ state->cursor--;
state->has_preferred_x = 0;
break;
}
@@ -977,6 +982,8 @@
stb_textedit_prep_selection_at_cursor(state);
stb_textedit_find_charpos(&find, str, state->cursor, state->single_line);
state->cursor = state->select_end = find.first_char + find.length;
+ if (find.length > 0 && STB_TEXTEDIT_GETCHAR(str, state->cursor-1) == STB_TEXTEDIT_NEWLINE)
+ state->cursor = state->select_end = state->cursor - 1;
state->has_preferred_x = 0;
break;
}