Mirror of the Vim source from https://github.com/vim/vim
Révision | 6837d2c14dee7783f533cf3d292600a571c131b1 (tree) |
---|---|
l'heure | 2022-01-19 22:00:04 |
Auteur | Bram Moolenaar <Bram@vim....> |
Commiter | Bram Moolenaar |
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
@@ -368,14 +368,14 @@ | ||
368 | 368 | typedef HANDLE DPI_AWARENESS_CONTEXT; |
369 | 369 | |
370 | 370 | typedef enum DPI_AWARENESS { |
371 | - DPI_AWARENESS_INVALID = -1, | |
372 | - DPI_AWARENESS_UNAWARE = 0, | |
373 | - DPI_AWARENESS_SYSTEM_AWARE = 1, | |
371 | + DPI_AWARENESS_INVALID = -1, | |
372 | + DPI_AWARENESS_UNAWARE = 0, | |
373 | + DPI_AWARENESS_SYSTEM_AWARE = 1, | |
374 | 374 | DPI_AWARENESS_PER_MONITOR_AWARE = 2 |
375 | 375 | } DPI_AWARENESS; |
376 | 376 | |
377 | -# define DPI_AWARENESS_CONTEXT_UNAWARE ((DPI_AWARENESS_CONTEXT)-1) | |
378 | -# define DPI_AWARENESS_CONTEXT_SYSTEM_AWARE ((DPI_AWARENESS_CONTEXT)-2) | |
377 | +# define DPI_AWARENESS_CONTEXT_UNAWARE ((DPI_AWARENESS_CONTEXT)-1) | |
378 | +# define DPI_AWARENESS_CONTEXT_SYSTEM_AWARE ((DPI_AWARENESS_CONTEXT)-2) | |
379 | 379 | # define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE ((DPI_AWARENESS_CONTEXT)-3) |
380 | 380 | # define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 ((DPI_AWARENESS_CONTEXT)-4) |
381 | 381 | # define DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED ((DPI_AWARENESS_CONTEXT)-5) |
@@ -4275,7 +4275,6 @@ | ||
4275 | 4275 | # endif |
4276 | 4276 | |
4277 | 4277 | static HINSTANCE hLibImm = NULL; |
4278 | -static LONG (WINAPI *pImmGetCompositionStringA)(HIMC, DWORD, LPVOID, DWORD); | |
4279 | 4278 | static LONG (WINAPI *pImmGetCompositionStringW)(HIMC, DWORD, LPVOID, DWORD); |
4280 | 4279 | static HIMC (WINAPI *pImmGetContext)(HWND); |
4281 | 4280 | static HIMC (WINAPI *pImmAssociateContext)(HWND, HIMC); |
@@ -4289,7 +4288,6 @@ | ||
4289 | 4288 | static BOOL (WINAPI *pImmSetConversionStatus)(HIMC, DWORD, DWORD); |
4290 | 4289 | static void dyn_imm_load(void); |
4291 | 4290 | #else |
4292 | -# define pImmGetCompositionStringA ImmGetCompositionStringA | |
4293 | 4291 | # define pImmGetCompositionStringW ImmGetCompositionStringW |
4294 | 4292 | # define pImmGetContext ImmGetContext |
4295 | 4293 | # define pImmAssociateContext ImmAssociateContext |
@@ -5880,56 +5878,6 @@ | ||
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 | 5881 | * void GetResultStr() |
5934 | 5882 | * |
5935 | 5883 | * This handles WM_IME_COMPOSITION with GCS_RESULTSTR flag on. |
@@ -5939,17 +5887,27 @@ | ||
5939 | 5887 | GetResultStr(HWND hwnd, int GCS, int *lenp) |
5940 | 5888 | { |
5941 | 5889 | HIMC hIMC; // Input context handle. |
5942 | - short_u *buf = NULL; | |
5890 | + LONG ret; | |
5891 | + WCHAR *buf = NULL; | |
5943 | 5892 | char_u *convbuf = NULL; |
5944 | 5893 | |
5945 | 5894 | if (!pImmGetContext || (hIMC = pImmGetContext(hwnd)) == (HIMC)0) |
5946 | 5895 | return NULL; |
5947 | 5896 | |
5948 | - // Reads in the composition string. | |
5949 | - buf = GetCompositionString_inUCS2(hIMC, GCS, lenp); | |
5897 | + // Get the length of the composition string. | |
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 | 5904 | if (buf == NULL) |
5951 | 5905 | return NULL; |
5952 | 5906 | |
5907 | + // Reads in the composition string. | |
5908 | + pImmGetCompositionStringW(hIMC, GCS, buf, ret); | |
5909 | + *lenp = ret / sizeof(WCHAR); | |
5910 | + | |
5953 | 5911 | convbuf = utf16_to_enc(buf, lenp); |
5954 | 5912 | pImmReleaseContext(hwnd, hIMC); |
5955 | 5913 | vim_free(buf); |
@@ -8399,8 +8357,6 @@ | ||
8399 | 8357 | if (hLibImm == NULL) |
8400 | 8358 | return; |
8401 | 8359 | |
8402 | - pImmGetCompositionStringA | |
8403 | - = (void *)GetProcAddress(hLibImm, "ImmGetCompositionStringA"); | |
8404 | 8360 | pImmGetCompositionStringW |
8405 | 8361 | = (void *)GetProcAddress(hLibImm, "ImmGetCompositionStringW"); |
8406 | 8362 | pImmGetContext |
@@ -8424,8 +8380,7 @@ | ||
8424 | 8380 | pImmSetConversionStatus |
8425 | 8381 | = (void *)GetProcAddress(hLibImm, "ImmSetConversionStatus"); |
8426 | 8382 | |
8427 | - if ( pImmGetCompositionStringA == NULL | |
8428 | - || pImmGetCompositionStringW == NULL | |
8383 | + if ( pImmGetCompositionStringW == NULL | |
8429 | 8384 | || pImmGetContext == NULL |
8430 | 8385 | || pImmAssociateContext == NULL |
8431 | 8386 | || pImmReleaseContext == NULL |
@@ -751,6 +751,8 @@ | ||
751 | 751 | static int included_patches[] = |
752 | 752 | { /* Add new patch number below this line */ |
753 | 753 | /**/ |
754 | + 4143, | |
755 | +/**/ | |
754 | 756 | 4142, |
755 | 757 | /**/ |
756 | 758 | 4141, |