MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / SetCurPosition

Method SetCurPosition

src/os/macosx/string_osx.cpp:430–446  ·  view source on GitHub ↗

virtual */

Source from the content-addressed store, hash-verified

428}
429
430/* virtual */ size_t OSXStringIterator::SetCurPosition(size_t pos)
431{
432 /* Convert incoming position to an UTF-16 string index. */
433 size_t utf16_pos = 0;
434 for (size_t i = 0; i < this->utf16_to_utf8.size(); i++) {
435 if (this->utf16_to_utf8[i] == pos) {
436 utf16_pos = i;
437 break;
438 }
439 }
440
441 /* Sanitize in case we get a position inside a grapheme cluster. */
442 while (utf16_pos > 0 && !this->str_info[utf16_pos].char_stop) utf16_pos--;
443 this->cur_pos = utf16_pos;
444
445 return this->utf16_to_utf8[this->cur_pos];
446}
447
448/* virtual */ size_t OSXStringIterator::Next(IterType what)
449{

Callers 2

UpdateStringIterMethod · 0.45
MovePosMethod · 0.45

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected