зеркало из https://github.com/github/putty.git
Glenn Maynard's IME patch
[originally from svn r1172]
This commit is contained in:
Родитель
3b81448ae4
Коммит
de987f33fe
2
Makefile
2
Makefile
|
@ -124,7 +124,7 @@ LRESRC = plink.$(RES)
|
|||
|
||||
LIBS1 = advapi32.lib user32.lib gdi32.lib
|
||||
LIBS2 = comctl32.lib comdlg32.lib
|
||||
LIBS3 = shell32.lib winmm.lib
|
||||
LIBS3 = shell32.lib winmm.lib imm32.lib
|
||||
SOCK1 = wsock32.lib
|
||||
SOCK2 = ws2_32.lib
|
||||
|
||||
|
|
63
window.c
63
window.c
|
@ -128,6 +128,8 @@ static char *window_name, *icon_name;
|
|||
|
||||
static int compose_state = 0;
|
||||
|
||||
static OSVERSIONINFOEX osVersion;
|
||||
|
||||
/* Dummy routine, only required in plink. */
|
||||
void ldisc_update(int echo, int edit)
|
||||
{
|
||||
|
@ -166,6 +168,19 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
|
|||
* config box. */
|
||||
defuse_showwindow();
|
||||
|
||||
{
|
||||
ZeroMemory(&osVersion, sizeof(osVersion));
|
||||
osVersion.dwOSVersionInfoSize = sizeof(osVersion);
|
||||
|
||||
if(!GetVersionEx ((OSVERSIONINFO *) &osVersion)) {
|
||||
// If OSVERSIONINFOEX doesn't work, try OSVERSIONINFO.
|
||||
|
||||
osVersion.dwOSVersionInfoSize = sizeof (osVersion);
|
||||
if (!GetVersionEx ( (OSVERSIONINFO *) &osVersion))
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Process the command line.
|
||||
*/
|
||||
|
@ -1873,6 +1888,31 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
|||
kbd_codepage = atoi(lbuf);
|
||||
}
|
||||
break;
|
||||
case WM_IME_COMPOSITION:
|
||||
{
|
||||
HIMC hIMC;
|
||||
int n;
|
||||
char *buff;
|
||||
|
||||
if(osVersion.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS ||
|
||||
osVersion.dwPlatformId == VER_PLATFORM_WIN32s) break; /* no Unicode */
|
||||
|
||||
if ((lParam & GCS_RESULTSTR) == 0) /* Composition unfinished. */
|
||||
break; /* fall back to DefWindowProc */
|
||||
|
||||
hIMC = ImmGetContext(hwnd);
|
||||
n = ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, NULL, 0);
|
||||
|
||||
if (n > 0) {
|
||||
buff = (char*) smalloc(n);
|
||||
ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, buff, n);
|
||||
luni_send((unsigned short *)buff, n / 2);
|
||||
free(buff);
|
||||
}
|
||||
ImmReleaseContext(hwnd, hIMC);
|
||||
return 1;
|
||||
}
|
||||
|
||||
case WM_IME_CHAR:
|
||||
if (wParam & 0xFF00) {
|
||||
unsigned char buf[2];
|
||||
|
@ -1916,8 +1956,27 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
|||
*/
|
||||
void sys_cursor(int x, int y)
|
||||
{
|
||||
if (has_focus)
|
||||
SetCaretPos(x * font_width, y * font_height);
|
||||
COMPOSITIONFORM cf;
|
||||
HIMC hIMC;
|
||||
|
||||
if (!has_focus) return;
|
||||
|
||||
SetCaretPos(x * font_width, y * font_height);
|
||||
|
||||
/* IMM calls on Win98 and beyond only */
|
||||
if(osVersion.dwPlatformId == VER_PLATFORM_WIN32s) return; /* 3.11 */
|
||||
|
||||
if(osVersion.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS &&
|
||||
osVersion.dwMinorVersion == 0) return; /* 95 */
|
||||
|
||||
/* we should have the IMM functions */
|
||||
hIMC = ImmGetContext(hwnd);
|
||||
cf.dwStyle = CFS_POINT;
|
||||
cf.ptCurrentPos.x = x * font_width;
|
||||
cf.ptCurrentPos.y = y * font_height;
|
||||
ImmSetCompositionWindow(hIMC, &cf);
|
||||
|
||||
ImmReleaseContext(hwnd, hIMC);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Загрузка…
Ссылка в новой задаче