home *** CD-ROM | disk | FTP | other *** search
- To: vim-dev@vim.org
- Subject: Patch 6.0.229
- Fcc: outbox
- From: Bram Moolenaar <Bram@moolenaar.net>
- MIME-Version: 1.0
- Content-Type: text/plain; charset=ISO-8859-1
- Content-Transfer-Encoding: 8bit
- ------------
-
- Patch 6.0.229
- Problem: Multi-byte: With 'm' in 'formatoptions', formatting doesn't break
- at a multi-byte char followed by an ASCII char, and the other way
- around. (Muraoka Taro)
- When joining lines a space is inserted between multi-byte
- characters, which is not always wanted.
- Solution: Check for multi-byte character before and after the breakpoint.
- Don't insert a space before or after a multi-byte character when
- joining lines and the 'M' flag is in 'formatoptions'. Don't
- insert a space between multi-byte characters when the 'B' flag is
- in 'formatoptions'.
- Files: src/edit.c, src/ops.c, src/option.h
-
-
- *** ../vim60.228/src/edit.c Sun Feb 10 17:03:38 2002
- --- src/edit.c Sun Feb 17 14:18:37 2002
- ***************
- *** 3686,3692 ****
- textwidth = comp_textwidth(flags & INSCHAR_FORMAT);
- fo_ins_blank = has_format_option(FO_INS_BLANK);
- #ifdef FEAT_MBYTE
- ! fo_multibyte = has_format_option(FO_MULTIBYTE);
- #endif
-
- /*
- --- 3686,3692 ----
- textwidth = comp_textwidth(flags & INSCHAR_FORMAT);
- fo_ins_blank = has_format_option(FO_INS_BLANK);
- #ifdef FEAT_MBYTE
- ! fo_multibyte = has_format_option(FO_MBYTE_BREAK);
- #endif
-
- /*
- ***************
- *** 3799,3825 ****
-
- /*
- * Find position to break at.
- - * Stop at start of line.
- * Stop at first entered white when 'formatoptions' has 'v'
- */
- ! while (curwin->w_cursor.col > 0
- ! && ((!fo_ins_blank && !has_format_option(FO_INS_VI))
- || curwin->w_cursor.lnum != Insstart.lnum
- ! || curwin->w_cursor.col >= Insstart.col))
- {
- cc = gchar_cursor();
- - #ifdef FEAT_MBYTE
- - if (cc >= 0x100 && fo_multibyte)
- - {
- - /* Break at a multi-byte character. */
- - end_foundcol = curwin->w_cursor.col;
- - foundcol = curwin->w_cursor.col;
- - dec_cursor();
- - if (curwin->w_cursor.col < (colnr_T)wantcol)
- - break;
- - continue;
- - }
- - #endif
- if (vim_iswhite(cc))
- {
- /* remember position of blank just before text */
- --- 3799,3811 ----
-
- /*
- * Find position to break at.
- * Stop at first entered white when 'formatoptions' has 'v'
- */
- ! while ((!fo_ins_blank && !has_format_option(FO_INS_VI))
- || curwin->w_cursor.lnum != Insstart.lnum
- ! || curwin->w_cursor.col >= Insstart.col)
- {
- cc = gchar_cursor();
- if (vim_iswhite(cc))
- {
- /* remember position of blank just before text */
- ***************
- *** 3862,3867 ****
- --- 3848,3867 ----
- if (curwin->w_cursor.col < (colnr_T)wantcol)
- break;
- }
- + #ifdef FEAT_MBYTE
- + else if (cc >= 0x100 && fo_multibyte
- + && curwin->w_cursor.col <= (colnr_T)wantcol)
- + {
- + /* Break after or before a multi-byte character. */
- + foundcol = curwin->w_cursor.col;
- + if (curwin->w_cursor.col < (colnr_T)wantcol)
- + foundcol += (*mb_char2len)(cc);
- + end_foundcol = foundcol;
- + break;
- + }
- + #endif
- + if (curwin->w_cursor.col == 0)
- + break;
- dec_cursor();
- }
-
- *** ../vim60.228/src/ops.c Sun Feb 17 23:22:34 2002
- --- src/ops.c Sun Feb 17 21:07:29 2002
- ***************
- *** 3741,3751 ****
- curr = ml_get_curline();
- currsize = (int)STRLEN(curr);
- endcurr1 = endcurr2 = NUL;
- ! if (currsize > 0)
- {
- ! endcurr1 = *(curr + currsize - 1);
- ! if (currsize > 1)
- ! endcurr2 = *(curr + currsize - 2);
- }
-
- next = ml_get((linenr_T)(curwin->w_cursor.lnum + 1));
- --- 3741,3768 ----
- curr = ml_get_curline();
- currsize = (int)STRLEN(curr);
- endcurr1 = endcurr2 = NUL;
- ! if (insert_space && currsize > 0)
- {
- ! #ifdef FEAT_MBYTE
- ! if (has_mbyte)
- ! {
- ! next = curr + currsize - 1;
- ! next -= (*mb_head_off)(curr, next);
- ! endcurr1 = (*mb_ptr2char)(next);
- ! if (next > curr)
- ! {
- ! --next;
- ! next -= (*mb_head_off)(curr, next);
- ! endcurr2 = (*mb_ptr2char)(next);
- ! }
- ! }
- ! else
- ! #endif
- ! {
- ! endcurr1 = *(curr + currsize - 1);
- ! if (currsize > 1)
- ! endcurr2 = *(curr + currsize - 2);
- ! }
- }
-
- next = ml_get((linenr_T)(curwin->w_cursor.lnum + 1));
- ***************
- *** 3753,3761 ****
- if (insert_space)
- {
- next = skipwhite(next);
- ! if (*next != ')' && currsize != 0 && endcurr1 != TAB)
- {
- ! /* don't add a space if the line is inding in a space */
- if (endcurr1 == ' ')
- endcurr1 = endcurr2;
- else
- --- 3770,3785 ----
- if (insert_space)
- {
- next = skipwhite(next);
- ! if (*next != ')' && currsize != 0 && endcurr1 != TAB
- ! #ifdef FEAT_MBYTE
- ! && (!has_format_option(FO_MBYTE_JOIN)
- ! || (mb_ptr2char(next) < 0x100 && endcurr1 < 0x100))
- ! && (!has_format_option(FO_MBYTE_JOIN2)
- ! || mb_ptr2char(next) < 0x100 || endcurr1 < 0x100)
- ! #endif
- ! )
- {
- ! /* don't add a space if the line is ending in a space */
- if (endcurr1 == ' ')
- endcurr1 = endcurr2;
- else
- *** ../vim60.228/src/option.h Sun Feb 3 17:31:23 2002
- --- src/option.h Sun Feb 17 14:21:19 2002
- ***************
- *** 103,114 ****
- #define FO_INS_VI 'v'
- #define FO_INS_LONG 'l'
- #define FO_INS_BLANK 'b'
- ! #define FO_MULTIBYTE 'm'
- #define FO_ONE_LETTER '1'
-
- #define DFLT_FO_VI "vt"
- #define DFLT_FO_VIM "tcq"
- ! #define FO_ALL "tcroq2vlb1mn," /* for do_set() */
-
- /* characters for the p_cpo option: */
- #define CPO_ALTREAD 'a' /* ":read" sets alternate file name */
- --- 103,116 ----
- #define FO_INS_VI 'v'
- #define FO_INS_LONG 'l'
- #define FO_INS_BLANK 'b'
- ! #define FO_MBYTE_BREAK 'm' /* break before/after multi-byte char */
- ! #define FO_MBYTE_JOIN 'M' /* no space before/after multi-byte char */
- ! #define FO_MBYTE_JOIN2 'B' /* no space between multi-byte chars */
- #define FO_ONE_LETTER '1'
-
- #define DFLT_FO_VI "vt"
- #define DFLT_FO_VIM "tcq"
- ! #define FO_ALL "tcroq2vlb1mMBn," /* for do_set() */
-
- /* characters for the p_cpo option: */
- #define CPO_ALTREAD 'a' /* ":read" sets alternate file name */
- *** ../vim60.228/src/version.c Sun Feb 17 23:22:34 2002
- --- src/version.c Mon Feb 18 10:23:14 2002
- ***************
- *** 608,609 ****
- --- 608,611 ----
- { /* Add new patch number below this line */
- + /**/
- + 229,
- /**/
-
- --
- The chat program is in public domain. This is not the GNU public license.
- If it breaks then you get to keep both pieces.
- -- Copyright notice for the chat program
-
- /// Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net \\\
- /// Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim \\\
- \\\ Project leader for A-A-P -- http://www.a-a-p.org ///
- \\\ Help me helping AIDS orphans in Uganda - http://iccf-holland.org ///
-