diff options
| author | nyamatongwe <unknown> | 2007-06-23 04:22:01 +0000 | 
|---|---|---|
| committer | nyamatongwe <unknown> | 2007-06-23 04:22:01 +0000 | 
| commit | 21619be4e971569b88ea9b551416991a7bedc217 (patch) | |
| tree | 118956af9c8e379f06510415bb5514b97470ad5b /win32/ScintillaWin.cxx | |
| parent | 81a80dc05eab0c39972b9ffac5f801a6905cd7e2 (diff) | |
| download | scintilla-mirror-21619be4e971569b88ea9b551416991a7bedc217.tar.gz | |
Fixes for bug #1732146, Armenian input on Windows by registering the
Scintilla windows class as wide and using GetMessageW/DispatchMessageW
in the SciTE event loop.
Diffstat (limited to 'win32/ScintillaWin.cxx')
| -rw-r--r-- | win32/ScintillaWin.cxx | 78 | 
1 files changed, 45 insertions, 33 deletions
| diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx index 248513e18..f8757ba6d 100644 --- a/win32/ScintillaWin.cxx +++ b/win32/ScintillaWin.cxx @@ -554,6 +554,24 @@ static unsigned int SciMessageFromEM(unsigned int iMessage) {  	return iMessage;  } +static UINT CodePageFromCharSet(DWORD characterSet, UINT documentCodePage) { +	CHARSETINFO ci = { 0, 0, { { 0, 0, 0, 0 }, { 0, 0 } } }; +	BOOL bci = ::TranslateCharsetInfo((DWORD*)characterSet, +		&ci, TCI_SRCCHARSET); + +	UINT cp; +	if (bci) +		cp = ci.ciACP; +	else +		cp = documentCodePage; + +	CPINFO cpi; +	if (!IsValidCodePage(cp) && !GetCPInfo(cp, &cpi)) +		cp = CP_ACP; + +	return cp; +} +  sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {  	//Platform::DebugPrintf("S M:%x WP:%x L:%x\n", iMessage, wParam, lParam);  	iMessage = SciMessageFromEM(iMessage); @@ -730,17 +748,29 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam  		}  	case WM_CHAR: -		if (!iscntrl(wParam&0xff) || !lastKeyDownConsumed) { -			if (IsUnicodeMode()) { -				// For a wide character version of the window: -				//char utfval[4]; -				//wchar_t wcs[2] = {wParam, 0}; -				//unsigned int len = UTF8Length(wcs, 1); -				//UTF8FromUTF16(wcs, 1, utfval, len); -				//AddCharUTF(utfval, len); -				AddCharBytes('\0', LOBYTE(wParam)); +		if (((wParam >= 128) || !iscntrl(wParam)) || !lastKeyDownConsumed) { +            if (::IsWindowUnicode(MainHWND())) { +			    wchar_t wcs[2] = {wParam, 0}; +                if (IsUnicodeMode()) { +				    // For a wide character version of the window: +				    char utfval[4]; +				    unsigned int len = UTF8Length(wcs, 1); +				    UTF8FromUTF16(wcs, 1, utfval, len); +				    AddCharUTF(utfval, len); +                } else { +    				UINT cpDest = CodePageFromCharSet( +	    				vs.styles[STYLE_DEFAULT].characterSet, pdoc->dbcsCodePage); +				    char inBufferCP[20]; +				    int size = ::WideCharToMultiByte(cpDest, +					    0, wcs, 1, inBufferCP, sizeof(inBufferCP) - 1, 0, 0); +				    AddCharUTF(inBufferCP, size); +                }  			} else { -				AddChar(LOBYTE(wParam)); +                if (IsUnicodeMode()) { +    			    AddCharBytes('\0', LOBYTE(wParam)); +                } else { +    				AddChar(LOBYTE(wParam)); +                }  			}  		}  		return 0; @@ -1215,24 +1245,6 @@ bool ScintillaWin::CanPaste() {  	return false;  } -static UINT CodePageFromCharSet(DWORD characterSet, UINT documentCodePage) { -	CHARSETINFO ci = { 0, 0, { { 0, 0, 0, 0 }, { 0, 0 } } }; -	BOOL bci = ::TranslateCharsetInfo((DWORD*)characterSet, -		&ci, TCI_SRCCHARSET); - -	UINT cp; -	if (bci) -		cp = ci.ciACP; -	else -		cp = documentCodePage; - -	CPINFO cpi; -	if (!IsValidCodePage(cp) && !GetCPInfo(cp, &cpi)) -		cp = CP_ACP; - -	return cp; -} -  class GlobalMemory {  	HGLOBAL hand;  public: @@ -2191,10 +2203,10 @@ bool ScintillaWin::Register(HINSTANCE hInstance_) {  	hInstance = hInstance_;  	bool result; -#if 0 +  	// Register the Scintilla class  	if (IsNT()) { -	//if (0) { +  		// Register Scintilla as a wide character window  		WNDCLASSEXW wndclass;  		wndclass.cbSize = sizeof(wndclass); @@ -2209,9 +2221,9 @@ bool ScintillaWin::Register(HINSTANCE hInstance_) {  		wndclass.lpszMenuName = NULL;  		wndclass.lpszClassName = L"Scintilla";  		wndclass.hIconSm = 0; -		result = ::RegisterClassExW(&wndclass); +		result = ::RegisterClassExW(&wndclass) != 0;  	} else { -#endif +  		// Register Scintilla as a normal character window  		WNDCLASSEX wndclass;  		wndclass.cbSize = sizeof(wndclass); @@ -2227,7 +2239,7 @@ bool ScintillaWin::Register(HINSTANCE hInstance_) {  		wndclass.lpszClassName = scintillaClassName;  		wndclass.hIconSm = 0;  		result = ::RegisterClassEx(&wndclass) != 0; -	//} +	}  	if (result) {  		// Register the CallTip class | 
