[LyX/master] Better identification of the focused IM segment
Koji Yokota
yokota at lyx.org
Wed Jun 10 11:43:58 UTC 2026
commit a2921b65c74caa5929f6169ba0369bec00281ba7
Author: Koji Yokota <yokota at lyx.org>
Date: Wed Jun 10 15:22:06 2026 +0900
Better identification of the focused IM segment
---
src/frontends/qt/GuiInputMethod.cpp | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/frontends/qt/GuiInputMethod.cpp b/src/frontends/qt/GuiInputMethod.cpp
index 9b7e24f556..43059024ac 100644
--- a/src/frontends/qt/GuiInputMethod.cpp
+++ b/src/frontends/qt/GuiInputMethod.cpp
@@ -81,8 +81,10 @@ struct GuiInputMethod::Private
pos_type cur_row_idx_;
/// the row index of the end of preedit
pos_type preedit_end_row_idx_;
- /// position of the caret
+ /// position of the caret within the paragraph
pos_type caret_pos_;
+ /// position of the caret within the preedit string
+ pos_type caret_rel_pos_;
/// the row index and pos of the caret
PreeditElement caret_row_;
/// caret index and pos in preedit elements
@@ -412,6 +414,7 @@ void GuiInputMethod::setPreeditStyle(
break;
case QInputMethodEvent::Cursor:
+ d->caret_rel_pos_ = it.start;
d->caret_pos_ = getCaretPos(it.start);
d->style_.caret_visible_ = it.length != 0;
@@ -543,7 +546,7 @@ pos_type GuiInputMethod::setTextFormat(const QInputMethodEvent::Attribute & it,
// NOTE: brush size is assumed to be four
// if it is to be changed, change the declaration of array in
// setPreeditStyle()
- if (char_format.background().color() != QColorConstants::Black) {
+ if (it.start == d->caret_rel_pos_) {
char_format.setForeground(brush[0]);
char_format.setBackground(brush[1]);
} else {
More information about the lyx-cvs
mailing list