MCPcopy Create free account
hub / github.com/VCVRack/Rack / locationToPosition

Function locationToPosition

src/string.cpp:183–201  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

181
182
183size_t locationToPosition(const std::string& s, Location location) {
184 size_t pos = 0;
185
186 // Advance `location.line` newlines
187 for (size_t lines = 0; lines < location.line && pos < s.size(); pos++) {
188 if (s[pos] == '\n')
189 lines++;
190 }
191
192 // Advance `location.column` codepoints
193 for (size_t columns = 0; columns < location.column && pos < s.size(); columns++) {
194 // Stop if column is beyond newline
195 if (s[pos] == '\n')
196 break;
197 pos = UTF8NextCodepoint(s, pos);
198 }
199
200 return pos;
201}
202
203
204std::string toBase64(const uint8_t* data, size_t dataLen) {

Callers 1

onSelectKeyMethod · 0.85

Calls 2

UTF8NextCodepointFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected