mirror of https://github.com/OpenTTD/OpenTTD
Change: Position caret on left or right of glyph depending on language direction.
parent
5cd81a980e
commit
fce9361bf2
|
@ -309,15 +309,18 @@ void Textbuf::UpdateWidth()
|
||||||
/** Update pixel position of the caret. */
|
/** Update pixel position of the caret. */
|
||||||
void Textbuf::UpdateCaretPosition()
|
void Textbuf::UpdateCaretPosition()
|
||||||
{
|
{
|
||||||
this->caretxoffs = this->chars > 1 ? GetCharPosInString(this->buf, this->buf + this->caretpos, FS_NORMAL).left : 0;
|
const auto pos = GetCharPosInString(this->buf, this->buf + this->caretpos, FS_NORMAL);
|
||||||
|
this->caretxoffs = _current_text_dir == TD_LTR ? pos.left : pos.right;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Update pixel positions of the marked text area. */
|
/** Update pixel positions of the marked text area. */
|
||||||
void Textbuf::UpdateMarkedText()
|
void Textbuf::UpdateMarkedText()
|
||||||
{
|
{
|
||||||
if (this->markend != 0) {
|
if (this->markend != 0) {
|
||||||
this->markxoffs = GetCharPosInString(this->buf, this->buf + this->markpos, FS_NORMAL).left;
|
const auto pos = GetCharPosInString(this->buf, this->buf + this->markpos, FS_NORMAL);
|
||||||
this->marklength = GetCharPosInString(this->buf, this->buf + this->markend, FS_NORMAL).left - this->markxoffs;
|
const auto end = GetCharPosInString(this->buf, this->buf + this->markend, FS_NORMAL);
|
||||||
|
this->markxoffs = std::min(pos.left, end.left);
|
||||||
|
this->marklength = std::max(pos.right, end.right) - this->markxoffs;
|
||||||
} else {
|
} else {
|
||||||
this->markxoffs = this->marklength = 0;
|
this->markxoffs = this->marklength = 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue