MCPcopy Create free account
hub / github.com/SunOner/sunone_aimbot_2 / InputTextLineIndexBuild

Function InputTextLineIndexBuild

sunone_aimbot_2/imgui/imgui_widgets.cpp:4797–4846  ·  view source on GitHub ↗

FIXME-WORDWRAP: Bundle some of this into ImGuiTextIndex and/or extract as a different tool? 'max_output_buffer_size' happens to be a meaningful optimization to avoid writing the full line_index when not necessarily needed (e.g. very large buffer, scrolled up, inactive)

Source from the content-addressed store, hash-verified

4795// FIXME-WORDWRAP: Bundle some of this into ImGuiTextIndex and/or extract as a different tool?
4796// 'max_output_buffer_size' happens to be a meaningful optimization to avoid writing the full line_index when not necessarily needed (e.g. very large buffer, scrolled up, inactive)
4797static int InputTextLineIndexBuild(ImGuiInputTextFlags flags, ImGuiTextIndex* line_index, const char* buf, const char* buf_end, float wrap_width, int max_output_buffer_size, const char** out_buf_end)
4798{
4799 ImGuiContext& g = *GImGui;
4800 int size = 0;
4801 const char* s;
4802 bool trailing_line_already_counted = false;
4803 if (flags & ImGuiInputTextFlags_WordWrap)
4804 {
4805 for (s = buf; s < buf_end; s = (*s == '\n') ? s + 1 : s)
4806 {
4807 if (size++ <= max_output_buffer_size)
4808 line_index->Offsets.push_back((int)(s - buf));
4809 s = ImFontCalcWordWrapPositionEx(g.Font, g.FontSize, s, buf_end, wrap_width, ImDrawTextFlags_WrapKeepBlanks);
4810 }
4811 }
4812 else if (buf_end != NULL)
4813 {
4814 for (s = buf; s < buf_end; s = s ? s + 1 : buf_end)
4815 {
4816 if (size++ <= max_output_buffer_size)
4817 line_index->Offsets.push_back((int)(s - buf));
4818 s = (const char*)ImMemchr(s, '\n', buf_end - s);
4819 }
4820 }
4821 else
4822 {
4823 // Inactive path: we don't know buf_end ahead of time.
4824 const char* s_eol;
4825 for (s = buf; ; s = s_eol + 1)
4826 {
4827 if (size++ <= max_output_buffer_size)
4828 line_index->Offsets.push_back((int)(s - buf));
4829 if ((s_eol = strchr(s, '\n')) != NULL)
4830 continue;
4831 s += strlen(s);
4832 trailing_line_already_counted = true;
4833 break;
4834 }
4835 }
4836 if (out_buf_end != NULL)
4837 *out_buf_end = buf_end = s;
4838 if (size == 0)
4839 {
4840 line_index->Offsets.push_back(0);
4841 size++;
4842 }
4843 if (buf_end > buf && buf_end[-1] == '\n' && !trailing_line_already_counted && size++ <= max_output_buffer_size)
4844 line_index->Offsets.push_back((int)(buf_end - buf));
4845 return size;
4846}
4847
4848static ImVec2 InputTextLineIndexGetPosOffset(ImGuiContext& g, ImGuiInputTextState* state, ImGuiTextIndex* line_index, const char* buf, const char* buf_end, int cursor_n)
4849{

Callers 1

InputTextExMethod · 0.70

Calls 2

push_backMethod · 0.45

Tested by

no test coverage detected