MCPcopy Create free account
hub / github.com/RenderKit/embree / stb_textedit_replace

Function stb_textedit_replace

tutorials/common/imgui/imgui_widgets.cpp:3717–3731  ·  view source on GitHub ↗

stb_textedit internally allows for a single undo record to do addition and deletion, but somehow, calling the stb_textedit_paste() function creates two separate records, so we perform it manually. (FIXME: Report to nothings/stb?)

Source from the content-addressed store, hash-verified

3715// stb_textedit internally allows for a single undo record to do addition and deletion, but somehow, calling
3716// the stb_textedit_paste() function creates two separate records, so we perform it manually. (FIXME: Report to nothings/stb?)
3717static void stb_textedit_replace(ImGuiInputTextState* str, STB_TexteditState* state, const STB_TEXTEDIT_CHARTYPE* text, int text_len)
3718{
3719 stb_text_makeundo_replace(str, state, 0, str->CurLenW, text_len);
3720 ImStb::STB_TEXTEDIT_DELETECHARS(str, 0, str->CurLenW);
3721 state->cursor = state->select_start = state->select_end = 0;
3722 if (text_len <= 0)
3723 return;
3724 if (ImStb::STB_TEXTEDIT_INSERTCHARS(str, 0, text, text_len))
3725 {
3726 state->cursor = state->select_start = state->select_end = text_len;
3727 state->has_preferred_x = 0;
3728 return;
3729 }
3730 IM_ASSERT(0); // Failed to insert character, normally shouldn't happen because of how we currently use stb_textedit_replace()
3731}
3732
3733} // namespace ImStb
3734

Callers 1

InputTextExMethod · 0.85

Calls 3

STB_TEXTEDIT_DELETECHARSFunction · 0.85
STB_TEXTEDIT_INSERTCHARSFunction · 0.85

Tested by

no test coverage detected