diff options
author | johnsonj <unknown> | 2016-01-25 13:18:26 +1100 |
---|---|---|
committer | johnsonj <unknown> | 2016-01-25 13:18:26 +1100 |
commit | 515973e4b8a6b293ca196804a5f5ce191ae9792d (patch) | |
tree | 23328276dcfa913a97e615398bac4fe17fa592a1 /qt/ScintillaEditBase/ScintillaEditBase.cpp | |
parent | 3d4f734f8bc601dcf27bb458a7794525688c806e (diff) | |
download | scintilla-mirror-515973e4b8a6b293ca196804a5f5ce191ae9792d.tar.gz |
Make IME indicators work similarly on all 3 platforms.
Diffstat (limited to 'qt/ScintillaEditBase/ScintillaEditBase.cpp')
-rw-r--r-- | qt/ScintillaEditBase/ScintillaEditBase.cpp | 42 |
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}; |