aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorZufu Liu <unknown>2019-10-30 09:41:36 +1100
committerZufu Liu <unknown>2019-10-30 09:41:36 +1100
commitdbc43f3f4eb3fb18c5887553c1d642aa01d0b25a (patch)
tree31c39c25c7d50fc0a4023f53efbcd9e94faf8a45
parentf42c64cf9a0e5e244c3bb4956b5377ef64f5a180 (diff)
downloadscintilla-mirror-dbc43f3f4eb3fb18c5887553c1d642aa01d0b25a.tar.gz
Feature [feature-requests:#1304] Avoid unnecessary IME caret movement.
-rw-r--r--doc/ScintillaHistory.html4
-rw-r--r--win32/ScintillaWin.cxx31
2 files changed, 28 insertions, 7 deletions
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html
index 00fca60a6..f512a01bc 100644
--- a/doc/ScintillaHistory.html
+++ b/doc/ScintillaHistory.html
@@ -570,6 +570,10 @@
properties like user.shortcuts.
<a href="https://sourceforge.net/p/scintilla/feature-requests/1317/">Feature #1317</a>.
</li>
+ <li>
+ Avoid unnecessary IME caret movement on Win32.
+ <a href="https://sourceforge.net/p/scintilla/feature-requests/1304/">Feature #1304</a>.
+ </li>
</ul>
<h3>
<a href="https://www.scintilla.org/scite421.zip">Release 4.2.1</a>
diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx
index 98ea15cea..d72f1958b 100644
--- a/win32/ScintillaWin.cxx
+++ b/win32/ScintillaWin.cxx
@@ -1122,15 +1122,32 @@ sptr_t ScintillaWin::HandleCompositionInline(uptr_t, sptr_t lParam) {
i += ucWidth;
}
- // Move IME caret from current last position to imeCaretPos.
- const int imeEndToImeCaretU16 = imc.GetImeCaretPos() - static_cast<unsigned int>(wcs.size());
- const Sci::Position imeCaretPosDoc = pdoc->GetRelativePositionUTF16(CurrentPosition(), imeEndToImeCaretU16);
+ // Japanese IME after pressing Tab replaces input string with first candidate item (target string);
+ // when selecting other candidate item, previous item will be replaced with current one.
+ // After candidate item been added, it's looks like been full selected, it's better to keep caret
+ // at end of "selection" (end of input) instead of jump to beginning of input ("selection").
+ const bool onlyTarget = std::all_of(imeIndicator.begin(), imeIndicator.end(), [](int i) noexcept {
+ return i == SC_INDICATOR_TARGET;
+ });
+ if (!onlyTarget) {
+ // CS_NOMOVECARET: keep caret at beginning if composition string which already moved in InsertCharacter().
+ // GCS_CURSORPOS: current caret position is provided by IME.
+ Sci::Position imeEndToImeCaretU16 = -static_cast<Sci::Position>(wcs.size());
+ if (!(lParam & CS_NOMOVECARET) && (lParam & GCS_CURSORPOS)) {
+ imeEndToImeCaretU16 += imc.GetImeCaretPos();
+ }
+ if (imeEndToImeCaretU16 != 0) {
+ // Move back IME caret from current last position to imeCaretPos.
+ const Sci::Position currentPos = CurrentPosition();
+ const Sci::Position imeCaretPosDoc = pdoc->GetRelativePositionUTF16(currentPos, imeEndToImeCaretU16);
- MoveImeCarets(- CurrentPosition() + imeCaretPosDoc);
+ MoveImeCarets(-currentPos + imeCaretPosDoc);
- if (std::find(imeIndicator.begin(), imeIndicator.end(), SC_INDICATOR_TARGET) != imeIndicator.end()) {
- // set candidate window left aligned to beginning of target string.
- SetCandidateWindowPos();
+ if (std::find(imeIndicator.begin(), imeIndicator.end(), SC_INDICATOR_TARGET) != imeIndicator.end()) {
+ // set candidate window left aligned to beginning of target string.
+ SetCandidateWindowPos();
+ }
+ }
}
if (KoreanIME()) {