To: vim-dev@vim.org Subject: Patch 6.1.228 (extra) Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.1.228 (extra) Problem: Win32: The special output function for Hangul is used too often, causing special handling for other situations to be skipped. bInComposition is always FALSE, causing ImeGetTempComposition() always to return NULL. Solution: Remove HanExtTextOut(). Delete the dead code around bInComposition and ImeGetTempComposition(). Files: src/gui_w16.c, src/gui_w32.c, src/gui_w48.c *** ../vim61.227/src/gui_w16.c Sun Jun 9 20:34:00 2002 --- src/gui_w16.c Tue Oct 15 21:00:14 2002 *************** *** 356,365 **** #endif return 0; - case WM_CREATE: /* HANDLE_MSG doesn't seem to handle this one */ - return _OnCreate (hwnd, (LPCREATESTRUCT)lParam); - - #if defined(MENUHINTS) && defined(FEAT_MENU) case WM_MENUSELECT: if (((UINT) LOWORD(lParam) --- 356,361 ---- *************** *** 764,772 **** */ HBRUSH hbr; RECT rc; - #ifdef FEAT_MBYTE_IME - char *szComp; - #endif if (!(flags & DRAW_TRANSP)) { --- 760,765 ---- *** ../vim61.227/src/gui_w32.c Mon Oct 14 20:18:19 2002 --- src/gui_w32.c Tue Oct 15 21:00:20 2002 *************** *** 729,737 **** #endif return 0; - case WM_CREATE: /* HANDLE_MSG doesn't seem to handle this one */ - return _OnCreate (hwnd, (LPCREATESTRUCT)lParam); - case WM_SIZING: /* HANDLE_MSG doesn't seem to handle this one */ return _DuringSizing(hwnd, (UINT)wParam, (LPRECT)lParam); --- 729,734 ---- *************** *** 1237,1244 **** } - - /* * Set the current text foreground color. */ --- 1234,1239 ---- *************** *** 1259,1341 **** #if defined(FEAT_MBYTE) && defined(FEAT_MBYTE_IME) /* ! * Multi-byte handling, by Sung-Hoon Baek * First static functions (no prototypes generated). */ - static void - HanExtTextOut(HDC hdc, int X, int Y, UINT fuOption, const RECT *lprc, - LPCTSTR lpString, UINT cbCount, const int *lpDx, BOOL bOpaque) - { - LPCTSTR pszTemp; - int i; - HPEN hpen, old_pen; - POINT point; - int n; - - if (gui.char_width == sysfixed_width && gui.char_height == sysfixed_height) - { - hpen = CreatePen(PS_SOLID, 2, gui.currFgColor); - old_pen = SelectObject(hdc, hpen); - - pszTemp = lpString; - i = 0; - while (cbCount > 0) - { - if (cbCount > 1 && (n = MB_BYTE2LEN(*(char_u *)pszTemp)) > 1) - { - cbCount -= n; - pszTemp += n; - i += n; - } - else if (*pszTemp == '\\') - { - if (i > 0) - ExtTextOut(hdc, X+((pszTemp-i)-lpString)*gui.char_width, Y, - fuOption, lprc, pszTemp-i, i, lpDx); - MoveToEx(hdc, (int)(X+(pszTemp-lpString)*gui.char_width - + gui.char_width*0.2), - (int)(Y + gui.char_height*0.2), &point); - LineTo(hdc, (int)(X+(pszTemp-lpString)*gui.char_width - + gui.char_width*0.8), - (int)(Y + gui.char_height*0.75)); - pszTemp++; - cbCount--; - i = 0; - } - else - { - pszTemp++; - cbCount--; - i++; - } - } - if (i > 0) - { - int OldBkMode = 0; - - if (bOpaque) - { - OldBkMode = GetBkMode(hdc); - SetBkMode(hdc, OPAQUE); - } - ExtTextOut(hdc, X+((pszTemp-i)-lpString)*gui.char_width, Y, - fuOption, lprc, pszTemp-i, i, lpDx); - if (bOpaque) - SetBkMode(hdc, OldBkMode); - } - - DeleteObject(SelectObject(hdc, old_pen)); - } - else - ExtTextOut(hdc, X, Y, fuOption, lprc, lpString, cbCount, lpDx); - } - #include #include - static BOOL bInComposition=FALSE; - /* * display composition string(korean) */ --- 1254,1266 ---- #if defined(FEAT_MBYTE) && defined(FEAT_MBYTE_IME) /* ! * Multi-byte handling, originally by Sung-Hoon Baek. * First static functions (no prototypes generated). */ #include #include /* * display composition string(korean) */ *************** *** 1495,1523 **** vim_free(buf); return convbuf; } - - static char_u * - ImeGetTempComposition(void) - { - if (bInComposition == TRUE) - { - HIMC hImc; - DWORD dwConvMode, dwSentMode; - - if (pImmGetContext && (hImc = pImmGetContext(s_hwnd))) - { - pImmGetConversionStatus(hImc, &dwConvMode, &dwSentMode); - pImmReleaseContext(s_hwnd, hImc); - if (dwConvMode & IME_CMODE_NATIVE) - { - return GetResultStr(s_hwnd, GCS_COMPSTR); - } - } - } - return NULL; - } - #endif /* For global functions we need prototypes. */ #if (defined(FEAT_MBYTE) && defined(FEAT_MBYTE_IME)) || defined(PROTO) --- 1420,1427 ---- vim_free(buf); return convbuf; } #endif + /* For global functions we need prototypes. */ #if (defined(FEAT_MBYTE) && defined(FEAT_MBYTE_IME)) || defined(PROTO) *************** *** 1722,1730 **** static int brush_lru = 0; HBRUSH hbr; RECT rc; - #ifdef FEAT_MBYTE_IME - char_u *szComp; - #endif if (!(flags & DRAW_TRANSP)) { --- 1626,1631 ---- *************** *** 1813,1914 **** * versions. * No check for DRAW_BOLD, Windows will have done it already. */ ! #ifdef FEAT_MBYTE_IME ! if (enc_dbcs != 0) ! { ! /* draw an incomplete composition character (korean) */ ! if (len == 1 && blink_state == BLINK_ON ! && (szComp = ImeGetTempComposition()) != NULL) // hangul ! { ! HanExtTextOut(s_hdc, TEXT_X(col), TEXT_Y(row), ! foptions, pcliprect, szComp, 2, padding, TRUE); ! vim_free(szComp); } else ! HanExtTextOut(s_hdc, TEXT_X(col), TEXT_Y(row), ! foptions, pcliprect, (char *)text, len, padding, FALSE); } else #endif { ! #ifdef FEAT_MBYTE ! /* Check if there are any UTF-8 characters. If not, use normal text ! * output to speed up output. */ ! if (enc_utf8) ! for (n = 0; n < len; ++n) ! if (text[n] >= 0x80) ! break; ! ! /* Check if the Unicode buffer exists and is big enough. Create it ! * with the same lengt as the multi-byte string, the number of wide ! * characters is always equal or smaller. */ ! if ((enc_utf8 || is_funky_dbcs) ! && (unicodebuf == NULL || len > unibuflen)) ! { ! vim_free(unicodebuf); ! unicodebuf = (WCHAR *)alloc(len * sizeof(WCHAR)); ! unibuflen = len; ! } ! ! if (enc_utf8 && n < len && unicodebuf != NULL) { - /* Output UTF-8 characters. Caller has already separated - * composing characters. */ - int i = 0; - int clen; /* string length up to composing char */ - int cells; /* cell width of string up to composing char */ - - cells = 0; - for (clen = 0; i < len; ) - { - unicodebuf[clen] = utf_ptr2char(text + i); - cells += utf_char2cells(unicodebuf[clen]); - i += utfc_ptr2len_check_len(text + i, len - i); - ++clen; - } if (os_version.dwPlatformId == VER_PLATFORM_WIN32_NT) ! ExtTextOutW(s_hdc, TEXT_X(col), TEXT_Y(row), ! foptions | ETO_IGNORELANGUAGE, ! pcliprect, unicodebuf, clen, NULL); else ! ExtTextOutW(s_hdc, TEXT_X(col), TEXT_Y(row), ! foptions, pcliprect, unicodebuf, clen, NULL); ! len = cells; /* used for underlining */ ! } ! else if (is_funky_dbcs) ! { ! /* If we want to display DBCS, and the current CP is not the DBCS ! * one, we need to go via Unicode. */ ! if (unicodebuf != NULL) ! { ! if ((len = MultiByteToWideChar(enc_dbcs, ! MB_PRECOMPOSED, ! (char *)text, len, ! (LPWSTR)unicodebuf, unibuflen))) ! ExtTextOutW(s_hdc, TEXT_X(col), TEXT_Y(row), ! foptions, pcliprect, unicodebuf, len, NULL); ! } } else #endif ! { ! #ifdef FEAT_RIGHTLEFT ! /* ron: fixed Hebrew on Win98/Win2000 */ ! if (curwin->w_p_rl) ! { ! if (os_version.dwPlatformId == VER_PLATFORM_WIN32_NT) ! ExtTextOut(s_hdc, TEXT_X(col), TEXT_Y(row), ! foptions | ETO_IGNORELANGUAGE, ! pcliprect, (char *)text, len, padding); ! else ! RevOut(s_hdc, TEXT_X(col), TEXT_Y(row), ! foptions, pcliprect, (char *)text, len, padding); ! } ! else ! #endif ! ExtTextOut(s_hdc, TEXT_X(col), TEXT_Y(row), ! foptions, pcliprect, (char *)text, len, padding); ! } } if (flags & DRAW_UNDERL) --- 1714,1796 ---- * versions. * No check for DRAW_BOLD, Windows will have done it already. */ ! ! #ifdef FEAT_MBYTE ! /* Check if there are any UTF-8 characters. If not, use normal text ! * output to speed up output. */ ! if (enc_utf8) ! for (n = 0; n < len; ++n) ! if (text[n] >= 0x80) ! break; ! ! /* Check if the Unicode buffer exists and is big enough. Create it ! * with the same lengt as the multi-byte string, the number of wide ! * characters is always equal or smaller. */ ! if ((enc_utf8 || is_funky_dbcs) && (unicodebuf == NULL || len > unibuflen)) ! { ! vim_free(unicodebuf); ! unicodebuf = (WCHAR *)alloc(len * sizeof(WCHAR)); ! unibuflen = len; ! } ! ! if (enc_utf8 && n < len && unicodebuf != NULL) ! { ! /* Output UTF-8 characters. Caller has already separated ! * composing characters. */ ! int i = 0; ! int clen; /* string length up to composing char */ ! int cells; /* cell width of string up to composing char */ ! ! cells = 0; ! for (clen = 0; i < len; ) ! { ! unicodebuf[clen] = utf_ptr2char(text + i); ! cells += utf_char2cells(unicodebuf[clen]); ! i += utfc_ptr2len_check_len(text + i, len - i); ! ++clen; } + if (os_version.dwPlatformId == VER_PLATFORM_WIN32_NT) + ExtTextOutW(s_hdc, TEXT_X(col), TEXT_Y(row), + foptions | ETO_IGNORELANGUAGE, + pcliprect, unicodebuf, clen, NULL); else ! ExtTextOutW(s_hdc, TEXT_X(col), TEXT_Y(row), ! foptions, pcliprect, unicodebuf, clen, NULL); ! len = cells; /* used for underlining */ ! } ! else if (is_funky_dbcs) ! { ! /* If we want to display DBCS, and the current CP is not the DBCS ! * one, we need to go via Unicode. */ ! if (unicodebuf != NULL) ! { ! if ((len = MultiByteToWideChar(enc_dbcs, ! MB_PRECOMPOSED, ! (char *)text, len, ! (LPWSTR)unicodebuf, unibuflen))) ! ExtTextOutW(s_hdc, TEXT_X(col), TEXT_Y(row), ! foptions, pcliprect, unicodebuf, len, NULL); ! } } else #endif { ! #ifdef FEAT_RIGHTLEFT ! /* ron: fixed Hebrew on Win98/Win2000 */ ! if (curwin->w_p_rl) { if (os_version.dwPlatformId == VER_PLATFORM_WIN32_NT) ! ExtTextOut(s_hdc, TEXT_X(col), TEXT_Y(row), ! foptions | ETO_IGNORELANGUAGE, ! pcliprect, (char *)text, len, padding); else ! RevOut(s_hdc, TEXT_X(col), TEXT_Y(row), ! foptions, pcliprect, (char *)text, len, padding); } else #endif ! ExtTextOut(s_hdc, TEXT_X(col), TEXT_Y(row), ! foptions, pcliprect, (char *)text, len, padding); } if (flags & DRAW_UNDERL) *** ../vim61.227/src/gui_w48.c Sun Oct 13 20:08:14 2002 --- src/gui_w48.c Tue Oct 15 21:00:25 2002 *************** *** 190,200 **** # define MyTranslateMessage(x) TranslateMessage(x) #endif - #ifdef FEAT_MBYTE - static int sysfixed_width = 0; - static int sysfixed_height = 0; - #endif - extern int current_font_height; /* this is in os_mswin.c */ static struct --- 190,195 ---- *************** *** 2221,2255 **** /* we call gui_focus_change() in _OnSetFocus() */ /* gui_focus_change((int)fActivate); */ return DefWindowProc(hwnd, WM_ACTIVATEAPP, fActivate, (DWORD)dwThreadId); - } - - static BOOL - _OnCreate(HWND hwnd, LPCREATESTRUCT lpcs) - { - #ifdef FEAT_MBYTE - /* get system fixed font size*/ - static const char ach[] = {'W', 'f', 'g', 'M'}; - - HDC hdc = GetWindowDC(hwnd); - HFONT hfntOld = SelectFont(hdc, GetStockObject(SYSTEM_FIXED_FONT)); - SIZE siz; - - GetTextExtentPoint(hdc, ach, sizeof(ach), &siz); - - sysfixed_width = siz.cx / sizeof(ach); - /* - * Make characters one pixel higher (by default), so that italic and bold - * fonts don't draw off the bottom of their character space. Also means - * that we can underline an underscore for normal text. - */ - sysfixed_height = siz.cy + p_linespace; - - SelectFont(hdc, hfntOld); - - ReleaseDC(hwnd, hdc); - #endif - - return 0; } #if defined(FEAT_WINDOWS) || defined(PROTO) --- 2216,2221 ---- *** ../vim61.227/src/version.c Mon Oct 14 21:43:21 2002 --- src/version.c Tue Oct 15 20:56:05 2002 *************** *** 608,609 **** --- 608,611 ---- { /* Add new patch number below this line */ + /**/ + 228, /**/ -- hundred-and-one symptoms of being an internet addict: 234. You started college as a chemistry major, and walk out four years later as an Internet provider. /// Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net \\\ /// Creator of Vim - Vi IMproved -- http://www.vim.org \\\ \\\ Project leader for A-A-P -- http://www.a-a-p.org /// \\\ Lord Of The Rings helps Uganda - http://iccf-holland.org/lotr.html ///