MCPcopy Create free account
hub / github.com/KebsCS/KBotExt / stb_textedit_paste_internal

Function stb_textedit_paste_internal

KBotExt/imgui/imstb_textedit.h:695–709  ·  view source on GitHub ↗

API paste: replace existing selection with passed-in text

Source from the content-addressed store, hash-verified

693
694// API paste: replace existing selection with passed-in text
695static int stb_textedit_paste_internal(STB_TEXTEDIT_STRING* str, STB_TexteditState* state, STB_TEXTEDIT_CHARTYPE* text, int len)
696{
697 // if there's a selection, the paste should delete it
698 stb_textedit_clamp(str, state);
699 stb_textedit_delete_selection(str, state);
700 // try to insert the characters
701 if (STB_TEXTEDIT_INSERTCHARS(str, state->cursor, text, len)) {
702 stb_text_makeundo_insert(state, state->cursor, len);
703 state->cursor += len;
704 state->has_preferred_x = 0;
705 return 1;
706 }
707 // note: paste failure will leave deleted selection, may be restored with an undo (see https://github.com/nothings/stb/issues/734 for details)
708 return 0;
709}
710
711#ifndef STB_TEXTEDIT_KEYTYPE
712#define STB_TEXTEDIT_KEYTYPE int

Callers 1

stb_textedit_pasteFunction · 0.85

Calls 4

stb_textedit_clampFunction · 0.85
STB_TEXTEDIT_INSERTCHARSFunction · 0.85
stb_text_makeundo_insertFunction · 0.85

Tested by

no test coverage detected