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

[vim-multibyte] IME font and compotision window

Expand Messages
  • Taro Muraoka
    IME font is not changed when screen font is changed. IME composition window does not trace cursor. Please test. ... Taro Muraoka Problem:
    Message 1 of 5 , Jan 22, 2000
    • 0 Attachment
      IME font is not changed when screen font is changed.
      IME composition window does not trace cursor.

      Please test.
      ----
      Taro Muraoka <koron@...>


      Problem: IME font is not changed when screen font is changed. And IME
      composition window does not trace cursor.
      Solution: Initialize IME font. And, when cursor is moved, set IME
      composition window (add new function ImeSetCompotionWindow).
      Files: src/gui.c src/gui_w32.c src/proto/gui_w32.pro


      diff -cr src.orig/gui.c src/gui.c
      *** src.orig/gui.c Sun Jan 16 20:30:34 2000
      --- src/gui.c Sat Jan 22 20:03:44 2000
      ***************
      *** 683,688 ****
      --- 683,692 ----
      gui_undraw_cursor();
      if (gui.row <0)
      return;
      + #if defined(MULTI_BYTE_IME) && defined(USE_GUI_MSWIN)
      + if (gui.row != gui.cursor_row || gui.col != gui.cursor_col)
      + ImeSetCompositionWindow();
      + #endif
      gui.cursor_row = gui.row;
      gui.cursor_col = gui.col;
      gui.cursor_is_valid = TRUE;
      diff -cr src.orig/gui_w32.c src/gui_w32.c
      *** src.orig/gui_w32.c Sat Jan 22 15:20:36 2000
      --- src/gui_w32.c Sat Jan 22 20:06:08 2000
      ***************
      *** 2641,2646 ****
      --- 2641,2655 ----
      font_name = lf.lfFaceName;
      #ifdef MULTI_BYTE_IME
      norm_logfont = lf;
      + {
      + /* Initialize font for IME */
      + HIMC hImc;
      + if ((hImc = ImmGetContext(s_hwnd)))
      + {
      + ImmSetCompositionFont( hImc, &norm_logfont );
      + ImmReleaseContext( s_hwnd, hImc );
      + }
      + }
      #endif
      gui_mch_free_font(gui.norm_font);
      gui.norm_font = font;
      ***************
      *** 3027,3039 ****


      /*
      * When enter to insert mode, set IME to previous language mode
      */
      void
      ImeSetOriginMode(void)
      {
      HIMC hImc;
      ! DWORD dwConvMode, dwSentMode;

      if ((hImc = ImmGetContext(s_hwnd)))
      {
      --- 3036,3068 ----


      /*
      + * Set IME composition window's position
      + */
      + void
      + ImeSetCompositionWindow(void)
      + {
      + HIMC hImc;
      + if ((hImc = ImmGetContext(s_hwnd)))
      + {
      + COMPOSITIONFORM cfs;
      + cfs.dwStyle = CFS_POINT;
      + cfs.ptCurrentPos.x = FILL_X(gui.col);
      + cfs.ptCurrentPos.y = FILL_Y(gui.row);
      + MapWindowPoints(s_textArea, s_hwnd, &cfs.ptCurrentPos, 1);
      + ImmSetCompositionWindow(hImc, &cfs);
      + ImmReleaseContext(s_hwnd, hImc);
      + }
      + }
      +
      +
      + /*
      * When enter to insert mode, set IME to previous language mode
      */
      void
      ImeSetOriginMode(void)
      {
      HIMC hImc;
      ! /* DWORD dwConvMode, dwSentMode; /* no use */

      if ((hImc = ImmGetContext(s_hwnd)))
      {
      ***************
      *** 3043,3048 ****
      --- 3072,3078 ----
      }
      else
      bImeOpenStatus = FALSE;
      + ImmReleaseContext(s_hwnd, hImc);
      }
      bCommandMode = FALSE;
      }
      ***************
      *** 3065,3070 ****
      --- 3095,3101 ----
      }
      else
      bImeOpenStatus = FALSE;
      + ImmReleaseContext(s_hwnd, hImc);
      }
      bCommandMode = TRUE;
      }
      ***************
      *** 3191,3196 ****
      --- 3222,3228 ----
      if ((hImc = ImmGetContext(s_hwnd)))
      {
      ImmGetConversionStatus(hImc, &dwConvMode, &dwSentMode);
      + ImmReleaseContext(s_hwnd, hImc);
      if ((dwConvMode & IME_CMODE_NATIVE))
      return lpCompStr;
      }
      diff -cr src.orig/proto/gui_w32.pro src/proto/gui_w32.pro
      *** src.orig/proto/gui_w32.pro Sun Jan 16 22:23:20 2000
      --- src/proto/gui_w32.pro Sat Jan 22 20:03:44 2000
      ***************
      *** 28,33 ****
      --- 28,34 ----
      GuiColor gui_mch_get_color __ARGS((char_u *name));
      void gui_mch_set_fg_color __ARGS((GuiColor color));
      void gui_mch_set_bg_color __ARGS((GuiColor color));
      + void ImeSetCompositionWindow __ARGS((void));
      void ImeSetOriginMode __ARGS((void));
      void ImeSetEnglishMode __ARGS((void));
      void gui_mch_draw_string __ARGS((int row, int col, char_u *s, int len, int flags));
    • Bram Moolenaar
      ... It looks OK (didn t compile it though). It seems the computation of the position is now doubled. Let s move it into a function, so that it only appears
      Message 2 of 5 , Jan 22, 2000
      • 0 Attachment
        Taro Muraoka wrote:

        > IME font is not changed when screen font is changed.
        > IME composition window does not trace cursor.
        >
        > Please test.

        It looks OK (didn't compile it though).

        It seems the computation of the position is now doubled. Let's move it into a
        function, so that it only appears once. I'll include my alternative patch for
        gui_w32.c below.

        > + ImmReleaseContext(s_hwnd, hImc);

        Does this line also need to be added in ImeNotify()? It does call
        ImmGetContext(), shouldn't these always be called in pairs?

        *** ../../vim-5.6.6/src/gui_w32.c Fri Jan 21 12:14:46 2000
        --- gui_w32.c Sat Jan 22 17:59:39 2000
        ***************
        *** 148,153 ****
        --- 148,154 ----
        # define LPCTSTR int
        # define OSVERSIONINFO int
        # define HBRUSH int
        + # define HIMC int
        #endif

        /* For the Intellimouse: */
        ***************
        *** 2641,2646 ****
        --- 2642,2657 ----
        font_name = lf.lfFaceName;
        #ifdef MULTI_BYTE_IME
        norm_logfont = lf;
        + {
        + HIMC hImc;
        +
        + /* Initialize font for IME */
        + if ((hImc = ImmGetContext(s_hwnd)))
        + {
        + ImmSetCompositionFont(hImc, &norm_logfont);
        + ImmReleaseContext(s_hwnd, hImc);
        + }
        + }
        #endif
        gui_mch_free_font(gui.norm_font);
        gui.norm_font = font;
        ***************
        *** 3025,3030 ****
        --- 3036,3071 ----
        SetBkMode(s_hdc,OldBkMode);
        }

        + /*
        + * Position IME composition window.
        + */
        + static void
        + ImePositionWindow(HIMC hImc)
        + {
        + COMPOSITIONFORM cfs;
        +
        + cfs.dwStyle = CFS_POINT;
        + cfs.ptCurrentPos.x = FILL_X(gui.col);
        + cfs.ptCurrentPos.y = FILL_Y(gui.row);
        + MapWindowPoints(s_textArea, s_hwnd, &cfs.ptCurrentPos, 1);
        + ImmSetCompositionWindow(hImc, &cfs);
        + }
        +
        + /*
        + * Get context and position IME composition window.
        + */
        + void
        + ImeSetCompositionWindow(void)
        + {
        + HIMC hImc;
        +
        + if ((hImc = ImmGetContext(s_hwnd)))
        + {
        + ImePositionWindow(hImc);
        + ImmReleaseContext(s_hwnd, hImc);
        + }
        + }
        +

        /*
        * When enter to insert mode, set IME to previous language mode
        ***************
        *** 3033,3048 ****
        ImeSetOriginMode(void)
        {
        HIMC hImc;
        - DWORD dwConvMode, dwSentMode;

        if ((hImc = ImmGetContext(s_hwnd)))
        {
        if (!ImmGetOpenStatus(hImc) && bImeOpenStatus == TRUE)
        ! {
        ! ImmSetOpenStatus(hImc, TRUE);
        ! }
        else
        bImeOpenStatus = FALSE;
        }
        bCommandMode = FALSE;
        }
        --- 3074,3087 ----
        ImeSetOriginMode(void)
        {
        HIMC hImc;

        if ((hImc = ImmGetContext(s_hwnd)))
        {
        if (!ImmGetOpenStatus(hImc) && bImeOpenStatus == TRUE)
        ! ImmSetOpenStatus(hImc, TRUE);
        else
        bImeOpenStatus = FALSE;
        + ImmReleaseContext(s_hwnd, hImc);
        }
        bCommandMode = FALSE;
        }
        ***************
        *** 3065,3070 ****
        --- 3104,3110 ----
        }
        else
        bImeOpenStatus = FALSE;
        + ImmReleaseContext(s_hwnd, hImc);
        }
        bCommandMode = TRUE;
        }
        ***************
        *** 3191,3196 ****
        --- 3231,3237 ----
        if ((hImc = ImmGetContext(s_hwnd)))
        {
        ImmGetConversionStatus(hImc, &dwConvMode, &dwSentMode);
        + ImmReleaseContext(s_hwnd, hImc);
        if ((dwConvMode & IME_CMODE_NATIVE))
        return lpCompStr;
        }
        ***************
        *** 3203,3209 ****
        {
        HIMC hImc;
        DWORD dwConvMode, dwSentMode;
        - COMPOSITIONFORM cf;

        if ((hImc = ImmGetContext(s_hwnd)))
        {
        --- 3244,3249 ----
        ***************
        *** 3213,3234 ****
        RECT t_rct;
        RECT w_rct;
        if (w = IMN_SETOPENSTATUS && GetWindowRect(s_textArea, &t_rct)
        ! && GetWindowRect(s_hwnd, &w_rct))
        {
        ImmSetCompositionFont(hImc, &norm_logfont);
        ! cf.dwStyle = CFS_POINT;
        ! cf.ptCurrentPos.x = TEXT_X(gui.col) + gui.border_offset;
        ! cf.ptCurrentPos.y = TEXT_Y(gui.row) + gui.border_offset;
        ! #ifdef WANT_MENU
        ! if (gui.menu_is_active)
        ! cf.ptCurrentPos.y += gui.menu_height;
        ! #endif
        ! #ifdef USE_TOOLBAR
        ! if (vim_strchr(p_go, GO_TOOLBAR) != NULL)
        ! cf.ptCurrentPos.y +=
        ! TOOLBAR_BUTTON_HEIGHT + TOOLBAR_BORDER_HEIGHT;
        ! #endif
        ! ImmSetCompositionWindow(hImc, &cf);
        }
        bImeNative = TRUE;
        }
        --- 3253,3262 ----
        RECT t_rct;
        RECT w_rct;
        if (w = IMN_SETOPENSTATUS && GetWindowRect(s_textArea, &t_rct)
        ! && GetWindowRect(s_hwnd, &w_rct))
        {
        ImmSetCompositionFont(hImc, &norm_logfont);
        ! ImePositionWindow(hImc);
        }
        bImeNative = TRUE;
        }
        --
        TALL KNIGHT: We shall say Ni! again to you if you do not appease us.
        ARTHUR: All right! What do you want?
        TALL KNIGHT: We want ... a shrubbery!
        "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

        --/-/---- Bram Moolenaar ---- Bram@... ---- Bram@... ---\-\--
        \ \ www.vim.org/iccf www.moolenaar.net www.vim.org / /
      • Taro Muraoka
        ... I compiled it. It works fine. ... Yes, it needs. There is alternative patch below. ... Taro Muraoka ... *************** *** 3250,3259
        Message 3 of 5 , Jan 22, 2000
        • 0 Attachment
          Bram Moolenaar wrote:

          > It seems the computation of the position is now doubled. Let's move it into a
          > function, so that it only appears once. I'll include my alternative patch for
          > gui_w32.c below.

          I compiled it. It works fine.

          > > + ImmReleaseContext(s_hwnd, hImc);
          >
          > Does this line also need to be added in ImeNotify()? It does call
          > ImmGetContext(), shouldn't these always be called in pairs?

          Yes, it needs. There is alternative patch below.
          ----
          Taro Muraoka <koron@...>


          *** bram.patched.gui_w32.c Sun Jan 23 13:41:16 2000
          --- gui_w32.c Sun Jan 23 14:27:12 2000
          ***************
          *** 3250,3259 ****
          ImmGetConversionStatus(hImc, &dwConvMode, &dwSentMode);
          if (dwConvMode & IME_CMODE_NATIVE)
          {
          ! RECT t_rct;
          ! RECT w_rct;
          ! if (w = IMN_SETOPENSTATUS && GetWindowRect(s_textArea, &t_rct)
          ! && GetWindowRect(s_hwnd, &w_rct))
          {
          ImmSetCompositionFont(hImc, &norm_logfont);
          ImePositionWindow(hImc);
          --- 3250,3256 ----
          ImmGetConversionStatus(hImc, &dwConvMode, &dwSentMode);
          if (dwConvMode & IME_CMODE_NATIVE)
          {
          ! if (w = IMN_SETOPENSTATUS)
          {
          ImmSetCompositionFont(hImc, &norm_logfont);
          ImePositionWindow(hImc);
          ***************
          *** 3262,3267 ****
          --- 3259,3265 ----
          }
          else
          bImeNative = FALSE;
          + ImmReleaseContext(s_hwnd, hImc);
          }
          }
        • Bram Moolenaar
          ... Good cleanup. But it made me look closer at this line: if (w = IMN_SETOPENSTATUS) The assignment doesn t have any effect. Shouldn t that be: if (w ==
          Message 4 of 5 , Jan 23, 2000
          • 0 Attachment
            Taro Muraoka wrote:

            > > > + ImmReleaseContext(s_hwnd, hImc);
            > >
            > > Does this line also need to be added in ImeNotify()? It does call
            > > ImmGetContext(), shouldn't these always be called in pairs?
            >
            > Yes, it needs. There is alternative patch below.

            Good cleanup. But it made me look closer at this line:

            if (w = IMN_SETOPENSTATUS)

            The assignment doesn't have any effect. Shouldn't that be:

            if (w == IMN_SETOPENSTATUS)

            Please test if it still works then (I can't compile with IME support).

            --
            CONCORDE: Message for you, sir.
            He falls forward revealing the arrow with the note.
            "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

            --/-/---- Bram Moolenaar ---- Bram@... ---- Bram@... ---\-\--
            \ \ www.vim.org/iccf www.moolenaar.net www.vim.org / /
          • Taro Muraoka
            ... Oh! yes. There was a bug in original gui_w32.c. I didn t notice that. I have fixed this and compiled. It seems to work very good. ... Taro Muraoka
            Message 5 of 5 , Jan 23, 2000
            • 0 Attachment
              Bram Moolenaar wrote:

              > Good cleanup. But it made me look closer at this line:
              >
              > if (w = IMN_SETOPENSTATUS)
              >
              > The assignment doesn't have any effect. Shouldn't that be:
              >
              > if (w == IMN_SETOPENSTATUS)
              >
              > Please test if it still works then (I can't compile with IME support).

              Oh! yes. There was a bug in original gui_w32.c. I didn't notice that.
              I have fixed this and compiled. It seems to work very good.
              ----
              Taro Muraoka <koron@...>
            Your message has been successfully submitted and would be delivered to recipients shortly.