From 9fc5e4bed535bca4b42fdb04c6ae88015d7ee3d2 Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Sun, 20 May 2001 07:10:12 +0000 Subject: Support for IME input of Asian languages on W2K. --- win32/ScintillaWin.cxx | 51 ++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 12 deletions(-) diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx index 2ab5db13c..ffd804e2d 100644 --- a/win32/ScintillaWin.cxx +++ b/win32/ScintillaWin.cxx @@ -168,6 +168,7 @@ class ScintillaWin : virtual void StartDrag(); sptr_t WndPaint(unsigned long wParam); + sptr_t HandleComposition(uptr_t wParam, sptr_t lParam); virtual sptr_t WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam); virtual sptr_t DefWndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam); virtual void SetTicking(bool on); @@ -406,6 +407,43 @@ LRESULT ScintillaWin::WndPaint(unsigned long wParam) { return 0l; } +static BOOL IsNT() { + OSVERSIONINFO osv = {sizeof(OSVERSIONINFO),0,0,0,0,""}; + ::GetVersionEx(&osv); + return osv.dwPlatformId == VER_PLATFORM_WIN32_NT; +} + +sptr_t ScintillaWin::HandleComposition(uptr_t wParam, sptr_t lParam) { + if ((lParam & GCS_RESULTSTR) && (IsNT())) { + HIMC hIMC = ::ImmGetContext(wMain.GetID()); + if (hIMC) { + const int maxLenInputIME = 200; + wchar_t wcs[maxLenInputIME]; + LONG bytes = ::ImmGetCompositionStringW(hIMC, + GCS_RESULTSTR, wcs, (maxLenInputIME-1)*2); + int wides = bytes / 2; + if (IsUnicodeMode()) { + char utfval[maxLenInputIME * 3]; + unsigned int len = UTF8Length(wcs, wides); + UTF8FromUCS2(wcs, wides, utfval, len); + utfval[len] = '\0'; + AddCharUTF(utfval, len); + } else { + char dbcsval[maxLenInputIME * 2]; + int size = ::WideCharToMultiByte(InputCodePage(), + 0, wcs, wides, dbcsval, sizeof(dbcsval) - 1, 0, 0); + for (int i=0; i