To: vim_dev@googlegroups.com Subject: Patch 8.2.4143 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.4143 Problem: MS-Windows: IME support for Win9x is obsolete. Solution: Remove the Win9x code. (Ken Takata, closes #9559) Files: src/gui_w32.c *** ../vim-8.2.4142/src/gui_w32.c 2022-01-16 14:15:45.517045001 +0000 --- src/gui_w32.c 2022-01-19 12:58:34.751910173 +0000 *************** *** 368,381 **** typedef HANDLE DPI_AWARENESS_CONTEXT; typedef enum DPI_AWARENESS { ! DPI_AWARENESS_INVALID = -1, ! DPI_AWARENESS_UNAWARE = 0, ! DPI_AWARENESS_SYSTEM_AWARE = 1, DPI_AWARENESS_PER_MONITOR_AWARE = 2 } DPI_AWARENESS; ! # define DPI_AWARENESS_CONTEXT_UNAWARE ((DPI_AWARENESS_CONTEXT)-1) ! # define DPI_AWARENESS_CONTEXT_SYSTEM_AWARE ((DPI_AWARENESS_CONTEXT)-2) # define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE ((DPI_AWARENESS_CONTEXT)-3) # define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 ((DPI_AWARENESS_CONTEXT)-4) # define DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED ((DPI_AWARENESS_CONTEXT)-5) --- 368,381 ---- typedef HANDLE DPI_AWARENESS_CONTEXT; typedef enum DPI_AWARENESS { ! DPI_AWARENESS_INVALID = -1, ! DPI_AWARENESS_UNAWARE = 0, ! DPI_AWARENESS_SYSTEM_AWARE = 1, DPI_AWARENESS_PER_MONITOR_AWARE = 2 } DPI_AWARENESS; ! # define DPI_AWARENESS_CONTEXT_UNAWARE ((DPI_AWARENESS_CONTEXT)-1) ! # define DPI_AWARENESS_CONTEXT_SYSTEM_AWARE ((DPI_AWARENESS_CONTEXT)-2) # define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE ((DPI_AWARENESS_CONTEXT)-3) # define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 ((DPI_AWARENESS_CONTEXT)-4) # define DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED ((DPI_AWARENESS_CONTEXT)-5) *************** *** 4275,4281 **** # endif static HINSTANCE hLibImm = NULL; - static LONG (WINAPI *pImmGetCompositionStringA)(HIMC, DWORD, LPVOID, DWORD); static LONG (WINAPI *pImmGetCompositionStringW)(HIMC, DWORD, LPVOID, DWORD); static HIMC (WINAPI *pImmGetContext)(HWND); static HIMC (WINAPI *pImmAssociateContext)(HWND, HIMC); --- 4275,4280 ---- *************** *** 4289,4295 **** static BOOL (WINAPI *pImmSetConversionStatus)(HIMC, DWORD, DWORD); static void dyn_imm_load(void); #else - # define pImmGetCompositionStringA ImmGetCompositionStringA # define pImmGetCompositionStringW ImmGetCompositionStringW # define pImmGetContext ImmGetContext # define pImmAssociateContext ImmAssociateContext --- 4288,4293 ---- *************** *** 5880,5935 **** } /* - * get the current composition string, in UCS-2; *lenp is the number of - * *lenp is the number of Unicode characters. - */ - static short_u * - GetCompositionString_inUCS2(HIMC hIMC, DWORD GCS, int *lenp) - { - LONG ret; - LPWSTR wbuf = NULL; - char_u *buf; - - if (!pImmGetContext) - return NULL; // no imm32.dll - - // Try Unicode; this will always work on NT regardless of codepage. - ret = pImmGetCompositionStringW(hIMC, GCS, NULL, 0); - if (ret == 0) - return NULL; // empty - - if (ret > 0) - { - // Allocate the requested buffer plus space for the NUL character. - wbuf = alloc(ret + sizeof(WCHAR)); - if (wbuf != NULL) - { - pImmGetCompositionStringW(hIMC, GCS, wbuf, ret); - *lenp = ret / sizeof(WCHAR); - } - return (short_u *)wbuf; - } - - // ret < 0; we got an error, so try the ANSI version. This will work - // on 9x/ME, but only if the codepage happens to be set to whatever - // we're inputting. - ret = pImmGetCompositionStringA(hIMC, GCS, NULL, 0); - if (ret <= 0) - return NULL; // empty or error - - buf = alloc(ret); - if (buf == NULL) - return NULL; - pImmGetCompositionStringA(hIMC, GCS, buf, ret); - - // convert from codepage to UCS-2 - MultiByteToWideChar_alloc(GetACP(), 0, (LPCSTR)buf, ret, &wbuf, lenp); - vim_free(buf); - - return (short_u *)wbuf; - } - - /* * void GetResultStr() * * This handles WM_IME_COMPOSITION with GCS_RESULTSTR flag on. --- 5878,5883 ---- *************** *** 5939,5955 **** GetResultStr(HWND hwnd, int GCS, int *lenp) { HIMC hIMC; // Input context handle. ! short_u *buf = NULL; char_u *convbuf = NULL; if (!pImmGetContext || (hIMC = pImmGetContext(hwnd)) == (HIMC)0) return NULL; ! // Reads in the composition string. ! buf = GetCompositionString_inUCS2(hIMC, GCS, lenp); if (buf == NULL) return NULL; convbuf = utf16_to_enc(buf, lenp); pImmReleaseContext(hwnd, hIMC); vim_free(buf); --- 5887,5913 ---- GetResultStr(HWND hwnd, int GCS, int *lenp) { HIMC hIMC; // Input context handle. ! LONG ret; ! WCHAR *buf = NULL; char_u *convbuf = NULL; if (!pImmGetContext || (hIMC = pImmGetContext(hwnd)) == (HIMC)0) return NULL; ! // Get the length of the composition string. ! ret = pImmGetCompositionStringW(hIMC, GCS, NULL, 0); ! if (ret <= 0) ! return NULL; ! ! // Allocate the requested buffer plus space for the NUL character. ! buf = alloc(ret + sizeof(WCHAR)); if (buf == NULL) return NULL; + // Reads in the composition string. + pImmGetCompositionStringW(hIMC, GCS, buf, ret); + *lenp = ret / sizeof(WCHAR); + convbuf = utf16_to_enc(buf, lenp); pImmReleaseContext(hwnd, hIMC); vim_free(buf); *************** *** 8399,8406 **** if (hLibImm == NULL) return; - pImmGetCompositionStringA - = (void *)GetProcAddress(hLibImm, "ImmGetCompositionStringA"); pImmGetCompositionStringW = (void *)GetProcAddress(hLibImm, "ImmGetCompositionStringW"); pImmGetContext --- 8357,8362 ---- *************** *** 8424,8431 **** pImmSetConversionStatus = (void *)GetProcAddress(hLibImm, "ImmSetConversionStatus"); ! if ( pImmGetCompositionStringA == NULL ! || pImmGetCompositionStringW == NULL || pImmGetContext == NULL || pImmAssociateContext == NULL || pImmReleaseContext == NULL --- 8380,8386 ---- pImmSetConversionStatus = (void *)GetProcAddress(hLibImm, "ImmSetConversionStatus"); ! if ( pImmGetCompositionStringW == NULL || pImmGetContext == NULL || pImmAssociateContext == NULL || pImmReleaseContext == NULL *** ../vim-8.2.4142/src/version.c 2022-01-19 11:24:35.874972747 +0000 --- src/version.c 2022-01-19 12:58:02.232746153 +0000 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 4143, /**/ -- The early bird gets the worm. If you want something else for breakfast, get up later. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///