3ef2ca
To: vim_dev@googlegroups.com
3ef2ca
Subject: Patch 7.4.338
3ef2ca
Fcc: outbox
3ef2ca
From: Bram Moolenaar <Bram@moolenaar.net>
3ef2ca
Mime-Version: 1.0
3ef2ca
Content-Type: text/plain; charset=UTF-8
3ef2ca
Content-Transfer-Encoding: 8bit
3ef2ca
------------
3ef2ca
3ef2ca
Patch 7.4.338
3ef2ca
Problem:    Cannot wrap lines taking indent into account.
3ef2ca
Solution:   Add the 'breakindent' option. (many authors, final improvements by
3ef2ca
	    Christian Brabandt)
3ef2ca
Files:	    runtime/doc/eval.txt, runtime/doc/options.txt, runtime/optwin.vim,
3ef2ca
	    src/buffer.c, src/charset.c, src/edit.c, src/ex_getln.c,
3ef2ca
	    src/getchar.c, src/misc1.c, src/misc2.c, src/ops.c, src/option.c,
3ef2ca
	    src/option.h, src/proto/charset.pro, src/proto/misc1.pro,
3ef2ca
	    src/proto/option.pro, src/screen.c, src/structs.h,
3ef2ca
	    src/testdir/Make_amiga.mak, src/testdir/Make_dos.mak,
3ef2ca
	    src/testdir/Make_ming.mak, src/testdir/Make_os2.mak,
3ef2ca
	    src/testdir/Make_vms.mms, src/testdir/Makefile,
3ef2ca
	    src/testdir/test_breakindent.in, src/testdir/test_breakindent.ok,
3ef2ca
	    src/ui.c
3ef2ca
3ef2ca
3ef2ca
*** ../vim-7.4.337/runtime/doc/eval.txt	2014-06-17 17:48:21.768628007 +0200
3ef2ca
--- runtime/doc/eval.txt	2014-06-25 12:57:00.986115765 +0200
3ef2ca
***************
3ef2ca
*** 6639,6646 ****
3ef2ca
  keymap			Compiled with 'keymap' support.
3ef2ca
  langmap			Compiled with 'langmap' support.
3ef2ca
  libcall			Compiled with |libcall()| support.
3ef2ca
! linebreak		Compiled with 'linebreak', 'breakat' and 'showbreak'
3ef2ca
! 			support.
3ef2ca
  lispindent		Compiled with support for lisp indenting.
3ef2ca
  listcmds		Compiled with commands for the buffer list |:files|
3ef2ca
  			and the argument list |arglist|.
3ef2ca
--- 6651,6658 ----
3ef2ca
  keymap			Compiled with 'keymap' support.
3ef2ca
  langmap			Compiled with 'langmap' support.
3ef2ca
  libcall			Compiled with |libcall()| support.
3ef2ca
! linebreak		Compiled with 'linebreak', 'breakat', 'showbreak' and
3ef2ca
! 			'breakindent' support.
3ef2ca
  lispindent		Compiled with support for lisp indenting.
3ef2ca
  listcmds		Compiled with commands for the buffer list |:files|
3ef2ca
  			and the argument list |arglist|.
3ef2ca
*** ../vim-7.4.337/runtime/doc/options.txt	2014-06-17 17:48:21.768628007 +0200
3ef2ca
--- runtime/doc/options.txt	2014-06-25 12:57:00.986115765 +0200
3ef2ca
***************
3ef2ca
*** 1200,1205 ****
3ef2ca
--- 1200,1237 ----
3ef2ca
  	break if 'linebreak' is on.  Only works for ASCII and also for 8-bit
3ef2ca
  	characters when 'encoding' is an 8-bit encoding.
3ef2ca
  
3ef2ca
+ 						*'breakindent'* *'bri'*
3ef2ca
+ 'breakindent' 'bri'	boolean (default off)
3ef2ca
+ 			local to window
3ef2ca
+ 			{not in Vi}
3ef2ca
+ 			{not available when compiled without the |+linebreak|
3ef2ca
+ 			feature}
3ef2ca
+ 	Every wrapped line will continue visually indented (same amount of
3ef2ca
+ 	space as the beginning of that line), thus preserving horizontal blocks
3ef2ca
+ 	of text.
3ef2ca
+ 
3ef2ca
+ 						*'breakindentopt'* *'briopt'*
3ef2ca
+ 'breakindentopt' 'briopt' string (default empty)
3ef2ca
+ 			local to window
3ef2ca
+ 			{not in Vi}
3ef2ca
+ 			{not available when compiled without the |+linebreak|
3ef2ca
+ 			feature}
3ef2ca
+ 	Settings for 'breakindent'. It can consist of the following optional
3ef2ca
+ 	items and must be seperated by a comma:
3ef2ca
+ 		min:{n}	    Minimum text width that will be kept after
3ef2ca
+ 			    applying 'breakindent', even if the resulting
3ef2ca
+ 			    text should normally be narrower. This prevents
3ef2ca
+ 			    text indented almost to the right window border
3ef2ca
+ 			    occupying lot of vertical space when broken.
3ef2ca
+ 		shift:{n}   After applying 'breakindent', wrapped line
3ef2ca
+ 			    beginning will be shift by given number of
3ef2ca
+ 			    characters. It permits dynamic French paragraph
3ef2ca
+ 			    indentation (negative) or emphasizing the line
3ef2ca
+ 			    continuation (positive).
3ef2ca
+ 		sbr	    Display the 'showbreak' value before applying the 
3ef2ca
+ 			    additional indent.
3ef2ca
+ 	The default value for min is 20 and shift is 0.
3ef2ca
+ 
3ef2ca
  						*'browsedir'* *'bsdir'*
3ef2ca
  'browsedir' 'bsdir'	string	(default: "last")
3ef2ca
  			global
3ef2ca
*** ../vim-7.4.337/runtime/optwin.vim	2014-04-01 12:26:40.241157964 +0200
3ef2ca
--- runtime/optwin.vim	2014-06-25 12:57:00.990115765 +0200
3ef2ca
***************
3ef2ca
*** 324,329 ****
3ef2ca
--- 324,335 ----
3ef2ca
  call append("$", "linebreak\twrap long lines at a character in 'breakat'")
3ef2ca
  call append("$", "\t(local to window)")
3ef2ca
  call <SID>BinOptionL("lbr")
3ef2ca
+ call append("$", "breakindent\tpreserve indentation in wrapped text")
3ef2ca
+ call append("$", "\t(local to window)")
3ef2ca
+ call <SID>BinOptionL("bri")
3ef2ca
+ call append("$", "breakindentopt\tadjust breakindent behaviour")
3ef2ca
+ call append("$", "\t(local to window)")
3ef2ca
+ call <SID>OptionL("briopt")
3ef2ca
  call append("$", "breakat\twhich characters might cause a line break")
3ef2ca
  call <SID>OptionG("brk", &brk)
3ef2ca
  call append("$", "showbreak\tstring to put before wrapped screen lines")
3ef2ca
*** ../vim-7.4.337/src/charset.c	2014-03-23 15:12:29.911264336 +0100
3ef2ca
--- src/charset.c	2014-06-25 13:23:05.842174966 +0200
3ef2ca
***************
3ef2ca
*** 867,875 ****
3ef2ca
      char_u	*s;
3ef2ca
  {
3ef2ca
      colnr_T	col = startcol;
3ef2ca
  
3ef2ca
      while (*s != NUL)
3ef2ca
! 	col += lbr_chartabsize_adv(&s, col);
3ef2ca
      return (int)col;
3ef2ca
  }
3ef2ca
  
3ef2ca
--- 867,876 ----
3ef2ca
      char_u	*s;
3ef2ca
  {
3ef2ca
      colnr_T	col = startcol;
3ef2ca
+     char_u	*line = s; /* pointer to start of line, for breakindent */
3ef2ca
  
3ef2ca
      while (*s != NUL)
3ef2ca
! 	col += lbr_chartabsize_adv(line, &s, col);
3ef2ca
      return (int)col;
3ef2ca
  }
3ef2ca
  
3ef2ca
***************
3ef2ca
*** 877,892 ****
3ef2ca
   * Like linetabsize(), but for a given window instead of the current one.
3ef2ca
   */
3ef2ca
      int
3ef2ca
! win_linetabsize(wp, p, len)
3ef2ca
      win_T	*wp;
3ef2ca
!     char_u	*p;
3ef2ca
      colnr_T	len;
3ef2ca
  {
3ef2ca
      colnr_T	col = 0;
3ef2ca
      char_u	*s;
3ef2ca
  
3ef2ca
!     for (s = p; *s != NUL && (len == MAXCOL || s < p + len); mb_ptr_adv(s))
3ef2ca
! 	col += win_lbr_chartabsize(wp, s, col, NULL);
3ef2ca
      return (int)col;
3ef2ca
  }
3ef2ca
  
3ef2ca
--- 878,894 ----
3ef2ca
   * Like linetabsize(), but for a given window instead of the current one.
3ef2ca
   */
3ef2ca
      int
3ef2ca
! win_linetabsize(wp, line, len)
3ef2ca
      win_T	*wp;
3ef2ca
!     char_u	*line;
3ef2ca
      colnr_T	len;
3ef2ca
  {
3ef2ca
      colnr_T	col = 0;
3ef2ca
      char_u	*s;
3ef2ca
  
3ef2ca
!     for (s = line; *s != NUL && (len == MAXCOL || s < line + len);
3ef2ca
! 								mb_ptr_adv(s))
3ef2ca
! 	col += win_lbr_chartabsize(wp, line, s, col, NULL);
3ef2ca
      return (int)col;
3ef2ca
  }
3ef2ca
  
3ef2ca
***************
3ef2ca
*** 1021,1032 ****
3ef2ca
   * like chartabsize(), but also check for line breaks on the screen
3ef2ca
   */
3ef2ca
      int
3ef2ca
! lbr_chartabsize(s, col)
3ef2ca
      unsigned char	*s;
3ef2ca
      colnr_T		col;
3ef2ca
  {
3ef2ca
  #ifdef FEAT_LINEBREAK
3ef2ca
!     if (!curwin->w_p_lbr && *p_sbr == NUL)
3ef2ca
      {
3ef2ca
  #endif
3ef2ca
  #ifdef FEAT_MBYTE
3ef2ca
--- 1023,1035 ----
3ef2ca
   * like chartabsize(), but also check for line breaks on the screen
3ef2ca
   */
3ef2ca
      int
3ef2ca
! lbr_chartabsize(line, s, col)
3ef2ca
!     char_u		*line; /* start of the line */
3ef2ca
      unsigned char	*s;
3ef2ca
      colnr_T		col;
3ef2ca
  {
3ef2ca
  #ifdef FEAT_LINEBREAK
3ef2ca
!     if (!curwin->w_p_lbr && *p_sbr == NUL && !curwin->w_p_bri)
3ef2ca
      {
3ef2ca
  #endif
3ef2ca
  #ifdef FEAT_MBYTE
3ef2ca
***************
3ef2ca
*** 1036,1042 ****
3ef2ca
  	RET_WIN_BUF_CHARTABSIZE(curwin, curbuf, s, col)
3ef2ca
  #ifdef FEAT_LINEBREAK
3ef2ca
      }
3ef2ca
!     return win_lbr_chartabsize(curwin, s, col, NULL);
3ef2ca
  #endif
3ef2ca
  }
3ef2ca
  
3ef2ca
--- 1039,1045 ----
3ef2ca
  	RET_WIN_BUF_CHARTABSIZE(curwin, curbuf, s, col)
3ef2ca
  #ifdef FEAT_LINEBREAK
3ef2ca
      }
3ef2ca
!     return win_lbr_chartabsize(curwin, line == NULL ? s : line, s, col, NULL);
3ef2ca
  #endif
3ef2ca
  }
3ef2ca
  
3ef2ca
***************
3ef2ca
*** 1044,1056 ****
3ef2ca
   * Call lbr_chartabsize() and advance the pointer.
3ef2ca
   */
3ef2ca
      int
3ef2ca
! lbr_chartabsize_adv(s, col)
3ef2ca
      char_u	**s;
3ef2ca
      colnr_T	col;
3ef2ca
  {
3ef2ca
      int		retval;
3ef2ca
  
3ef2ca
!     retval = lbr_chartabsize(*s, col);
3ef2ca
      mb_ptr_adv(*s);
3ef2ca
      return retval;
3ef2ca
  }
