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

Method UpdateSize

src/textbuf.cpp:445–457  ·  view source on GitHub ↗

* Update Textbuf type with its actual physical character and screenlength * Get the count of characters in the string as well as the width in pixels. * Useful when copying in a larger amount of text at once */

Source from the content-addressed store, hash-verified

443 * Useful when copying in a larger amount of text at once
444 */
445void Textbuf::UpdateSize()
446{
447 this->chars = static_cast<uint16_t>(Utf8StringLength(this->buf) + 1); // terminating zero
448 assert(this->buf.size() < this->max_bytes);
449 assert(this->chars <= this->max_chars);
450
451 this->caretpos = static_cast<uint16_t>(this->buf.size());
452 this->UpdateStringIter();
453 this->UpdateWidth();
454 this->UpdateMarkedText();
455
456 this->UpdateCaretPosition();
457}
458
459/**
460 * Handle the flashing of the caret.

Callers 1

AssignMethod · 0.95

Calls 6

UpdateStringIterMethod · 0.95
UpdateWidthMethod · 0.95
UpdateMarkedTextMethod · 0.95
UpdateCaretPositionMethod · 0.95
Utf8StringLengthFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected