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 / 7.3 / 7.3.196 < prev    next >
Encoding:
Internet Message Format  |  2012-11-20  |  7.3 KB

  1. To: vim_dev@googlegroups.com
  2. Subject: Patch 7.3.196
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. Mime-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. ------------
  9.  
  10. Patch 7.3.196
  11. Problem:    Can't intercept a character that is going to be inserted.
  12. Solution:   Add the InsertCharPre autocommand event. (Jakson A. Aquino)
  13. Files:        runtime/doc/autocmd.txt, runtime/doc/eval.txt,
  14.         runtime/doc/map.txt, src/edit.c, src/eval.c, src/fileio.c,
  15.         src/vim.h
  16.  
  17.  
  18. *** ../mercurial/vim73/runtime/doc/autocmd.txt    2011-04-28 19:01:26.000000000 +0200
  19. --- runtime/doc/autocmd.txt    2011-05-19 17:12:17.000000000 +0200
  20. ***************
  21. *** 299,304 ****
  22. --- 299,306 ----
  23.   |InsertEnter|        starting Insert mode
  24.   |InsertChange|        when typing <Insert> while in Insert or Replace mode
  25.   |InsertLeave|        when leaving Insert mode
  26. + |InsertCharPre|        when a character was typed in Insert mode, before
  27. +             inserting it
  28.   
  29.   |ColorScheme|        after loading a color scheme
  30.   
  31. ***************
  32. *** 657,662 ****
  33. --- 659,675 ----
  34.                   indicates the new mode.
  35.                   Be careful not to move the cursor or do
  36.                   anything else that the user does not expect.
  37. +                             *InsertCharPre*
  38. + InsertCharPre            When a character is typed in Insert mode,
  39. +                 before inserting the char.
  40. +                 The |v:char| variable indicates the char typed
  41. +                 and can be changed during the event to insert
  42. +                 a different character.  When |v:char| is set
  43. +                 to more than one character this text is
  44. +                 inserted literally.
  45. +                 It is not allowed to change the text |textlock|.
  46. +                 The event is not triggered when 'paste' is
  47. +                 set.
  48.                               *InsertEnter*
  49.   InsertEnter            Just before starting Insert mode.  Also for
  50.                   Replace mode and Virtual Replace mode.  The
  51. *** ../mercurial/vim73/runtime/doc/eval.txt    2011-05-19 12:22:41.000000000 +0200
  52. --- runtime/doc/eval.txt    2011-05-19 16:55:58.000000000 +0200
  53. ***************
  54. *** 1293,1298 ****
  55. --- 1293,1299 ----
  56.                       *v:char* *char-variable*
  57.   v:char        Argument for evaluating 'formatexpr' and used for the typed
  58.           character when using <expr> in an abbreviation |:map-<expr>|.
  59. +         It is also used by the |InsertPreChar| event.
  60.   
  61.               *v:charconvert_from* *charconvert_from-variable*
  62.   v:charconvert_from
  63. *** ../mercurial/vim73/runtime/doc/map.txt    2011-05-10 17:17:38.000000000 +0200
  64. --- runtime/doc/map.txt    2011-05-19 16:40:34.000000000 +0200
  65. ***************
  66. *** 226,232 ****
  67.   
  68.   For abbreviations |v:char| is set to the character that was typed to trigger
  69.   the abbreviation.  You can use this to decide how to expand the {lhs}.  You
  70. ! can't change v:char and you should not insert it.
  71.   
  72.   Be very careful about side effects!  The expression is evaluated while
  73.   obtaining characters, you may very well make the command dysfunctional.
  74. --- 226,232 ----
  75.   
  76.   For abbreviations |v:char| is set to the character that was typed to trigger
  77.   the abbreviation.  You can use this to decide how to expand the {lhs}.  You
  78. ! you should not either insert or change the v:char.
  79.   
  80.   Be very careful about side effects!  The expression is evaluated while
  81.   obtaining characters, you may very well make the command dysfunctional.
  82. *** ../mercurial/vim73/src/edit.c    2011-05-10 14:22:10.000000000 +0200
  83. --- src/edit.c    2011-05-19 17:20:53.000000000 +0200
  84. ***************
  85. *** 1381,1390 ****
  86.           goto do_intr;
  87.   #endif
  88.   
  89.           /*
  90.            * Insert a nomal character.
  91.            */
  92. ! normalchar:
  93.   #ifdef FEAT_SMARTINDENT
  94.           /* Try to perform smart-indenting. */
  95.           ins_try_si(c);
  96. --- 1381,1425 ----
  97.           goto do_intr;
  98.   #endif
  99.   
  100. + normalchar:
  101.           /*
  102.            * Insert a nomal character.
  103.            */
  104. ! #ifdef FEAT_AUTOCMD
  105. !         if (!p_paste)
  106. !         {
  107. !         /* Trigger the InsertCharPre event.  Lock the text to avoid
  108. !          * weird things from happening. */
  109. !         set_vim_var_char(c);
  110. !         ++textlock;
  111. !         if (apply_autocmds(EVENT_INSERTCHARPRE, NULL, NULL,
  112. !                                    FALSE, curbuf))
  113. !         {
  114. !             /* Get the new value of v:char.  If it is more than one
  115. !              * character insert it literally. */
  116. !             char_u *s = get_vim_var_str(VV_CHAR);
  117. !             if (MB_CHARLEN(s) > 1)
  118. !             {
  119. !             if (stop_arrow() != FAIL)
  120. !             {
  121. !                 ins_str(s);
  122. !                 AppendToRedobuffLit(s, -1);
  123. !             }
  124. !             c = NUL;
  125. !             }
  126. !             else
  127. !             c = PTR2CHAR(s);
  128. !         }
  129. !         set_vim_var_string(VV_CHAR, NULL, -1);
  130. !         --textlock;
  131. !         /* If the new value is an empty string then don't insert a
  132. !          * char. */
  133. !         if (c == NUL)
  134. !             break;
  135. !         }
  136. ! #endif
  137.   #ifdef FEAT_SMARTINDENT
  138.           /* Try to perform smart-indenting. */
  139.           ins_try_si(c);
  140. ***************
  141. *** 3491,3501 ****
  142.           return;
  143.       }
  144.       p += len;
  145. ! #ifdef FEAT_MBYTE
  146. !     c = mb_ptr2char(p);
  147. ! #else
  148. !     c = *p;
  149. ! #endif
  150.       ins_compl_addleader(c);
  151.   }
  152.   
  153. --- 3526,3532 ----
  154.           return;
  155.       }
  156.       p += len;
  157. !     c = PTR2CHAR(p);
  158.       ins_compl_addleader(c);
  159.   }
  160.   
  161. *** ../mercurial/vim73/src/eval.c    2011-05-19 14:59:07.000000000 +0200
  162. --- src/eval.c    2011-05-19 16:40:39.000000000 +0200
  163. ***************
  164. *** 352,358 ****
  165.       {VV_NAME("swapname",     VAR_STRING), VV_RO},
  166.       {VV_NAME("swapchoice",     VAR_STRING), 0},
  167.       {VV_NAME("swapcommand",     VAR_STRING), VV_RO},
  168. !     {VV_NAME("char",         VAR_STRING), VV_RO},
  169.       {VV_NAME("mouse_win",     VAR_NUMBER), 0},
  170.       {VV_NAME("mouse_lnum",     VAR_NUMBER), 0},
  171.       {VV_NAME("mouse_col",     VAR_NUMBER), 0},
  172. --- 352,358 ----
  173.       {VV_NAME("swapname",     VAR_STRING), VV_RO},
  174.       {VV_NAME("swapchoice",     VAR_STRING), 0},
  175.       {VV_NAME("swapcommand",     VAR_STRING), VV_RO},
  176. !     {VV_NAME("char",         VAR_STRING), 0},
  177.       {VV_NAME("mouse_win",     VAR_NUMBER), 0},
  178.       {VV_NAME("mouse_lnum",     VAR_NUMBER), 0},
  179.       {VV_NAME("mouse_col",     VAR_NUMBER), 0},
  180. *** ../mercurial/vim73/src/fileio.c    2011-05-10 16:41:13.000000000 +0200
  181. --- src/fileio.c    2011-05-19 16:40:39.000000000 +0200
  182. ***************
  183. *** 7662,7667 ****
  184. --- 7662,7668 ----
  185.       {"InsertChange",    EVENT_INSERTCHANGE},
  186.       {"InsertEnter",    EVENT_INSERTENTER},
  187.       {"InsertLeave",    EVENT_INSERTLEAVE},
  188. +     {"InsertCharPre",    EVENT_INSERTCHARPRE},
  189.       {"MenuPopup",    EVENT_MENUPOPUP},
  190.       {"QuickFixCmdPost",    EVENT_QUICKFIXCMDPOST},
  191.       {"QuickFixCmdPre",    EVENT_QUICKFIXCMDPRE},
  192. *** ../mercurial/vim73/src/vim.h    2011-05-10 16:41:13.000000000 +0200
  193. --- src/vim.h    2011-05-19 16:40:39.000000000 +0200
  194. ***************
  195. *** 1274,1279 ****
  196. --- 1274,1280 ----
  197.       EVENT_WINENTER,        /* after entering a window */
  198.       EVENT_WINLEAVE,        /* before leaving a window */
  199.       EVENT_ENCODINGCHANGED,    /* after changing the 'encoding' option */
  200. +     EVENT_INSERTCHARPRE,    /* before inserting a char */
  201.       EVENT_CURSORHOLD,        /* cursor in same position for a while */
  202.       EVENT_CURSORHOLDI,        /* idem, in Insert mode */
  203.       EVENT_FUNCUNDEFINED,    /* if calling a function which doesn't exist */
  204. *** ../vim-7.3.195/src/version.c    2011-05-19 16:35:05.000000000 +0200
  205. --- src/version.c    2011-05-19 17:15:41.000000000 +0200
  206. ***************
  207. *** 711,712 ****
  208. --- 711,714 ----
  209.   {   /* Add new patch number below this line */
  210. + /**/
  211. +     196,
  212.   /**/
  213.  
  214. -- 
  215. I AM THANKFUL...
  216. ...for the mess to clean after a party because it means I have
  217. been surrounded by friends.
  218.  
  219.  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
  220. ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
  221. \\\  an exciting new programming language -- http://www.Zimbu.org        ///
  222.  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
  223.