3ef2ca
--- 1047,1060 ----
3ef2ca
   * Call lbr_chartabsize() and advance the pointer.
3ef2ca
   */
3ef2ca
      int
3ef2ca
! lbr_chartabsize_adv(line, s, col)
3ef2ca
!     char_u	*line; /* start of the line */
3ef2ca
      char_u	**s;
3ef2ca
      colnr_T	col;
3ef2ca
  {
3ef2ca
      int		retval;
3ef2ca
  
3ef2ca
!     retval = lbr_chartabsize(line, *s, col);
3ef2ca
      mb_ptr_adv(*s);
3ef2ca
      return retval;
3ef2ca
  }
3ef2ca
***************
3ef2ca
*** 1063,1070 ****
3ef2ca
   * value, init to 0 before calling.
3ef2ca
   */
3ef2ca
      int
3ef2ca
! win_lbr_chartabsize(wp, s, col, headp)
3ef2ca
      win_T	*wp;
3ef2ca
      char_u	*s;
3ef2ca
      colnr_T	col;
3ef2ca
      int		*headp UNUSED;
3ef2ca
--- 1067,1075 ----
3ef2ca
   * value, init to 0 before calling.
3ef2ca
   */
3ef2ca
      int
3ef2ca
! win_lbr_chartabsize(wp, line, s, col, headp)
3ef2ca
      win_T	*wp;
3ef2ca
+     char_u	*line; /* start of the line */
3ef2ca
      char_u	*s;
3ef2ca
      colnr_T	col;
3ef2ca
      int		*headp UNUSED;
3ef2ca
***************
3ef2ca
*** 1086,1094 ****
3ef2ca
      int		n;
3ef2ca
  
3ef2ca
      /*
3ef2ca
!      * No 'linebreak' and 'showbreak': return quickly.
3ef2ca
       */
3ef2ca
!     if (!wp->w_p_lbr && *p_sbr == NUL)
3ef2ca
  #endif
