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.229 < prev    next >
Encoding:
Internet Message Format  |  2002-02-17  |  6.7 KB

  1. To: vim-dev@vim.org
  2. Subject: Patch 6.0.229
  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.229
  11. Problem:    Multi-byte: With 'm' in 'formatoptions', formatting doesn't break
  12.         at a multi-byte char followed by an ASCII char, and the other way
  13.         around. (Muraoka Taro)
  14.         When joining lines a space is inserted between multi-byte
  15.         characters, which is not always wanted.
  16. Solution:   Check for multi-byte character before and after the breakpoint.
  17.         Don't insert a space before or after a multi-byte character when
  18.         joining lines and the 'M' flag is in 'formatoptions'.  Don't
  19.         insert a space between multi-byte characters when the 'B' flag is
  20.         in 'formatoptions'.
  21. Files:        src/edit.c, src/ops.c, src/option.h
  22.  
  23.  
  24. *** ../vim60.228/src/edit.c    Sun Feb 10 17:03:38 2002
  25. --- src/edit.c    Sun Feb 17 14:18:37 2002
  26. ***************
  27. *** 3686,3692 ****
  28.       textwidth = comp_textwidth(flags & INSCHAR_FORMAT);
  29.       fo_ins_blank = has_format_option(FO_INS_BLANK);
  30.   #ifdef FEAT_MBYTE
  31. !     fo_multibyte = has_format_option(FO_MULTIBYTE);
  32.   #endif
  33.   
  34.       /*
  35. --- 3686,3692 ----
  36.       textwidth = comp_textwidth(flags & INSCHAR_FORMAT);
  37.       fo_ins_blank = has_format_option(FO_INS_BLANK);
  38.   #ifdef FEAT_MBYTE
  39. !     fo_multibyte = has_format_option(FO_MBYTE_BREAK);
  40.   #endif
  41.   
  42.       /*
  43. ***************
  44. *** 3799,3825 ****
  45.   
  46.           /*
  47.            * Find position to break at.
  48. -          * Stop at start of line.
  49.            * Stop at first entered white when 'formatoptions' has 'v'
  50.            */
  51. !         while (curwin->w_cursor.col > 0
  52. !             && ((!fo_ins_blank && !has_format_option(FO_INS_VI))
  53.               || curwin->w_cursor.lnum != Insstart.lnum
  54. !             || curwin->w_cursor.col >= Insstart.col))
  55.           {
  56.           cc = gchar_cursor();
  57. - #ifdef FEAT_MBYTE
  58. -         if (cc >= 0x100 && fo_multibyte)
  59. -         {
  60. -             /* Break at a multi-byte character. */
  61. -             end_foundcol = curwin->w_cursor.col;
  62. -             foundcol = curwin->w_cursor.col;
  63. -             dec_cursor();
  64. -             if (curwin->w_cursor.col < (colnr_T)wantcol)
  65. -             break;
  66. -             continue;
  67. -         }
  68. - #endif
  69.           if (vim_iswhite(cc))
  70.           {
  71.               /* remember position of blank just before text */
  72. --- 3799,3811 ----
  73.   
  74.           /*
  75.            * Find position to break at.
  76.            * Stop at first entered white when 'formatoptions' has 'v'
  77.            */
  78. !         while ((!fo_ins_blank && !has_format_option(FO_INS_VI))
  79.               || curwin->w_cursor.lnum != Insstart.lnum
  80. !             || curwin->w_cursor.col >= Insstart.col)
  81.           {
  82.           cc = gchar_cursor();
  83.           if (vim_iswhite(cc))
  84.           {
  85.               /* remember position of blank just before text */
  86. ***************
  87. *** 3862,3867 ****
  88. --- 3848,3867 ----
  89.               if (curwin->w_cursor.col < (colnr_T)wantcol)
  90.               break;
  91.           }
  92. + #ifdef FEAT_MBYTE
  93. +         else if (cc >= 0x100 && fo_multibyte
  94. +                   && curwin->w_cursor.col <= (colnr_T)wantcol)
  95. +         {
  96. +             /* Break after or before a multi-byte character. */
  97. +             foundcol = curwin->w_cursor.col;
  98. +             if (curwin->w_cursor.col < (colnr_T)wantcol)
  99. +             foundcol += (*mb_char2len)(cc);
  100. +             end_foundcol = foundcol;
  101. +             break;
  102. +         }
  103. + #endif
  104. +         if (curwin->w_cursor.col == 0)
  105. +             break;
  106.           dec_cursor();
  107.           }
  108.   
  109. *** ../vim60.228/src/ops.c    Sun Feb 17 23:22:34 2002
  110. --- src/ops.c    Sun Feb 17 21:07:29 2002
  111. ***************
  112. *** 3741,3751 ****
  113.       curr = ml_get_curline();
  114.       currsize = (int)STRLEN(curr);
  115.       endcurr1 = endcurr2 = NUL;
  116. !     if (currsize > 0)
  117.       {
  118. !     endcurr1 = *(curr + currsize - 1);
  119. !     if (currsize > 1)
  120. !         endcurr2 = *(curr + currsize - 2);
  121.       }
  122.   
  123.       next = ml_get((linenr_T)(curwin->w_cursor.lnum + 1));
  124. --- 3741,3768 ----
  125.       curr = ml_get_curline();
  126.       currsize = (int)STRLEN(curr);
  127.       endcurr1 = endcurr2 = NUL;
  128. !     if (insert_space && currsize > 0)
  129.       {
  130. ! #ifdef FEAT_MBYTE
  131. !     if (has_mbyte)
  132. !     {
  133. !         next = curr + currsize - 1;
  134. !         next -= (*mb_head_off)(curr, next);
  135. !         endcurr1 = (*mb_ptr2char)(next);
  136. !         if (next > curr)
  137. !         {
  138. !         --next;
  139. !         next -= (*mb_head_off)(curr, next);
  140. !         endcurr2 = (*mb_ptr2char)(next);
  141. !         }
  142. !     }
  143. !     else
  144. ! #endif
  145. !     {
  146. !         endcurr1 = *(curr + currsize - 1);
  147. !         if (currsize > 1)
  148. !         endcurr2 = *(curr + currsize - 2);
  149. !     }
  150.       }
  151.   
  152.       next = ml_get((linenr_T)(curwin->w_cursor.lnum + 1));
  153. ***************
  154. *** 3753,3761 ****
  155.       if (insert_space)
  156.       {
  157.       next = skipwhite(next);
  158. !     if (*next != ')' && currsize != 0 && endcurr1 != TAB)
  159.       {
  160. !         /* don't add a space if the line is inding in a space */
  161.           if (endcurr1 == ' ')
  162.           endcurr1 = endcurr2;
  163.           else
  164. --- 3770,3785 ----
  165.       if (insert_space)
  166.       {
  167.       next = skipwhite(next);
  168. !     if (*next != ')' && currsize != 0 && endcurr1 != TAB
  169. ! #ifdef FEAT_MBYTE
  170. !         && (!has_format_option(FO_MBYTE_JOIN)
  171. !             || (mb_ptr2char(next) < 0x100 && endcurr1 < 0x100))
  172. !         && (!has_format_option(FO_MBYTE_JOIN2)
  173. !             || mb_ptr2char(next) < 0x100 || endcurr1 < 0x100)
  174. ! #endif
  175. !         )
  176.       {
  177. !         /* don't add a space if the line is ending in a space */
  178.           if (endcurr1 == ' ')
  179.           endcurr1 = endcurr2;
  180.           else
  181. *** ../vim60.228/src/option.h    Sun Feb  3 17:31:23 2002
  182. --- src/option.h    Sun Feb 17 14:21:19 2002
  183. ***************
  184. *** 103,114 ****
  185.   #define FO_INS_VI    'v'
  186.   #define FO_INS_LONG    'l'
  187.   #define FO_INS_BLANK    'b'
  188. ! #define FO_MULTIBYTE    'm'
  189.   #define FO_ONE_LETTER    '1'
  190.   
  191.   #define DFLT_FO_VI    "vt"
  192.   #define DFLT_FO_VIM    "tcq"
  193. ! #define FO_ALL        "tcroq2vlb1mn,"    /* for do_set() */
  194.   
  195.   /* characters for the p_cpo option: */
  196.   #define CPO_ALTREAD    'a'    /* ":read" sets alternate file name */
  197. --- 103,116 ----
  198.   #define FO_INS_VI    'v'
  199.   #define FO_INS_LONG    'l'
  200.   #define FO_INS_BLANK    'b'
  201. ! #define FO_MBYTE_BREAK    'm'    /* break before/after multi-byte char */
  202. ! #define FO_MBYTE_JOIN    'M'    /* no space before/after multi-byte char */
  203. ! #define FO_MBYTE_JOIN2    'B'    /* no space between multi-byte chars */
  204.   #define FO_ONE_LETTER    '1'
  205.   
  206.   #define DFLT_FO_VI    "vt"
  207.   #define DFLT_FO_VIM    "tcq"
  208. ! #define FO_ALL        "tcroq2vlb1mMBn,"    /* for do_set() */
  209.   
  210.   /* characters for the p_cpo option: */
  211.   #define CPO_ALTREAD    'a'    /* ":read" sets alternate file name */
  212. *** ../vim60.228/src/version.c    Sun Feb 17 23:22:34 2002
  213. --- src/version.c    Mon Feb 18 10:23:14 2002
  214. ***************
  215. *** 608,609 ****
  216. --- 608,611 ----
  217.   {   /* Add new patch number below this line */
  218. + /**/
  219. +     229,
  220.   /**/
  221.  
  222. -- 
  223. The chat program is in public domain.  This is not the GNU public license.
  224. If it breaks then you get to keep both pieces.
  225.         -- Copyright notice for the chat program
  226.  
  227.  ///  Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net  \\\
  228. ///   Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim   \\\
  229. \\\           Project leader for A-A-P -- http://www.a-a-p.org           ///
  230.  \\\  Help me helping AIDS orphans in Uganda - http://iccf-holland.org  ///
  231.