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