aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorjohnsonj <devnull@localhost>2016-02-06 15:15:20 +1100
committerjohnsonj <devnull@localhost>2016-02-06 15:15:20 +1100
commit24189dbf387e7d33d65b15c9756292d7f0e8da2a (patch)
tree4d0ccba8de41dc0811d4188358970b55716ef208
parente135df6492424b1153eed215ab8fcea6d0948e23 (diff)
downloadscintilla-mirror-24189dbf387e7d33d65b15c9756292d7f0e8da2a.tar.gz
Move IME code into IMContext.
-rw-r--r--win32/ScintillaWin.cxx44
1 files changed, 22 insertions, 22 deletions
diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx
index 67d61b834..f03648fe7 100644
--- a/win32/ScintillaWin.cxx
+++ b/win32/ScintillaWin.cxx
@@ -210,6 +210,24 @@ public:
if (hIMC)
::ImmReleaseContext(hwnd, hIMC);
}
+
+ unsigned int GetImeCaretPos() {
+ return ImmGetCompositionStringW(hIMC, GCS_CURSORPOS, NULL, 0);
+ }
+
+ std::vector<BYTE> GetImeAttributes() {
+ int attrLen = ::ImmGetCompositionStringW(hIMC, GCS_COMPATTR, NULL, 0);
+ std::vector<BYTE> attr(attrLen, 0);
+ ::ImmGetCompositionStringW(hIMC, GCS_COMPATTR, &attr[0], static_cast<DWORD>(attr.size()));
+ return attr;
+ }
+
+ std::wstring GetCompositionString(DWORD dwIndex) {
+ const LONG byteLen = ::ImmGetCompositionStringW(hIMC, dwIndex, NULL, 0);
+ std::wstring wcs(byteLen / 2, 0);
+ ::ImmGetCompositionStringW(hIMC, dwIndex, &wcs[0], byteLen);
+ return wcs;
+ }
};
}
@@ -1002,17 +1020,6 @@ void ScintillaWin::ToggleHanja() {
namespace {
-unsigned int GetImeCaretPos(HIMC hIMC) {
- return ImmGetCompositionStringW(hIMC, GCS_CURSORPOS, NULL, 0);
-}
-
-std::vector<BYTE> GetImeAttributes(HIMC hIMC) {
- int attrLen = ::ImmGetCompositionStringW(hIMC, GCS_COMPATTR, NULL, 0);
- std::vector<BYTE> attr(attrLen, 0);
- ::ImmGetCompositionStringW(hIMC, GCS_COMPATTR, &attr[0], static_cast<DWORD>(attr.size()));
- return attr;
-}
-
std::vector<int> MapImeIndicators(std::vector<BYTE> inputStyle) {
std::vector<int> imeIndicator(inputStyle.size(), SC_INDICATOR_UNKNOWN);
for (size_t i = 0; i < inputStyle.size(); i++) {
@@ -1035,13 +1042,6 @@ std::vector<int> MapImeIndicators(std::vector<BYTE> inputStyle) {
return imeIndicator;
}
-std::wstring GetCompositionString(HIMC hIMC, DWORD dwIndex) {
- const LONG byteLen = ::ImmGetCompositionStringW(hIMC, dwIndex, NULL, 0);
- std::wstring wcs(byteLen / 2, 0);
- ::ImmGetCompositionStringW(hIMC, dwIndex, &wcs[0], byteLen);
- return wcs;
-}
-
}
sptr_t ScintillaWin::HandleCompositionInline(uptr_t, sptr_t lParam) {
@@ -1067,7 +1067,7 @@ sptr_t ScintillaWin::HandleCompositionInline(uptr_t, sptr_t lParam) {
view.imeCaretBlockOverride = false;
if (lParam & GCS_COMPSTR) {
- const std::wstring wcs = GetCompositionString(imc.hIMC, GCS_COMPSTR);
+ const std::wstring wcs = imc.GetCompositionString(GCS_COMPSTR);
if ((wcs.size() == 0) || (wcs.size() >= maxLenInputIME)) {
ShowCaretAtCurrentPosition();
return 0;
@@ -1075,7 +1075,7 @@ sptr_t ScintillaWin::HandleCompositionInline(uptr_t, sptr_t lParam) {
pdoc->TentativeStart(); // TentativeActive from now on.
- std::vector<int> imeIndicator = MapImeIndicators(GetImeAttributes(imc.hIMC));
+ std::vector<int> imeIndicator = MapImeIndicators(imc.GetImeAttributes());
// Display character by character.
int numBytes = 0;
@@ -1100,13 +1100,13 @@ sptr_t ScintillaWin::HandleCompositionInline(uptr_t, sptr_t lParam) {
recordingMacro = tmpRecordingMacro;
// Move IME caret position.
- unsigned int imeCursorPos = GetImeCaretPos(imc.hIMC);
+ unsigned int imeCursorPos = imc.GetImeCaretPos();
MoveImeCarets(-imeCharPos[wcs.size()] + imeCharPos[imeCursorPos]);
if (KoreanIME()) {
view.imeCaretBlockOverride = true;
}
} else if (lParam & GCS_RESULTSTR) {
- const std::wstring wcs = GetCompositionString(imc.hIMC, GCS_RESULTSTR);
+ const std::wstring wcs = imc.GetCompositionString(GCS_RESULTSTR);
for (size_t i = 0; i < wcs.size();) {
const size_t ucWidth = UTF16CharLength(wcs[i]);
const std::wstring uniChar(wcs, i, ucWidth);