Loading ...
Sorry, an error occurred while loading the content.

Patch for Win32 with IME and "funky dbcs"

Expand Messages
  • Bram Moolenaar
    This patch should fix a problem when compiling the Win32 version with IME support and then using a DBCS codepage different from the system one. Please verify
    Message 1 of 1 , Oct 8, 2002
    • 0 Attachment
      This patch should fix a problem when compiling the Win32 version with
      IME support and then using a DBCS codepage different from the system
      one. Please verify this doesn't cause any trouble!

      Perhaps the whole HanExtTextOut() function can be deleted. It is
      currently only used for a specific size of a character, which looks
      weird to me.

      Problem: Win32: The special output function for Hangul is used too often,
      special handling for other situations is skipped.
      bInComposition is always FALSE, causing ImeGetTempComposition()
      always to return NULL.
      Solution: Check size of the font before deciding to call HanExtTextOut().
      Delete the dead code around bInComposition and
      ImeGetTempComposition().
      Files: src/gui_w16.c, src/gui_w32.c, src/gui_w48.c


      *** ../vim61.213/src/gui_w16.c Sun Jun 9 20:34:00 2002
      --- src/gui_w16.c Tue Oct 8 20:55:46 2002
      ***************
      *** 356,363 ****
      --- 356,365 ----
      #endif
      return 0;

      + #ifdef FEAT_MBYTE_IME
      case WM_CREATE: /* HANDLE_MSG doesn't seem to handle this one */
      return _OnCreate (hwnd, (LPCREATESTRUCT)lParam);
      + #endif


      #if defined(MENUHINTS) && defined(FEAT_MENU)
      *** ../vim61.213/src/gui_w32.c Mon Sep 16 22:00:32 2002
      --- src/gui_w32.c Tue Oct 8 21:03:29 2002
      ***************
      *** 729,736 ****
      --- 729,738 ----
      #endif
      return 0;

      + #ifdef FEAT_MBYTE_IME
      case WM_CREATE: /* HANDLE_MSG doesn't seem to handle this one */
      return _OnCreate (hwnd, (LPCREATESTRUCT)lParam);
      + #endif

      case WM_SIZING: /* HANDLE_MSG doesn't seem to handle this one */
      return _DuringSizing(hwnd, (UINT)wParam, (LPRECT)lParam);
      ***************
      *** 1273,1341 ****
      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 <ime.h>
      #include <imm.h>

      - static BOOL bInComposition=FALSE;
      -
      /*
      * display composition string(korean)
      */
      --- 1275,1336 ----
      POINT point;
      int n;

      ! 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));
      }

      #include <ime.h>
      #include <imm.h>

      /*
      * display composition string(korean)
      */
      ***************
      *** 1499,1527 ****
      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)

      --- 1490,1497 ----
      vim_free(buf);
      return convbuf;
      }
      #endif
      +
      /* For global functions we need prototypes. */
      #if (defined(FEAT_MBYTE) && defined(FEAT_MBYTE_IME)) || defined(PROTO)

      ***************
      *** 1818,1835 ****
      * 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
      --- 1788,1797 ----
      * No check for DRAW_BOLD, Windows will have done it already.
      */
      #ifdef FEAT_MBYTE_IME
      ! if (enc_dbcs != 0 && gui.char_width == sysfixed_width
      ! && gui.char_height == sysfixed_height)
      {
      ! HanExtTextOut(s_hdc, TEXT_X(col), TEXT_Y(row),
      foptions, pcliprect, (char *)text, len, padding, FALSE);
      }
      else
      *** ../vim61.213/src/gui_w48.c Mon Sep 16 22:00:32 2002
      --- src/gui_w48.c Tue Oct 8 20:55:33 2002
      ***************
      *** 190,196 ****
      # define MyTranslateMessage(x) TranslateMessage(x)
      #endif

      ! #ifdef FEAT_MBYTE
      static int sysfixed_width = 0;
      static int sysfixed_height = 0;
      #endif
      --- 190,196 ----
      # define MyTranslateMessage(x) TranslateMessage(x)
      #endif

      ! #ifdef FEAT_MBYTE_IME
      static int sysfixed_width = 0;
      static int sysfixed_height = 0;
      #endif
      ***************
      *** 2223,2233 ****
      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);
      --- 2223,2233 ----
      return DefWindowProc(hwnd, WM_ACTIVATEAPP, fActivate, (DWORD)dwThreadId);
      }

      + #ifdef FEAT_MBYTE_IME
      static BOOL
      _OnCreate(HWND hwnd, LPCREATESTRUCT lpcs)
      {
      ! /* get system fixed font size */
      static const char ach[] = {'W', 'f', 'g', 'M'};

      HDC hdc = GetWindowDC(hwnd);
      ***************
      *** 2237,2256 ****
      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)
      void
      --- 2237,2250 ----
      GetTextExtentPoint(hdc, ach, sizeof(ach), &siz);

      sysfixed_width = siz.cx / sizeof(ach);
      sysfixed_height = siz.cy + p_linespace;

      SelectFont(hdc, hfntOld);
      ReleaseDC(hwnd, hdc);

      return 0;
      }
      + #endif

      #if defined(FEAT_WINDOWS) || defined(PROTO)
      void

      --
      hundred-and-one symptoms of being an internet addict:
      166. You have been on your computer soo long that you didn't realize
      you had grandchildren.

      /// Bram Moolenaar -- Bram@... -- 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 ///
    Your message has been successfully submitted and would be delivered to recipients shortly.