3ef2ca
      {
3ef2ca
  #ifdef FEAT_MBYTE
3ef2ca
--- 1091,1099 ----
3ef2ca
      int		n;
3ef2ca
  
3ef2ca
      /*
3ef2ca
!      * No 'linebreak', 'showbreak' and 'breakindent': return quickly.
3ef2ca
       */
3ef2ca
!     if (!wp->w_p_lbr && !wp->w_p_bri && *p_sbr == NUL)
3ef2ca
  #endif
3ef2ca
      {
3ef2ca
  #ifdef FEAT_MBYTE
3ef2ca
***************
3ef2ca
*** 1163,1173 ****
3ef2ca
  # endif
3ef2ca
  
3ef2ca
      /*
3ef2ca
!      * May have to add something for 'showbreak' string at start of line
3ef2ca
       * Set *headp to the size of what we add.
3ef2ca
       */
3ef2ca
      added = 0;
3ef2ca
!     if (*p_sbr != NUL && wp->w_p_wrap && col != 0)
3ef2ca
      {
3ef2ca
  	numberextra = win_col_off(wp);
3ef2ca
  	col += numberextra + mb_added;
3ef2ca
--- 1168,1179 ----
3ef2ca
  # endif
3ef2ca
  
3ef2ca
      /*
3ef2ca
!      * May have to add something for 'breakindent' and/or 'showbreak'
3ef2ca
!      * string at start of line.
3ef2ca
       * Set *headp to the size of what we add.
3ef2ca
       */
3ef2ca
      added = 0;
3ef2ca
!     if ((*p_sbr != NUL || wp->w_p_bri) && wp->w_p_wrap && col != 0)
3ef2ca
      {
3ef2ca
  	numberextra = win_col_off(wp);
3ef2ca
  	col += numberextra + mb_added;
3ef2ca
***************
3ef2ca
*** 1180,1186 ****
3ef2ca
  	}
3ef2ca
  	if (col == 0 || col + size > (colnr_T)W_WIDTH(wp))
3ef2ca
  	{
3ef2ca
! 	    added = vim_strsize(p_sbr);
3ef2ca
  	    if (tab_corr)
3ef2ca
  		size += (added / wp->w_buffer->b_p_ts) * wp->w_buffer->b_p_ts;
3ef2ca
  	    else
3ef2ca
--- 1186,1197 ----
3ef2ca
  	}
3ef2ca
  	if (col == 0 || col + size > (colnr_T)W_WIDTH(wp))
3ef2ca
  	{
3ef2ca
! 	    added = 0;
3ef2ca
! 	    if (*p_sbr != NUL)
3ef2ca
! 		added += vim_strsize(p_sbr);
3ef2ca
! 	    if (wp->w_p_bri)
3ef2ca
! 		added += get_breakindent_win(wp, line);
3ef2ca
! 
3ef2ca
  	    if (tab_corr)
3ef2ca
  		size += (added / wp->w_buffer->b_p_ts) * wp->w_buffer->b_p_ts;
3ef2ca
  	    else
3ef2ca
***************
3ef2ca
*** 1274,1286 ****
3ef2ca
      colnr_T	vcol;
3ef2ca
      char_u	*ptr;		/* points to current char */
3ef2ca
      char_u	*posptr;	/* points to char at pos->col */
3ef2ca
      int		incr;
3ef2ca
      int		head;
3ef2ca
      int		ts = wp->w_buffer->b_p_ts;
3ef2ca
      int		c;
3ef2ca
  
3ef2ca
      vcol = 0;
3ef2ca
!     ptr = ml_get_buf(wp->w_buffer, pos->lnum, FALSE);
3ef2ca
      if (pos->col == MAXCOL)
3ef2ca
  	posptr = NULL;  /* continue until the NUL */
3ef2ca
      else
3ef2ca
--- 1285,1298 ----
3ef2ca
      colnr_T	vcol;
3ef2ca
      char_u	*ptr;		/* points to current char */
3ef2ca
      char_u	*posptr;	/* points to char at pos->col */
3ef2ca
+     char_u	*line;		/* start of the line */
3ef2ca
      int		incr;
3ef2ca
      int		head;
3ef2ca
      int		ts = wp->w_buffer->b_p_ts;
3ef2ca
      int		c;
3ef2ca
  
3ef2ca
      vcol = 0;
3ef2ca
!     line = ptr = ml_get_buf(wp->w_buffer, pos->lnum, FALSE);
3ef2ca
      if (pos->col == MAXCOL)
3ef2ca
  	posptr = NULL;  /* continue until the NUL */
3ef2ca
      else
3ef2ca
***************
3ef2ca
*** 1288,1299 ****
3ef2ca
  
3ef2ca
      /*
3ef2ca
       * This function is used very often, do some speed optimizations.
3ef2ca
!      * When 'list', 'linebreak' and 'showbreak' are not set use a simple loop.
3ef2ca
       * Also use this when 'list' is set but tabs take their normal size.
3ef2ca
       */
3ef2ca
      if ((!wp->w_p_list || lcs_tab1 != NUL)
3ef2ca
  #ifdef FEAT_LINEBREAK
3ef2ca
! 	    && !wp->w_p_lbr && *p_sbr == NUL
3ef2ca
  #endif
3ef2ca
         )
3ef2ca
      {
3ef2ca
--- 1300,1312 ----
3ef2ca
  
3ef2ca
      /*
3ef2ca
       * This function is used very often, do some speed optimizations.
3ef2ca
!      * When 'list', 'linebreak', 'showbreak' and 'breakindent' are not set
3ef2ca
!      * use a simple loop.
3ef2ca
       * Also use this when 'list' is set but tabs take their normal size.
3ef2ca
       */
3ef2ca
      if ((!wp->w_p_list || lcs_tab1 != NUL)
3ef2ca
  #ifdef FEAT_LINEBREAK
3ef2ca
! 	    && !wp->w_p_lbr && *p_sbr == NUL && !wp->w_p_bri
3ef2ca
  #endif
3ef2ca
         )
3ef2ca
      {
3ef2ca
***************
3ef2ca
*** 1355,1361 ****
3ef2ca
  	{
3ef2ca
  	    /* A tab gets expanded, depending on the current column */
3ef2ca
  	    head = 0;
3ef2ca
! 	    incr = win_lbr_chartabsize(wp, ptr, vcol, &head;;
3ef2ca
  	    /* make sure we don't go past the end of the line */
3ef2ca
  	    if (*ptr == NUL)
3ef2ca
  	    {
3ef2ca
--- 1368,1374 ----
3ef2ca
  	{
3ef2ca
  	    /* A tab gets expanded, depending on the current column */
3ef2ca
  	    head = 0;
3ef2ca
! 	    incr = win_lbr_chartabsize(wp, line, ptr, vcol, &head;;
3ef2ca
  	    /* make sure we don't go past the end of the line */
3ef2ca
  	    if (*ptr == NUL)
3ef2ca
  	    {
3ef2ca
*** ../vim-7.4.337/src/edit.c	2014-05-28 21:40:47.092329130 +0200
3ef2ca
--- src/edit.c	2014-06-25 13:16:43.278160493 +0200
3ef2ca
***************
3ef2ca
*** 1956,1962 ****
3ef2ca
  	    else
3ef2ca
  #endif
3ef2ca
  		++new_cursor_col;
3ef2ca
! 	    vcol += lbr_chartabsize(ptr + new_cursor_col, (colnr_T)vcol);
3ef2ca
  	}
3ef2ca
  	vcol = last_vcol;
3ef2ca
  
3ef2ca
--- 1956,1962 ----
3ef2ca
  	    else
3ef2ca
  #endif
3ef2ca
  		++new_cursor_col;
3ef2ca
! 	    vcol += lbr_chartabsize(ptr, ptr + new_cursor_col, (colnr_T)vcol);
3ef2ca
  	}
3ef2ca
  	vcol = last_vcol;
3ef2ca
  
3ef2ca
***************
3ef2ca
*** 7126,7134 ****
3ef2ca
  	for (;;)
3ef2ca
  	{
3ef2ca
  	    coladvance(v - width);
3ef2ca
! 	    /* getviscol() is slow, skip it when 'showbreak' is empty and
3ef2ca
! 	     * there are no multi-byte characters */
3ef2ca
! 	    if ((*p_sbr == NUL
3ef2ca
  #  ifdef FEAT_MBYTE
3ef2ca
  			&& !has_mbyte
3ef2ca
  #  endif
3ef2ca
--- 7126,7135 ----
3ef2ca
  	for (;;)
3ef2ca
  	{
3ef2ca
  	    coladvance(v - width);
3ef2ca
! 	    /* getviscol() is slow, skip it when 'showbreak' is empty,
3ef2ca
! 	     * 'breakindent' is not set and there are no multi-byte
3ef2ca
! 	     * characters */
3ef2ca
! 	    if ((*p_sbr == NUL && !curwin->w_p_bri
3ef2ca
  #  ifdef FEAT_MBYTE
3ef2ca
  			&& !has_mbyte
3ef2ca
  #  endif
3ef2ca
***************
3ef2ca
*** 9758,9768 ****
3ef2ca
  	getvcol(curwin, &fpos, &vcol, NULL, NULL);
3ef2ca
  	getvcol(curwin, cursor, &want_vcol, NULL, NULL);
3ef2ca
  
3ef2ca
! 	/* Use as many TABs as possible.  Beware of 'showbreak' and
3ef2ca
! 	 * 'linebreak' adding extra virtual columns. */
3ef2ca
  	while (vim_iswhite(*ptr))
3ef2ca
  	{
3ef2ca
! 	    i = lbr_chartabsize((char_u *)"\t", vcol);
3ef2ca
  	    if (vcol + i > want_vcol)
3ef2ca
  		break;
3ef2ca
  	    if (*ptr != TAB)
3ef2ca
--- 9759,9769 ----
3ef2ca
  	getvcol(curwin, &fpos, &vcol, NULL, NULL);
3ef2ca
  	getvcol(curwin, cursor, &want_vcol, NULL, NULL);
3ef2ca
  
3ef2ca
! 	/* Use as many TABs as possible.  Beware of 'breakindent', 'showbreak'
3ef2ca
! 	 * and 'linebreak' adding extra virtual columns. */
3ef2ca
  	while (vim_iswhite(*ptr))
3ef2ca
  	{
3ef2ca
! 	    i = lbr_chartabsize(NULL, (char_u *)"\t", vcol);
3ef2ca
  	    if (vcol + i > want_vcol)
3ef2ca
  		break;
3ef2ca
  	    if (*ptr != TAB)
3ef2ca
***************
3ef2ca
*** 9784,9794 ****
3ef2ca
  	if (change_col >= 0)
3ef2ca
  	{
3ef2ca
  	    int repl_off = 0;
3ef2ca
  
3ef2ca
  	    /* Skip over the spaces we need. */
3ef2ca
  	    while (vcol < want_vcol && *ptr == ' ')
3ef2ca
  	    {
3ef2ca
! 		vcol += lbr_chartabsize(ptr, vcol);
3ef2ca
  		++ptr;
3ef2ca
  		++repl_off;
3ef2ca
  	    }
3ef2ca
--- 9785,9796 ----
3ef2ca
  	if (change_col >= 0)
3ef2ca
  	{
3ef2ca
  	    int repl_off = 0;
3ef2ca
+ 	    char_u *line = ptr;
3ef2ca
  
3ef2ca
  	    /* Skip over the spaces we need. */
3ef2ca
  	    while (vcol < want_vcol && *ptr == ' ')
3ef2ca
  	    {
3ef2ca
! 		vcol += lbr_chartabsize(line, ptr, vcol);
3ef2ca
  		++ptr;
3ef2ca
  		++repl_off;
3ef2ca
  	    }
3ef2ca
***************
3ef2ca
*** 10029,10034 ****
3ef2ca
--- 10031,10037 ----
3ef2ca
      int	    c;
3ef2ca
      int	    temp;
3ef2ca
      char_u  *ptr, *prev_ptr;
3ef2ca
+     char_u  *line;
3ef2ca
  
3ef2ca
      if (lnum < 1 || lnum > curbuf->b_ml.ml_line_count)
3ef2ca
      {
3ef2ca
***************
3ef2ca
*** 10038,10050 ****
3ef2ca
  
3ef2ca
      /* try to advance to the cursor column */
3ef2ca
      temp = 0;
3ef2ca
!     ptr = ml_get(lnum);
3ef2ca
      prev_ptr = ptr;
3ef2ca
      validate_virtcol();
3ef2ca
      while ((colnr_T)temp < curwin->w_virtcol && *ptr != NUL)
3ef2ca
      {
3ef2ca
  	prev_ptr = ptr;
3ef2ca
! 	temp += lbr_chartabsize_adv(&ptr, (colnr_T)temp);
3ef2ca
      }
3ef2ca
      if ((colnr_T)temp > curwin->w_virtcol)
3ef2ca
  	ptr = prev_ptr;
3ef2ca
--- 10041,10053 ----
3ef2ca
  
3ef2ca
      /* try to advance to the cursor column */
3ef2ca
      temp = 0;
3ef2ca
!     line = ptr = ml_get(lnum);
3ef2ca
      prev_ptr = ptr;
3ef2ca
      validate_virtcol();
3ef2ca
      while ((colnr_T)temp < curwin->w_virtcol && *ptr != NUL)
3ef2ca
      {
3ef2ca
  	prev_ptr = ptr;
3ef2ca
! 	temp += lbr_chartabsize_adv(line, &ptr, (colnr_T)temp);
3ef2ca
      }
3ef2ca
      if ((colnr_T)temp > curwin->w_virtcol)
3ef2ca
  	ptr = prev_ptr;
3ef2ca
*** ../vim-7.4.337/src/ex_getln.c	2014-06-25 12:26:42.230046959 +0200
3ef2ca
--- src/ex_getln.c	2014-06-25 12:57:00.998115765 +0200
3ef2ca
***************
3ef2ca
*** 2302,2311 ****
3ef2ca
  
3ef2ca
  		p = (char_u *)line_ga.ga_data;
3ef2ca
  		p[line_ga.ga_len] = NUL;
3ef2ca
! 		indent = get_indent_str(p, 8);
3ef2ca
  		indent += sw - indent % sw;
3ef2ca
  add_indent:
3ef2ca
! 		while (get_indent_str(p, 8) < indent)
3ef2ca
  		{
3ef2ca
  		    char_u *s = skipwhite(p);
3ef2ca
  
3ef2ca
--- 2302,2311 ----
3ef2ca
  
3ef2ca
  		p = (char_u *)line_ga.ga_data;
3ef2ca
  		p[line_ga.ga_len] = NUL;
3ef2ca
! 		indent = get_indent_str(p, 8, FALSE);
3ef2ca
  		indent += sw - indent % sw;
3ef2ca
  add_indent:
3ef2ca
! 		while (get_indent_str(p, 8, FALSE) < indent)
3ef2ca
  		{
3ef2ca
  		    char_u *s = skipwhite(p);
3ef2ca
  
3ef2ca
***************
3ef2ca
*** 2357,2367 ****
3ef2ca
  		else
3ef2ca
  		{
3ef2ca
  		    p[line_ga.ga_len] = NUL;
3ef2ca
! 		    indent = get_indent_str(p, 8);
3ef2ca
  		    --indent;
3ef2ca
  		    indent -= indent % get_sw_value(curbuf);
3ef2ca
  		}
3ef2ca
! 		while (get_indent_str(p, 8) > indent)
3ef2ca
  		{
3ef2ca
  		    char_u *s = skipwhite(p);
3ef2ca
  
3ef2ca
--- 2357,2367 ----
3ef2ca
  		else
3ef2ca
  		{
3ef2ca
  		    p[line_ga.ga_len] = NUL;
3ef2ca
! 		    indent = get_indent_str(p, 8, FALSE);
3ef2ca
  		    --indent;
3ef2ca
  		    indent -= indent % get_sw_value(curbuf);
3ef2ca
  		}
3ef2ca
! 		while (get_indent_str(p, 8, FALSE) > indent)
3ef2ca
  		{
3ef2ca
  		    char_u *s = skipwhite(p);
3ef2ca
  
3ef2ca
*** ../vim-7.4.337/src/getchar.c	2014-05-22 18:59:54.510169240 +0200
3ef2ca
--- src/getchar.c	2014-06-25 13:16:53.946160896 +0200
3ef2ca
***************
3ef2ca
*** 2675,2681 ****
3ef2ca
  				{
3ef2ca
  				    if (!vim_iswhite(ptr[col]))
3ef2ca
  					curwin->w_wcol = vcol;
3ef2ca
! 				    vcol += lbr_chartabsize(ptr + col,
3ef2ca
  							       (colnr_T)vcol);
3ef2ca
  #ifdef FEAT_MBYTE
3ef2ca
  				    if (has_mbyte)
3ef2ca
--- 2675,2681 ----
3ef2ca
  				{
3ef2ca
  				    if (!vim_iswhite(ptr[col]))
3ef2ca
  					curwin->w_wcol = vcol;
3ef2ca
! 				    vcol += lbr_chartabsize(ptr, ptr + col,
3ef2ca
  							       (colnr_T)vcol);
3ef2ca
  #ifdef FEAT_MBYTE
3ef2ca
  				    if (has_mbyte)
3ef2ca
*** ../vim-7.4.337/src/misc1.c	2014-05-22 14:00:12.698534712 +0200
3ef2ca
--- src/misc1.c	2014-06-25 13:39:43.598212712 +0200
3ef2ca
***************
3ef2ca
*** 32,38 ****
3ef2ca
      int
3ef2ca
  get_indent()
3ef2ca
  {
3ef2ca
!     return get_indent_str(ml_get_curline(), (int)curbuf->b_p_ts);
3ef2ca
  }
3ef2ca
  
3ef2ca
  /*
3ef2ca
--- 32,38 ----
3ef2ca
      int
3ef2ca
  get_indent()
3ef2ca
  {
3ef2ca
!     return get_indent_str(ml_get_curline(), (int)curbuf->b_p_ts, FALSE);
3ef2ca
  }
3ef2ca
  
3ef2ca
  /*
3ef2ca
***************
3ef2ca
*** 42,48 ****
3ef2ca
  get_indent_lnum(lnum)
3ef2ca
      linenr_T	lnum;
3ef2ca
  {
3ef2ca
!     return get_indent_str(ml_get(lnum), (int)curbuf->b_p_ts);
3ef2ca
  }
3ef2ca
  
3ef2ca
  #if defined(FEAT_FOLDING) || defined(PROTO)
3ef2ca
--- 42,48 ----
3ef2ca
  get_indent_lnum(lnum)
3ef2ca
      linenr_T	lnum;
3ef2ca
  {
3ef2ca
!     return get_indent_str(ml_get(lnum), (int)curbuf->b_p_ts, FALSE);
3ef2ca
  }
3ef2ca
  
3ef2ca
  #if defined(FEAT_FOLDING) || defined(PROTO)
3ef2ca
***************
3ef2ca
*** 55,61 ****
3ef2ca
      buf_T	*buf;
3ef2ca
      linenr_T	lnum;
3ef2ca
  {
3ef2ca
!     return get_indent_str(ml_get_buf(buf, lnum, FALSE), (int)buf->b_p_ts);
3ef2ca
  }
3ef2ca
  #endif
3ef2ca
  
3ef2ca
--- 55,61 ----
3ef2ca
      buf_T	*buf;
3ef2ca
      linenr_T	lnum;
3ef2ca
  {
3ef2ca
!     return get_indent_str(ml_get_buf(buf, lnum, FALSE), (int)buf->b_p_ts, FALSE);
3ef2ca
  }
3ef2ca
  #endif
3ef2ca
  
3ef2ca
***************
3ef2ca
*** 64,79 ****
3ef2ca
   * 'tabstop' at "ts"
3ef2ca
   */
3ef2ca
      int
3ef2ca
! get_indent_str(ptr, ts)
3ef2ca
      char_u	*ptr;
3ef2ca
      int		ts;
3ef2ca
  {
3ef2ca
      int		count = 0;
3ef2ca
  
3ef2ca
      for ( ; *ptr; ++ptr)
3ef2ca
      {
3ef2ca
! 	if (*ptr == TAB)    /* count a tab for what it is worth */
3ef2ca
! 	    count += ts - (count % ts);
3ef2ca
  	else if (*ptr == ' ')
3ef2ca
  	    ++count;		/* count a space for one */
3ef2ca
  	else
3ef2ca
--- 64,86 ----
3ef2ca
   * 'tabstop' at "ts"
3ef2ca
   */
3ef2ca
      int
3ef2ca
! get_indent_str(ptr, ts, list)
3ef2ca
      char_u	*ptr;
3ef2ca
      int		ts;
3ef2ca
+     int		list; /* if TRUE, count only screen size for tabs */
3ef2ca
  {
3ef2ca
      int		count = 0;
3ef2ca
  
3ef2ca
      for ( ; *ptr; ++ptr)
3ef2ca
      {
3ef2ca
! 	if (*ptr == TAB)
3ef2ca
! 	{
3ef2ca
! 	    if (!list || lcs_tab1)    /* count a tab for what it is worth */
3ef2ca
! 		count += ts - (count % ts);
3ef2ca
! 	    else
3ef2ca
! 	/* in list mode, when tab is not set, count screen char width for Tab: ^I */
3ef2ca
! 		count += ptr2cells(ptr);
3ef2ca
! 	}
3ef2ca
  	else if (*ptr == ' ')
3ef2ca
  	    ++count;		/* count a space for one */
3ef2ca
  	else
3ef2ca
***************
3ef2ca
*** 476,481 ****
3ef2ca
--- 483,540 ----
3ef2ca
      return (int)col;
3ef2ca
  }
3ef2ca
  
3ef2ca
+ #if defined(FEAT_LINEBREAK) || defined(PROTO)
3ef2ca
+ /*
3ef2ca
+  * Return appropriate space number for breakindent, taking influencing
3ef2ca
+  * parameters into account. Window must be specified, since it is not
3ef2ca
+  * necessarily always the current one.
3ef2ca
+  */
3ef2ca
+     int
3ef2ca
+ get_breakindent_win(wp, line)
3ef2ca
+     win_T	*wp;
3ef2ca
+     char_u	*line; /* start of the line */
3ef2ca
+ {
3ef2ca
+     static int	    prev_indent = 0;  /* cached indent value */
3ef2ca
+     static long	    prev_ts     = 0L; /* cached tabstop value */
3ef2ca
+     static char_u   *prev_line = NULL; /* cached pointer to line */
3ef2ca
+     int		    bri = 0;
3ef2ca
+     /* window width minus window margin space, i.e. what rests for text */
3ef2ca
+     const int	    eff_wwidth = W_WIDTH(wp)
3ef2ca
+ 			    - ((wp->w_p_nu || wp->w_p_rnu)
3ef2ca
+ 				&& (vim_strchr(p_cpo, CPO_NUMCOL) == NULL)
3ef2ca
+ 						? number_width(wp) + 1 : 0);
3ef2ca
+ 
3ef2ca
+     /* used cached indent, unless pointer or 'tabstop' changed */
3ef2ca
+     if (prev_line != line || prev_ts != wp->w_buffer->b_p_ts)
3ef2ca
+     {
3ef2ca
+ 	prev_line = line;
3ef2ca
+ 	prev_ts = wp->w_buffer->b_p_ts;
3ef2ca
+ 	prev_indent = get_indent_str(line,
3ef2ca
+ 		  (int)wp->w_buffer->b_p_ts, wp->w_p_list) + wp->w_p_brishift;
3ef2ca
+     }
3ef2ca
+ 
3ef2ca
+     /* indent minus the length of the showbreak string */
3ef2ca
+     bri = prev_indent;
3ef2ca
+     if (wp->w_p_brisbr)
3ef2ca
+ 	bri -= vim_strsize(p_sbr);
3ef2ca
+ 
3ef2ca
+     /* Add offset for number column, if 'n' is in 'cpoptions' */
3ef2ca
+     bri += win_col_off2(wp);
3ef2ca
+ 
3ef2ca
+     /* never indent past left window margin */
3ef2ca
+     if (bri < 0)
3ef2ca
+ 	bri = 0;
3ef2ca
+     /* always leave at least bri_min characters on the left,
3ef2ca
+      * if text width is sufficient */
3ef2ca
+     else if (bri > eff_wwidth - wp->w_p_brimin)
3ef2ca
+ 	bri = (eff_wwidth - wp->w_p_brimin < 0)
3ef2ca
+ 			    ? 0 : eff_wwidth - wp->w_p_brimin;
3ef2ca
+ 
3ef2ca
+     return bri;
3ef2ca
+ }
3ef2ca
+ #endif
3ef2ca
+ 
3ef2ca
+ 
3ef2ca
  #if defined(FEAT_CINDENT) || defined(FEAT_SMARTINDENT)
3ef2ca
  
3ef2ca
  static int cin_is_cinword __ARGS((char_u *line));
3ef2ca
***************
3ef2ca
*** 678,684 ****
3ef2ca
  	/*
3ef2ca
  	 * count white space on current line
3ef2ca
  	 */
3ef2ca
! 	newindent = get_indent_str(saved_line, (int)curbuf->b_p_ts);
3ef2ca
  	if (newindent == 0 && !(flags & OPENLINE_COM_LIST))
3ef2ca
  	    newindent = second_line_indent; /* for ^^D command in insert mode */
3ef2ca
  
3ef2ca
--- 737,743 ----
3ef2ca
  	/*
3ef2ca
  	 * count white space on current line
3ef2ca
  	 */
3ef2ca
! 	newindent = get_indent_str(saved_line, (int)curbuf->b_p_ts, FALSE);
3ef2ca
  	if (newindent == 0 && !(flags & OPENLINE_COM_LIST))
3ef2ca
  	    newindent = second_line_indent; /* for ^^D command in insert mode */
3ef2ca
  
3ef2ca
***************
3ef2ca
*** 1201,1207 ****
3ef2ca
  					|| do_si
3ef2ca
  #endif
3ef2ca
  							   )
3ef2ca
! 			newindent = get_indent_str(leader, (int)curbuf->b_p_ts);
3ef2ca
  
3ef2ca
  		    /* Add the indent offset */
3ef2ca
  		    if (newindent + off < 0)
3ef2ca
--- 1260,1266 ----
3ef2ca
  					|| do_si
3ef2ca
  #endif
3ef2ca
  							   )
3ef2ca
! 			newindent = get_indent_str(leader, (int)curbuf->b_p_ts, FALSE);
3ef2ca
  
3ef2ca
  		    /* Add the indent offset */
3ef2ca
  		    if (newindent + off < 0)
3ef2ca
***************
3ef2ca
*** 1994,1999 ****
3ef2ca
--- 2053,2059 ----
3ef2ca
      char_u	*s;
3ef2ca
      int		lines = 0;
3ef2ca
      int		width;
3ef2ca
+     char_u	*line;
3ef2ca
  
3ef2ca
  #ifdef FEAT_DIFF
3ef2ca
      /* Check for filler lines above this buffer line.  When folded the result
3ef2ca
***************
3ef2ca
*** 2009,2020 ****
3ef2ca
  	return lines + 1;
3ef2ca
  #endif
3ef2ca
  
3ef2ca
!     s = ml_get_buf(wp->w_buffer, lnum, FALSE);
3ef2ca
  
3ef2ca
      col = 0;
3ef2ca
      while (*s != NUL && --column >= 0)
3ef2ca
      {
3ef2ca
! 	col += win_lbr_chartabsize(wp, s, (colnr_T)col, NULL);
3ef2ca
  	mb_ptr_adv(s);
3ef2ca
      }
3ef2ca
  
3ef2ca
--- 2069,2080 ----
3ef2ca
  	return lines + 1;
3ef2ca
  #endif
3ef2ca
  
3ef2ca
!     line = s = ml_get_buf(wp->w_buffer, lnum, FALSE);
3ef2ca
  
3ef2ca
      col = 0;
3ef2ca
      while (*s != NUL && --column >= 0)
3ef2ca
      {
3ef2ca
! 	col += win_lbr_chartabsize(wp, line, s, (colnr_T)col, NULL);
3ef2ca
  	mb_ptr_adv(s);
3ef2ca
      }
3ef2ca
  
3ef2ca
***************
3ef2ca
*** 2026,2032 ****
3ef2ca
       * 'ts') -- webb.
3ef2ca
       */
3ef2ca
      if (*s == TAB && (State & NORMAL) && (!wp->w_p_list || lcs_tab1))
3ef2ca
! 	col += win_lbr_chartabsize(wp, s, (colnr_T)col, NULL) - 1;
3ef2ca
  
3ef2ca
      /*
3ef2ca
       * Add column offset for 'number', 'relativenumber', 'foldcolumn', etc.
3ef2ca
--- 2086,2092 ----
3ef2ca
       * 'ts') -- webb.
3ef2ca
       */
3ef2ca
      if (*s == TAB && (State & NORMAL) && (!wp->w_p_list || lcs_tab1))
3ef2ca
! 	col += win_lbr_chartabsize(wp, line, s, (colnr_T)col, NULL) - 1;
3ef2ca
  
3ef2ca
      /*
3ef2ca
       * Add column offset for 'number', 'relativenumber', 'foldcolumn', etc.
3ef2ca
***************
3ef2ca
*** 9002,9011 ****
3ef2ca
  		amount = 2;
3ef2ca
  	    else
3ef2ca
  	    {
3ef2ca
  		amount = 0;
3ef2ca
  		while (*that && col)
3ef2ca
  		{
3ef2ca
! 		    amount += lbr_chartabsize_adv(&that, (colnr_T)amount);
3ef2ca
  		    col--;
3ef2ca
  		}
3ef2ca
  
3ef2ca
--- 9062,9073 ----
3ef2ca
  		amount = 2;
3ef2ca
  	    else
3ef2ca
  	    {
3ef2ca
+ 		char_u *line = that;
3ef2ca
+ 
3ef2ca
  		amount = 0;
3ef2ca
  		while (*that && col)
3ef2ca
  		{
3ef2ca
! 		    amount += lbr_chartabsize_adv(line, &that, (colnr_T)amount);
3ef2ca
  		    col--;
3ef2ca
  		}
3ef2ca
  
3ef2ca
***************
3ef2ca
*** 9028,9034 ****
3ef2ca
  
3ef2ca
  		    while (vim_iswhite(*that))
3ef2ca
  		    {
3ef2ca
! 			amount += lbr_chartabsize(that, (colnr_T)amount);
3ef2ca
  			++that;
3ef2ca
  		    }
3ef2ca
  
3ef2ca
--- 9090,9096 ----
3ef2ca
  
3ef2ca
  		    while (vim_iswhite(*that))
3ef2ca
  		    {
3ef2ca
! 			amount += lbr_chartabsize(line, that, (colnr_T)amount);
3ef2ca
  			++that;
3ef2ca
  		    }
3ef2ca
  
3ef2ca
***************
3ef2ca
*** 9066,9080 ****
3ef2ca
  							       && !quotecount)
3ef2ca
  				    --parencount;
3ef2ca
  				if (*that == '\\' && *(that+1) != NUL)
3ef2ca
! 				    amount += lbr_chartabsize_adv(&that,
3ef2ca
! 							     (colnr_T)amount);
3ef2ca
! 				amount += lbr_chartabsize_adv(&that,
3ef2ca
! 							     (colnr_T)amount);
3ef2ca
  			    }
3ef2ca
  			}
3ef2ca
  			while (vim_iswhite(*that))
3ef2ca
  			{
3ef2ca
! 			    amount += lbr_chartabsize(that, (colnr_T)amount);
3ef2ca
  			    that++;
3ef2ca
  			}
3ef2ca
  			if (!*that || *that == ';')
3ef2ca
--- 9128,9143 ----
3ef2ca
  							       && !quotecount)
3ef2ca
  				    --parencount;
3ef2ca
  				if (*that == '\\' && *(that+1) != NUL)
3ef2ca
! 				    amount += lbr_chartabsize_adv(
3ef2ca
! 						line, &that, (colnr_T)amount);
3ef2ca
! 				amount += lbr_chartabsize_adv(
3ef2ca
! 						line, &that, (colnr_T)amount);
3ef2ca
  			    }
3ef2ca
  			}
3ef2ca
  			while (vim_iswhite(*that))
3ef2ca
  			{
3ef2ca
! 			    amount += lbr_chartabsize(
3ef2ca
! 						 line, that, (colnr_T)amount);
3ef2ca
  			    that++;
3ef2ca
  			}
3ef2ca
  			if (!*that || *that == ';')
3ef2ca
*** ../vim-7.4.337/src/misc2.c	2014-05-07 18:35:25.669216052 +0200
3ef2ca
--- src/misc2.c	2014-06-25 13:21:18.474170904 +0200
3ef2ca
***************
3ef2ca
*** 201,210 ****
3ef2ca
  	{
3ef2ca
  	    /* Count a tab for what it's worth (if list mode not on) */
3ef2ca
  #ifdef FEAT_LINEBREAK
3ef2ca
! 	    csize = win_lbr_chartabsize(curwin, ptr, col, &head;;
3ef2ca
  	    mb_ptr_adv(ptr);
3ef2ca
  #else
3ef2ca
! 	    csize = lbr_chartabsize_adv(&ptr, col);
3ef2ca
  #endif
3ef2ca
  	    col += csize;
3ef2ca
  	}
3ef2ca
--- 201,210 ----
3ef2ca
  	{
3ef2ca
  	    /* Count a tab for what it's worth (if list mode not on) */
3ef2ca
  #ifdef FEAT_LINEBREAK
3ef2ca
! 	    csize = win_lbr_chartabsize(curwin, line, ptr, col, &head;;
3ef2ca
  	    mb_ptr_adv(ptr);
3ef2ca
  #else
3ef2ca
! 	    csize = lbr_chartabsize_adv(line, &ptr, col);
3ef2ca
  #endif
3ef2ca
  	    col += csize;
3ef2ca
  	}
3ef2ca
***************
3ef2ca
*** 2156,2162 ****
3ef2ca
      }
3ef2ca
  }
3ef2ca
  
3ef2ca
! #if (defined(UNIX) && !defined(USE_SYSTEM)) || defined(WIN3264)
3ef2ca
  /*
3ef2ca
   * Append the text in "gap" below the cursor line and clear "gap".
3ef2ca
   */
3ef2ca
--- 2156,2163 ----
3ef2ca
      }
3ef2ca
  }
3ef2ca
  
3ef2ca
! #if (defined(UNIX) && !defined(USE_SYSTEM)) || defined(WIN3264) \
3ef2ca
! 	|| defined(PROTO)
3ef2ca
  /*
3ef2ca
   * Append the text in "gap" below the cursor line and clear "gap".
3ef2ca
   */
3ef2ca
*** ../vim-7.4.337/src/ops.c	2014-06-17 18:16:08.420691059 +0200
3ef2ca
--- src/ops.c	2014-06-25 13:18:27.082164420 +0200
3ef2ca
***************
3ef2ca
*** 420,426 ****
3ef2ca
  	}
3ef2ca
  	for ( ; vim_iswhite(*bd.textstart); )
3ef2ca
  	{
3ef2ca
! 	    incr = lbr_chartabsize_adv(&bd.textstart, (colnr_T)(bd.start_vcol));
3ef2ca
  	    total += incr;
3ef2ca
  	    bd.start_vcol += incr;
3ef2ca
  	}
3ef2ca
--- 420,428 ----
3ef2ca
  	}
3ef2ca
  	for ( ; vim_iswhite(*bd.textstart); )
3ef2ca
  	{
3ef2ca
! 	    /* TODO: is passing bd.textstart for start of the line OK? */
3ef2ca
! 	    incr = lbr_chartabsize_adv(bd.textstart, &bd.textstart,
3ef2ca
! 						    (colnr_T)(bd.start_vcol));
3ef2ca
  	    total += incr;
3ef2ca
  	    bd.start_vcol += incr;
3ef2ca
  	}
3ef2ca
***************
3ef2ca
*** 480,486 ****
3ef2ca
  
3ef2ca
  	while (vim_iswhite(*non_white))
3ef2ca
  	{
3ef2ca
! 	    incr = lbr_chartabsize_adv(&non_white, non_white_col);
3ef2ca
  	    non_white_col += incr;
3ef2ca
  	}
3ef2ca
  
3ef2ca
--- 482,488 ----
3ef2ca
  
3ef2ca
  	while (vim_iswhite(*non_white))
3ef2ca
  	{
3ef2ca
! 	    incr = lbr_chartabsize_adv(bd.textstart, &non_white, non_white_col);
3ef2ca
  	    non_white_col += incr;
3ef2ca
  	}
3ef2ca
  
3ef2ca
***************
3ef2ca
*** 505,511 ****
3ef2ca
  	    verbatim_copy_width -= bd.start_char_vcols;
3ef2ca
  	while (verbatim_copy_width < destination_col)
3ef2ca
  	{
3ef2ca
! 	    incr = lbr_chartabsize(verbatim_copy_end, verbatim_copy_width);
3ef2ca
  	    if (verbatim_copy_width + incr > destination_col)
3ef2ca
  		break;
3ef2ca
  	    verbatim_copy_width += incr;
3ef2ca
--- 507,517 ----
3ef2ca
  	    verbatim_copy_width -= bd.start_char_vcols;
3ef2ca
  	while (verbatim_copy_width < destination_col)
3ef2ca
  	{
3ef2ca
! 	    char_u *line = verbatim_copy_end;
3ef2ca
! 
3ef2ca
! 	    /* TODO: is passing verbatim_copy_end for start of the line OK? */
3ef2ca
! 	    incr = lbr_chartabsize(line, verbatim_copy_end,
3ef2ca
! 							 verbatim_copy_width);
3ef2ca
  	    if (verbatim_copy_width + incr > destination_col)
3ef2ca
  		break;
3ef2ca
  	    verbatim_copy_width += incr;
3ef2ca
***************
3ef2ca
*** 3617,3623 ****
3ef2ca
  	    for (ptr = oldp; vcol < col && *ptr; )
3ef2ca
  	    {
3ef2ca
  		/* Count a tab for what it's worth (if list mode not on) */
3ef2ca
! 		incr = lbr_chartabsize_adv(&ptr, (colnr_T)vcol);
3ef2ca
  		vcol += incr;
3ef2ca
  	    }
3ef2ca
  	    bd.textcol = (colnr_T)(ptr - oldp);
3ef2ca
--- 3623,3629 ----
3ef2ca
  	    for (ptr = oldp; vcol < col && *ptr; )
3ef2ca
  	    {
3ef2ca
  		/* Count a tab for what it's worth (if list mode not on) */
3ef2ca
! 		incr = lbr_chartabsize_adv(oldp, &ptr, (colnr_T)vcol);
3ef2ca
  		vcol += incr;
3ef2ca
  	    }
3ef2ca
  	    bd.textcol = (colnr_T)(ptr - oldp);
3ef2ca
***************
3ef2ca
*** 3651,3657 ****
3ef2ca
  	    /* calculate number of spaces required to fill right side of block*/
3ef2ca
  	    spaces = y_width + 1;
3ef2ca
  	    for (j = 0; j < yanklen; j++)
3ef2ca
! 		spaces -= lbr_chartabsize(&y_array[i][j], 0);
3ef2ca
  	    if (spaces < 0)
3ef2ca
  		spaces = 0;
3ef2ca
  
3ef2ca
--- 3657,3663 ----
3ef2ca
  	    /* calculate number of spaces required to fill right side of block*/
3ef2ca
  	    spaces = y_width + 1;
3ef2ca
  	    for (j = 0; j < yanklen; j++)
3ef2ca
! 		spaces -= lbr_chartabsize(NULL, &y_array[i][j], 0);
3ef2ca
  	    if (spaces < 0)
3ef2ca
  		spaces = 0;
3ef2ca
  
3ef2ca
***************
3ef2ca
*** 5203,5209 ****
3ef2ca
      while (bdp->start_vcol < oap->start_vcol && *pstart)
3ef2ca
      {
3ef2ca
  	/* Count a tab for what it's worth (if list mode not on) */
3ef2ca
! 	incr = lbr_chartabsize(pstart, (colnr_T)bdp->start_vcol);
3ef2ca
  	bdp->start_vcol += incr;
3ef2ca
  #ifdef FEAT_VISUALEXTRA
3ef2ca
  	if (vim_iswhite(*pstart))
3ef2ca
--- 5209,5215 ----
3ef2ca
      while (bdp->start_vcol < oap->start_vcol && *pstart)
3ef2ca
      {
3ef2ca
  	/* Count a tab for what it's worth (if list mode not on) */
3ef2ca
! 	incr = lbr_chartabsize(line, pstart, (colnr_T)bdp->start_vcol);
3ef2ca
  	bdp->start_vcol += incr;
3ef2ca
  #ifdef FEAT_VISUALEXTRA
3ef2ca
  	if (vim_iswhite(*pstart))
3ef2ca
***************
3ef2ca
*** 5272,5278 ****
3ef2ca
  	    {
3ef2ca
  		/* Count a tab for what it's worth (if list mode not on) */
3ef2ca
  		prev_pend = pend;
3ef2ca
! 		incr = lbr_chartabsize_adv(&pend, (colnr_T)bdp->end_vcol);
3ef2ca
  		bdp->end_vcol += incr;
3ef2ca
  	    }
3ef2ca
  	    if (bdp->end_vcol <= oap->end_vcol
3ef2ca
--- 5278,5287 ----
3ef2ca
  	    {
3ef2ca
  		/* Count a tab for what it's worth (if list mode not on) */
3ef2ca
  		prev_pend = pend;
3ef2ca
! 		/* TODO: is passing prev_pend for start of the line OK?
3ef2ca
! 		 * perhaps it should be "line". */
3ef2ca
! 		incr = lbr_chartabsize_adv(prev_pend, &pend,
3ef2ca
! 						      (colnr_T)bdp->end_vcol);
3ef2ca
  		bdp->end_vcol += incr;
3ef2ca
  	    }
3ef2ca
  	    if (bdp->end_vcol <= oap->end_vcol
3ef2ca
***************
3ef2ca
*** 6882,6888 ****
3ef2ca
  	    validate_virtcol();
3ef2ca
  	    col_print(buf1, sizeof(buf1), (int)curwin->w_cursor.col + 1,
3ef2ca
  		    (int)curwin->w_virtcol + 1);
3ef2ca
! 	    col_print(buf2, sizeof(buf2), (int)STRLEN(p), linetabsize(p));
3ef2ca
  
3ef2ca
  	    if (char_count_cursor == byte_count_cursor
3ef2ca
  		    && char_count == byte_count)
3ef2ca
--- 6891,6898 ----
3ef2ca
  	    validate_virtcol();
3ef2ca
  	    col_print(buf1, sizeof(buf1), (int)curwin->w_cursor.col + 1,
3ef2ca
  		    (int)curwin->w_virtcol + 1);
3ef2ca
! 	    col_print(buf2, sizeof(buf2), (int)STRLEN(p),
3ef2ca
! 				linetabsize(p));
3ef2ca
  
3ef2ca
  	    if (char_count_cursor == byte_count_cursor
3ef2ca
  		    && char_count == byte_count)
3ef2ca
*** ../vim-7.4.337/src/option.c	2014-06-25 11:48:40.733960646 +0200
3ef2ca
--- src/option.c	2014-06-25 14:31:41.630330672 +0200
3ef2ca
***************
3ef2ca
*** 188,193 ****
3ef2ca
--- 188,197 ----
3ef2ca
  #ifdef FEAT_ARABIC
3ef2ca
  # define PV_ARAB	OPT_WIN(WV_ARAB)
3ef2ca
  #endif
3ef2ca
+ #ifdef FEAT_LINEBREAK
3ef2ca
+ # define PV_BRI		OPT_WIN(WV_BRI)
3ef2ca
+ # define PV_BRIOPT	OPT_WIN(WV_BRIOPT)
3ef2ca
+ #endif
3ef2ca
  #ifdef FEAT_DIFF
3ef2ca
  # define PV_DIFF	OPT_WIN(WV_DIFF)
3ef2ca
  #endif
3ef2ca
***************
3ef2ca
*** 648,653 ****
3ef2ca
--- 652,675 ----
3ef2ca
  			    {(char_u *)0L, (char_u *)0L}
3ef2ca
  #endif
3ef2ca
  			    SCRIPTID_INIT},
3ef2ca
+     {"breakindent",   "bri",  P_BOOL|P_VI_DEF|P_VIM|P_RWIN,
3ef2ca
+ #ifdef FEAT_LINEBREAK
3ef2ca
+ 			    (char_u *)VAR_WIN, PV_BRI,
3ef2ca
+ 			    {(char_u *)FALSE, (char_u *)0L}
3ef2ca
+ #else
3ef2ca
+ 			    (char_u *)NULL, PV_NONE,
3ef2ca
+ 			    {(char_u *)0L, (char_u *)0L}
3ef2ca
+ #endif
3ef2ca
+ 			    SCRIPTID_INIT},
3ef2ca
+     {"breakindentopt", "briopt", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF|P_COMMA|P_NODUP,
3ef2ca
+ #ifdef FEAT_LINEBREAK
3ef2ca
+ 			    (char_u *)VAR_WIN, PV_BRIOPT,
3ef2ca
+ 			    {(char_u *)"", (char_u *)NULL}
3ef2ca
+ #else
3ef2ca
+ 			    (char_u *)NULL, PV_NONE,
3ef2ca
+ 			    {(char_u *)"", (char_u *)NULL}
3ef2ca
+ #endif
3ef2ca
+ 			    SCRIPTID_INIT},
3ef2ca
      {"browsedir",   "bsdir",P_STRING|P_VI_DEF,
3ef2ca
  #ifdef FEAT_BROWSE
3ef2ca
  			    (char_u *)&p_bsdir, PV_NONE,
3ef2ca
***************
3ef2ca
*** 5256,5261 ****
3ef2ca
--- 5278,5286 ----
3ef2ca
      /* set cedit_key */
3ef2ca
      (void)check_cedit();
3ef2ca
  #endif
3ef2ca
+ #ifdef FEAT_LINEBREAK
3ef2ca
+     briopt_check();
3ef2ca
+ #endif
3ef2ca
  }
3ef2ca
  
3ef2ca
  /*
3ef2ca
***************
3ef2ca
*** 5709,5714 ****
3ef2ca
--- 5734,5747 ----
3ef2ca
  		     *p_pm == '.' ? p_pm + 1 : p_pm) == 0)
3ef2ca
  	    errmsg = (char_u *)N_("E589: 'backupext' and 'patchmode' are equal");
3ef2ca
      }
3ef2ca
+ #ifdef FEAT_LINEBREAK
3ef2ca
+     /* 'breakindentopt' */
3ef2ca
+     else if (varp == &curwin->w_p_briopt)
3ef2ca
+     {
3ef2ca
+ 	if (briopt_check() == FAIL)
3ef2ca
+ 	    errmsg = e_invarg;
3ef2ca
+     }
3ef2ca
+ #endif
3ef2ca
  
3ef2ca
      /*
3ef2ca
       * 'isident', 'iskeyword', 'isprint or 'isfname' option: refill chartab[]
3ef2ca
***************
3ef2ca
*** 10018,10023 ****
3ef2ca
--- 10051,10058 ----
3ef2ca
  	case PV_WRAP:	return (char_u *)&(curwin->w_p_wrap);
3ef2ca
  #ifdef FEAT_LINEBREAK
3ef2ca
  	case PV_LBR:	return (char_u *)&(curwin->w_p_lbr);
3ef2ca
+ 	case PV_BRI:	return (char_u *)&(curwin->w_p_bri);
3ef2ca
+ 	case PV_BRIOPT: return (char_u *)&(curwin->w_p_briopt);
3ef2ca
  #endif
3ef2ca
  #ifdef FEAT_SCROLLBIND
3ef2ca
  	case PV_SCBIND: return (char_u *)&(curwin->w_p_scb);
3ef2ca
***************
3ef2ca
*** 10207,10212 ****
3ef2ca
--- 10242,10249 ----
3ef2ca
  #endif
3ef2ca
  #ifdef FEAT_LINEBREAK
3ef2ca
      to->wo_lbr = from->wo_lbr;
3ef2ca
+     to->wo_bri = from->wo_bri;
3ef2ca
+     to->wo_briopt = vim_strsave(from->wo_briopt);
3ef2ca
  #endif
3ef2ca
  #ifdef FEAT_SCROLLBIND
3ef2ca
      to->wo_scb = from->wo_scb;
3ef2ca
***************
3ef2ca
*** 10294,10299 ****
3ef2ca
--- 10331,10339 ----
3ef2ca
  #ifdef FEAT_CONCEAL
3ef2ca
      check_string_option(&wop->wo_cocu);
3ef2ca
  #endif
3ef2ca
+ #ifdef FEAT_LINEBREAK
3ef2ca
+     check_string_option(&wop->wo_briopt);
3ef2ca
+ #endif
3ef2ca
  }
3ef2ca
  
3ef2ca
  /*
3ef2ca
***************
3ef2ca
*** 10313,10318 ****
3ef2ca
--- 10353,10361 ----
3ef2ca
  # endif
3ef2ca
      clear_string_option(&wop->wo_fmr);
3ef2ca
  #endif
3ef2ca
+ #ifdef FEAT_LINEBREAK
3ef2ca
+     clear_string_option(&wop->wo_briopt);
3ef2ca
+ #endif
3ef2ca
  #ifdef FEAT_RIGHTLEFT
3ef2ca
      clear_string_option(&wop->wo_rlc);
3ef2ca
  #endif
3ef2ca
***************
3ef2ca
*** 11927,11929 ****
3ef2ca
--- 11970,12018 ----
3ef2ca
  	    ++ptr;
3ef2ca
      }
3ef2ca
  }
3ef2ca
+ 
3ef2ca
+ #if defined(FEAT_LINEBREAK) || defined(PROTO)
3ef2ca
+ /*
3ef2ca
+  * This is called when 'breakindentopt' is changed and when a window is
3ef2ca
+  * initialized.
3ef2ca
+  */
3ef2ca
+     int
3ef2ca
+ briopt_check()
3ef2ca
+ {
3ef2ca
+     char_u	*p;
3ef2ca
+     int		bri_shift = 0;
3ef2ca
+     long	bri_min = 20;
3ef2ca
+     int		bri_sbr = FALSE;
3ef2ca
+ 
3ef2ca
+     p = curwin->w_p_briopt;
3ef2ca
+     while (*p != NUL)
3ef2ca
+     {
3ef2ca
+ 	if (STRNCMP(p, "shift:", 6) == 0
3ef2ca
+ 		 && ((p[6] == '-' && VIM_ISDIGIT(p[7])) || VIM_ISDIGIT(p[6])))
3ef2ca
+ 	{
3ef2ca
+ 	    p += 6;
3ef2ca
+ 	    bri_shift = getdigits(&p);
3ef2ca
+ 	}
3ef2ca
+ 	else if (STRNCMP(p, "min:", 4) == 0 && VIM_ISDIGIT(p[4]))
3ef2ca
+ 	{
3ef2ca
+ 	    p += 4;
3ef2ca
+ 	    bri_min = getdigits(&p);
3ef2ca
+ 	}
3ef2ca
+ 	else if (STRNCMP(p, "sbr", 3) == 0)
3ef2ca
+ 	{
3ef2ca
+ 	    p += 3;
3ef2ca
+ 	    bri_sbr = TRUE;
3ef2ca
+ 	}
3ef2ca
+ 	if (*p != ',' && *p != NUL)
3ef2ca
+ 	    return FAIL;
3ef2ca
+ 	if (*p == ',')
3ef2ca
+ 	    ++p;
3ef2ca
+     }
3ef2ca
+ 
3ef2ca
+     curwin->w_p_brishift = bri_shift;
3ef2ca
+     curwin->w_p_brimin   = bri_min;
3ef2ca
+     curwin->w_p_brisbr   = bri_sbr;
3ef2ca
+ 
3ef2ca
+     return OK;
3ef2ca
+ }
3ef2ca
+ #endif
3ef2ca
*** ../vim-7.4.337/src/option.h	2014-05-28 21:40:47.092329130 +0200
3ef2ca
--- src/option.h	2014-06-25 12:57:01.002115765 +0200
3ef2ca
***************
3ef2ca
*** 1052,1057 ****
3ef2ca
--- 1052,1061 ----
3ef2ca
  #ifdef FEAT_CURSORBIND
3ef2ca
      , WV_CRBIND
3ef2ca
  #endif
3ef2ca
+ #ifdef FEAT_LINEBREAK
3ef2ca
+     , WV_BRI
3ef2ca
+     , WV_BRIOPT
3ef2ca
+ #endif
3ef2ca
  #ifdef FEAT_DIFF
3ef2ca
      , WV_DIFF
3ef2ca
  #endif
3ef2ca
*** ../vim-7.4.337/src/proto/charset.pro	2013-08-10 13:37:07.000000000 +0200
3ef2ca
--- src/proto/charset.pro	2014-06-25 13:22:32.934173721 +0200
3ef2ca
***************
3ef2ca
*** 16,22 ****
3ef2ca
  int chartabsize __ARGS((char_u *p, colnr_T col));
3ef2ca
  int linetabsize __ARGS((char_u *s));
3ef2ca
  int linetabsize_col __ARGS((int startcol, char_u *s));
3ef2ca
! int win_linetabsize __ARGS((win_T *wp, char_u *p, colnr_T len));
3ef2ca
  int vim_isIDc __ARGS((int c));
3ef2ca
  int vim_iswordc __ARGS((int c));
3ef2ca
  int vim_iswordc_buf __ARGS((int c, buf_T *buf));
3ef2ca
--- 16,22 ----
3ef2ca
  int chartabsize __ARGS((char_u *p, colnr_T col));
3ef2ca
  int linetabsize __ARGS((char_u *s));
3ef2ca
  int linetabsize_col __ARGS((int startcol, char_u *s));
3ef2ca
! int win_linetabsize __ARGS((win_T *wp, char_u *line, colnr_T len));
3ef2ca
  int vim_isIDc __ARGS((int c));
3ef2ca
  int vim_iswordc __ARGS((int c));
3ef2ca
  int vim_iswordc_buf __ARGS((int c, buf_T *buf));
3ef2ca
***************
3ef2ca
*** 26,34 ****
3ef2ca
  int vim_isfilec_or_wc __ARGS((int c));
3ef2ca
  int vim_isprintc __ARGS((int c));
3ef2ca
  int vim_isprintc_strict __ARGS((int c));
3ef2ca
! int lbr_chartabsize __ARGS((unsigned char *s, colnr_T col));
3ef2ca
! int lbr_chartabsize_adv __ARGS((char_u **s, colnr_T col));
3ef2ca
! int win_lbr_chartabsize __ARGS((win_T *wp, char_u *s, colnr_T col, int *headp));
3ef2ca
  int in_win_border __ARGS((win_T *wp, colnr_T vcol));
3ef2ca
  void getvcol __ARGS((win_T *wp, pos_T *pos, colnr_T *start, colnr_T *cursor, colnr_T *end));
3ef2ca
  colnr_T getvcol_nolist __ARGS((pos_T *posp));
3ef2ca
--- 26,34 ----
3ef2ca
  int vim_isfilec_or_wc __ARGS((int c));
3ef2ca
  int vim_isprintc __ARGS((int c));
3ef2ca
  int vim_isprintc_strict __ARGS((int c));
3ef2ca
! int lbr_chartabsize __ARGS((char_u *line, unsigned char *s, colnr_T col));
3ef2ca
! int lbr_chartabsize_adv __ARGS((char_u *line, char_u **s, colnr_T col));
3ef2ca
! int win_lbr_chartabsize __ARGS((win_T *wp, char_u *line, char_u *s, colnr_T col, int *headp));
3ef2ca
  int in_win_border __ARGS((win_T *wp, colnr_T vcol));
3ef2ca
  void getvcol __ARGS((win_T *wp, pos_T *pos, colnr_T *start, colnr_T *cursor, colnr_T *end));
3ef2ca
  colnr_T getvcol_nolist __ARGS((pos_T *posp));
3ef2ca
*** ../vim-7.4.337/src/proto/misc1.pro	2014-05-07 15:10:17.661108310 +0200
3ef2ca
--- src/proto/misc1.pro	2014-06-25 12:57:01.002115765 +0200
3ef2ca
***************
3ef2ca
*** 2,10 ****
3ef2ca
  int get_indent __ARGS((void));
3ef2ca
  int get_indent_lnum __ARGS((linenr_T lnum));
3ef2ca
  int get_indent_buf __ARGS((buf_T *buf, linenr_T lnum));
3ef2ca
! int get_indent_str __ARGS((char_u *ptr, int ts));
3ef2ca
  int set_indent __ARGS((int size, int flags));
3ef2ca
  int get_number_indent __ARGS((linenr_T lnum));
3ef2ca
  int open_line __ARGS((int dir, int flags, int second_line_indent));
3ef2ca
  int get_leader_len __ARGS((char_u *line, char_u **flags, int backward, int include_space));
3ef2ca
  int get_last_leader_offset __ARGS((char_u *line, char_u **flags));
3ef2ca
--- 2,11 ----
3ef2ca
  int get_indent __ARGS((void));
3ef2ca
  int get_indent_lnum __ARGS((linenr_T lnum));
3ef2ca
  int get_indent_buf __ARGS((buf_T *buf, linenr_T lnum));
3ef2ca
! int get_indent_str __ARGS((char_u *ptr, int ts, int list));
3ef2ca
  int set_indent __ARGS((int size, int flags));
3ef2ca
  int get_number_indent __ARGS((linenr_T lnum));
3ef2ca
+ int get_breakindent_win __ARGS((win_T *wp, char_u *ptr));
3ef2ca
  int open_line __ARGS((int dir, int flags, int second_line_indent));
3ef2ca
  int get_leader_len __ARGS((char_u *line, char_u **flags, int backward, int include_space));
3ef2ca
  int get_last_leader_offset __ARGS((char_u *line, char_u **flags));
3ef2ca
*** ../vim-7.4.337/src/proto/option.pro	2014-01-14 16:54:53.000000000 +0100
3ef2ca
--- src/proto/option.pro	2014-06-25 14:16:04.882295233 +0200
3ef2ca
***************
3ef2ca
*** 63,66 ****
3ef2ca
--- 63,67 ----
3ef2ca
  long get_sw_value __ARGS((buf_T *buf));
3ef2ca
  long get_sts_value __ARGS((void));
3ef2ca
  void find_mps_values __ARGS((int *initc, int *findc, int *backwards, int switchit));
3ef2ca
+ int briopt_check __ARGS((void));
3ef2ca
  /* vim: set ft=c : */
3ef2ca
*** ../vim-7.4.337/src/screen.c	2014-06-18 21:20:07.232377308 +0200
3ef2ca
--- src/screen.c	2014-06-25 13:43:39.930221653 +0200
3ef2ca
***************
3ef2ca
*** 2962,2971 ****
3ef2ca
  # define WL_SIGN	WL_FOLD		/* column for signs */
3ef2ca
  #endif
3ef2ca
  #define WL_NR		WL_SIGN + 1	/* line number */
3ef2ca
  #if defined(FEAT_LINEBREAK) || defined(FEAT_DIFF)
3ef2ca
! # define WL_SBR		WL_NR + 1	/* 'showbreak' or 'diff' */
3ef2ca
  #else
3ef2ca
! # define WL_SBR		WL_NR
3ef2ca
  #endif
3ef2ca
  #define WL_LINE		WL_SBR + 1	/* text in the line */
3ef2ca
      int		draw_state = WL_START;	/* what to draw next */
3ef2ca
--- 2962,2976 ----
3ef2ca
  # define WL_SIGN	WL_FOLD		/* column for signs */
3ef2ca
  #endif
3ef2ca
  #define WL_NR		WL_SIGN + 1	/* line number */
3ef2ca
+ #ifdef FEAT_LINEBREAK
3ef2ca
+ # define WL_BRI		WL_NR + 1	/* 'breakindent' */
3ef2ca
+ #else
3ef2ca
+ # define WL_BRI		WL_NR
3ef2ca
+ #endif
3ef2ca
  #if defined(FEAT_LINEBREAK) || defined(FEAT_DIFF)
3ef2ca
! # define WL_SBR		WL_BRI + 1	/* 'showbreak' or 'diff' */
3ef2ca
  #else
3ef2ca
! # define WL_SBR		WL_BRI
3ef2ca
  #endif
3ef2ca
  #define WL_LINE		WL_SBR + 1	/* text in the line */
3ef2ca
      int		draw_state = WL_START;	/* what to draw next */
3ef2ca
***************
3ef2ca
*** 3301,3307 ****
3ef2ca
  #endif
3ef2ca
  	while (vcol < v && *ptr != NUL)
3ef2ca
  	{
3ef2ca
! 	    c = win_lbr_chartabsize(wp, ptr, (colnr_T)vcol, NULL);
3ef2ca
  	    vcol += c;
3ef2ca
  #ifdef FEAT_MBYTE
3ef2ca
  	    prev_ptr = ptr;
3ef2ca
--- 3306,3312 ----
3ef2ca
  #endif
3ef2ca
  	while (vcol < v && *ptr != NUL)
3ef2ca
  	{
3ef2ca
! 	    c = win_lbr_chartabsize(wp, line, ptr, (colnr_T)vcol, NULL);
3ef2ca
  	    vcol += c;
3ef2ca
  #ifdef FEAT_MBYTE
3ef2ca
  	    prev_ptr = ptr;
3ef2ca
***************
3ef2ca
*** 3670,3675 ****
3ef2ca
--- 3675,3718 ----
3ef2ca
  		}
3ef2ca
  	    }
3ef2ca
  
3ef2ca
+ #ifdef FEAT_LINEBREAK
3ef2ca
+ 	    if (wp->w_p_brisbr && draw_state == WL_BRI - 1
3ef2ca
+ 					     && n_extra == 0 && *p_sbr != NUL)
3ef2ca
+ 		/* draw indent after showbreak value */
3ef2ca
+ 		draw_state = WL_BRI;
3ef2ca
+ 	    else if (wp->w_p_brisbr && draw_state == WL_SBR && n_extra == 0)
3ef2ca
+ 		/* After the showbreak, draw the breakindent */
3ef2ca
+ 		draw_state = WL_BRI - 1;
3ef2ca
+ 
3ef2ca
+ 	    /* draw 'breakindent': indent wrapped text accordingly */
3ef2ca
+ 	    if (draw_state == WL_BRI - 1 && n_extra == 0)
3ef2ca
+ 	    {
3ef2ca
+ 		draw_state = WL_BRI;
3ef2ca
+ # ifdef FEAT_DIFF
3ef2ca
+ # endif
3ef2ca
+ 		if (wp->w_p_bri && n_extra == 0 && row != startrow
3ef2ca
+ #ifdef FEAT_DIFF
3ef2ca
+ 			&& filler_lines == 0
3ef2ca
+ #endif
3ef2ca
+ 		   )
3ef2ca
+ 		{
3ef2ca
+ 		    char_attr = 0; /* was: hl_attr(HLF_AT); */
3ef2ca
+ #ifdef FEAT_DIFF
3ef2ca
+ 		    if (diff_hlf != (hlf_T)0)
3ef2ca
+ 			char_attr = hl_attr(diff_hlf);
3ef2ca
+ #endif
3ef2ca
+ 		    p_extra = NUL;
3ef2ca
+ 		    c_extra = ' ';
3ef2ca
+ 		    n_extra = get_breakindent_win(wp,
3ef2ca
+ 				       ml_get_buf(wp->w_buffer, lnum, FALSE));
3ef2ca
+ 		    /* Correct end of highlighted area for 'breakindent',
3ef2ca
+ 		     * required when 'linebreak' is also set. */
3ef2ca
+ 		    if (tocol == vcol)
3ef2ca
+ 			tocol += n_extra;
3ef2ca
+ 		}
3ef2ca
+ 	    }
3ef2ca
+ #endif
3ef2ca
+ 
3ef2ca
  #if defined(FEAT_LINEBREAK) || defined(FEAT_DIFF)
3ef2ca
  	    if (draw_state == WL_SBR - 1 && n_extra == 0)
3ef2ca
  	    {
3ef2ca
***************
3ef2ca
*** 4382,4392 ****
3ef2ca
  		if (wp->w_p_lbr && vim_isbreak(c) && !vim_isbreak(*ptr)
3ef2ca
  							     && !wp->w_p_list)
3ef2ca
  		{
3ef2ca
! 		    n_extra = win_lbr_chartabsize(wp, ptr - (
3ef2ca
  # ifdef FEAT_MBYTE
3ef2ca
  				has_mbyte ? mb_l :
3ef2ca
  # endif
3ef2ca
! 				1), (colnr_T)vcol, NULL) - 1;
3ef2ca
  		    c_extra = ' ';
3ef2ca
  		    if (vim_iswhite(c))
3ef2ca
  		    {
3ef2ca
--- 4425,4438 ----
3ef2ca
  		if (wp->w_p_lbr && vim_isbreak(c) && !vim_isbreak(*ptr)
3ef2ca
  							     && !wp->w_p_list)
3ef2ca
  		{
3ef2ca
! 		    char_u *p = ptr - (
3ef2ca
  # ifdef FEAT_MBYTE
3ef2ca
  				has_mbyte ? mb_l :
3ef2ca
  # endif
3ef2ca
! 				1);
3ef2ca
! 		    /* TODO: is passing p for start of the line OK? */
3ef2ca
! 		    n_extra = win_lbr_chartabsize(wp, p, p, (colnr_T)vcol,
3ef2ca
! 								    NULL) - 1;
3ef2ca
  		    c_extra = ' ';
3ef2ca
  		    if (vim_iswhite(c))
3ef2ca
  		    {
3ef2ca
***************
3ef2ca
*** 8916,8923 ****
3ef2ca
  	{
3ef2ca
  	    if (noinvcurs)
3ef2ca
  		screen_stop_highlight();
3ef2ca
! 	    if (row == screen_cur_row && (col > screen_cur_col) &&
3ef2ca
! 								*T_CRI != NUL)
3ef2ca
  		term_cursor_right(col - screen_cur_col);
3ef2ca
  	    else
3ef2ca
  		term_windgoto(row, col);
3ef2ca
--- 8962,8969 ----
3ef2ca
  	{
3ef2ca
  	    if (noinvcurs)
3ef2ca
  		screen_stop_highlight();
3ef2ca
! 	    if (row == screen_cur_row && (col > screen_cur_col)
3ef2ca
! 							     && *T_CRI != NUL)
3ef2ca
  		term_cursor_right(col - screen_cur_col);
3ef2ca
  	    else
3ef2ca
  		term_windgoto(row, col);
3ef2ca
*** ../vim-7.4.337/src/structs.h	2014-06-17 17:48:21.784628008 +0200
3ef2ca
--- src/structs.h	2014-06-25 12:57:01.006115766 +0200
3ef2ca
***************
3ef2ca
*** 134,139 ****
3ef2ca
--- 134,145 ----
3ef2ca
      int		wo_arab;
3ef2ca
  # define w_p_arab w_onebuf_opt.wo_arab	/* 'arabic' */
3ef2ca
  #endif
3ef2ca
+ #ifdef FEAT_LINEBREAK
3ef2ca
+     int		wo_bri;
3ef2ca
+ # define w_p_bri w_onebuf_opt.wo_bri	/* 'breakindent' */
3ef2ca
+     char_u		*wo_briopt;
3ef2ca
+ # define w_p_briopt w_onebuf_opt.wo_briopt /* 'breakindentopt' */
3ef2ca
+ #endif
3ef2ca
  #ifdef FEAT_DIFF
3ef2ca
      int		wo_diff;
3ef2ca
  # define w_p_diff w_onebuf_opt.wo_diff	/* 'diff' */
3ef2ca
***************
3ef2ca
*** 2189,2194 ****
3ef2ca
--- 2195,2205 ----
3ef2ca
  #ifdef FEAT_SYN_HL
3ef2ca
      int		*w_p_cc_cols;	    /* array of columns to highlight or NULL */
3ef2ca
  #endif
3ef2ca
+ #ifdef FEAT_LINEBREAK
3ef2ca
+     int		w_p_brimin;	    /* minimum width for breakindent */
3ef2ca
+     int		w_p_brishift;	    /* additional shift for breakindent */
3ef2ca
+     int		w_p_brisbr;	    /* sbr in 'briopt' */
3ef2ca
+ #endif
3ef2ca
  
3ef2ca
      /* transform a pointer to a "onebuf" option into a "allbuf" option */
3ef2ca
  #define GLOBAL_WO(p)	((char *)p + sizeof(winopt_T))
3ef2ca
*** ../vim-7.4.337/src/testdir/Make_amiga.mak	2014-05-29 11:47:19.804773758 +0200
3ef2ca
--- src/testdir/Make_amiga.mak	2014-06-25 12:57:01.006115766 +0200
3ef2ca
***************
3ef2ca
*** 37,42 ****
3ef2ca
--- 37,43 ----
3ef2ca
  		test99.out test100.out test101.out test102.out test103.out \
3ef2ca
  		test104.out test105.out test106.out test107.out \
3ef2ca
  		test_autoformat_join.out \
3ef2ca
+ 		test_breakindent.out \
3ef2ca
  		test_eval.out \
3ef2ca
  		test_options.out
3ef2ca
  
3ef2ca
***************
3ef2ca
*** 163,167 ****
3ef2ca
--- 164,169 ----
3ef2ca
  test106.out: test106.in
3ef2ca
  test107.out: test107.in
3ef2ca
  test_autoformat_join.out: test_autoformat_join.in
3ef2ca
+ test_breakindent.out: test_breakindent.in
3ef2ca
  test_eval.out: test_eval.in
3ef2ca
  test_options.out: test_options.in
3ef2ca
*** ../vim-7.4.337/src/testdir/Make_dos.mak	2014-05-29 11:47:19.804773758 +0200
3ef2ca
--- src/testdir/Make_dos.mak	2014-06-25 12:57:01.006115766 +0200
3ef2ca
***************
3ef2ca
*** 36,41 ****
3ef2ca
--- 36,42 ----
3ef2ca
  		test100.out test101.out test102.out test103.out test104.out \
3ef2ca
  		test105.out test106.out  test107.out\
3ef2ca
  		test_autoformat_join.out \
3ef2ca
+ 		test_breakindent.out \
3ef2ca
  		test_eval.out \
3ef2ca
  		test_options.out
3ef2ca
  
3ef2ca
*** ../vim-7.4.337/src/testdir/Make_ming.mak	2014-05-29 11:47:19.804773758 +0200
3ef2ca
--- src/testdir/Make_ming.mak	2014-06-25 12:57:01.006115766 +0200
3ef2ca
***************
3ef2ca
*** 56,61 ****
3ef2ca
--- 56,62 ----
3ef2ca
  		test100.out test101.out test102.out test103.out test104.out \
3ef2ca
  		test105.out test106.out test107.out \
3ef2ca
  		test_autoformat_join.out \
3ef2ca
+ 		test_breakindent.out \
3ef2ca
  		test_eval.out \
3ef2ca
  		test_options.out
3ef2ca
  
3ef2ca
*** ../vim-7.4.337/src/testdir/Make_os2.mak	2014-05-29 11:47:19.804773758 +0200
3ef2ca
--- src/testdir/Make_os2.mak	2014-06-25 12:59:45.774121999 +0200
3ef2ca
***************
3ef2ca
*** 39,44 ****
3ef2ca
--- 39,45 ----
3ef2ca
  		test105.out test106.out test107.out \
3ef2ca
  		test_autoformat_join.out \
3ef2ca
  		test_eval.out \
3ef2ca
+ 		test_breakindent.out \
3ef2ca
  		test_options.out
3ef2ca
  
3ef2ca
  .SUFFIXES: .in .out
3ef2ca
*** ../vim-7.4.337/src/testdir/Make_vms.mms	2014-05-29 11:47:19.804773758 +0200
3ef2ca
--- src/testdir/Make_vms.mms	2014-06-25 12:57:01.006115766 +0200
3ef2ca
***************
3ef2ca
*** 97,102 ****
3ef2ca
--- 97,103 ----
3ef2ca
  	 test100.out test101.out test103.out test104.out \
3ef2ca
  	 test105.out test106.out test107.out \
3ef2ca
  	 test_autoformat_join.out \
3ef2ca
+ 	 test_breakindent.out \
3ef2ca
  	 test_eval.out \
3ef2ca
  	 test_options.out
3ef2ca
  
3ef2ca
*** ../vim-7.4.337/src/testdir/Makefile	2014-05-29 11:47:19.804773758 +0200
3ef2ca
--- src/testdir/Makefile	2014-06-25 12:57:01.006115766 +0200
3ef2ca
***************
3ef2ca
*** 34,39 ****
3ef2ca
--- 34,40 ----
3ef2ca
  		test99.out test100.out test101.out test102.out test103.out \
3ef2ca
  		test104.out test105.out test106.out test107.out \
3ef2ca
  		test_autoformat_join.out \
3ef2ca
+ 		test_breakindent.out \
3ef2ca
  		test_eval.out \
3ef2ca
  		test_options.out
3ef2ca
  
3ef2ca
*** ../vim-7.4.337/src/testdir/test_breakindent.in	2014-06-25 14:36:28.690341532 +0200
3ef2ca
--- src/testdir/test_breakindent.in	2014-06-25 14:26:00.994317785 +0200
3ef2ca
***************
3ef2ca
*** 0 ****
3ef2ca
--- 1,79 ----
3ef2ca
+ Test for breakindent
3ef2ca
+ 
3ef2ca
+ STARTTEST
3ef2ca
+ :so small.vim
3ef2ca
+ :if !exists("+breakindent") | e! test.ok | w! test.out | qa! | endif
3ef2ca
+ :10new|:vsp|:vert resize 20
3ef2ca
+ :put =\"\tabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP\"
3ef2ca
+ :set ts=4 sw=4 sts=4 breakindent
3ef2ca
+ :fu! ScreenChar(width)
3ef2ca
+ :	let c=''
3ef2ca
+ :	for i in range(1,a:width)
3ef2ca
+ :		let c.=nr2char(screenchar(line('.'), i))
3ef2ca
+ :	endfor
3ef2ca
+ :       let c.="\n"
3ef2ca
+ :	for i in range(1,a:width)
3ef2ca
+ :		let c.=nr2char(screenchar(line('.')+1, i))
3ef2ca
+ :	endfor
3ef2ca
+ :       let c.="\n"
3ef2ca
+ :	for i in range(1,a:width)
3ef2ca
+ :		let c.=nr2char(screenchar(line('.')+2, i))
3ef2ca
+ :	endfor
3ef2ca
+ :	return c
3ef2ca
+ :endfu
3ef2ca
+ :fu DoRecordScreen()
3ef2ca
+ :	wincmd l
3ef2ca
+ :	$put =printf(\"\n%s\", g:test)
3ef2ca
+ :	$put =g:line1
3ef2ca
+ :	wincmd p
3ef2ca
+ :endfu
3ef2ca
+ :let g:test="Test 1: Simple breakindent"
3ef2ca
+ :let line1=ScreenChar(8)
3ef2ca
+ :call DoRecordScreen()
3ef2ca
+ :let g:test="Test 2: Simple breakindent + sbr=>>"
3ef2ca
+ :set sbr=>>
3ef2ca
+ :let line1=ScreenChar(8)
3ef2ca
+ :call DoRecordScreen()
3ef2ca
+ :let g:test ="Test 3: Simple breakindent + briopt:sbr"
3ef2ca
+ :set briopt=sbr,min:0 sbr=++
3ef2ca
+ :let line1=ScreenChar(8)
3ef2ca
+ :call DoRecordScreen()
3ef2ca
+ :let g:test ="Test 4: Simple breakindent + min width: 18"
3ef2ca
+ :set sbr= briopt=min:18
3ef2ca
+ :let line1=ScreenChar(8)
3ef2ca
+ :call DoRecordScreen()
3ef2ca
+ :let g:test =" Test 5: Simple breakindent + shift by 2"
3ef2ca
+ :set briopt=shift:2,min:0
3ef2ca
+ :let line1=ScreenChar(8)
3ef2ca
+ :call DoRecordScreen()
3ef2ca
+ :let g:test=" Test 6: Simple breakindent + shift by -1"
3ef2ca
+ :set briopt=shift:-1,min:0
3ef2ca
+ :let line1=ScreenChar(8)
3ef2ca
+ :call DoRecordScreen()
3ef2ca
+ :let g:test=" Test 7: breakindent + shift by +1 + nu + sbr=? briopt:sbr"
3ef2ca
+ :set briopt=shift:1,sbr,min:0 nu sbr=? nuw=4
3ef2ca
+ :let line1=ScreenChar(10)
3ef2ca
+ :call DoRecordScreen()
3ef2ca
+ :let g:test=" Test 8: breakindent + shift:1 + nu + sbr=# list briopt:sbr"
3ef2ca
+ :set briopt=shift:1,sbr,min:0 nu sbr=# list
3ef2ca
+ :let line1=ScreenChar(10)
3ef2ca
+ :call DoRecordScreen()
3ef2ca
+ :let g:test=" Test 9: breakindent + shift by +1 + 'nu' + sbr=# list"
3ef2ca
+ :set briopt-=sbr
3ef2ca
+ :let line1=ScreenChar(10)
3ef2ca
+ :call DoRecordScreen()
3ef2ca
+ :let g:test=" Test 10: breakindent + shift by +1 + 'nu' + sbr=~ cpo+=n"
3ef2ca
+ :set cpo+=n sbr=~ nu nuw=4 nolist briopt=sbr,min:0
3ef2ca
+ :let line1=ScreenChar(10)
3ef2ca
+ :call DoRecordScreen()
3ef2ca
+ :wincmd p
3ef2ca
+ :let g:test="\n Test 11: strdisplaywidth when breakindent is on"
3ef2ca
+ :set cpo-=n sbr=>> nu nuw=4 nolist briopt= ts=4
3ef2ca
+ :let text=getline(2) "skip leading tab when calculating text width
3ef2ca
+ :let width = strlen(text[1:])+indent(2)*4+strlen(&sbr)*3 " text wraps 3 times
3ef2ca
+ :$put =g:test
3ef2ca
+ :$put =printf(\"strdisplaywidth: %d == calculated: %d\", strdisplaywidth(text), width)
3ef2ca
+ :%w! test.out
3ef2ca
+ :qa!
3ef2ca
+ ENDTEST
3ef2ca
+ dummy text
3ef2ca
*** ../vim-7.4.337/src/testdir/test_breakindent.ok	2014-06-25 14:36:28.698341532 +0200
3ef2ca
--- src/testdir/test_breakindent.ok	2014-06-25 12:57:01.006115766 +0200
3ef2ca
***************
3ef2ca
*** 0 ****
3ef2ca
--- 1,55 ----
3ef2ca
+ 
3ef2ca
+ 	abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP
3ef2ca
+ 
3ef2ca
+ Test 1: Simple breakindent
3ef2ca
+     abcd
3ef2ca
+     qrst
3ef2ca
+     GHIJ
3ef2ca
+ 
3ef2ca
+ Test 2: Simple breakindent + sbr=>>
3ef2ca
+     abcd
3ef2ca
+     >>qr
3ef2ca
+     >>EF
3ef2ca
+ 
3ef2ca
+ Test 3: Simple breakindent + briopt:sbr
3ef2ca
+     abcd
3ef2ca
+ ++  qrst
3ef2ca
+ ++  GHIJ
3ef2ca
+ 
3ef2ca
+ Test 4: Simple breakindent + min width: 18
3ef2ca
+     abcd
3ef2ca
+   qrstuv
3ef2ca
+   IJKLMN
3ef2ca
+ 
3ef2ca
+  Test 5: Simple breakindent + shift by 2
3ef2ca
+     abcd
3ef2ca
+       qr
3ef2ca
+       EF
3ef2ca
+ 
3ef2ca
+  Test 6: Simple breakindent + shift by -1
3ef2ca
+     abcd
3ef2ca
+    qrstu
3ef2ca
+    HIJKL
3ef2ca
+ 
3ef2ca
+  Test 7: breakindent + shift by +1 + nu + sbr=? briopt:sbr
3ef2ca
+   2     ab
3ef2ca
+ ?        m
3ef2ca
+ ?        x
3ef2ca
+ 
3ef2ca
+  Test 8: breakindent + shift:1 + nu + sbr=# list briopt:sbr
3ef2ca
+   2 ^Iabcd
3ef2ca
+ #      opq
3ef2ca
+ #      BCD
3ef2ca
+ 
3ef2ca
+  Test 9: breakindent + shift by +1 + 'nu' + sbr=# list
3ef2ca
+   2 ^Iabcd
3ef2ca
+        #op
3ef2ca
+        #AB
3ef2ca
+ 
3ef2ca
+  Test 10: breakindent + shift by +1 + 'nu' + sbr=~ cpo+=n
3ef2ca
+   2     ab
3ef2ca
+ ~       mn
3ef2ca
+ ~       yz
3ef2ca
+ 
3ef2ca
+  Test 11: strdisplaywidth when breakindent is on
3ef2ca
+ strdisplaywidth: 46 == calculated: 64
3ef2ca
*** ../vim-7.4.337/src/ui.c	2014-06-12 13:28:26.771694851 +0200
3ef2ca
--- src/ui.c	2014-06-25 13:22:20.218173240 +0200
3ef2ca
***************
3ef2ca
*** 3162,3176 ****
3ef2ca
      /* try to advance to the specified column */
3ef2ca
      int		count = 0;
3ef2ca
      char_u	*ptr;
3ef2ca
!     char_u	*start;
3ef2ca
  
3ef2ca
!     start = ptr = ml_get_buf(wp->w_buffer, lnum, FALSE);
3ef2ca
      while (count < vcol && *ptr != NUL)
3ef2ca
      {
3ef2ca
! 	count += win_lbr_chartabsize(wp, ptr, count, NULL);
3ef2ca
  	mb_ptr_adv(ptr);
3ef2ca
      }
3ef2ca
!     return (int)(ptr - start);
3ef2ca
  }
3ef2ca
  #endif
3ef2ca
  
3ef2ca
--- 3162,3176 ----
3ef2ca
      /* try to advance to the specified column */
3ef2ca
      int		count = 0;
3ef2ca
      char_u	*ptr;
3ef2ca
!     char_u	*line;
3ef2ca
  
3ef2ca
!     line = ptr = ml_get_buf(wp->w_buffer, lnum, FALSE);
3ef2ca
      while (count < vcol && *ptr != NUL)
3ef2ca
      {
3ef2ca
! 	count += win_lbr_chartabsize(wp, line, ptr, count, NULL);
3ef2ca
  	mb_ptr_adv(ptr);
3ef2ca
      }
3ef2ca
!     return (int)(ptr - line);
3ef2ca
  }
3ef2ca
  #endif
3ef2ca
  
3ef2ca
*** ../vim-7.4.337/src/version.c	2014-06-25 12:26:42.230046959 +0200
3ef2ca
--- src/version.c	2014-06-25 13:00:26.990123558 +0200
3ef2ca
***************
3ef2ca
*** 736,737 ****
3ef2ca
--- 736,739 ----
3ef2ca
  {   /* Add new patch number below this line */
3ef2ca
+ /**/
3ef2ca
+     338,
3ef2ca
  /**/
3ef2ca
3ef2ca
-- 
3ef2ca
MORTICIAN:    Bring out your dead!
3ef2ca
              [clang]
3ef2ca
              Bring out your dead!
3ef2ca
              [clang]
3ef2ca
              Bring out your dead!
3ef2ca
CUSTOMER:     Here's one -- nine pence.
3ef2ca
DEAD PERSON:  I'm not dead!
3ef2ca
                                  The Quest for the Holy Grail (Monty Python)
3ef2ca
3ef2ca
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
3ef2ca
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
3ef2ca
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
3ef2ca
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///