home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / patches / 6.0.262 < prev    next >
Encoding:
Internet Message Format  |  2002-02-21  |  19.3 KB

  1. To: vim-dev@vim.org
  2. Subject: Patch 6.0.262 (extra)
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=ISO-8859-1
  7. Content-Transfer-Encoding: 8bit
  8. ------------
  9.  
  10. Patch 6.0.262 (extra)
  11. Problem:    Win32: IME doesn't work properly.  OnImeComposition() isn't used
  12.         at all.
  13. Solution:   Adjust various things for IME.
  14. Files:        src/globals.h, src/gui_w32.c, src/mbyte.c, src/proto/ui.pro,
  15.         src/structs.h, src/ui.c
  16.  
  17.  
  18. *** ../vim60.261/src/globals.h    Thu Feb 21 17:14:51 2002
  19. --- src/globals.h    Fri Feb 22 16:07:45 2002
  20. ***************
  21. *** 576,581 ****
  22. --- 577,586 ----
  23.   EXTERN vimconv_T input_conv;            /* type of input conversion */
  24.   EXTERN vimconv_T output_conv;            /* type of output conversion */
  25.   
  26. + #ifdef FEAT_MBYTE_IME
  27. + EXTERN vimconv_T ime_conv;            /* ucs-2 -> encoding */
  28. + EXTERN vimconv_T ime_conv_cp;            /* codepage -> ucs-2 */
  29. + #endif
  30.   /*
  31.    * Function pointers, used to quickly get to the right function.  Each has
  32.    * three possible values: latin_ (8-bit), utfc_ or utf_ (utf-8) and dbcs_
  33. *** ../vim60.261/src/gui_w32.c    Mon Feb  4 22:35:33 2002
  34. --- src/gui_w32.c    Fri Feb 22 16:16:05 2002
  35. ***************
  36. *** 210,215 ****
  37. --- 210,219 ----
  38.   static int get_toolbar_bitmap(vimmenu_T *menu);
  39.   #endif
  40.   
  41. + #ifdef FEAT_MBYTE_IME
  42. + static LRESULT _OnImeComposition(HWND hwnd, WPARAM dbcs, LPARAM param);
  43. + static char_u *GetResultStr(HWND hwnd, int GCS);
  44. + #endif
  45.   #if defined(FEAT_MBYTE_IME) && defined(DYNAMIC_IME)
  46.   # ifdef NOIME
  47.   typedef struct tagCOMPOSITIONFORM {
  48. ***************
  49. *** 221,227 ****
  50.   # endif
  51.   
  52.   HINSTANCE hLibImm = NULL;
  53. ! LONG (WINAPI *pImmGetCompositionString)(HIMC, DWORD, LPVOID, DWORD);
  54.   HIMC (WINAPI *pImmGetContext)(HWND);
  55.   BOOL (WINAPI *pImmReleaseContext)(HWND, HIMC);
  56.   BOOL (WINAPI *pImmGetOpenStatus)(HIMC);
  57. --- 225,232 ----
  58.   # endif
  59.   
  60.   HINSTANCE hLibImm = NULL;
  61. ! LONG (WINAPI *pImmGetCompositionStringA)(HIMC, DWORD, LPVOID, DWORD);
  62. ! LONG (WINAPI *pImmGetCompositionStringW)(HIMC, DWORD, LPVOID, DWORD);
  63.   HIMC (WINAPI *pImmGetContext)(HWND);
  64.   BOOL (WINAPI *pImmReleaseContext)(HWND, HIMC);
  65.   BOOL (WINAPI *pImmGetOpenStatus)(HIMC);
  66. ***************
  67. *** 232,238 ****
  68.   BOOL (WINAPI *pImmGetConversionStatus)(HIMC, LPDWORD, LPDWORD);
  69.   static void dyn_imm_load(void);
  70.   #else
  71. ! # define pImmGetCompositionString ImmGetCompositionStringA
  72.   # define pImmGetContext          ImmGetContext
  73.   # define pImmReleaseContext      ImmReleaseContext
  74.   # define pImmGetOpenStatus      ImmGetOpenStatus
  75. --- 237,244 ----
  76.   BOOL (WINAPI *pImmGetConversionStatus)(HIMC, LPDWORD, LPDWORD);
  77.   static void dyn_imm_load(void);
  78.   #else
  79. ! # define pImmGetCompositionStringA ImmGetCompositionStringA
  80. ! # define pImmGetCompositionStringW ImmGetCompositionStringW
  81.   # define pImmGetContext          ImmGetContext
  82.   # define pImmReleaseContext      ImmReleaseContext
  83.   # define pImmGetOpenStatus      ImmGetOpenStatus
  84. ***************
  85. *** 792,797 ****
  86. --- 798,808 ----
  87.       case WM_IME_NOTIFY:
  88.       if (!_OnImeNotify(hwnd, (DWORD)wParam, (DWORD)lParam))
  89.           return DefWindowProc(hwnd, uMsg, wParam, lParam);
  90. +     break;
  91. +     case WM_IME_COMPOSITION:
  92. +         if (!_OnImeComposition(hwnd, wParam, lParam))
  93. +         return DefWindowProc(hwnd, uMsg, wParam, lParam);
  94. +     break;
  95.   #endif
  96.   
  97.       default:
  98. ***************
  99. *** 1294,1300 ****
  100.   #include <ime.h>
  101.   #include <imm.h>
  102.   
  103. - static char lpCompStr[100];        // Pointer to composition str.
  104.   static BOOL bInComposition=FALSE;
  105.   
  106.   /*
  107. --- 1305,1310 ----
  108. ***************
  109. *** 1333,1455 ****
  110.           State &= ~LANGMAP;
  111.           if (State & INSERT)
  112.           {
  113. !             int old_row, old_col;
  114. !             /* Save cursor position */
  115. !             old_row = gui.row;
  116. !             old_col = gui.col;
  117.   
  118.               curbuf->b_p_iminsert = B_IMODE_IM;
  119.   
  120. -             // This must be called here before status_redraw_curbuf(),
  121. -             // otherwise the mode message may appear in the wrong
  122. -             // position.
  123. -             showmode();
  124.   #if defined(FEAT_WINDOWS) && defined(FEAT_KEYMAP)
  125. !             /* Show/unshow value of 'keymap' in status lines. */
  126. !             status_redraw_curbuf();
  127.   #endif
  128. -             update_screen(0);
  129. -             /* Restore cursor position */
  130. -             gui.row = old_row;
  131. -             gui.col = old_col;
  132.           }
  133.           }
  134.           gui_update_cursor(TRUE, FALSE);
  135. !         lResult = 1;
  136.           break;
  137.       }
  138.       pImmReleaseContext(hWnd, hImc);
  139.       return lResult;
  140.   }
  141.   
  142. ! /* get composition string from WIN_IME */
  143. !     static void
  144. ! GetCompositionStr(HWND hwnd, LPARAM CompFlag)
  145.   {
  146. !     DWORD    dwBufLen;        // Stogare for len. of composition str
  147. !     HIMC    hIMC;            // Input context handle.
  148.   
  149. !     // If fail to get input context handle then do nothing.
  150. !     // Applications should call ImmGetContext API to get
  151. !     // input context handle.
  152.   
  153. !     if (!pImmGetContext || !(hIMC = pImmGetContext(hwnd)))
  154. !     return;
  155.   
  156. !     // Determines how much memory space to store the composition string.
  157. !     // Applications should call ImmGetCompositionString with
  158. !     // GCS_COMPSTR flag on, buffer length zero, to get the bullfer
  159. !     // length.
  160.   
  161. !     if ((dwBufLen = pImmGetCompositionString(hIMC, GCS_COMPSTR,
  162. !             (void FAR*)NULL, 0l)) < 0)
  163. !     goto exit2;
  164.   
  165. !     if (dwBufLen > 99)
  166. !     goto exit2;
  167.   
  168. !     // Reads in the composition string.
  169. !     if ( dwBufLen != 0 )
  170.       {
  171. !     pImmGetCompositionString(hIMC, GCS_COMPSTR, lpCompStr, dwBufLen);
  172. !     lpCompStr[dwBufLen] = 0;
  173.       }
  174.       else
  175.       {
  176. !     strcpy(lpCompStr, "  ");
  177. !     dwBufLen = 2;
  178. !     }
  179.   
  180. !     // Display new composition chars.
  181. !     DisplayCompStringOpaque(lpCompStr, dwBufLen);
  182.   
  183. ! exit2:
  184. !     pImmReleaseContext(hwnd, hIMC);
  185.   }
  186.   
  187. ! // void GetResultStr()
  188. ! //
  189. ! // This handles WM_IME_COMPOSITION with GCS_RESULTSTR flag on.
  190. ! //
  191. ! // get complete composition string
  192. !     static void
  193. ! GetResultStr(HWND hwnd)
  194.   {
  195. !     DWORD    dwBufLen;        // Storage for length of result str.
  196. !     HIMC    hIMC;            // Input context handle.
  197.   
  198. -     // If fail to get input context handle then do nothing.
  199.       if (!pImmGetContext || !(hIMC = pImmGetContext(hwnd)))
  200. !     return;
  201. !     // Determines how much memory space to store the result string.
  202. !     // Applications should call ImmGetCompositionString with
  203. !     // GCS_RESULTSTR flag on, buffer length zero, to get the bullfer
  204. !     // length.
  205. !     if ((dwBufLen = pImmGetCompositionString(hIMC, GCS_RESULTSTR,
  206. !             (void FAR *)NULL, (DWORD) 0)) <= 0)
  207. !     goto exit2;
  208. !     if (dwBufLen > 99)
  209. !     goto exit2;
  210. !     // Reads in the result string.
  211. !     pImmGetCompositionString(hIMC, GCS_RESULTSTR, lpCompStr, dwBufLen);
  212.   
  213. !     // Displays the result string.
  214. !     DisplayCompStringOpaque(lpCompStr, dwBufLen);
  215.   
  216. ! exit2:
  217.       pImmReleaseContext(hwnd, hIMC);
  218.   }
  219.   
  220. !     static char *
  221.   ImeGetTempComposition(void)
  222.   {
  223.       if (bInComposition == TRUE)
  224. --- 1343,1477 ----
  225.           State &= ~LANGMAP;
  226.           if (State & INSERT)
  227.           {
  228. !             long old_imi = curbuf->b_p_iminsert;
  229.   
  230.               curbuf->b_p_iminsert = B_IMODE_IM;
  231.   
  232.   #if defined(FEAT_WINDOWS) && defined(FEAT_KEYMAP)
  233. !             /* Unshown 'keymap' in status lines */
  234. !             if (old_imi == B_IMODE_LMAP)
  235. !             {
  236. !             /* Save cursor position */
  237. !             int old_row = gui.row;
  238. !             int old_col = gui.col;
  239. !             // This must be called here before
  240. !             // status_redraw_curbuf(), otherwise the mode
  241. !             // message may appear in the wrong position.
  242. !             showmode();
  243. !             status_redraw_curbuf();
  244. !             update_screen(0);
  245. !             /* Restore cursor position */
  246. !             gui.row = old_row;
  247. !             gui.col = old_col;
  248. !             }
  249.   #endif
  250.           }
  251.           }
  252.           gui_update_cursor(TRUE, FALSE);
  253. !         lResult = 0;
  254.           break;
  255.       }
  256.       pImmReleaseContext(hWnd, hImc);
  257.       return lResult;
  258.   }
  259.   
  260. !     static LRESULT
  261. ! _OnImeComposition(HWND hwnd, WPARAM dbcs, LPARAM param)
  262.   {
  263. !     char_u    *ret;
  264.   
  265. !     if ((param & GCS_RESULTSTR) == 0) /* Composition unfinished. */
  266. !     return 0;
  267.   
  268. !     if (ret = GetResultStr(hwnd, GCS_RESULTSTR))
  269. !     {
  270. !     add_to_input_buf_csi(ret, strlen(ret));
  271. !     vim_free(ret);
  272. !     return 1;
  273. !     }
  274. !     else
  275. !     return 0;
  276. ! }
  277.   
  278. ! /*
  279. !  * get the currnet composition string, in UCS-2; len is the number of
  280. !  * Unicode characters
  281. !  */
  282. !     unsigned short *
  283. ! GetCompositionString_inUCS2(HIMC hIMC, DWORD GCS, int *len)
  284. ! {
  285. !     LONG ret;
  286. !     unsigned short *wbuf = NULL;
  287.   
  288. !     if (!pImmGetContext)
  289. !     return NULL; /* no imm32.dll */
  290.   
  291. !     /* Try Unicode; this'll always work on NT regardless of codepage. */
  292. !     ret = pImmGetCompositionStringW(hIMC, GCS, NULL, 0);
  293. !     if (ret == 0)
  294. !     return NULL; /* empty */
  295.   
  296. !     if (ret > 0)
  297.       {
  298. !     wbuf = (unsigned short *) alloc(ret * sizeof(unsigned short));
  299. !     if(!wbuf) return NULL;
  300. !     pImmGetCompositionStringW(hIMC, GCS, wbuf, ret);
  301. !     *len = ret / sizeof(unsigned short); /* char -> wchar */
  302. !     return wbuf;
  303.       }
  304. +     /* ret < 0; we got an error, so try the ANSI version.  This'll work
  305. +      * on 9x/ME, but only if the codepage happens to be set to whatever
  306. +      * we're inputting. */
  307. +     ret = pImmGetCompositionStringA(hIMC, GCS, NULL, 0);
  308. +     if (ret <= 0)
  309. +     return NULL; /* empty or error */
  310.       else
  311.       {
  312. !     char_u *buf;
  313.   
  314. !     buf = alloc(ret);
  315. !     if (buf == NULL)
  316. !         return NULL;
  317. !     pImmGetCompositionStringA(hIMC, GCS, buf, ret);
  318.   
  319. !     /* convert from codepage to UCS-2 */
  320. !     wbuf = (unsigned short *)string_convert(&ime_conv_cp, buf, &ret);
  321. !     vim_free(buf);
  322. !     *len = ret / sizeof(unsigned short); /* char_u -> wchar */
  323. !     }
  324. !     return wbuf;
  325.   }
  326.   
  327. ! /*
  328. !  * void GetResultStr()
  329. !  *
  330. !  * This handles WM_IME_COMPOSITION with GCS_RESULTSTR flag on.
  331. !  * get complete composition string
  332. !  */
  333. !     static char_u *
  334. ! GetResultStr(HWND hwnd, int GCS)
  335.   {
  336. !     DWORD    dwBufLen;    /* Stogare for len. of composition str. */
  337. !     HIMC    hIMC;        /* Input context handle. */
  338. !     unsigned short *buf = NULL;
  339. !     char *convbuf = NULL;
  340.   
  341.       if (!pImmGetContext || !(hIMC = pImmGetContext(hwnd)))
  342. !     return NULL;
  343.   
  344. !     /* Reads in the composition string. */
  345. !     buf = GetCompositionString_inUCS2(hIMC, GCS, &dwBufLen);
  346. !     if (buf == NULL)
  347. !     return NULL;
  348.   
  349. !     convbuf = string_convert(&ime_conv, (unsigned char *) buf, &dwBufLen);
  350.       pImmReleaseContext(hwnd, hIMC);
  351. +     vim_free(buf);
  352. +     return convbuf;
  353.   }
  354.   
  355. !     static char_u *
  356.   ImeGetTempComposition(void)
  357.   {
  358.       if (bInComposition == TRUE)
  359. ***************
  360. *** 1461,1468 ****
  361.       {
  362.           pImmGetConversionStatus(hImc, &dwConvMode, &dwSentMode);
  363.           pImmReleaseContext(s_hwnd, hImc);
  364. !         if ((dwConvMode & IME_CMODE_NATIVE))
  365. !         return lpCompStr;
  366.       }
  367.       }
  368.       return NULL;
  369. --- 1483,1492 ----
  370.       {
  371.           pImmGetConversionStatus(hImc, &dwConvMode, &dwSentMode);
  372.           pImmReleaseContext(s_hwnd, hImc);
  373. !         if (dwConvMode & IME_CMODE_NATIVE)
  374. !         {
  375. !         return GetResultStr(s_hwnd, GCS_COMPSTR);
  376. !         }
  377.       }
  378.       }
  379.       return NULL;
  380. ***************
  381. *** 1670,1676 ****
  382.       HBRUSH        hbr;
  383.       RECT        rc;
  384.   #ifdef FEAT_MBYTE_IME
  385. !     char        *szComp;
  386.   #endif
  387.   
  388.       if (!(flags & DRAW_TRANSP))
  389. --- 1694,1700 ----
  390.       HBRUSH        hbr;
  391.       RECT        rc;
  392.   #ifdef FEAT_MBYTE_IME
  393. !     char_u        *szComp;
  394.   #endif
  395.   
  396.       if (!(flags & DRAW_TRANSP))
  397. ***************
  398. *** 1766,1773 ****
  399. --- 1790,1800 ----
  400.       /* draw an incomplete composition character (korean) */
  401.       if (len == 1 && blink_state == BLINK_ON
  402.           && (szComp = ImeGetTempComposition()) != NULL) // hangul
  403. +     {
  404.           HanExtTextOut(s_hdc, TEXT_X(col), TEXT_Y(row),
  405.                      foptions, pcliprect, szComp, 2, padding, TRUE);
  406. +         vim_free(szComp);
  407. +     }
  408.       else
  409.           HanExtTextOut(s_hdc, TEXT_X(col), TEXT_Y(row),
  410.                 foptions, pcliprect, (char *)text, len, padding, FALSE);
  411. ***************
  412. *** 1957,1967 ****
  413.       POINT    p;
  414.   
  415.       /* Find the position of the current cursor */
  416. !     GetDCOrgEx(s_hdc,&p);
  417.       if (curwin != NULL)
  418.       {
  419. !         p.x+= TEXT_X(W_WINCOL(curwin) + curwin->w_wcol +1);
  420. !         p.y+= TEXT_Y(W_WINROW(curwin) + curwin->w_wrow +1);
  421.       }
  422.       msg_scroll = FALSE;
  423.       gui_mch_show_popupmenu_at(menu, (int)p.x, (int)p.y);
  424. --- 1984,1994 ----
  425.       POINT    p;
  426.   
  427.       /* Find the position of the current cursor */
  428. !     GetDCOrgEx(s_hdc, &p);
  429.       if (curwin != NULL)
  430.       {
  431. !         p.x += TEXT_X(W_WINCOL(curwin) + curwin->w_wcol + 1);
  432. !         p.y += TEXT_Y(W_WINROW(curwin) + curwin->w_wrow + 1);
  433.       }
  434.       msg_scroll = FALSE;
  435.       gui_mch_show_popupmenu_at(menu, (int)p.x, (int)p.y);
  436. ***************
  437. *** 3336,3344 ****
  438.       hLibImm = LoadLibrary("imm32.dll");
  439.       if (hLibImm == NULL)
  440.       return;
  441. !     if ((*((FARPROC*)&pImmGetCompositionString)
  442.           = GetProcAddress(hLibImm, "ImmGetCompositionStringA")))
  443.       nImmFunc++;
  444.       if ((*((FARPROC*)&pImmGetContext)
  445.           = GetProcAddress(hLibImm, "ImmGetContext")))
  446.       nImmFunc++;
  447. --- 3363,3374 ----
  448.       hLibImm = LoadLibrary("imm32.dll");
  449.       if (hLibImm == NULL)
  450.       return;
  451. !     if ((*((FARPROC*)&pImmGetCompositionStringA)
  452.           = GetProcAddress(hLibImm, "ImmGetCompositionStringA")))
  453.       nImmFunc++;
  454. +     if ((*((FARPROC*)&pImmGetCompositionStringW)
  455. +         = GetProcAddress(hLibImm, "ImmGetCompositionStringW")))
  456. +     nImmFunc++;
  457.       if ((*((FARPROC*)&pImmGetContext)
  458.           = GetProcAddress(hLibImm, "ImmGetContext")))
  459.       nImmFunc++;
  460. ***************
  461. *** 3364,3370 ****
  462.           = GetProcAddress(hLibImm, "ImmGetConversionStatus")))
  463.       nImmFunc++;
  464.   
  465. !     if (nImmFunc != 9)
  466.       {
  467.       FreeLibrary(hLibImm);
  468.       hLibImm = NULL;
  469. --- 3394,3400 ----
  470.           = GetProcAddress(hLibImm, "ImmGetConversionStatus")))
  471.       nImmFunc++;
  472.   
  473. !     if (nImmFunc != 10)
  474.       {
  475.       FreeLibrary(hLibImm);
  476.       hLibImm = NULL;
  477. *** ../vim60.261/src/mbyte.c    Thu Feb  7 16:50:47 2002
  478. --- src/mbyte.c    Fri Feb 22 16:58:36 2002
  479. ***************
  480. *** 572,577 ****
  481. --- 572,586 ----
  482.       if (enc_utf8 && !option_was_set((char_u *)"fencs"))
  483.       set_string_option_direct((char_u *)"fencs", -1,
  484.                    (char_u *)"ucs-bom,utf-8,latin1", OPT_FREE);
  485. + #ifdef FEAT_MBYTE_IME
  486. + # ifdef USE_ICONV
  487. +     ime_conv.vc_fd = (iconv_t)-1;
  488. +     ime_conv_cp.vc_fd = (iconv_t)-1;
  489. + # endif
  490. +     convert_setup(&ime_conv, "ucs-2", p_enc);
  491. +     ime_conv_cp.vc_type = CONV_CODEPAGE;
  492. +     ime_conv_cp.vc_factor = 2; /* we don't really know anything about the codepage */
  493. + #endif
  494.   
  495.   #ifdef HAVE_BIND_TEXTDOMAIN_CODESET
  496.       /* GNU gettext 0.10.37 supports this feature: set the codeset used for
  497. ***************
  498. *** 3595,3622 ****
  499.       add_to_input_buf(str, 3);
  500.   }
  501.   
  502. - /*
  503. -  * Add "str[len]" to the input buffer while escaping CSI bytes.
  504. -  */
  505. -     static void
  506. - add_to_input_buf_csi(char_u *str, int len)
  507. - {
  508. -     int        i;
  509. -     char_u    buf[2];
  510. -     for (i = 0; i < len; ++i)
  511. -     {
  512. -     add_to_input_buf(str + i, 1);
  513. -     if (str[i] == CSI)
  514. -     {
  515. -         /* Turn CSI into K_CSI. */
  516. -         buf[0] = KS_EXTRA;
  517. -         buf[1] = (int)KE_CSI;
  518. -         add_to_input_buf(buf, 2);
  519. -     }
  520. -     }
  521. - }
  522.   static GSList *key_press_event_queue = NULL;
  523.   static int preedit_buf_len = 0;
  524.   static gboolean processing_queued_event = FALSE;
  525. --- 3611,3616 ----
  526. ***************
  527. *** 3953,3958 ****
  528. --- 3947,3970 ----
  529.       /* Internal utf-8 -> latin1 conversion. */
  530.       vcp->vc_type = CONV_TO_LATIN1;
  531.       }
  532. + #ifdef WIN32
  533. +     /* Win32-specific UTF-16 -> DBCS conversion, for the IME,
  534. +      * so we don't need iconv ... */
  535. +     else if ((from_prop & ENC_UNICODE)
  536. +                && (from_prop & ENC_2BYTE) && (to_prop & ENC_DBCS))
  537. +     {
  538. +     vcp->vc_type = CONV_DBCS;
  539. +     vcp->vc_factor = 2;    /* up to twice as long */
  540. +     vcp->vc_dbcs = atoi(to + 2);
  541. +     }
  542. +     else if ((from_prop & ENC_UNICODE)
  543. +             && (from_prop & ENC_2BYTE) && (to_prop & ENC_UNICODE))
  544. +     {
  545. +     vcp->vc_type = CONV_DBCS;
  546. +     vcp->vc_factor = 2;    /* up to twice as long */
  547. +     vcp->vc_dbcs = CP_UTF8;
  548. +     }
  549. + #endif
  550.   # ifdef USE_ICONV
  551.       else
  552.       {
  553. ***************
  554. *** 4079,4084 ****
  555. --- 4091,4130 ----
  556.           retval = iconv_string(vcp->vc_fd, ptr, len);
  557.           if (retval != NULL && lenp != NULL)
  558.           *lenp = (int)STRLEN(retval);
  559. +         break;
  560. + # endif
  561. + # ifdef WIN32
  562. +     case CONV_DBCS:        /* UTF-16 -> dbcs or UTF8 */
  563. +     {
  564. +         int retlen;
  565. +             if (!lenp)
  566. +                 len /= sizeof(unsigned short);
  567. +             retlen = WideCharToMultiByte(vcp->vc_dbcs, 0,
  568. +                 (const unsigned short *)ptr, len, 0, 0, 0, 0);
  569. +         retval = alloc(retlen + 1);
  570. +         if (retval == NULL)
  571. +         break;
  572. +         WideCharToMultiByte(vcp->vc_dbcs, 0,
  573. +              (const unsigned short *) ptr, len, retval, retlen, 0, 0);
  574. +         retval[retlen] = NUL;
  575. +         if (lenp != NULL)
  576. +             *lenp = retlen;
  577. +         break;
  578. +     }
  579. +     case CONV_CODEPAGE:    /* current codepage -> ucs-2 */
  580. +     {
  581. +         int retlen;
  582. +         retlen = MultiByteToWideChar(GetACP(), 0, ptr, len, 0, 0);
  583. +         retval = alloc(sizeof(unsigned short) * retlen);
  584. +         if (retval == NULL)
  585. +         break;
  586. +         MultiByteToWideChar(GetACP(), 0, ptr, len,
  587. +                        (unsigned short *) retval, retlen);
  588. +         if (lenp != NULL)
  589. +             *lenp = retlen * sizeof(unsigned short); /* number of shorts -> buffer size */
  590. +     }
  591.   # endif
  592.       }
  593.   
  594. *** ../vim60.261/src/proto/ui.pro    Tue Sep 25 21:49:26 2001
  595. --- src/proto/ui.pro    Fri Feb 22 16:28:18 2002
  596. ***************
  597. *** 34,39 ****
  598. --- 34,40 ----
  599.   int vim_free_in_input_buf __ARGS((void));
  600.   int vim_used_in_input_buf __ARGS((void));
  601.   void add_to_input_buf __ARGS((char_u *s, int len));
  602. + void add_to_input_buf_csi __ARGS((char_u *str, int len));
  603.   void push_raw_key __ARGS((char_u *s, int len));
  604.   void trash_input_buf __ARGS((void));
  605.   int read_from_input_buf __ARGS((char_u *buf, long maxlen));
  606. *** ../vim60.261/src/structs.h    Sun Feb 17 23:22:34 2002
  607. --- src/structs.h    Fri Feb 22 16:58:41 2002
  608. ***************
  609. *** 669,678 ****
  610.    */
  611.   typedef struct
  612.   {
  613. !     int        vc_type;        /* zero or one of the CONV_ values */
  614. !     int        vc_factor;        /* max. expansion factor */
  615.   # ifdef USE_ICONV
  616. !     iconv_t    vc_fd;            /* for CONV_ICONV */
  617.   # endif
  618.   } vimconv_T;
  619.   
  620. --- 669,681 ----
  621.    */
  622.   typedef struct
  623.   {
  624. !     int        vc_type;    /* zero or one of the CONV_ values */
  625. !     int        vc_factor;    /* max. expansion factor */
  626. ! # ifdef FEAT_WINDOWS
  627. !     int        vc_dbcs;    /* codepage to convert to (CONV_CODEPAGE) */
  628. ! # endif
  629.   # ifdef USE_ICONV
  630. !     iconv_t    vc_fd;        /* for CONV_ICONV */
  631.   # endif
  632.   } vimconv_T;
  633.   
  634. ***************
  635. *** 692,697 ****
  636. --- 695,704 ----
  637.   #define CONV_TO_UTF8    1
  638.   #define CONV_TO_LATIN1    2
  639.   #define CONV_ICONV    3
  640. + #ifdef FEAT_WINDOWS
  641. + # define CONV_DBCS    4    /* ucs-2 -> dbcs */
  642. + # define CONV_CODEPAGE    5    /* current codepage -> ucs-2 */
  643. + #endif
  644.   
  645.   /*
  646.    * Structure used for mappings and abbreviations.
  647. *** ../vim60.261/src/ui.c    Fri Feb 22 12:33:04 2002
  648. --- src/ui.c    Fri Feb 22 16:28:16 2002
  649. ***************
  650. *** 1533,1538 ****
  651. --- 1533,1564 ----
  652.   }
  653.   #endif
  654.   
  655. + #if (defined(FEAT_XIM) && defined(FEAT_GUI_GTK)) \
  656. +     || (defined(FEAT_MBYTE) && defined(FEAT_MBYTE_IME)) \
  657. +     || defined(PROTO)
  658. + /*
  659. +  * Add "str[len]" to the input buffer while escaping CSI bytes.
  660. +  */
  661. +     void
  662. + add_to_input_buf_csi(char_u *str, int len)
  663. + {
  664. +     int        i;
  665. +     char_u    buf[2];
  666. +     for (i = 0; i < len; ++i)
  667. +     {
  668. +     add_to_input_buf(str + i, 1);
  669. +     if (str[i] == CSI)
  670. +     {
  671. +         /* Turn CSI into K_CSI. */
  672. +         buf[0] = KS_EXTRA;
  673. +         buf[1] = (int)KE_CSI;
  674. +         add_to_input_buf(buf, 2);
  675. +     }
  676. +     }
  677. + }
  678. + #endif
  679.   #if defined(FEAT_HANGULIN) || defined(PROTO)
  680.       void
  681.   push_raw_key (s, len)
  682. *** ../vim60.261/src/version.c    Fri Feb 22 14:32:58 2002
  683. --- src/version.c    Fri Feb 22 16:54:25 2002
  684. ***************
  685. *** 608,609 ****
  686. --- 608,611 ----
  687.   {   /* Add new patch number below this line */
  688. + /**/
  689. +     262,
  690.   /**/
  691.  
  692. -- 
  693. A)bort, R)etry, D)o it right this time
  694.  
  695.  ///  Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net  \\\
  696. ///   Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim   \\\
  697. \\\           Project leader for A-A-P -- http://www.a-a-p.org           ///
  698.  \\\  Help me helping AIDS orphans in Uganda - http://iccf-holland.org  ///
  699.