| 2167 | } |
| 2168 | |
| 2169 | size_t colAndRowToPosition(size_t target_row, size_t target_col, struct linenoiseState* l) { |
| 2170 | int plen = linenoiseComputeRenderWidth(l->prompt, strlen(l->prompt)); |
| 2171 | size_t rows = 1; |
| 2172 | size_t cols = plen; |
| 2173 | size_t last_cpos = 0; |
| 2174 | size_t cpos = 0; |
| 2175 | while (cpos < l->len) { |
| 2176 | if (cols >= l->cols) { |
| 2177 | // exceeded width - move to next line |
| 2178 | rows++; |
| 2179 | cols = 0; |
| 2180 | } |
| 2181 | if (rows > target_row) { |
| 2182 | // we have skipped our target row - that means "target_col" was out of range for this |
| 2183 | // row return the last position within the target row |
| 2184 | return last_cpos; |
| 2185 | } |
| 2186 | if (rows == target_row) { |
| 2187 | last_cpos = cpos; |
| 2188 | } |
| 2189 | if (rows == target_row && cols == target_col) { |
| 2190 | return cpos; |
| 2191 | } |
| 2192 | nextPosition(l->buf, l->len, cpos, rows, cols, plen, l->cols); |
| 2193 | } |
| 2194 | return cpos; |
| 2195 | } |
| 2196 | |
| 2197 | std::string linenoiseAddContinuationMarkers(const char* buf, size_t len, size_t plen, |
| 2198 | int cursor_row, struct linenoiseState* l, std::vector<highlightToken>& tokens) { |
no test coverage detected