Mercurial > vim
comparison src/gui_w32.c @ 27229:6837d2c14dee v8.2.4143
patch 8.2.4143: MS-Windows: IME support for Win9x is obsolete
Commit: https://github.com/vim/vim/commit/b0b2b73dca40c26ff1f4befe5c3aad3fd4bccfad
Author: K.Takata <kentkt@csc.jp>
Date: Wed Jan 19 12:59:21 2022 +0000
patch 8.2.4143: MS-Windows: IME support for Win9x is obsolete
Problem: MS-Windows: IME support for Win9x is obsolete.
Solution: Remove the Win9x code. (Ken Takata, closes https://github.com/vim/vim/issues/9559)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 19 Jan 2022 14:00:04 +0100 |
parents | 4482dd5f8869 |
children | d5570658f18d |
comparison
equal
deleted
inserted
replaced
27228:50d7f7e0cbd2 | 27229:6837d2c14dee |
---|---|
366 | 366 |
367 #ifndef _DPI_AWARENESS_CONTEXTS_ | 367 #ifndef _DPI_AWARENESS_CONTEXTS_ |
368 typedef HANDLE DPI_AWARENESS_CONTEXT; | 368 typedef HANDLE DPI_AWARENESS_CONTEXT; |
369 | 369 |
370 typedef enum DPI_AWARENESS { | 370 typedef enum DPI_AWARENESS { |
371 DPI_AWARENESS_INVALID = -1, | 371 DPI_AWARENESS_INVALID = -1, |
372 DPI_AWARENESS_UNAWARE = 0, | 372 DPI_AWARENESS_UNAWARE = 0, |
373 DPI_AWARENESS_SYSTEM_AWARE = 1, | 373 DPI_AWARENESS_SYSTEM_AWARE = 1, |
374 DPI_AWARENESS_PER_MONITOR_AWARE = 2 | 374 DPI_AWARENESS_PER_MONITOR_AWARE = 2 |
375 } DPI_AWARENESS; | 375 } DPI_AWARENESS; |
376 | 376 |
377 # define DPI_AWARENESS_CONTEXT_UNAWARE ((DPI_AWARENESS_CONTEXT)-1) | 377 # define DPI_AWARENESS_CONTEXT_UNAWARE ((DPI_AWARENESS_CONTEXT)-1) |
378 # define DPI_AWARENESS_CONTEXT_SYSTEM_AWARE ((DPI_AWARENESS_CONTEXT)-2) | 378 # define DPI_AWARENESS_CONTEXT_SYSTEM_AWARE ((DPI_AWARENESS_CONTEXT)-2) |
379 # define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE ((DPI_AWARENESS_CONTEXT)-3) | 379 # define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE ((DPI_AWARENESS_CONTEXT)-3) |
380 # define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 ((DPI_AWARENESS_CONTEXT)-4) | 380 # define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 ((DPI_AWARENESS_CONTEXT)-4) |
381 # define DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED ((DPI_AWARENESS_CONTEXT)-5) | 381 # define DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED ((DPI_AWARENESS_CONTEXT)-5) |
382 #endif | 382 #endif |
383 | 383 |
4273 } COMPOSITIONFORM, *PCOMPOSITIONFORM, NEAR *NPCOMPOSITIONFORM, FAR *LPCOMPOSITIONFORM; | 4273 } COMPOSITIONFORM, *PCOMPOSITIONFORM, NEAR *NPCOMPOSITIONFORM, FAR *LPCOMPOSITIONFORM; |
4274 typedef HANDLE HIMC; | 4274 typedef HANDLE HIMC; |
4275 # endif | 4275 # endif |
4276 | 4276 |
4277 static HINSTANCE hLibImm = NULL; | 4277 static HINSTANCE hLibImm = NULL; |
4278 static LONG (WINAPI *pImmGetCompositionStringA)(HIMC, DWORD, LPVOID, DWORD); | |
4279 static LONG (WINAPI *pImmGetCompositionStringW)(HIMC, DWORD, LPVOID, DWORD); | 4278 static LONG (WINAPI *pImmGetCompositionStringW)(HIMC, DWORD, LPVOID, DWORD); |
4280 static HIMC (WINAPI *pImmGetContext)(HWND); | 4279 static HIMC (WINAPI *pImmGetContext)(HWND); |
4281 static HIMC (WINAPI *pImmAssociateContext)(HWND, HIMC); | 4280 static HIMC (WINAPI *pImmAssociateContext)(HWND, HIMC); |
4282 static BOOL (WINAPI *pImmReleaseContext)(HWND, HIMC); | 4281 static BOOL (WINAPI *pImmReleaseContext)(HWND, HIMC); |
4283 static BOOL (WINAPI *pImmGetOpenStatus)(HIMC); | 4282 static BOOL (WINAPI *pImmGetOpenStatus)(HIMC); |
4287 static BOOL (WINAPI *pImmSetCompositionWindow)(HIMC, LPCOMPOSITIONFORM); | 4286 static BOOL (WINAPI *pImmSetCompositionWindow)(HIMC, LPCOMPOSITIONFORM); |
4288 static BOOL (WINAPI *pImmGetConversionStatus)(HIMC, LPDWORD, LPDWORD); | 4287 static BOOL (WINAPI *pImmGetConversionStatus)(HIMC, LPDWORD, LPDWORD); |
4289 static BOOL (WINAPI *pImmSetConversionStatus)(HIMC, DWORD, DWORD); | 4288 static BOOL (WINAPI *pImmSetConversionStatus)(HIMC, DWORD, DWORD); |
4290 static void dyn_imm_load(void); | 4289 static void dyn_imm_load(void); |
4291 #else | 4290 #else |
4292 # define pImmGetCompositionStringA ImmGetCompositionStringA | |
4293 # define pImmGetCompositionStringW ImmGetCompositionStringW | 4291 # define pImmGetCompositionStringW ImmGetCompositionStringW |
4294 # define pImmGetContext ImmGetContext | 4292 # define pImmGetContext ImmGetContext |
4295 # define pImmAssociateContext ImmAssociateContext | 4293 # define pImmAssociateContext ImmAssociateContext |
4296 # define pImmReleaseContext ImmReleaseContext | 4294 # define pImmReleaseContext ImmReleaseContext |
4297 # define pImmGetOpenStatus ImmGetOpenStatus | 4295 # define pImmGetOpenStatus ImmGetOpenStatus |
5878 } | 5876 } |
5879 return 0; | 5877 return 0; |
5880 } | 5878 } |
5881 | 5879 |
5882 /* | 5880 /* |
5883 * get the current composition string, in UCS-2; *lenp is the number of | |
5884 * *lenp is the number of Unicode characters. | |
5885 */ | |
5886 static short_u * | |
5887 GetCompositionString_inUCS2(HIMC hIMC, DWORD GCS, int *lenp) | |
5888 { | |
5889 LONG ret; | |
5890 LPWSTR wbuf = NULL; | |
5891 char_u *buf; | |
5892 | |
5893 if (!pImmGetContext) | |
5894 return NULL; // no imm32.dll | |
5895 | |
5896 // Try Unicode; this will always work on NT regardless of codepage. | |
5897 ret = pImmGetCompositionStringW(hIMC, GCS, NULL, 0); | |
5898 if (ret == 0) | |
5899 return NULL; // empty | |
5900 | |
5901 if (ret > 0) | |
5902 { | |
5903 // Allocate the requested buffer plus space for the NUL character. | |
5904 wbuf = alloc(ret + sizeof(WCHAR)); | |
5905 if (wbuf != NULL) | |
5906 { | |
5907 pImmGetCompositionStringW(hIMC, GCS, wbuf, ret); | |
5908 *lenp = ret / sizeof(WCHAR); | |
5909 } | |
5910 return (short_u *)wbuf; | |
5911 } | |
5912 | |
5913 // ret < 0; we got an error, so try the ANSI version. This will work | |
5914 // on 9x/ME, but only if the codepage happens to be set to whatever | |
5915 // we're inputting. | |
5916 ret = pImmGetCompositionStringA(hIMC, GCS, NULL, 0); | |
5917 if (ret <= 0) | |
5918 return NULL; // empty or error | |
5919 | |
5920 buf = alloc(ret); | |
5921 if (buf == NULL) | |
5922 return NULL; | |
5923 pImmGetCompositionStringA(hIMC, GCS, buf, ret); | |
5924 | |
5925 // convert from codepage to UCS-2 | |
5926 MultiByteToWideChar_alloc(GetACP(), 0, (LPCSTR)buf, ret, &wbuf, lenp); | |
5927 vim_free(buf); | |
5928 | |
5929 return (short_u *)wbuf; | |
5930 } | |
5931 | |
5932 /* | |
5933 * void GetResultStr() | 5881 * void GetResultStr() |
5934 * | 5882 * |
5935 * This handles WM_IME_COMPOSITION with GCS_RESULTSTR flag on. | 5883 * This handles WM_IME_COMPOSITION with GCS_RESULTSTR flag on. |
5936 * get complete composition string | 5884 * get complete composition string |
5937 */ | 5885 */ |
5938 static char_u * | 5886 static char_u * |
5939 GetResultStr(HWND hwnd, int GCS, int *lenp) | 5887 GetResultStr(HWND hwnd, int GCS, int *lenp) |
5940 { | 5888 { |
5941 HIMC hIMC; // Input context handle. | 5889 HIMC hIMC; // Input context handle. |
5942 short_u *buf = NULL; | 5890 LONG ret; |
5891 WCHAR *buf = NULL; | |
5943 char_u *convbuf = NULL; | 5892 char_u *convbuf = NULL; |
5944 | 5893 |
5945 if (!pImmGetContext || (hIMC = pImmGetContext(hwnd)) == (HIMC)0) | 5894 if (!pImmGetContext || (hIMC = pImmGetContext(hwnd)) == (HIMC)0) |
5946 return NULL; | 5895 return NULL; |
5947 | 5896 |
5948 // Reads in the composition string. | 5897 // Get the length of the composition string. |
5949 buf = GetCompositionString_inUCS2(hIMC, GCS, lenp); | 5898 ret = pImmGetCompositionStringW(hIMC, GCS, NULL, 0); |
5899 if (ret <= 0) | |
5900 return NULL; | |
5901 | |
5902 // Allocate the requested buffer plus space for the NUL character. | |
5903 buf = alloc(ret + sizeof(WCHAR)); | |
5950 if (buf == NULL) | 5904 if (buf == NULL) |
5951 return NULL; | 5905 return NULL; |
5906 | |
5907 // Reads in the composition string. | |
5908 pImmGetCompositionStringW(hIMC, GCS, buf, ret); | |
5909 *lenp = ret / sizeof(WCHAR); | |
5952 | 5910 |
5953 convbuf = utf16_to_enc(buf, lenp); | 5911 convbuf = utf16_to_enc(buf, lenp); |
5954 pImmReleaseContext(hwnd, hIMC); | 5912 pImmReleaseContext(hwnd, hIMC); |
5955 vim_free(buf); | 5913 vim_free(buf); |
5956 return convbuf; | 5914 return convbuf; |
8397 { | 8355 { |
8398 hLibImm = vimLoadLib("imm32.dll"); | 8356 hLibImm = vimLoadLib("imm32.dll"); |
8399 if (hLibImm == NULL) | 8357 if (hLibImm == NULL) |
8400 return; | 8358 return; |
8401 | 8359 |
8402 pImmGetCompositionStringA | |
8403 = (void *)GetProcAddress(hLibImm, "ImmGetCompositionStringA"); | |
8404 pImmGetCompositionStringW | 8360 pImmGetCompositionStringW |
8405 = (void *)GetProcAddress(hLibImm, "ImmGetCompositionStringW"); | 8361 = (void *)GetProcAddress(hLibImm, "ImmGetCompositionStringW"); |
8406 pImmGetContext | 8362 pImmGetContext |
8407 = (void *)GetProcAddress(hLibImm, "ImmGetContext"); | 8363 = (void *)GetProcAddress(hLibImm, "ImmGetContext"); |
8408 pImmAssociateContext | 8364 pImmAssociateContext |
8422 pImmGetConversionStatus | 8378 pImmGetConversionStatus |
8423 = (void *)GetProcAddress(hLibImm, "ImmGetConversionStatus"); | 8379 = (void *)GetProcAddress(hLibImm, "ImmGetConversionStatus"); |
8424 pImmSetConversionStatus | 8380 pImmSetConversionStatus |
8425 = (void *)GetProcAddress(hLibImm, "ImmSetConversionStatus"); | 8381 = (void *)GetProcAddress(hLibImm, "ImmSetConversionStatus"); |
8426 | 8382 |
8427 if ( pImmGetCompositionStringA == NULL | 8383 if ( pImmGetCompositionStringW == NULL |
8428 || pImmGetCompositionStringW == NULL | |
8429 || pImmGetContext == NULL | 8384 || pImmGetContext == NULL |
8430 || pImmAssociateContext == NULL | 8385 || pImmAssociateContext == NULL |
8431 || pImmReleaseContext == NULL | 8386 || pImmReleaseContext == NULL |
8432 || pImmGetOpenStatus == NULL | 8387 || pImmGetOpenStatus == NULL |
8433 || pImmSetOpenStatus == NULL | 8388 || pImmSetOpenStatus == NULL |