MCPcopy Create free account
hub / github.com/BlitterStudio/amiberry / InputTextLineIndexGetPosOffset

Function InputTextLineIndexGetPosOffset

external/imgui/imgui_widgets.cpp:4677–4693  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4675}
4676
4677static ImVec2 InputTextLineIndexGetPosOffset(ImGuiContext& g, ImGuiInputTextState* state, ImGuiTextIndex* line_index, const char* buf, const char* buf_end, int cursor_n)
4678{
4679 const char* cursor_ptr = buf + cursor_n;
4680 int* it_begin = line_index->Offsets.begin();
4681 int* it_end = line_index->Offsets.end();
4682 const int* it = ImLowerBound(it_begin, it_end, cursor_n);
4683 if (it > it_begin)
4684 if (it == it_end || *it != cursor_n || (state != NULL && state->WrapWidth > 0.0f && state->LastMoveDirectionLR == ImGuiDir_Right && cursor_ptr[-1] != '\n' && cursor_ptr[-1] != 0))
4685 it--;
4686
4687 const int line_no = (it == it_begin) ? 0 : line_index->Offsets.index_from_ptr(it);
4688 const char* line_start = line_index->get_line_begin(buf, line_no);
4689 ImVec2 offset;
4690 offset.x = InputTextCalcTextSize(&g, line_start, cursor_ptr, buf_end, NULL, NULL, ImDrawTextFlags_WrapKeepBlanks).x;
4691 offset.y = (line_no + 1) * g.FontSize;
4692 return offset;
4693}
4694
4695// Edit a string of text
4696// - buf_size account for the zero-terminator, so a buf_size of 6 can hold "Hello" but not "Hello!".

Callers 1

InputTextExMethod · 0.85

Calls 5

InputTextCalcTextSizeFunction · 0.85
get_line_beginMethod · 0.80
ImLowerBoundFunction · 0.70
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected