aboutsummaryrefslogtreecommitdiffhomepage
path: root/qt/ScintillaEditBase/ScintillaEditBase.cpp
diff options
context:
space:
mode:
authorjohnsonj <devnull@localhost>2016-01-25 13:18:26 +1100
committerjohnsonj <devnull@localhost>2016-01-25 13:18:26 +1100
commit71c673f7511f4f7f890ffe7ded65a0cf0cec3836 (patch)
tree4a0d2e117677f567dae844c557183d738fc4f496 /qt/ScintillaEditBase/ScintillaEditBase.cpp
parent89c4aeb98383ac8aa6e3c8d9983ef53307cba090 (diff)
downloadscintilla-mirror-71c673f7511f4f7f890ffe7ded65a0cf0cec3836.tar.gz
Make IME indicators work similarly on all 3 platforms.
Diffstat (limited to 'qt/ScintillaEditBase/ScintillaEditBase.cpp')
-rw-r--r--qt/ScintillaEditBase/ScintillaEditBase.cpp42
1 files changed, 17 insertions, 25 deletions
diff --git a/qt/ScintillaEditBase/ScintillaEditBase.cpp b/qt/ScintillaEditBase/ScintillaEditBase.cpp
index fd91e395d..ca4819726 100644
--- a/qt/ScintillaEditBase/ScintillaEditBase.cpp
+++ b/qt/ScintillaEditBase/ScintillaEditBase.cpp
@@ -447,17 +447,9 @@ static int GetImeCaretPos(QInputMethodEvent *event)
return 0;
}
-static std::vector<int> MapImeIndicators(QInputMethodEvent *event, bool preeditNotChanged)
+static std::vector<int> MapImeIndicators(QInputMethodEvent *event)
{
-#ifndef Q_OS_LINUX
- Q_UNUSED(preeditNotChanged)
-#endif
- const QString preeditStr = event->preeditString();
- std::vector<int> imeIndicator(preeditStr.length(), SC_INDICATOR_UNKNOWN);
-#ifdef Q_OS_LINUX
- const int imeCaretPos = GetImeCaretPos(event);
-#endif
-
+ std::vector<int> imeIndicator(event->preeditString().size(), SC_INDICATOR_UNKNOWN);
foreach (QInputMethodEvent::Attribute attr, event->attributes()) {
if (attr.type == QInputMethodEvent::TextFormat) {
QTextFormat format = attr.value.value<QTextFormat>();
@@ -465,12 +457,12 @@ static std::vector<int> MapImeIndicators(QInputMethodEvent *event, bool preeditN
int indicator = SC_INDICATOR_UNKNOWN;
switch (charFormat.underlineStyle()) {
- case QTextCharFormat::NoUnderline:
- indicator = SC_INDICATOR_TARGET; //target input
+ case QTextCharFormat::NoUnderline: // win32, linux
+ indicator = SC_INDICATOR_TARGET;
break;
- case QTextCharFormat::SingleUnderline:
- case QTextCharFormat::DashUnderline:
- indicator = SC_INDICATOR_INPUT; //normal input
+ case QTextCharFormat::SingleUnderline: // osx
+ case QTextCharFormat::DashUnderline: // win32, linux
+ indicator = SC_INDICATOR_INPUT;
break;
case QTextCharFormat::DotLine:
case QTextCharFormat::DashDotLine:
@@ -482,16 +474,19 @@ static std::vector<int> MapImeIndicators(QInputMethodEvent *event, bool preeditN
default:
indicator = SC_INDICATOR_UNKNOWN;
}
-#ifdef Q_OS_LINUX
- // ibus-qt has a bug to return only one underline style.
- // Q_OS_LINUX blocks are temporary work around to cope with it.
- if ((attr.length > 0) && (attr.start == imeCaretPos)) {
+
+ if (format.hasProperty(QTextFormat::BackgroundBrush)) // win32, linux
indicator = SC_INDICATOR_TARGET;
- if ((imeCaretPos == 0) && (preeditNotChanged)) { // moved by an arrow key.
- indicator = SC_INDICATOR_INPUT;
+
+#ifdef Q_OS_OSX
+ if (charFormat.underlineStyle() == QTextCharFormat::SingleUnderline) {
+ QColor uc = charFormat.underlineColor();
+ if (uc.lightness() < 2) { // osx
+ indicator = SC_INDICATOR_TARGET;
}
}
#endif
+
for (int i = attr.start; i < attr.start+attr.length; i++) {
imeIndicator[i] = indicator;
}
@@ -544,10 +539,7 @@ void ScintillaEditBase::inputMethodEvent(QInputMethodEvent *event)
sqt->pdoc->TentativeStart(); // TentativeActive() from now on.
- std::vector<int> imeIndicator = MapImeIndicators(event, preeditString == preeditStr);
-#ifdef Q_OS_LINUX
- preeditString = preeditStr;
-#endif
+ std::vector<int> imeIndicator = MapImeIndicators(event);
// Display preedit characters one by one.
int imeCharPos[MAXLENINPUTIME] = {0};