Blog: Better line wrapping in Vim, 6th iteration: vim-7.3.682-breakindent.patch

File vim-7.3.682-breakindent.patch, 31.8 KB (added by retracile, 12 years ago)

breakindent for Vim 7.3.682

  • runtime/doc/eval.txt

    diff '--exclude=*.orig' -urN vim73.orig/runtime/doc/eval.txt vim73/runtime/doc/eval.txt
    old new  
    62726272keymap                  Compiled with 'keymap' support.
    62736273langmap                 Compiled with 'langmap' support.
    62746274libcall                 Compiled with |libcall()| support.
    6275 linebreak               Compiled with 'linebreak', 'breakat' and 'showbreak'
    6276                         support.
     6275linebreak               Compiled with 'linebreak', 'breakat', 'showbreak' and
     6276                        'breakindent' support.
    62776277lispindent              Compiled with support for lisp indenting.
    62786278listcmds                Compiled with commands for the buffer list |:files|
    62796279                        and the argument list |arglist|.
  • runtime/doc/options.txt

    diff '--exclude=*.orig' -urN vim73.orig/runtime/doc/options.txt vim73/runtime/doc/options.txt
    old new  
    11771177        break if 'linebreak' is on.  Only works for ASCII and also for 8-bit
    11781178        characters when 'encoding' is an 8-bit encoding.
    11791179
     1180       
     1181                                                *'breakindent'* *'bri'*
     1182'breakindent' 'bri'     boolean (default off)
     1183                        local to window
     1184                        {not in Vi}
     1185                        {not available when compiled without the |+linebreak|
     1186                        feature}
     1187        Every wrapped line will continue visually indented (same amount of
     1188        space as the beginning of that line), thus preserving horizontal blocks
     1189        of text.
     1190
     1191                                                *'breakindentmin'* *'brimin'*
     1192'breakindentmin' 'brimin' number (default 20)
     1193                        local to window
     1194                        {not in Vi}
     1195                        {not available when compiled without the |+linebreak|
     1196                        feature}
     1197        Minimum text width that will be kept after applying 'breakindent',
     1198        even if the resulting text should normally be narrower. This prevents
     1199        text indented almost to the right window border oocupying lot of
     1200        vertical space when broken.
     1201
     1202                                                *'breakindentshift'* *'brishift'*
     1203'breakindentshift' 'brishift' number (default 20)
     1204                        local to window
     1205                        {not in Vi}
     1206                        {not available when compiled without the |+linebreak|
     1207                        feature}
     1208        After applying 'breakindent', wrapped line beginning will be shift by
     1209        given number of characters. It permits dynamic French paragraph
     1210        indentation (negative) or emphasizing the line continuation
     1211        (positive).
     1212
    11801213                                                *'browsedir'* *'bsdir'*
    11811214'browsedir' 'bsdir'     string  (default: "last")
    11821215                        global
     
    44604493                        {not in Vi}
    44614494                        {not available when compiled without the |+linebreak|
    44624495                        feature}
    4463         If on Vim will wrap long lines at a character in 'breakat' rather
     4496        If on, Vim will wrap long lines at a character in 'breakat' rather
    44644497        than at the last character that fits on the screen.  Unlike
    44654498        'wrapmargin' and 'textwidth', this does not insert <EOL>s in the file,
    4466         it only affects the way the file is displayed, not its contents.  The
    4467         value of 'showbreak' is used to put in front of wrapped lines.
    4468         This option is not used when the 'wrap' option is off or 'list' is on.
     4499        it only affects the way the file is displayed, not its contents.
     4500        If 'breakindent' is set, line is visually indented. Then, the value
     4501        of 'showbreak' is used to put in front of wrapped lines. This option
     4502        is not used when the 'wrap' option is off or 'list' is on.
    44694503        Note that <Tab> characters after an <EOL> are mostly not displayed
    44704504        with the right amount of white space.
    44714505
  • runtime/doc/tags

    diff '--exclude=*.orig' -urN vim73.orig/runtime/doc/tags vim73/runtime/doc/tags
    old new  
    9090'bl'    options.txt     /*'bl'*
    9191'bomb'  options.txt     /*'bomb'*
    9292'breakat'       options.txt     /*'breakat'*
     93'breakindent'   options.txt     /*'breakindent'*
     94'breakindentmin'        options.txt     /*'breakindentmin'*
     95'breakindentshift'      options.txt     /*'breakindentshift'*
     96'bri'   options.txt     /*'bri'*
     97'brimin'        options.txt     /*'brimin'*
     98'brishift'      options.txt     /*'brishift'*
    9399'brk'   options.txt     /*'brk'*
    94100'browsedir'     options.txt     /*'browsedir'*
    95101'bs'    options.txt     /*'bs'*
  • runtime/optwin.vim

    diff '--exclude=*.orig' -urN vim73.orig/runtime/optwin.vim vim73/runtime/optwin.vim
    old new  
    329329call append("$", "linebreak\twrap long lines at a character in 'breakat'")
    330330call append("$", "\t(local to window)")
    331331call <SID>BinOptionL("lbr")
     332call append("$", "breakindent\tpreserve indentation in wrapped text")
     333call append("$", "\t(local to window)")
     334call <SID>BinOptionL("bri")
     335call append("$", "breakindentmin\tminimum text width after indent in 'breakindent'")
     336call append("$", "\t(local to window)")
     337call <SID>OptionL("brimin")
     338call append("$", "breakindentshift\tshift beginning of 'breakindent'ed line by this number of characters (negative left)")
     339call append("$", "\t(local to window)")
     340call <SID>OptionL("brishift")
    332341call append("$", "breakat\twhich characters might cause a line break")
    333342call <SID>OptionG("brk", &brk)
    334343call append("$", "showbreak\tstring to put before wrapped screen lines")
  • src/charset.c

    diff '--exclude=*.orig' -urN vim73.orig/src/charset.c vim73/src/charset.c
    old new  
    847847 * taking into account the size of a tab.
    848848 */
    849849    int
    850 linetabsize(s)
     850linetabsize(s, lnum)
    851851    char_u      *s;
     852    linenr_T    lnum;
    852853{
    853     return linetabsize_col(0, s);
     854    return linetabsize_col(0, s, lnum);
    854855}
    855856
    856857/*
    857858 * Like linetabsize(), but starting at column "startcol".
    858859 */
    859860    int
    860 linetabsize_col(startcol, s)
     861linetabsize_col(startcol, s, lnum)
    861862    int         startcol;
    862863    char_u      *s;
     864    linenr_T    lnum;
    863865{
    864866    colnr_T     col = startcol;
    865867
    866868    while (*s != NUL)
    867         col += lbr_chartabsize_adv(&s, col);
     869        col += lbr_chartabsize_adv(&s, col, lnum);
    868870    return (int)col;
    869871}
    870872
     
    872874 * Like linetabsize(), but for a given window instead of the current one.
    873875 */
    874876    int
    875 win_linetabsize(wp, p, len)
     877win_linetabsize(wp, p, len, lnum)
    876878    win_T       *wp;
    877879    char_u      *p;
    878880    colnr_T     len;
     881    linenr_T    lnum;
    879882{
    880883    colnr_T     col = 0;
    881884    char_u      *s;
    882885
    883886    for (s = p; *s != NUL && (len == MAXCOL || s < p + len); mb_ptr_adv(s))
    884         col += win_lbr_chartabsize(wp, s, col, NULL);
     887        col += win_lbr_chartabsize(wp, s, col, NULL, lnum);
    885888    return (int)col;
    886889}
    887890
     
    10101013 * like chartabsize(), but also check for line breaks on the screen
    10111014 */
    10121015    int
    1013 lbr_chartabsize(s, col)
     1016lbr_chartabsize(s, col, lnum)
    10141017    unsigned char       *s;
    10151018    colnr_T             col;
     1019    linenr_T            lnum;
    10161020{
    10171021#ifdef FEAT_LINEBREAK
    1018     if (!curwin->w_p_lbr && *p_sbr == NUL)
     1022    if (!curwin->w_p_lbr && *p_sbr == NUL && !curwin->w_p_bri)
    10191023    {
    10201024#endif
    10211025#ifdef FEAT_MBYTE
     
    10251029        RET_WIN_BUF_CHARTABSIZE(curwin, curbuf, s, col)
    10261030#ifdef FEAT_LINEBREAK
    10271031    }
    1028     return win_lbr_chartabsize(curwin, s, col, NULL);
     1032    return win_lbr_chartabsize(curwin, s, col, NULL, lnum);
    10291033#endif
    10301034}
    10311035
     
    10331037 * Call lbr_chartabsize() and advance the pointer.
    10341038 */
    10351039    int
    1036 lbr_chartabsize_adv(s, col)
     1040lbr_chartabsize_adv(s, col, lnum)
    10371041    char_u      **s;
    10381042    colnr_T     col;
     1043    linenr_T    lnum;
    10391044{
    10401045    int         retval;
    10411046
    1042     retval = lbr_chartabsize(*s, col);
     1047    retval = lbr_chartabsize(*s, col, lnum);
    10431048    mb_ptr_adv(*s);
    10441049    return retval;
    10451050}
     
    10501055 * If "headp" not NULL, set *headp to the size of what we for 'showbreak'
    10511056 * string at start of line.  Warning: *headp is only set if it's a non-zero
    10521057 * value, init to 0 before calling.
     1058 *
     1059 * linenr argument needed if in visual highlighting and breakindent=on, then
     1060 * the line calculated is not current; if 0, normal functionality is preserved.
    10531061 */
    10541062    int
    1055 win_lbr_chartabsize(wp, s, col, headp)
     1063win_lbr_chartabsize(wp, s, col, headp, lnum)
    10561064    win_T       *wp;
    10571065    char_u      *s;
    10581066    colnr_T     col;
    10591067    int         *headp UNUSED;
     1068    linenr_T    lnum;
    10601069{
    10611070#ifdef FEAT_LINEBREAK
    10621071    int         c;
     
    10751084    int         n;
    10761085
    10771086    /*
    1078      * No 'linebreak' and 'showbreak': return quickly.
     1087     * No 'linebreak' and 'showbreak' and 'breakindent': return quickly.
    10791088     */
    1080     if (!wp->w_p_lbr && *p_sbr == NUL)
     1089    if (!wp->w_p_lbr && !wp->w_p_bri && *p_sbr == NUL)
    10811090#endif
    10821091    {
    10831092#ifdef FEAT_MBYTE
     
    11521161# endif
    11531162
    11541163    /*
    1155      * May have to add something for 'showbreak' string at start of line
     1164     * May have to add something for 'breakindent' and/or 'showbreak'
     1165     * string at start of line.
    11561166     * Set *headp to the size of what we add.
    11571167     */
    11581168    added = 0;
    1159     if (*p_sbr != NUL && wp->w_p_wrap && col != 0)
     1169    if ((*p_sbr != NUL || wp->w_p_bri) && wp->w_p_wrap && col != 0)
    11601170    {
    11611171        numberextra = win_col_off(wp);
    11621172        col += numberextra + mb_added;
     
    11691179        }
    11701180        if (col == 0 || col + size > (colnr_T)W_WIDTH(wp))
    11711181        {
    1172             added = vim_strsize(p_sbr);
     1182            added = 0;
     1183            if (*p_sbr != NUL)
     1184                added += vim_strsize(p_sbr);
     1185            if (wp->w_p_bri)
     1186                added += get_breakindent_win(wp,lnum);
     1187
    11731188            if (tab_corr)
    11741189                size += (added / wp->w_buffer->b_p_ts) * wp->w_buffer->b_p_ts;
    11751190            else
     
    12771292
    12781293    /*
    12791294     * This function is used very often, do some speed optimizations.
    1280      * When 'list', 'linebreak' and 'showbreak' are not set use a simple loop.
     1295     * When 'list', 'linebreak', 'showbreak' and 'breakindent' are not set
     1296     * use a simple loop.
    12811297     * Also use this when 'list' is set but tabs take their normal size.
    12821298     */
    12831299    if ((!wp->w_p_list || lcs_tab1 != NUL)
    12841300#ifdef FEAT_LINEBREAK
    1285             && !wp->w_p_lbr && *p_sbr == NUL
     1301            && !wp->w_p_lbr && *p_sbr == NUL && !wp->w_p_bri
    12861302#endif
    12871303       )
    12881304    {
     
    13441360        {
    13451361            /* A tab gets expanded, depending on the current column */
    13461362            head = 0;
    1347             incr = win_lbr_chartabsize(wp, ptr, vcol, &head);
     1363            incr = win_lbr_chartabsize(wp, ptr, vcol, &head, pos->lnum);
    13481364            /* make sure we don't go past the end of the line */
    13491365            if (*ptr == NUL)
    13501366            {
  • src/edit.c

    diff '--exclude=*.orig' -urN vim73.orig/src/edit.c vim73/src/edit.c
    old new  
    405405        if (startln)
    406406            Insstart.col = 0;
    407407    }
    408     Insstart_textlen = (colnr_T)linetabsize(ml_get_curline());
     408    Insstart_textlen = (colnr_T)linetabsize(ml_get_curline(), Insstart.lnum);
    409409    Insstart_blank_vcol = MAXCOL;
    410410    if (!did_ai)
    411411        ai_col = 0;
     
    19131913            else
    19141914#endif
    19151915                ++new_cursor_col;
    1916             vcol += lbr_chartabsize(ptr + new_cursor_col, (colnr_T)vcol);
     1916            vcol += lbr_chartabsize(ptr + new_cursor_col, (colnr_T)vcol, curwin->w_cursor.lnum);
    19171917        }
    19181918        vcol = last_vcol;
    19191919
     
    67016701            ins_need_undo = FALSE;
    67026702        }
    67036703        Insstart = curwin->w_cursor;    /* new insertion starts here */
    6704         Insstart_textlen = (colnr_T)linetabsize(ml_get_curline());
     6704        Insstart_textlen = (colnr_T)linetabsize(ml_get_curline(), curwin->w_cursor.lnum);
    67056705        ai_col = 0;
    67066706#ifdef FEAT_VREPLACE
    67076707        if (State & VREPLACE_FLAG)
     
    70567056        for (;;)
    70577057        {
    70587058            coladvance(v - width);
    7059             /* getviscol() is slow, skip it when 'showbreak' is empty and
    7060              * there are no multi-byte characters */
    7061             if ((*p_sbr == NUL
     7059            /* getviscol() is slow, skip it when 'showbreak' is empty,
     7060             * 'breakindent' is not set and there are no multi-byte
     7061             * characters */
     7062            if ((*p_sbr == NUL && !curwin->w_p_bri
    70627063#  ifdef FEAT_MBYTE
    70637064                        && !has_mbyte
    70647065#  endif
     
    96949695        getvcol(curwin, &fpos, &vcol, NULL, NULL);
    96959696        getvcol(curwin, cursor, &want_vcol, NULL, NULL);
    96969697
    9697         /* Use as many TABs as possible.  Beware of 'showbreak' and
     9698        /* Use as many TABs as possible.  Beware of 'breakindent', 'showbreak' and
    96989699         * 'linebreak' adding extra virtual columns. */
    96999700        while (vim_iswhite(*ptr))
    97009701        {
    9701             i = lbr_chartabsize((char_u *)"\t", vcol);
     9702            i = lbr_chartabsize((char_u *)"\t", vcol, cursor->lnum);
    97029703            if (vcol + i > want_vcol)
    97039704                break;
    97049705            if (*ptr != TAB)
     
    97249725            /* Skip over the spaces we need. */
    97259726            while (vcol < want_vcol && *ptr == ' ')
    97269727            {
    9727                 vcol += lbr_chartabsize(ptr, vcol);
     9728                vcol += lbr_chartabsize(ptr, vcol, cursor->lnum);
    97289729                ++ptr;
    97299730                ++repl_off;
    97309731            }
     
    99809981    while ((colnr_T)temp < curwin->w_virtcol && *ptr != NUL)
    99819982    {
    99829983        prev_ptr = ptr;
    9983         temp += lbr_chartabsize_adv(&ptr, (colnr_T)temp);
     9984        temp += lbr_chartabsize_adv(&ptr, (colnr_T)temp, lnum);
    99849985    }
    99859986    if ((colnr_T)temp > curwin->w_virtcol)
    99869987        ptr = prev_ptr;
  • src/eval.c

    diff '--exclude=*.orig' -urN vim73.orig/src/eval.c vim73/src/eval.c
    old new  
    1733217332
    1733317333    if (argvars[1].v_type != VAR_UNKNOWN)
    1733417334        col = get_tv_number(&argvars[1]);
    17335 
    17336     rettv->vval.v_number = (varnumber_T)(linetabsize_col(col, s) - col);
     17335    /*
     17336     * FIXME: passing 0 as 3rd argument to linetabsize_col, instead of real line number;
     17337     * (can we get it from here somehow?); might give incorrect result with breakindent!
     17338     */
     17339    rettv->vval.v_number = (varnumber_T)(linetabsize_col(col, s, 0) - col);
    1733717340}
    1733817341
    1733917342/*
  • src/ex_cmds.c

    diff '--exclude=*.orig' -urN vim73.orig/src/ex_cmds.c vim73/src/ex_cmds.c
    old new  
    261261        ;
    262262    save = *last;
    263263    *last = NUL;
    264     len = linetabsize(line);            /* get line length */
     264    len = linetabsize(line, curwin->w_cursor.lnum); /* get line length */
    265265    if (has_tab != NULL)                /* check for embedded TAB */
    266266        *has_tab = (vim_strrchr(first, TAB) != NULL);
    267267    *last = save;
  • src/getchar.c

    diff '--exclude=*.orig' -urN vim73.orig/src/getchar.c vim73/src/getchar.c
    old new  
    26192619                                    if (!vim_iswhite(ptr[col]))
    26202620                                        curwin->w_wcol = vcol;
    26212621                                    vcol += lbr_chartabsize(ptr + col,
    2622                                                                (colnr_T)vcol);
     2622                                                               (colnr_T)vcol, curwin->w_cursor.lnum);
    26232623#ifdef FEAT_MBYTE
    26242624                                    if (has_mbyte)
    26252625                                        col += (*mb_ptr2len)(ptr + col);
  • src/gui_beval.c

    diff '--exclude=*.orig' -urN vim73.orig/src/gui_beval.c vim73/src/gui_beval.c
    old new  
    335335        {
    336336            /* Not past end of the file. */
    337337            lbuf = ml_get_buf(wp->w_buffer, lnum, FALSE);
    338             if (col <= win_linetabsize(wp, lbuf, (colnr_T)MAXCOL))
     338            if (col <= win_linetabsize(wp, lbuf, (colnr_T)MAXCOL, lnum))
    339339            {
    340340                /* Not past end of line. */
    341341                if (getword)
  • src/misc1.c

    diff '--exclude=*.orig' -urN vim73.orig/src/misc1.c vim73/src/misc1.c
    old new  
    465465    return (int)col;
    466466}
    467467
     468#ifdef FEAT_LINEBREAK
     469/*
     470 * Return appropriate space number for breakindent, taking influencing
     471 * parameters into account. Window must be specified, since it is not
     472 * necessarily always the current one. If lnum==0, current line is calculated,
     473 * specified line otherwise.
     474 */
     475   int
     476get_breakindent_win (wp,lnum)
     477    win_T*      wp;
     478    linenr_T    lnum;
     479{
     480    int bri;
     481    /* window width minus barren space, i.e. what rests for text */
     482    const int eff_wwidth = W_WIDTH(wp)
     483        - (wp->w_p_nu && !vim_strchr(p_cpo,CPO_NUMCOL)?number_width(wp):0);
     484        /* - (*p_sbr == NUL ? 0 : vim_strsize(p_sbr)); */
     485
     486    bri = get_indent_buf(wp->w_buffer,lnum?lnum:wp->w_cursor.lnum) + wp->w_p_brishift;
     487
     488    /* if numbering and 'c' in 'cpoptions', cancel it out effectively */
     489    /* (this could be replaced by an equivalent call to win_col_off2()) */
     490    if (curwin->w_p_nu && vim_strchr(p_cpo, CPO_NUMCOL))
     491        bri += number_width(wp);
     492   
     493    /* never indent past left window margin */
     494    if (bri < 0)
     495        bri = 0;
     496    /* always leave at least bri_min characters on the left,
     497     * if text width is sufficient */
     498    else if (bri > eff_wwidth - wp->w_p_brimin)
     499        bri = eff_wwidth - wp->w_p_brimin < 0 ? 0 : eff_wwidth - wp->w_p_brimin;
     500
     501    return bri;
     502}
     503#endif
     504
     505
    468506#if defined(FEAT_CINDENT) || defined(FEAT_SMARTINDENT)
    469507
    470508static int cin_is_cinword __ARGS((char_u *line));
     
    19471985    s = ml_get_buf(wp->w_buffer, lnum, FALSE);
    19481986    if (*s == NUL)              /* empty line */
    19491987        return 1;
    1950     col = win_linetabsize(wp, s, (colnr_T)MAXCOL);
     1988    col = win_linetabsize(wp, s, (colnr_T)MAXCOL, lnum);
    19511989
    19521990    /*
    19531991     * If list mode is on, then the '$' at the end of the line may take up one
     
    20032041    col = 0;
    20042042    while (*s != NUL && --column >= 0)
    20052043    {
    2006         col += win_lbr_chartabsize(wp, s, (colnr_T)col, NULL);
     2044        col += win_lbr_chartabsize(wp, s, (colnr_T)col, NULL, lnum);
    20072045        mb_ptr_adv(s);
    20082046    }
    20092047
     
    20152053     * 'ts') -- webb.
    20162054     */
    20172055    if (*s == TAB && (State & NORMAL) && (!wp->w_p_list || lcs_tab1))
    2018         col += win_lbr_chartabsize(wp, s, (colnr_T)col, NULL) - 1;
     2056        col += win_lbr_chartabsize(wp, s, (colnr_T)col, NULL, lnum) - 1;
    20192057
    20202058    /*
    20212059     * Add column offset for 'number', 'relativenumber', 'foldcolumn', etc.
     
    89729010                amount = 0;
    89739011                while (*that && col)
    89749012                {
    8975                     amount += lbr_chartabsize_adv(&that, (colnr_T)amount);
     9013                    amount += lbr_chartabsize_adv(&that, (colnr_T)amount, pos->lnum);
    89769014                    col--;
    89779015                }
    89789016
     
    89959033
    89969034                    while (vim_iswhite(*that))
    89979035                    {
    8998                         amount += lbr_chartabsize(that, (colnr_T)amount);
     9036                        amount += lbr_chartabsize(that, (colnr_T)amount, pos->lnum);
    89999037                        ++that;
    90009038                    }
    90019039
     
    90349072                                    --parencount;
    90359073                                if (*that == '\\' && *(that+1) != NUL)
    90369074                                    amount += lbr_chartabsize_adv(&that,
    9037                                                              (colnr_T)amount);
     9075                                                             (colnr_T)amount, pos->lnum);
    90389076                                amount += lbr_chartabsize_adv(&that,
    9039                                                              (colnr_T)amount);
     9077                                                             (colnr_T)amount, pos->lnum);
    90409078                            }
    90419079                        }
    90429080                        while (vim_iswhite(*that))
    90439081                        {
    9044                             amount += lbr_chartabsize(that, (colnr_T)amount);
     9082                            amount += lbr_chartabsize(that, (colnr_T)amount, pos->lnum);
    90459083                            that++;
    90469084                        }
    90479085                        if (!*that || *that == ';')
  • src/misc2.c

    diff '--exclude=*.orig' -urN vim73.orig/src/misc2.c vim73/src/misc2.c
    old new  
    166166#ifdef FEAT_VIRTUALEDIT
    167167            if ((addspaces || finetune) && !VIsual_active)
    168168            {
    169                 curwin->w_curswant = linetabsize(line) + one_more;
     169                curwin->w_curswant = linetabsize(line, pos->lnum) + one_more;
    170170                if (curwin->w_curswant > 0)
    171171                    --curwin->w_curswant;
    172172            }
     
    184184# endif
    185185                && wcol >= (colnr_T)width)
    186186        {
    187             csize = linetabsize(line);
     187            csize = linetabsize(line, pos->lnum);
    188188            if (csize > 0)
    189189                csize--;
    190190
     
    205205        {
    206206            /* Count a tab for what it's worth (if list mode not on) */
    207207#ifdef FEAT_LINEBREAK
    208             csize = win_lbr_chartabsize(curwin, ptr, col, &head);
     208            csize = win_lbr_chartabsize(curwin, ptr, col, &head, pos->lnum);
    209209            mb_ptr_adv(ptr);
    210210#else
    211             csize = lbr_chartabsize_adv(&ptr, col);
     211            csize = lbr_chartabsize_adv(&ptr, col, pos->lnum);
    212212#endif
    213213            col += csize;
    214214        }
  • src/normal.c

    diff '--exclude=*.orig' -urN vim73.orig/src/normal.c vim73/src/normal.c
    old new  
    44904490    int         dir;
    44914491    long        dist;
    44924492{
    4493     int         linelen = linetabsize(ml_get_curline());
     4493    int         linelen = linetabsize(ml_get_curline(), curwin->w_cursor.lnum);
    44944494    int         retval = OK;
    44954495    int         atend = FALSE;
    44964496    int         n;
     
    45634563                    (void)hasFolding(curwin->w_cursor.lnum,
    45644564                                                &curwin->w_cursor.lnum, NULL);
    45654565#endif
    4566                 linelen = linetabsize(ml_get_curline());
     4566                linelen = linetabsize(ml_get_curline(), curwin->w_cursor.lnum);
    45674567                if (linelen > width1)
    45684568                    curwin->w_curswant += (((linelen - width1 - 1) / width2)
    45694569                                                                + 1) * width2;
     
    45934593                }
    45944594                curwin->w_cursor.lnum++;
    45954595                curwin->w_curswant %= width2;
    4596                 linelen = linetabsize(ml_get_curline());
     4596                linelen = linetabsize(ml_get_curline(), curwin->w_cursor.lnum);
    45974597            }
    45984598        }
    45994599      }
  • src/ops.c

    diff '--exclude=*.orig' -urN vim73.orig/src/ops.c vim73/src/ops.c
    old new  
    431431        }
    432432        for ( ; vim_iswhite(*bd.textstart); )
    433433        {
    434             incr = lbr_chartabsize_adv(&bd.textstart, (colnr_T)(bd.start_vcol));
     434            incr = lbr_chartabsize_adv(&bd.textstart, (colnr_T)(bd.start_vcol), curwin->w_cursor.lnum);
    435435            total += incr;
    436436            bd.start_vcol += incr;
    437437        }
     
    491491
    492492        while (vim_iswhite(*non_white))
    493493        {
    494             incr = lbr_chartabsize_adv(&non_white, non_white_col);
     494            incr = lbr_chartabsize_adv(&non_white, non_white_col, curwin->w_cursor.lnum);
    495495            non_white_col += incr;
    496496        }
    497497
     
    516516            verbatim_copy_width -= bd.start_char_vcols;
    517517        while (verbatim_copy_width < destination_col)
    518518        {
    519             incr = lbr_chartabsize(verbatim_copy_end, verbatim_copy_width);
     519            incr = lbr_chartabsize(verbatim_copy_end, verbatim_copy_width, curwin->w_cursor.lnum);
    520520            if (verbatim_copy_width + incr > destination_col)
    521521                break;
    522522            verbatim_copy_width += incr;
     
    35923592            for (ptr = oldp; vcol < col && *ptr; )
    35933593            {
    35943594                /* Count a tab for what it's worth (if list mode not on) */
    3595                 incr = lbr_chartabsize_adv(&ptr, (colnr_T)vcol);
     3595                incr = lbr_chartabsize_adv(&ptr, (colnr_T)vcol, lnum);
    35963596                vcol += incr;
    35973597            }
    35983598            bd.textcol = (colnr_T)(ptr - oldp);
     
    36263626            /* calculate number of spaces required to fill right side of block*/
    36273627            spaces = y_width + 1;
    36283628            for (j = 0; j < yanklen; j++)
    3629                 spaces -= lbr_chartabsize(&y_array[i][j], 0);
     3629                spaces -= lbr_chartabsize(&y_array[i][j], 0, lnum);
    36303630            if (spaces < 0)
    36313631                spaces = 0;
    36323632
     
    51435143    while (bdp->start_vcol < oap->start_vcol && *pstart)
    51445144    {
    51455145        /* Count a tab for what it's worth (if list mode not on) */
    5146         incr = lbr_chartabsize(pstart, (colnr_T)bdp->start_vcol);
     5146        incr = lbr_chartabsize(pstart, (colnr_T)bdp->start_vcol, lnum);
    51475147        bdp->start_vcol += incr;
    51485148#ifdef FEAT_VISUALEXTRA
    51495149        if (vim_iswhite(*pstart))
     
    52125212            {
    52135213                /* Count a tab for what it's worth (if list mode not on) */
    52145214                prev_pend = pend;
    5215                 incr = lbr_chartabsize_adv(&pend, (colnr_T)bdp->end_vcol);
     5215                incr = lbr_chartabsize_adv(&pend, (colnr_T)bdp->end_vcol, lnum);
    52165216                bdp->end_vcol += incr;
    52175217            }
    52185218            if (bdp->end_vcol <= oap->end_vcol
     
    67086708            validate_virtcol();
    67096709            col_print(buf1, sizeof(buf1), (int)curwin->w_cursor.col + 1,
    67106710                    (int)curwin->w_virtcol + 1);
    6711             col_print(buf2, sizeof(buf2), (int)STRLEN(p), linetabsize(p));
     6711            col_print(buf2, sizeof(buf2), (int)STRLEN(p), linetabsize(p, curwin->w_cursor.lnum));
    67126712
    67136713            if (char_count_cursor == byte_count_cursor
    67146714                    && char_count == byte_count)
  • src/option.c

    diff '--exclude=*.orig' -urN vim73.orig/src/option.c vim73/src/option.c
    old new  
    187187#ifdef FEAT_ARABIC
    188188# define PV_ARAB        OPT_WIN(WV_ARAB)
    189189#endif
     190#ifdef FEAT_LINEBREAK
     191# define PV_BRI         OPT_WIN(WV_BRI)
     192# define PV_BRIMIN      OPT_WIN(WV_BRIMIN)
     193# define PV_BRISHIFT    OPT_WIN(WV_BRISHIFT)
     194#endif
    190195#ifdef FEAT_DIFF
    191196# define PV_DIFF        OPT_WIN(WV_DIFF)
    192197#endif
     
    646651                            {(char_u *)0L, (char_u *)0L}
    647652#endif
    648653                            SCRIPTID_INIT},
     654    {"breakindent",   "bri",  P_BOOL|P_VI_DEF|P_VIM|P_RWIN,
     655#ifdef FEAT_LINEBREAK
     656                            (char_u *)VAR_WIN, PV_BRI,
     657                            {(char_u *)FALSE, (char_u *)0L}
     658#else
     659                            (char_u *)NULL, PV_NONE,
     660                            {(char_u *)0L, (char_u *)0L}
     661#endif
     662                            SCRIPTID_INIT},
     663    {"breakindentmin", "brimin", P_NUM|P_VI_DEF|P_VIM|P_RWIN,
     664#ifdef FEAT_LINEBREAK
     665                            (char_u *)VAR_WIN, PV_BRIMIN,
     666                            {(char_u *)20L, (char_u *)20L}
     667#else
     668                            (char_u *)NULL, PV_NONE,
     669                            {(char_u *)0L, (char_u *)0L}
     670#endif
     671                            SCRIPTID_INIT},
     672    {"breakindentshift", "brishift", P_NUM|P_VI_DEF|P_VIM|P_RWIN,
     673#ifdef FEAT_LINEBREAK
     674                            (char_u *)VAR_WIN, PV_BRISHIFT,
     675                            {(char_u *)0L, (char_u *)0L}
     676#else
     677                            (char_u *)NULL, PV_NONE,
     678                            {(char_u *)0L, (char_u *)0L}
     679#endif
     680                            SCRIPTID_INIT},
    649681    {"browsedir",   "bsdir",P_STRING|P_VI_DEF,
    650682#ifdef FEAT_BROWSE
    651683                            (char_u *)&p_bsdir, PV_NONE,
     
    84238455        }
    84248456        curwin->w_nrwidth_line_count = 0;
    84258457    }
     8458
     8459    /* 'breakindentmin' must be positive */
     8460    else if (pp == &curwin->w_p_brimin)
     8461    {
     8462        if (curwin->w_p_brimin < 1)
     8463        {
     8464            errmsg = e_positive;
     8465            curwin->w_p_brimin = 1;
     8466        }
     8467    }
    84268468#endif
    84278469
    84288470    else if (pp == &curbuf->b_p_tw)
     
    96609702        case PV_WRAP:   return (char_u *)&(curwin->w_p_wrap);
    96619703#ifdef FEAT_LINEBREAK
    96629704        case PV_LBR:    return (char_u *)&(curwin->w_p_lbr);
     9705        case PV_BRI:    return (char_u *)&(curwin->w_p_bri);
     9706        case PV_BRIMIN: return (char_u *)&(curwin->w_p_brimin);
     9707        case PV_BRISHIFT: return (char_u *)&(curwin->w_p_brishift);
    96639708#endif
    96649709#ifdef FEAT_SCROLLBIND
    96659710        case PV_SCBIND: return (char_u *)&(curwin->w_p_scb);
     
    98469891    to->wo_wrap = from->wo_wrap;
    98479892#ifdef FEAT_LINEBREAK
    98489893    to->wo_lbr = from->wo_lbr;
     9894    to->wo_bri = from->wo_bri;
     9895    to->wo_brimin = from->wo_brimin;
    98499896#endif
    98509897#ifdef FEAT_SCROLLBIND
    98519898    to->wo_scb = from->wo_scb;
  • src/option.h

    diff '--exclude=*.orig' -urN vim73.orig/src/option.h vim73/src/option.h
    old new  
    10491049#ifdef FEAT_CURSORBIND
    10501050    , WV_CRBIND
    10511051#endif
     1052#ifdef FEAT_LINEBREAK
     1053    , WV_BRI
     1054    , WV_BRIMIN
     1055    , WV_BRISHIFT
     1056#endif
    10521057#ifdef FEAT_DIFF
    10531058    , WV_DIFF
    10541059#endif
  • src/proto/charset.pro

    diff '--exclude=*.orig' -urN vim73.orig/src/proto/charset.pro vim73/src/proto/charset.pro
    old new  
    1414int vim_strsize __ARGS((char_u *s));
    1515int vim_strnsize __ARGS((char_u *s, int len));
    1616int chartabsize __ARGS((char_u *p, colnr_T col));
    17 int linetabsize __ARGS((char_u *s));
    18 int linetabsize_col __ARGS((int startcol, char_u *s));
    19 int win_linetabsize __ARGS((win_T *wp, char_u *p, colnr_T len));
     17int linetabsize __ARGS((char_u *s, linenr_T lnum));
     18int linetabsize_col __ARGS((int startcol, char_u *s, linenr_T lnum));
     19int win_linetabsize __ARGS((win_T *wp, char_u *p, colnr_T len, linenr_T lnum));
    2020int vim_isIDc __ARGS((int c));
    2121int vim_iswordc __ARGS((int c));
    2222int vim_iswordp __ARGS((char_u *p));
     
    2525int vim_isfilec_or_wc __ARGS((int c));
    2626int vim_isprintc __ARGS((int c));
    2727int vim_isprintc_strict __ARGS((int c));
    28 int lbr_chartabsize __ARGS((unsigned char *s, colnr_T col));
    29 int lbr_chartabsize_adv __ARGS((char_u **s, colnr_T col));
    30 int win_lbr_chartabsize __ARGS((win_T *wp, char_u *s, colnr_T col, int *headp));
     28int lbr_chartabsize __ARGS((unsigned char *s, colnr_T col, linenr_T lnum));
     29int lbr_chartabsize_adv __ARGS((char_u **s, colnr_T col, linenr_T lnum));
     30int win_lbr_chartabsize __ARGS((win_T *wp, char_u *s, colnr_T col, int *headp, linenr_T lnum));
    3131int in_win_border __ARGS((win_T *wp, colnr_T vcol));
    3232void getvcol __ARGS((win_T *wp, pos_T *pos, colnr_T *start, colnr_T *cursor, colnr_T *end));
    3333colnr_T getvcol_nolist __ARGS((pos_T *posp));
  • src/proto/misc1.pro

    diff '--exclude=*.orig' -urN vim73.orig/src/proto/misc1.pro vim73/src/proto/misc1.pro
    old new  
    55int get_indent_str __ARGS((char_u *ptr, int ts));
    66int set_indent __ARGS((int size, int flags));
    77int get_number_indent __ARGS((linenr_T lnum));
     8int get_breakindent_win __ARGS((win_T *wp, linenr_T lnum));
    89int open_line __ARGS((int dir, int flags, int old_indent));
    910int get_leader_len __ARGS((char_u *line, char_u **flags, int backward, int do_skip_space));
    1011int get_last_leader_offset __ARGS((char_u *line, char_u **flags));
  • src/regexp.c

    diff '--exclude=*.orig' -urN vim73.orig/src/regexp.c vim73/src/regexp.c
    old new  
    42694269                    if (top.col == MAXCOL || bot.col == MAXCOL)
    42704270                        end = MAXCOL;
    42714271                    cols = win_linetabsize(wp,
    4272                                       regline, (colnr_T)(reginput - regline));
     4272                                      regline, (colnr_T)(reginput - regline), reglnum + reg_firstlnum);
    42734273                    if (cols < start || cols > end - (*p_sel == 'e'))
    42744274                        status = RA_NOMATCH;
    42754275                }
     
    42934293          case RE_VCOL:
    42944294            if (!re_num_cmp((long_u)win_linetabsize(
    42954295                            reg_win == NULL ? curwin : reg_win,
    4296                             regline, (colnr_T)(reginput - regline)) + 1, scan))
     4296                            regline, (colnr_T)(reginput - regline), reglnum + reg_firstlnum ) + 1, scan))
    42974297                status = RA_NOMATCH;
    42984298            break;
    42994299
  • src/screen.c

    diff '--exclude=*.orig' -urN vim73.orig/src/screen.c vim73/src/screen.c
    old new  
    28152815# define WL_SIGN        WL_FOLD         /* column for signs */
    28162816#endif
    28172817#define WL_NR           WL_SIGN + 1     /* line number */
     2818#ifdef FEAT_LINEBREAK
     2819# define WL_BRI         WL_NR + 1       /* 'breakindent' */
     2820#else
     2821# define WL_BRI         WL_NR
     2822#endif
    28182823#if defined(FEAT_LINEBREAK) || defined(FEAT_DIFF)
    2819 # define WL_SBR         WL_NR + 1       /* 'showbreak' or 'diff' */
     2824# define WL_SBR         WL_BRI + 1      /* 'showbreak' or 'diff' */
    28202825#else
    2821 # define WL_SBR         WL_NR
     2826# define WL_SBR         WL_BRI
    28222827#endif
    28232828#define WL_LINE         WL_SBR + 1      /* text in the line */
    28242829    int         draw_state = WL_START;  /* what to draw next */
     
    31493154#endif
    31503155        while (vcol < v && *ptr != NUL)
    31513156        {
    3152             c = win_lbr_chartabsize(wp, ptr, (colnr_T)vcol, NULL);
     3157            c = win_lbr_chartabsize(wp, ptr, (colnr_T)vcol, NULL, lnum);
    31533158            vcol += c;
    31543159#ifdef FEAT_MBYTE
    31553160            prev_ptr = ptr;
     
    35193524                }
    35203525            }
    35213526
     3527#ifdef FEAT_LINEBREAK
     3528            /* draw 'breakindent': indent wrapped text accordingly */
     3529            if (draw_state == WL_BRI -1 && n_extra == 0){
     3530                draw_state = WL_BRI;
     3531# ifdef FEAT_DIFF
     3532                /* FIXME: handle (filler_todo > 0): or modify showbreak so that ---- lines are shorter by the amount needed? */
     3533# endif
     3534                if (wp->w_p_bri && row != startrow){ /* FIXME: what is startrow? Don't we need it as well?? */
     3535                    p_extra = NUL;
     3536                    c_extra = ' ';
     3537                    n_extra = get_breakindent_win(wp,lnum);
     3538                    char_attr = 0; /* was: hl_attr(HLF_AT); */
     3539                    /* FIXME: why do we need to adjust vcol if showbreak does not?? */
     3540                    // vcol += n_extra;
     3541                    /* FIXME: is this relevant here? copied shamelessly from showbreak */
     3542                    /* Correct end of highlighted area for 'breakindent',
     3543                     * required when 'linebreak' is also set. */
     3544                    if (tocol == vcol)
     3545                        tocol += n_extra;
     3546                }
     3547            }
     3548#endif
     3549           
     3550
    35223551#if defined(FEAT_LINEBREAK) || defined(FEAT_DIFF)
    35233552            if (draw_state == WL_SBR - 1 && n_extra == 0)
    35243553            {
     
    42254254# ifdef FEAT_MBYTE
    42264255                                has_mbyte ? mb_l :
    42274256# endif
    4228                                 1), (colnr_T)vcol, NULL) - 1;
     4257                                1), (colnr_T)vcol, NULL, lnum) - 1;
    42294258                    c_extra = ' ';
    42304259                    if (vim_iswhite(c))
    42314260                        c = ' ';
  • src/structs.h

    diff '--exclude=*.orig' -urN vim73.orig/src/structs.h vim73/src/structs.h
    old new  
    133133    int         wo_arab;
    134134# define w_p_arab w_onebuf_opt.wo_arab  /* 'arabic' */
    135135#endif
     136#ifdef FEAT_LINEBREAK
     137    int         wo_bri;
     138# define w_p_bri w_onebuf_opt.wo_bri    /* 'breakindent' */
     139    long        wo_brimin;
     140# define w_p_brimin w_onebuf_opt.wo_brimin /* 'breakindentmin' */
     141    long        wo_brishift;
     142# define w_p_brishift w_onebuf_opt.wo_brishift /* 'breakindentshift' */
     143#endif
    136144#ifdef FEAT_DIFF
    137145    int         wo_diff;
    138146# define w_p_diff w_onebuf_opt.wo_diff  /* 'diff' */
  • src/ui.c

    diff '--exclude=*.orig' -urN vim73.orig/src/ui.c vim73/src/ui.c
    old new  
    31343134    start = ptr = ml_get_buf(wp->w_buffer, lnum, FALSE);
    31353135    while (count <= vcol && *ptr != NUL)
    31363136    {
    3137         count += win_lbr_chartabsize(wp, ptr, count, NULL);
     3137        count += win_lbr_chartabsize(wp, ptr, count, NULL, lnum);
    31383138        mb_ptr_adv(ptr);
    31393139    }
    31403140    return (int)(ptr - start);