MCPcopy Create free account
hub / github.com/LadybugDB/ladybug / colAndRowToPosition

Function colAndRowToPosition

tools/shell/linenoise.cpp:2169–2195  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2167}
2168
2169size_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
2197std::string linenoiseAddContinuationMarkers(const char* buf, size_t len, size_t plen,
2198 int cursor_row, struct linenoiseState* l, std::vector<highlightToken>& tokens) {

Callers 3

refreshMultiLineFunction · 0.85
linenoiseEditMoveRowUpFunction · 0.85
linenoiseEditMoveRowDownFunction · 0.85

Calls 2

nextPositionFunction · 0.85

Tested by

no test coverage detected