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.2.398 < prev    next >
Encoding:
Internet Message Format  |  2004-03-22  |  9.8 KB

  1. To: vim-dev@vim.org
  2. Subject: Patch 6.2.398 (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.2.398 (extra)
  11. Problem:    Win32 console: no extra key modifiers are supported.
  12. Solution:   Encode the modifiers into the input stream.  Also fix that special
  13.         keys are converted and stop working when 'tenc' is set.  Also fix
  14.         that when 'tenc' is intialized the input and output conversion is
  15.         not setup properly until 'enc' or 'tenc' is set.
  16. Files:        src/getchar.c, src/option.c, src/os_win32.c
  17.  
  18.  
  19. *** ../vim-6.2.397/src/getchar.c    Sun Feb 29 14:45:49 2004
  20. --- src/getchar.c    Tue Mar 23 19:44:59 2004
  21. ***************
  22. *** 2750,2756 ****
  23.       }
  24.       else
  25.   #endif
  26. !     if (p[0] == NUL || (p[0] == K_SPECIAL && !script))
  27.       {
  28.           mch_memmove(p + 3, p + 1, (size_t)i);
  29.           p[2] = K_THIRD(p[0]);
  30. --- 2750,2761 ----
  31.       }
  32.       else
  33.   #endif
  34. !     if (p[0] == NUL || (p[0] == K_SPECIAL && !script
  35. ! #if defined(WIN3264) && !defined(FEAT_GUI)
  36. !             /* Win32 console passes modifiers */
  37. !             && (i < 2 || p[1] != KS_MODIFIER)
  38. ! #endif
  39. !             ))
  40.       {
  41.           mch_memmove(p + 3, p + 1, (size_t)i);
  42.           p[2] = K_THIRD(p[0]);
  43. *** ../vim-6.2.397/src/option.c    Mon Mar 22 21:11:50 2004
  44. --- src/option.c    Tue Mar 23 16:16:31 2004
  45. ***************
  46. *** 2820,2825 ****
  47. --- 2832,2839 ----
  48.               opt_idx = findoption((char_u *)"termencoding");
  49.               options[opt_idx].def_val[VI_DEFAULT] = p_tenc;
  50.               options[opt_idx].flags |= P_DEF_ALLOCED;
  51. +             convert_setup(&input_conv, p_tenc, p_enc);
  52. +             convert_setup(&output_conv, p_enc, p_tenc);
  53.           }
  54.           else
  55.               p_tenc = empty_option;
  56. *** ../vim-6.2.397/src/os_win32.c    Sat Mar 20 21:17:12 2004
  57. --- src/os_win32.c    Tue Mar 23 20:33:33 2004
  58. ***************
  59. *** 163,169 ****
  60.   static int g_fCBrkPressed = FALSE;  /* set by ctrl-break interrupt */
  61.   static int g_fCtrlCPressed = FALSE; /* set when ctrl-C or ctrl-break detected */
  62.   static int g_fForceExit = FALSE;    /* set when forcefully exiting */
  63. - static char_u g_chPending = NUL;
  64.   
  65.   static void termcap_mode_start(void);
  66.   static void termcap_mode_end(void);
  67. --- 163,168 ----
  68. ***************
  69. *** 186,192 ****
  70.   static void visual_bell(void);
  71.   static void cursor_visible(BOOL fVisible);
  72.   static BOOL write_chars(LPCSTR pchBuf, DWORD cchToWrite);
  73. ! static char_u tgetch(void);
  74.   static void create_conin(void);
  75.   static int s_cursor_visible = TRUE;
  76.   static int did_create_conin = FALSE;
  77. --- 185,191 ----
  78.   static void visual_bell(void);
  79.   static void cursor_visible(BOOL fVisible);
  80.   static BOOL write_chars(LPCSTR pchBuf, DWORD cchToWrite);
  81. ! static char_u tgetch(int *pmodifiers, char_u *pch2);
  82.   static void create_conin(void);
  83.   static int s_cursor_visible = TRUE;
  84.   static int did_create_conin = FALSE;
  85. ***************
  86. *** 596,608 ****
  87.   decode_key_event(
  88.       KEY_EVENT_RECORD    *pker,
  89.       char_u        *pch,
  90. !     char_u        *pchPending,
  91.       BOOL        fDoPost)
  92.   {
  93.       int i;
  94.       const int nModifs = pker->dwControlKeyState & (SHIFT | ALT | CTRL);
  95.   
  96. !     *pch = *pchPending = NUL;
  97.       g_fJustGotFocus = FALSE;
  98.   
  99.       /* ignore key up events */
  100. --- 595,608 ----
  101.   decode_key_event(
  102.       KEY_EVENT_RECORD    *pker,
  103.       char_u        *pch,
  104. !     char_u        *pch2,
  105. !     int            *pmodifiers,
  106.       BOOL        fDoPost)
  107.   {
  108.       int i;
  109.       const int nModifs = pker->dwControlKeyState & (SHIFT | ALT | CTRL);
  110.   
  111. !     *pch = *pch2 = NUL;
  112.       g_fJustGotFocus = FALSE;
  113.   
  114.       /* ignore key up events */
  115. ***************
  116. *** 649,655 ****
  117.       if (pker->wVirtualKeyCode == VK_TAB && (nModifs & SHIFT_PRESSED))
  118.       {
  119.       *pch = K_NUL;
  120. !     *pchPending = '\017';
  121.       return TRUE;
  122.       }
  123.   
  124. --- 649,655 ----
  125.       if (pker->wVirtualKeyCode == VK_TAB && (nModifs & SHIFT_PRESSED))
  126.       {
  127.       *pch = K_NUL;
  128. !     *pch2 = '\017';
  129.       return TRUE;
  130.       }
  131.   
  132. ***************
  133. *** 670,676 ****
  134.           {
  135.           if (VirtKeyMap[i].fAnsiKey)
  136.           {
  137. !             *pchPending = *pch;
  138.               *pch = K_NUL;
  139.           }
  140.   
  141. --- 670,676 ----
  142.           {
  143.           if (VirtKeyMap[i].fAnsiKey)
  144.           {
  145. !             *pch2 = *pch;
  146.               *pch = K_NUL;
  147.           }
  148.   
  149. ***************
  150. *** 685,695 ****
  151.       *pch = NUL;
  152.       else
  153.       {
  154. !     *pch = (i > 0)    ? pker->AChar  :  NUL;
  155. !     /* Interpret the ALT key as making the key META, but only when not
  156. !      * combined with CTRL (which is ALTGR). */
  157. !     if ((nModifs & ALT) != 0 && (nModifs & CTRL) == 0)
  158. !         *pch |= 0x80;
  159.       }
  160.   
  161.       return (*pch != NUL);
  162. --- 685,711 ----
  163.       *pch = NUL;
  164.       else
  165.       {
  166. !     *pch = (i > 0) ? pker->AChar : NUL;
  167. !     if (pmodifiers != NULL)
  168. !     {
  169. !         /* Pass on the ALT key as a modifier, but only when not combined
  170. !          * with CTRL (which is ALTGR). */
  171. !         if ((nModifs & ALT) != 0 && (nModifs & CTRL) == 0)
  172. !         *pmodifiers |= MOD_MASK_ALT;
  173. !         /* Pass on SHIFT only for special keys, because we don't know when
  174. !          * it's already included with the character. */
  175. !         if ((nModifs & SHIFT) != 0 && *pch <= 0x20)
  176. !         *pmodifiers |= MOD_MASK_SHIFT;
  177. !         /* Pass on CTRL only for non-special keys, because we don't know
  178. !          * when it's already included with the character.  And not when
  179. !          * combined with ALT (which is ALTGR). */
  180. !         if ((nModifs & CTRL) != 0 && (nModifs & ALT) == 0
  181. !                            && *pch >= 0x20 && *pch < 0x80)
  182. !         *pmodifiers |= MOD_MASK_CTRL;
  183. !     }
  184.       }
  185.   
  186.       return (*pch != NUL);
  187. ***************
  188. *** 1079,1085 ****
  189.   #ifdef FEAT_CLIENTSERVER
  190.       serverProcessPendingMessages();
  191.   #endif
  192. !     if (g_chPending != NUL
  193.   #ifdef FEAT_MOUSE
  194.           || g_nMouseClick != -1
  195.   #endif
  196. --- 1095,1101 ----
  197.   #ifdef FEAT_CLIENTSERVER
  198.       serverProcessPendingMessages();
  199.   #endif
  200. !     if (0
  201.   #ifdef FEAT_MOUSE
  202.           || g_nMouseClick != -1
  203.   #endif
  204. ***************
  205. *** 1146,1152 ****
  206.               continue;
  207.           }
  208.   #endif
  209. !         if (decode_key_event(&ir.Event.KeyEvent, &ch, &ch2, FALSE))
  210.               return TRUE;
  211.           }
  212.   
  213. --- 1162,1169 ----
  214.               continue;
  215.           }
  216.   #endif
  217. !         if (decode_key_event(&ir.Event.KeyEvent, &ch, &ch2,
  218. !                                  NULL, FALSE))
  219.               return TRUE;
  220.           }
  221.   
  222. ***************
  223. *** 1202,1218 ****
  224.    * Get a keystroke or a mouse event
  225.    */
  226.       static char_u
  227. ! tgetch(void)
  228.   {
  229.       char_u ch;
  230.   
  231. -     if (g_chPending != NUL)
  232. -     {
  233. -     ch = g_chPending;
  234. -     g_chPending = NUL;
  235. -     return ch;
  236. -     }
  237.       for (;;)
  238.       {
  239.       INPUT_RECORD ir;
  240. --- 1219,1228 ----
  241.    * Get a keystroke or a mouse event
  242.    */
  243.       static char_u
  244. ! tgetch(int *pmodifiers, char_u *pch2)
  245.   {
  246.       char_u ch;
  247.   
  248.       for (;;)
  249.       {
  250.       INPUT_RECORD ir;
  251. ***************
  252. *** 1237,1243 ****
  253.   
  254.       if (ir.EventType == KEY_EVENT)
  255.       {
  256. !         if (decode_key_event(&ir.Event.KeyEvent, &ch, &g_chPending, TRUE))
  257.           return ch;
  258.       }
  259.       else if (ir.EventType == FOCUS_EVENT)
  260. --- 1247,1254 ----
  261.   
  262.       if (ir.EventType == KEY_EVENT)
  263.       {
  264. !         if (decode_key_event(&ir.Event.KeyEvent, &ch, pch2,
  265. !                                 pmodifiers, TRUE))
  266.           return ch;
  267.       }
  268.       else if (ir.EventType == FOCUS_EVENT)
  269. ***************
  270. *** 1355,1361 ****
  271.       fputc('[', fdDump);
  272.   #endif
  273.   
  274. !     while ((len == 0 || WaitForChar(0L)) && len < maxlen)
  275.       {
  276.       if (typebuf_changed(tb_change_cnt))
  277.       {
  278. --- 1366,1372 ----
  279.       fputc('[', fdDump);
  280.   #endif
  281.   
  282. !     while ((len == 0 || WaitForChar(0L)) && len < maxlen - 1)
  283.       {
  284.       if (typebuf_changed(tb_change_cnt))
  285.       {
  286. ***************
  287. *** 1384,1390 ****
  288.       else
  289.   #endif /* FEAT_MOUSE */
  290.       {
  291. !         c = tgetch();
  292.   
  293.           if (typebuf_changed(tb_change_cnt))
  294.           {
  295. --- 1395,1404 ----
  296.       else
  297.   #endif /* FEAT_MOUSE */
  298.       {
  299. !         char_u    ch2 = NUL;
  300. !         int        modifiers = 0;
  301. !         c = tgetch(&modifiers, &ch2);
  302.   
  303.           if (typebuf_changed(tb_change_cnt))
  304.           {
  305. ***************
  306. *** 1406,1419 ****
  307.           if (g_nMouseClick == -1)
  308.   #endif
  309.           {
  310. !         *buf++ = c;
  311. !         len++;
  312.   #ifdef FEAT_MBYTE
  313. !         /* Only convert normal characters, not special keys. */
  314.           if (input_conv.vc_type != CONV_NONE
  315. !                         && (len == 1 || buf[-2] != K_NUL))
  316. !             len += convert_input(buf - 1, 1, maxlen - len + 1) - 1;
  317.   #endif
  318.   
  319.   #ifdef MCH_WRITE_DUMP
  320.           if (fdDump)
  321. --- 1420,1471 ----
  322.           if (g_nMouseClick == -1)
  323.   #endif
  324.           {
  325. !         int    n = 1;
  326. !         /* A key may have one or two bytes. */
  327. !         buf[0] = c;
  328. !         if (ch2 != NUL)
  329. !         {
  330. !             buf[1] = ch2;
  331. !             ++n;
  332. !         }
  333.   #ifdef FEAT_MBYTE
  334. !         /* Only convert normal characters, not special keys.  Need to
  335. !          * convert before applying ALT, otherwise mapping <M-x> breaks
  336. !          * when 'tenc' is set. */
  337.           if (input_conv.vc_type != CONV_NONE
  338. !                         && (ch2 == NUL || c != K_NUL))
  339. !             n = convert_input(buf, n, maxlen - len);
  340. ! #endif
  341. !         /* Use the ALT key to set the 8th bit of the character
  342. !          * when it's one byte, the 8th bit isn't set yet and not
  343. !          * using a double-byte encoding (would become a lead
  344. !          * byte). */
  345. !         if ((modifiers & MOD_MASK_ALT)
  346. !             && n == 1
  347. !             && (buf[0] & 0x80) == 0
  348. ! #ifdef FEAT_MBYTE
  349. !             && !enc_dbcs
  350.   #endif
  351. +            )
  352. +         {
  353. +             buf[0] |= 0x80;
  354. +             modifiers &= ~MOD_MASK_ALT;
  355. +         }
  356. +         if (modifiers != 0 && len + 4 < maxlen)
  357. +         {
  358. +             /* Prepend modifiers to the character. */
  359. +             mch_memmove(buf + 3, buf, n);
  360. +             buf[0] = K_SPECIAL;
  361. +             buf[1] = (char_u)KS_MODIFIER;
  362. +             buf[2] = modifiers;
  363. +             n += 3;
  364. +         }
  365. +         buf += n;
  366. +         len += n;
  367.   
  368.   #ifdef MCH_WRITE_DUMP
  369.           if (fdDump)
  370. *** ../vim-6.2.397/src/version.c    Tue Mar 23 21:19:08 2004
  371. --- src/version.c    Tue Mar 23 21:20:32 2004
  372. ***************
  373. *** 639,640 ****
  374. --- 639,642 ----
  375.   {   /* Add new patch number below this line */
  376. + /**/
  377. +     398,
  378.   /**/
  379.  
  380. -- 
  381. hundred-and-one symptoms of being an internet addict:
  382. 126. You brag to all of your friends about your date Saturday night...but
  383.      you don't tell them it was only in a chat room.
  384.  
  385.  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
  386. ///        Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
  387. \\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
  388.  \\\  Buy at Amazon and help AIDS victims -- http://ICCF.nl/click1.html ///
  389.