mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-11 13:10:45 +00:00
Change: Position caret on left or right of glyph depending on language direction.
This commit is contained in:
parent
5cd81a980e
commit
fce9361bf2
@ -309,15 +309,18 @@ void Textbuf::UpdateWidth()
|
||||
/** Update pixel position of the caret. */
|
||||
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. */
|
||||
void Textbuf::UpdateMarkedText()
|
||||
{
|
||||
if (this->markend != 0) {
|
||||
this->markxoffs = GetCharPosInString(this->buf, this->buf + this->markpos, FS_NORMAL).left;
|
||||
this->marklength = GetCharPosInString(this->buf, this->buf + this->markend, FS_NORMAL).left - this->markxoffs;
|
||||
const auto pos = GetCharPosInString(this->buf, this->buf + this->markpos, FS_NORMAL);
|
||||
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 {
|
||||
this->markxoffs = this->marklength = 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user