comparison src/gui_w32.c @ 777:f664cc974a7a

updated for version 7.0227
author vimboss
date Fri, 17 Mar 2006 23:19:38 +0000
parents 0f9f4761ad9c
children d20041a02ee5
comparison
equal deleted inserted replaced
776:5a5a080c2776 777:f664cc974a7a
321 static BOOL (WINAPI *pImmSetOpenStatus)(HIMC, BOOL); 321 static BOOL (WINAPI *pImmSetOpenStatus)(HIMC, BOOL);
322 static BOOL (WINAPI *pImmGetCompositionFont)(HIMC, LPLOGFONTA); 322 static BOOL (WINAPI *pImmGetCompositionFont)(HIMC, LPLOGFONTA);
323 static BOOL (WINAPI *pImmSetCompositionFont)(HIMC, LPLOGFONTA); 323 static BOOL (WINAPI *pImmSetCompositionFont)(HIMC, LPLOGFONTA);
324 static BOOL (WINAPI *pImmSetCompositionWindow)(HIMC, LPCOMPOSITIONFORM); 324 static BOOL (WINAPI *pImmSetCompositionWindow)(HIMC, LPCOMPOSITIONFORM);
325 static BOOL (WINAPI *pImmGetConversionStatus)(HIMC, LPDWORD, LPDWORD); 325 static BOOL (WINAPI *pImmGetConversionStatus)(HIMC, LPDWORD, LPDWORD);
326 static BOOL (WINAPI *pImmSetConversionStatus)(HIMC, DWORD, DWORD);
326 static void dyn_imm_load(void); 327 static void dyn_imm_load(void);
327 #else 328 #else
328 # define pImmGetCompositionStringA ImmGetCompositionStringA 329 # define pImmGetCompositionStringA ImmGetCompositionStringA
329 # define pImmGetCompositionStringW ImmGetCompositionStringW 330 # define pImmGetCompositionStringW ImmGetCompositionStringW
330 # define pImmGetContext ImmGetContext 331 # define pImmGetContext ImmGetContext
334 # define pImmSetOpenStatus ImmSetOpenStatus 335 # define pImmSetOpenStatus ImmSetOpenStatus
335 # define pImmGetCompositionFont ImmGetCompositionFontA 336 # define pImmGetCompositionFont ImmGetCompositionFontA
336 # define pImmSetCompositionFont ImmSetCompositionFontA 337 # define pImmSetCompositionFont ImmSetCompositionFontA
337 # define pImmSetCompositionWindow ImmSetCompositionWindow 338 # define pImmSetCompositionWindow ImmSetCompositionWindow
338 # define pImmGetConversionStatus ImmGetConversionStatus 339 # define pImmGetConversionStatus ImmGetConversionStatus
340 # define pImmSetConversionStatus ImmSetConversionStatus
339 #endif 341 #endif
340 342
341 #ifndef ETO_IGNORELANGUAGE 343 #ifndef ETO_IGNORELANGUAGE
342 # define ETO_IGNORELANGUAGE 0x1000 344 # define ETO_IGNORELANGUAGE 0x1000
343 #endif 345 #endif
1712 } 1714 }
1713 1715
1714 hImc = pImmGetContext(s_hwnd); 1716 hImc = pImmGetContext(s_hwnd);
1715 if (hImc) 1717 if (hImc)
1716 { 1718 {
1719 /*
1720 * for Korean ime
1721 */
1722 HKL hKL = GetKeyboardLayout(0);
1723
1724 if (LOWORD(hKL) == MAKELANGID(LANG_KOREAN, SUBLANG_KOREAN))
1725 {
1726 static DWORD dwConversionSaved = 0, dwSentenceSaved = 0;
1727 static BOOL bSaved = FALSE;
1728
1729 if (active)
1730 {
1731 /* if we have a saved conversion status, restore it */
1732 if (bSaved)
1733 pImmSetConversionStatus(hImc, dwConversionSaved,
1734 dwSentenceSaved);
1735 bSaved = FALSE;
1736 }
1737 else
1738 {
1739 /* save conversion status and disable korean */
1740 if (pImmGetConversionStatus(hImc, &dwConversionSaved,
1741 &dwSentenceSaved))
1742 {
1743 bSaved = TRUE;
1744 pImmSetConversionStatus(hImc,
1745 dwConversionSaved & ~(IME_CMODE_NATIVE
1746 | IME_CMODE_FULLSHAPE),
1747 dwSentenceSaved);
1748 }
1749 }
1750 }
1751
1717 pImmSetOpenStatus(hImc, active); 1752 pImmSetOpenStatus(hImc, active);
1718 pImmReleaseContext(s_hwnd, hImc); 1753 pImmReleaseContext(s_hwnd, hImc);
1719 } 1754 }
1720 } 1755 }
1721 } 1756 }
1783 static void 1818 static void
1784 latin9_to_ucs(char_u *text, int len, WCHAR *unicodebuf) 1819 latin9_to_ucs(char_u *text, int len, WCHAR *unicodebuf)
1785 { 1820 {
1786 int c; 1821 int c;
1787 1822
1788 while (len-- >= 0) 1823 while (--len >= 0)
1789 { 1824 {
1790 c = *text++; 1825 c = *text++;
1791 switch (c) 1826 switch (c)
1792 { 1827 {
1793 case 0xa4: c = 0x20ac; break; /* euro */ 1828 case 0xa4: c = 0x20ac; break; /* euro */
2019 2054
2020 if (enc_utf8 && n < len && unicodebuf != NULL) 2055 if (enc_utf8 && n < len && unicodebuf != NULL)
2021 { 2056 {
2022 /* Output UTF-8 characters. Caller has already separated 2057 /* Output UTF-8 characters. Caller has already separated
2023 * composing characters. */ 2058 * composing characters. */
2024 int i = 0; 2059 int i;
2025 int clen; /* string length up to composing char */ 2060 int wlen; /* string length in words */
2061 int clen; /* string length in characters */
2026 int cells; /* cell width of string up to composing char */ 2062 int cells; /* cell width of string up to composing char */
2027 int cw; /* width of current cell */ 2063 int cw; /* width of current cell */
2028 int c; 2064 int c;
2029 int xtra; 2065
2030 2066 wlen = 0
2067 clen = 0;
2031 cells = 0; 2068 cells = 0;
2032 for (clen = 0; i < len; ) 2069 for (i = 0; i < len; )
2033 { 2070 {
2034 c = utf_ptr2char(text + i); 2071 c = utf_ptr2char(text + i);
2035 if (c >= 0x10000) 2072 if (c >= 0x10000)
2036 { 2073 {
2037 /* Turn into UTF-16 encoding. */ 2074 /* Turn into UTF-16 encoding. */
2038 unicodebuf[clen] = ((c - 0x10000) >> 10) + 0xD800; 2075 unicodebuf[wlen++] = ((c - 0x10000) >> 10) + 0xD800;
2039 unicodebuf[clen + 1] = ((c - 0x10000) & 0x3ff) + 0xDC00; 2076 unicodebuf[wlen++] = ((c - 0x10000) & 0x3ff) + 0xDC00;
2040 xtra = 1;
2041 } 2077 }
2042 else 2078 else
2043 { 2079 {
2044 unicodebuf[clen] = c; 2080 unicodebuf[wlen++] = c;
2045 xtra = 0;
2046 } 2081 }
2047 cw = utf_char2cells(c); 2082 cw = utf_char2cells(c);
2048 if (cw > 2) /* don't use 4 for unprintable char */ 2083 if (cw > 2) /* don't use 4 for unprintable char */
2049 cw = 1; 2084 cw = 1;
2050 if (unicodepdy != NULL) 2085 if (unicodepdy != NULL)
2051 { 2086 {
2052 /* Use unicodepdy to make characters fit as we expect, even 2087 /* Use unicodepdy to make characters fit as we expect, even
2053 * when the font uses different widths (e.g., bold character 2088 * when the font uses different widths (e.g., bold character
2054 * is wider). */ 2089 * is wider). */
2055 unicodepdy[clen] = cw * gui.char_width; 2090 unicodepdy[clen] = cw * gui.char_width;
2056 if (xtra == 1)
2057 unicodepdy[clen + 1] = cw * gui.char_width;
2058 } 2091 }
2059 cells += cw; 2092 cells += cw;
2060 i += utfc_ptr2len_len(text + i, len - i); 2093 i += utfc_ptr2len_len(text + i, len - i);
2061 clen += xtra + 1; 2094 ++clen;
2062 } 2095 }
2063 ExtTextOutW(s_hdc, TEXT_X(col), TEXT_Y(row), 2096 ExtTextOutW(s_hdc, TEXT_X(col), TEXT_Y(row),
2064 foptions, pcliprect, unicodebuf, clen, unicodepdy); 2097 foptions, pcliprect, unicodebuf, wlen, unicodepdy);
2065 len = cells; /* used for underlining */ 2098 len = cells; /* used for underlining */
2066 } 2099 }
2067 else if ((enc_codepage > 0 && (int)GetACP() != enc_codepage) || enc_latin9) 2100 else if ((enc_codepage > 0 && (int)GetACP() != enc_codepage) || enc_latin9)
2068 { 2101 {
2069 /* If we want to display codepage data, and the current CP is not the 2102 /* If we want to display codepage data, and the current CP is not the
3892 = (void *)GetProcAddress(hLibImm, "ImmSetCompositionFontA"); 3925 = (void *)GetProcAddress(hLibImm, "ImmSetCompositionFontA");
3893 pImmSetCompositionWindow 3926 pImmSetCompositionWindow
3894 = (void *)GetProcAddress(hLibImm, "ImmSetCompositionWindow"); 3927 = (void *)GetProcAddress(hLibImm, "ImmSetCompositionWindow");
3895 pImmGetConversionStatus 3928 pImmGetConversionStatus
3896 = (void *)GetProcAddress(hLibImm, "ImmGetConversionStatus"); 3929 = (void *)GetProcAddress(hLibImm, "ImmGetConversionStatus");
3930 pImmSetConversionStatus
3931 = (void *)GetProcAddress(hLibImm, "ImmSetConversionStatus");
3897 3932
3898 if ( pImmGetCompositionStringA == NULL 3933 if ( pImmGetCompositionStringA == NULL
3899 || pImmGetCompositionStringW == NULL 3934 || pImmGetCompositionStringW == NULL
3900 || pImmGetContext == NULL 3935 || pImmGetContext == NULL
3901 || pImmAssociateContext == NULL 3936 || pImmAssociateContext == NULL
3903 || pImmGetOpenStatus == NULL 3938 || pImmGetOpenStatus == NULL
3904 || pImmSetOpenStatus == NULL 3939 || pImmSetOpenStatus == NULL
3905 || pImmGetCompositionFont == NULL 3940 || pImmGetCompositionFont == NULL
3906 || pImmSetCompositionFont == NULL 3941 || pImmSetCompositionFont == NULL
3907 || pImmSetCompositionWindow == NULL 3942 || pImmSetCompositionWindow == NULL
3908 || pImmGetConversionStatus == NULL) 3943 || pImmGetConversionStatus == NULL
3944 || pImmSetConversionStatus == NULL)
3909 { 3945 {
3910 FreeLibrary(hLibImm); 3946 FreeLibrary(hLibImm);
3911 hLibImm = NULL; 3947 hLibImm = NULL;
3912 pImmGetContext = NULL; 3948 pImmGetContext = NULL;
3913 return; 3949 return;