| 4588 | } |
| 4589 | |
| 4590 | static ImVec2 InputTextLineIndexGetPosOffset(ImGuiContext& g, ImGuiInputTextState* state, ImGuiTextIndex* line_index, const char* buf, const char* buf_end, int cursor_n) |
| 4591 | { |
| 4592 | const char* cursor_ptr = buf + cursor_n; |
| 4593 | int* it_begin = line_index->Offsets.begin(); |
| 4594 | int* it_end = line_index->Offsets.end(); |
| 4595 | const int* it = ImLowerBound(it_begin, it_end, cursor_n); |
| 4596 | if (it > it_begin) |
| 4597 | 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)) |
| 4598 | it--; |
| 4599 | |
| 4600 | const int line_no = (it == it_begin) ? 0 : line_index->Offsets.index_from_ptr(it); |
| 4601 | const char* line_start = line_index->get_line_begin(buf, line_no); |
| 4602 | ImVec2 offset; |
| 4603 | offset.x = InputTextCalcTextSize(&g, line_start, cursor_ptr, buf_end, NULL, NULL, ImDrawTextFlags_WrapKeepBlanks).x; |
| 4604 | offset.y = (line_no + 1) * g.FontSize; |
| 4605 | return offset; |
| 4606 | } |
| 4607 | |
| 4608 | // Edit a string of text |
| 4609 | // - buf_size account for the zero-terminator, so a buf_size of 6 can hold "Hello" but not "Hello!". |
no test coverage detected