Blog: Better line wrapping in Vim, 2nd iteration: vim-7.2-breakindent.patch

File vim-7.2-breakindent.patch, 29.4 KB (added by retracile, 14 years ago)

updated breakindent patch

  • runtime/doc/eval.txt

    diff -urN vim72.orig/runtime/doc/eval.txt vim72.work/runtime/doc/eval.txt
    old new  
    58255825keymap                  Compiled with 'keymap' support.
    58265826langmap                 Compiled with 'langmap' support.
    58275827libcall                 Compiled with |libcall()| support.
    5828 linebreak               Compiled with 'linebreak', 'breakat' and 'showbreak'
    5829                         support.
     5828linebreak               Compiled with 'linebreak', 'breakat', 'showbreak' and
     5829                        'breakindent' support.
    58305830lispindent              Compiled with support for lisp indenting.
    58315831listcmds                Compiled with commands for the buffer list |:files|
    58325832                        and the argument list |arglist|.
  • runtime/doc/options.txt

    diff -urN vim72.orig/runtime/doc/options.txt vim72.work/runtime/doc/options.txt
    old new  
    11601160        break if 'linebreak' is on.  Only works for ASCII and also for 8-bit
    11611161        characters when 'encoding' is an 8-bit encoding.
    11621162
     1163
     1164                                                *'breakindent'* *'bri'*
     1165'breakindent' 'bri'     boolean (default off)
     1166                        local to window
     1167                        {not in Vi}
     1168                        {not available when compiled without the |+linebreak|
     1169                        feature}
     1170        Every wrapped line will continue visually indented (same amount of
     1171        space as the beginning of that line), thus preserving horizontal blocks
     1172        of text.
     1173
     1174                                                *'breakindentmin'* *'brimin'*
     1175'breakindentmin' 'brimin' number (default 20)
     1176                        local to window
     1177                        {not in Vi}
     1178                        {not available when compiled without the |+linebreak|
     1179                        feature}
     1180        Minimum text width that will be kept after applying 'breakindent',
     1181        even if the resulting text should normally be narrower. This prevents
     1182        text indented almost to the right window border oocupying lot of
     1183        vertical space when broken.
     1184
     1185                                                *'breakindentshift'* *'brishift'*
     1186'breakindentshift' 'brishift' number (default 20)
     1187                        local to window
     1188                        {not in Vi}
     1189                        {not available when compiled without the |+linebreak|
     1190                        feature}
     1191        After applying 'breakindent', wrapped line beginning will be shift by
     1192        given number of characters. It permits dynamic French paragraph
     1193        indentation (negative) or emphasizing the line continuation
     1194        (positive).
     1195
    11631196                                                *'browsedir'* *'bsdir'*
    11641197'browsedir' 'bsdir'     string  (default: "last")
    11651198                        global
     
    42634296                        {not in Vi}
    42644297                        {not available when compiled without the  |+linebreak|
    42654298                        feature}
    4266         If on Vim will wrap long lines at a character in 'breakat' rather
     4299        If on, Vim will wrap long lines at a character in 'breakat' rather
    42674300        than at the last character that fits on the screen.  Unlike
    42684301        'wrapmargin' and 'textwidth', this does not insert <EOL>s in the file,
    4269         it only affects the way the file is displayed, not its contents.  The
    4270         value of 'showbreak' is used to put in front of wrapped lines.
    4271         This option is not used when the 'wrap' option is off or 'list' is on.
     4302        it only affects the way the file is displayed, not its contents.
     4303        If 'breakindent' is set, line is visually indented. Then, the value
     4304        of 'showbreak' is used to put in front of wrapped lines. This option
     4305        is not used when the 'wrap' option is off or 'list' is on.
    42724306        Note that <Tab> characters after an <EOL> are mostly not displayed
    42734307        with the right amount of white space.
    42744308
  • runtime/optwin.vim

    diff -urN vim72.orig/runtime/optwin.vim vim72.work/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 -urN vim72.orig/src/charset.c vim72.work/src/charset.c
    old new  
    843843 * taking into account the size of a tab
    844844 */
    845845    int
    846 linetabsize(s)
     846linetabsize(s, lnum)
    847847    char_u      *s;
     848    linenr_T    lnum;
    848849{
    849850    colnr_T     col = 0;
    850851
    851852    while (*s != NUL)
    852         col += lbr_chartabsize_adv(&s, col);
     853        col += lbr_chartabsize_adv(&s, col, lnum);
    853854    return (int)col;
    854855}
    855856
     
    857858 * Like linetabsize(), but for a given window instead of the current one.
    858859 */
    859860    int
    860 win_linetabsize(wp, p, len)
     861win_linetabsize(wp, p, len, lnum)
    861862    win_T       *wp;
    862863    char_u      *p;
    863864    colnr_T     len;
     865    linenr_T    lnum;
    864866{
    865867    colnr_T     col = 0;
    866868    char_u      *s;
    867869
    868870    for (s = p; *s != NUL && (len == MAXCOL || s < p + len); mb_ptr_adv(s))
    869         col += win_lbr_chartabsize(wp, s, col, NULL);
     871        col += win_lbr_chartabsize(wp, s, col, NULL, lnum);
    870872    return (int)col;
    871873}
    872874
     
    995997 * like chartabsize(), but also check for line breaks on the screen
    996998 */
    997999    int
    998 lbr_chartabsize(s, col)
     1000lbr_chartabsize(s, col, lnum)
    9991001    unsigned char       *s;
    10001002    colnr_T             col;
     1003    linenr_T            lnum;
    10011004{
    10021005#ifdef FEAT_LINEBREAK
    1003     if (!curwin->w_p_lbr && *p_sbr == NUL)
     1006    if (!curwin->w_p_lbr && *p_sbr == NUL && !curwin->w_p_bri)
    10041007    {
    10051008#endif
    10061009#ifdef FEAT_MBYTE
     
    10101013        RET_WIN_BUF_CHARTABSIZE(curwin, curbuf, s, col)
    10111014#ifdef FEAT_LINEBREAK
    10121015    }
    1013     return win_lbr_chartabsize(curwin, s, col, NULL);
     1016    return win_lbr_chartabsize(curwin, s, col, NULL, lnum);
    10141017#endif
    10151018}
    10161019
     
    10181021 * Call lbr_chartabsize() and advance the pointer.
    10191022 */
    10201023    int
    1021 lbr_chartabsize_adv(s, col)
     1024lbr_chartabsize_adv(s, col, lnum)
    10221025    char_u      **s;
    10231026    colnr_T     col;
     1027    linenr_T    lnum;
    10241028{
    10251029    int         retval;
    10261030
    1027     retval = lbr_chartabsize(*s, col);
     1031    retval = lbr_chartabsize(*s, col, lnum);
    10281032    mb_ptr_adv(*s);
    10291033    return retval;
    10301034}
     
    10351039 * If "headp" not NULL, set *headp to the size of what we for 'showbreak'
    10361040 * string at start of line.  Warning: *headp is only set if it's a non-zero
    10371041 * value, init to 0 before calling.
     1042 *
     1043 * linenr argument needed if in visual highlighting and breakindent=on, then
     1044 * the line calculated is not current; if 0, normal functionality is preserved.
    10381045 */
    10391046    int
    1040 win_lbr_chartabsize(wp, s, col, headp)
     1047win_lbr_chartabsize(wp, s, col, headp, lnum)
    10411048    win_T       *wp;
    10421049    char_u      *s;
    10431050    colnr_T     col;
    10441051    int         *headp UNUSED;
     1052    linenr_T    lnum;
    10451053{
    10461054#ifdef FEAT_LINEBREAK
    10471055    int         c;
     
    10601068    int         n;
    10611069
    10621070    /*
    1063      * No 'linebreak' and 'showbreak': return quickly.
     1071     * No 'linebreak' and 'showbreak' and 'breakindent': return quickly.
    10641072     */
    1065     if (!wp->w_p_lbr && *p_sbr == NUL)
     1073    if (!wp->w_p_lbr && !wp->w_p_bri && *p_sbr == NUL)
    10661074#endif
    10671075    {
    10681076#ifdef FEAT_MBYTE
     
    11371145# endif
    11381146
    11391147    /*
    1140      * May have to add something for 'showbreak' string at start of line
     1148     * May have to add something for 'breakindent' and/or 'showbreak'
     1149     * string at start of line.
    11411150     * Set *headp to the size of what we add.
    11421151     */
    11431152    added = 0;
    1144     if (*p_sbr != NUL && wp->w_p_wrap && col != 0)
     1153    if ((*p_sbr != NUL || wp->w_p_bri) && wp->w_p_wrap && col != 0)
    11451154    {
    11461155        numberextra = win_col_off(wp);
    11471156        col += numberextra + mb_added;
     
    11541163        }
    11551164        if (col == 0 || col + size > (colnr_T)W_WIDTH(wp))
    11561165        {
    1157             added = vim_strsize(p_sbr);
     1166            added = 0;
     1167            if (*p_sbr != NUL)
     1168                added += vim_strsize(p_sbr);
     1169            if (wp->w_p_bri)
     1170                added += get_breakindent_win(wp,lnum);
     1171
    11581172            if (tab_corr)
    11591173                size += (added / wp->w_buffer->b_p_ts) * wp->w_buffer->b_p_ts;
    11601174            else
     
    12591273
    12601274    /*
    12611275     * This function is used very often, do some speed optimizations.
    1262      * When 'list', 'linebreak' and 'showbreak' are not set use a simple loop.
     1276     * When 'list', 'linebreak', 'showbreak' and 'breakindent' are not set
     1277     * use a simple loop.
    12631278     * Also use this when 'list' is set but tabs take their normal size.
    12641279     */
    12651280    if ((!wp->w_p_list || lcs_tab1 != NUL)
    12661281#ifdef FEAT_LINEBREAK
    1267             && !wp->w_p_lbr && *p_sbr == NUL
     1282            && !wp->w_p_lbr && *p_sbr == NUL && !wp->w_p_bri
    12681283#endif
    12691284       )
    12701285    {
     
    13261341        {
    13271342            /* A tab gets expanded, depending on the current column */
    13281343            head = 0;
    1329             incr = win_lbr_chartabsize(wp, ptr, vcol, &head);
     1344            incr = win_lbr_chartabsize(wp, ptr, vcol, &head, pos->lnum);
    13301345            /* make sure we don't go past the end of the line */
    13311346            if (*ptr == NUL)
    13321347            {
  • src/edit.c

    diff -urN vim72.orig/src/edit.c vim72.work/src/edit.c
    old new  
    391391        if (startln)
    392392            Insstart.col = 0;
    393393    }
    394     Insstart_textlen = (colnr_T)linetabsize(ml_get_curline());
     394    Insstart_textlen = (colnr_T)linetabsize(ml_get_curline(), Insstart.lnum);
    395395    Insstart_blank_vcol = MAXCOL;
    396396    if (!did_ai)
    397397        ai_col = 0;
     
    17951795            else
    17961796#endif
    17971797                ++new_cursor_col;
    1798             vcol += lbr_chartabsize(ptr + new_cursor_col, (colnr_T)vcol);
     1798            vcol += lbr_chartabsize(ptr + new_cursor_col, (colnr_T)vcol, curwin->w_cursor.lnum);
    17991799        }
    18001800        vcol = last_vcol;
    18011801
     
    63686368            ins_need_undo = FALSE;
    63696369        }
    63706370        Insstart = curwin->w_cursor;    /* new insertion starts here */
    6371         Insstart_textlen = (colnr_T)linetabsize(ml_get_curline());
     6371        Insstart_textlen = (colnr_T)linetabsize(ml_get_curline(),curwin->w_cursor.lnum);
    63726372        ai_col = 0;
    63736373#ifdef FEAT_VREPLACE
    63746374        if (State & VREPLACE_FLAG)
     
    67276727        for (;;)
    67286728        {
    67296729            coladvance(v - width);
    6730             /* getviscol() is slow, skip it when 'showbreak' is empty and
    6731              * there are no multi-byte characters */
    6732             if ((*p_sbr == NUL
     6730            /* getviscol() is slow, skip it when 'showbreak' is empty,
     6731             * 'breakindent' is not set and there are no multi-byte
     6732             * characters */
     6733            if ((*p_sbr == NUL && !curwin->w_p_bri
    67336734#  ifdef FEAT_MBYTE
    67346735                        && !has_mbyte
    67356736#  endif
     
    93659366        getvcol(curwin, &fpos, &vcol, NULL, NULL);
    93669367        getvcol(curwin, cursor, &want_vcol, NULL, NULL);
    93679368
    9368         /* Use as many TABs as possible.  Beware of 'showbreak' and
     9369        /* Use as many TABs as possible.  Beware of 'breakindent', 'showbreak' and
    93699370         * 'linebreak' adding extra virtual columns. */
    93709371        while (vim_iswhite(*ptr))
    93719372        {
    9372             i = lbr_chartabsize((char_u *)"\t", vcol);
     9373            i = lbr_chartabsize((char_u *)"\t", vcol, cursor->lnum);
    93739374            if (vcol + i > want_vcol)
    93749375                break;
    93759376            if (*ptr != TAB)
     
    93959396            /* Skip over the spaces we need. */
    93969397            while (vcol < want_vcol && *ptr == ' ')
    93979398            {
    9398                 vcol += lbr_chartabsize(ptr, vcol);
     9399                vcol += lbr_chartabsize(ptr, vcol, cursor->lnum);
    93999400                ++ptr;
    94009401                ++repl_off;
    94019402            }
     
    96439644    while ((colnr_T)temp < curwin->w_virtcol && *ptr != NUL)
    96449645    {
    96459646        prev_ptr = ptr;
    9646         temp += lbr_chartabsize_adv(&ptr, (colnr_T)temp);
     9647        temp += lbr_chartabsize_adv(&ptr, (colnr_T)temp, lnum);
    96479648    }
    96489649    if ((colnr_T)temp > curwin->w_virtcol)
    96499650        ptr = prev_ptr;
  • src/ex_cmds.c

    diff -urN vim72.orig/src/ex_cmds.c vim72.work/src/ex_cmds.c
    old new  
    266266        ;
    267267    save = *last;
    268268    *last = NUL;
    269     len = linetabsize(line);            /* get line length */
     269    len = linetabsize(line, curwin->w_cursor.lnum); /* get line length */
    270270    if (has_tab != NULL)                /* check for embedded TAB */
    271271        *has_tab = (vim_strrchr(first, TAB) != NULL);
    272272    *last = save;
  • src/getchar.c

    diff -urN vim72.orig/src/getchar.c vim72.work/src/getchar.c
    old new  
    25642564                                    if (!vim_iswhite(ptr[col]))
    25652565                                        curwin->w_wcol = vcol;
    25662566                                    vcol += lbr_chartabsize(ptr + col,
    2567                                                                (colnr_T)vcol);
     2567                                                               (colnr_T)vcol, curwin->w_cursor.lnum);
    25682568#ifdef FEAT_MBYTE
    25692569                                    if (has_mbyte)
    25702570                                        col += (*mb_ptr2len)(ptr + col);
  • src/gui_beval.c

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

    diff -urN vim72.orig/src/misc1.c vim72.work/src/misc1.c
    old new  
    451451    return (int)col;
    452452}
    453453
     454#ifdef FEAT_LINEBREAK
     455/*
     456 * Return appropriate space number for breakindent, taking influencing
     457 * parameters into account. Window must be specified, since it is not
     458 * necessarily always the current one. If lnum==0, current line is calculated,
     459 * specified line otherwise.
     460 */
     461   int
     462get_breakindent_win (wp,lnum)
     463    win_T*      wp;
     464    linenr_T    lnum;
     465{
     466    int bri;
     467    /* window width minus barren space, i.e. what rests for text */
     468    const int eff_wwidth = W_WIDTH(wp)
     469        - (wp->w_p_nu && !vim_strchr(p_cpo,CPO_NUMCOL)?number_width(wp):0);
     470        /* - (*p_sbr == NUL ? 0 : vim_strsize(p_sbr)); */
     471
     472    bri = get_indent_buf(wp->w_buffer,lnum?lnum:wp->w_cursor.lnum) + wp->w_p_brishift;
     473
     474    /* if numbering and 'c' in 'cpoptions', cancel it out effectively */
     475    /* (this could be replaced by an equivalent call to win_col_off2()) */
     476    if (curwin->w_p_nu && vim_strchr(p_cpo, CPO_NUMCOL))
     477        bri += number_width(wp);
     478
     479    /* never indent past left window margin */
     480    if (bri < 0)
     481        bri = 0;
     482    /* always leave at least bri_min characters on the left,
     483     * if text width is sufficient */
     484    else if (bri > eff_wwidth - wp->w_p_brimin)
     485        bri = eff_wwidth - wp->w_p_brimin < 0 ? 0 : eff_wwidth - wp->w_p_brimin;
     486
     487    return bri;
     488}
     489
     490
     491
     492#endif
     493
    454494#if defined(FEAT_CINDENT) || defined(FEAT_SMARTINDENT)
    455495
    456496static int cin_is_cinword __ARGS((char_u *line));
     
    17321772    s = ml_get_buf(wp->w_buffer, lnum, FALSE);
    17331773    if (*s == NUL)              /* empty line */
    17341774        return 1;
    1735     col = win_linetabsize(wp, s, (colnr_T)MAXCOL);
     1775    col = win_linetabsize(wp, s, (colnr_T)MAXCOL, lnum);
    17361776
    17371777    /*
    17381778     * If list mode is on, then the '$' at the end of the line may take up one
     
    17881828    col = 0;
    17891829    while (*s != NUL && --column >= 0)
    17901830    {
    1791         col += win_lbr_chartabsize(wp, s, (colnr_T)col, NULL);
     1831        col += win_lbr_chartabsize(wp, s, (colnr_T)col, NULL, lnum);
    17921832        mb_ptr_adv(s);
    17931833    }
    17941834
     
    18001840     * 'ts') -- webb.
    18011841     */
    18021842    if (*s == TAB && (State & NORMAL) && (!wp->w_p_list || lcs_tab1))
    1803         col += win_lbr_chartabsize(wp, s, (colnr_T)col, NULL) - 1;
     1843        col += win_lbr_chartabsize(wp, s, (colnr_T)col, NULL, lnum) - 1;
    18041844
    18051845    /*
    18061846     * Add column offset for 'number', 'foldcolumn', etc.
     
    82288268                amount = 0;
    82298269                while (*that && col)
    82308270                {
    8231                     amount += lbr_chartabsize_adv(&that, (colnr_T)amount);
     8271                    amount += lbr_chartabsize_adv(&that, (colnr_T)amount, pos->lnum);
    82328272                    col--;
    82338273                }
    82348274
     
    82518291
    82528292                    while (vim_iswhite(*that))
    82538293                    {
    8254                         amount += lbr_chartabsize(that, (colnr_T)amount);
     8294                        amount += lbr_chartabsize(that, (colnr_T)amount, pos->lnum);
    82558295                        ++that;
    82568296                    }
    82578297
     
    82908330                                    --parencount;
    82918331                                if (*that == '\\' && *(that+1) != NUL)
    82928332                                    amount += lbr_chartabsize_adv(&that,
    8293                                                              (colnr_T)amount);
     8333                                                             (colnr_T)amount, pos->lnum);
    82948334                                amount += lbr_chartabsize_adv(&that,
    8295                                                              (colnr_T)amount);
     8335                                                             (colnr_T)amount, pos->lnum);
    82968336                            }
    82978337                        }
    82988338                        while (vim_iswhite(*that))
    82998339                        {
    8300                             amount += lbr_chartabsize(that, (colnr_T)amount);
     8340                            amount += lbr_chartabsize(that, (colnr_T)amount, pos->lnum);
    83018341                            that++;
    83028342                        }
    83038343                        if (!*that || *that == ';')
  • src/misc2.c

    diff -urN vim72.orig/src/misc2.c vim72.work/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
     
    206206        {
    207207            /* Count a tab for what it's worth (if list mode not on) */
    208208#ifdef FEAT_LINEBREAK
    209             csize = win_lbr_chartabsize(curwin, ptr, col, &head);
     209            csize = win_lbr_chartabsize(curwin, ptr, col, &head, pos->lnum);
    210210            mb_ptr_adv(ptr);
    211211#else
    212             csize = lbr_chartabsize_adv(&ptr, col);
     212            csize = lbr_chartabsize_adv(&ptr, col, pos->lnum);
    213213#endif
    214214            col += csize;
    215215        }
  • src/normal.c

    diff -urN vim72.orig/src/normal.c vim72.work/src/normal.c
    old new  
    43274327    int         dir;
    43284328    long        dist;
    43294329{
    4330     int         linelen = linetabsize(ml_get_curline());
     4330    int         linelen = linetabsize(ml_get_curline(), curwin->w_cursor.lnum);
    43314331    int         retval = OK;
    43324332    int         atend = FALSE;
    43334333    int         n;
     
    44004400                    (void)hasFolding(curwin->w_cursor.lnum,
    44014401                                                &curwin->w_cursor.lnum, NULL);
    44024402#endif
    4403                 linelen = linetabsize(ml_get_curline());
     4403                linelen = linetabsize(ml_get_curline(), curwin->w_cursor.lnum);
    44044404                if (linelen > width1)
    44054405                    curwin->w_curswant += (((linelen - width1 - 1) / width2)
    44064406                                                                + 1) * width2;
  • src/ops.c

    diff -urN vim72.orig/src/ops.c vim72.work/src/ops.c
    old new  
    428428        }
    429429        for ( ; vim_iswhite(*bd.textstart); )
    430430        {
    431             incr = lbr_chartabsize_adv(&bd.textstart, (colnr_T)(bd.start_vcol));
     431            incr = lbr_chartabsize_adv(&bd.textstart, (colnr_T)(bd.start_vcol), curwin->w_cursor.lnum);
    432432            total += incr;
    433433            bd.start_vcol += incr;
    434434        }
     
    488488
    489489        while (vim_iswhite(*non_white))
    490490        {
    491             incr = lbr_chartabsize_adv(&non_white, non_white_col);
     491            incr = lbr_chartabsize_adv(&non_white, non_white_col, curwin->w_cursor.lnum);
    492492            non_white_col += incr;
    493493        }
    494494
     
    513513            verbatim_copy_width -= bd.start_char_vcols;
    514514        while (verbatim_copy_width < destination_col)
    515515        {
    516             incr = lbr_chartabsize(verbatim_copy_end, verbatim_copy_width);
     516            incr = lbr_chartabsize(verbatim_copy_end, verbatim_copy_width, curwin->w_cursor.lnum);
    517517            if (verbatim_copy_width + incr > destination_col)
    518518                break;
    519519            verbatim_copy_width += incr;
     
    35193519            for (ptr = oldp; vcol < col && *ptr; )
    35203520            {
    35213521                /* Count a tab for what it's worth (if list mode not on) */
    3522                 incr = lbr_chartabsize_adv(&ptr, (colnr_T)vcol);
     3522                incr = lbr_chartabsize_adv(&ptr, (colnr_T)vcol, lnum);
    35233523                vcol += incr;
    35243524            }
    35253525            bd.textcol = (colnr_T)(ptr - oldp);
     
    35533553            /* calculate number of spaces required to fill right side of block*/
    35543554            spaces = y_width + 1;
    35553555            for (j = 0; j < yanklen; j++)
    3556                 spaces -= lbr_chartabsize(&y_array[i][j], 0);
     3556                spaces -= lbr_chartabsize(&y_array[i][j], 0, lnum);
    35573557            if (spaces < 0)
    35583558                spaces = 0;
    35593559
     
    49064906    while (bdp->start_vcol < oap->start_vcol && *pstart)
    49074907    {
    49084908        /* Count a tab for what it's worth (if list mode not on) */
    4909         incr = lbr_chartabsize(pstart, (colnr_T)bdp->start_vcol);
     4909        incr = lbr_chartabsize(pstart, (colnr_T)bdp->start_vcol, lnum);
    49104910        bdp->start_vcol += incr;
    49114911#ifdef FEAT_VISUALEXTRA
    49124912        if (vim_iswhite(*pstart))
     
    49754975            {
    49764976                /* Count a tab for what it's worth (if list mode not on) */
    49774977                prev_pend = pend;
    4978                 incr = lbr_chartabsize_adv(&pend, (colnr_T)bdp->end_vcol);
     4978                incr = lbr_chartabsize_adv(&pend, (colnr_T)bdp->end_vcol, lnum);
    49794979                bdp->end_vcol += incr;
    49804980            }
    49814981            if (bdp->end_vcol <= oap->end_vcol
     
    64656465            validate_virtcol();
    64666466            col_print(buf1, sizeof(buf1), (int)curwin->w_cursor.col + 1,
    64676467                    (int)curwin->w_virtcol + 1);
    6468             col_print(buf2, sizeof(buf2), (int)STRLEN(p), linetabsize(p));
     6468            col_print(buf2, sizeof(buf2), (int)STRLEN(p), linetabsize(p, curwin->w_cursor.lnum));
    64696469
    64706470            if (char_count_cursor == byte_count_cursor
    64716471                    && char_count == byte_count)
  • src/option.c

    diff -urN vim72.orig/src/option.c vim72.work/src/option.c
    old new  
    186186#ifdef FEAT_ARABIC
    187187# define PV_ARAB        OPT_WIN(WV_ARAB)
    188188#endif
     189#ifdef FEAT_LINEBREAK
     190# define PV_BRI         OPT_WIN(WV_BRI)
     191# define PV_BRIMIN      OPT_WIN(WV_BRIMIN)
     192# define PV_BRISHIFT    OPT_WIN(WV_BRISHIFT)
     193#endif
    189194#ifdef FEAT_DIFF
    190195# define PV_DIFF        OPT_WIN(WV_DIFF)
    191196#endif
     
    634639                            {(char_u *)0L, (char_u *)0L}
    635640#endif
    636641                            SCRIPTID_INIT},
     642    {"breakindent",   "bri",  P_BOOL|P_VI_DEF|P_VIM|P_RWIN,
     643#ifdef FEAT_LINEBREAK
     644                            (char_u *)VAR_WIN, PV_BRI,
     645#else
     646                            (char_u *)NULL, PV_NONE,
     647#endif
     648                            {(char_u *)FALSE, (char_u *)0L}},
     649    {"breakindentmin", "brimin", P_NUM|P_VI_DEF|P_VIM|P_RWIN,
     650#ifdef FEAT_LINEBREAK
     651                            (char_u *)VAR_WIN, PV_BRIMIN,
     652#else
     653                            (char_u *)NULL, PV_NONE,
     654#endif
     655                            {(char_u *)20L, (char_u *)20L}},
     656    {"breakindentshift", "brishift", P_NUM|P_VI_DEF|P_VIM|P_RWIN,
     657#ifdef FEAT_LINEBREAK
     658                            (char_u *)VAR_WIN, PV_BRISHIFT,
     659#else
     660                            (char_u *)NULL, PV_NONE,
     661#endif
     662                            {(char_u *)0L, (char_u *)0L}},
    637663    {"browsedir",   "bsdir",P_STRING|P_VI_DEF,
    638664#ifdef FEAT_BROWSE
    639665                            (char_u *)&p_bsdir, PV_NONE,
     
    80158041        }
    80168042        curwin->w_nrwidth_line_count = 0;
    80178043    }
     8044
     8045    /* 'breakindentmin' must be positive */
     8046    else if (pp == &curwin->w_p_brimin)
     8047    {
     8048        if (curwin->w_p_brimin < 1)
     8049        {
     8050            errmsg = e_positive;
     8051            curwin->w_p_brimin = 1;
     8052        }
     8053    }
    80188054#endif
    80198055
    80208056    /*
     
    92189254        case PV_WRAP:   return (char_u *)&(curwin->w_p_wrap);
    92199255#ifdef FEAT_LINEBREAK
    92209256        case PV_LBR:    return (char_u *)&(curwin->w_p_lbr);
     9257        case PV_BRI:    return (char_u *)&(curwin->w_p_bri);
     9258        case PV_BRIMIN: return (char_u *)&(curwin->w_p_brimin);
     9259        case PV_BRISHIFT: return (char_u *)&(curwin->w_p_brishift);
    92219260#endif
    92229261#ifdef FEAT_SCROLLBIND
    92239262        case PV_SCBIND: return (char_u *)&(curwin->w_p_scb);
     
    93969435    to->wo_wrap = from->wo_wrap;
    93979436#ifdef FEAT_LINEBREAK
    93989437    to->wo_lbr = from->wo_lbr;
     9438    to->wo_bri = from->wo_bri;
     9439    to->wo_brimin = from->wo_brimin;
    93999440#endif
    94009441#ifdef FEAT_SCROLLBIND
    94019442    to->wo_scb = from->wo_scb;
  • src/option.h

    diff -urN vim72.orig/src/option.h vim72.work/src/option.h
    old new  
    10181018#ifdef FEAT_ARABIC
    10191019    , WV_ARAB
    10201020#endif
     1021#ifdef FEAT_LINEBREAK
     1022    , WV_BRI
     1023    , WV_BRIMIN
     1024    , WV_BRISHIFT
     1025#endif
    10211026#ifdef FEAT_DIFF
    10221027    , WV_DIFF
    10231028#endif
  • src/proto/charset.pro

    diff -urN vim72.orig/src/proto/charset.pro vim72.work/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 win_linetabsize __ARGS((win_T *wp, char_u *p, colnr_T len));
     17int linetabsize __ARGS((char_u *s, linenr_T lnum));
     18int win_linetabsize __ARGS((win_T *wp, char_u *p, colnr_T len, linenr_T lnum));
    1919int vim_isIDc __ARGS((int c));
    2020int vim_iswordc __ARGS((int c));
    2121int vim_iswordp __ARGS((char_u *p));
     
    2424int vim_isfilec_or_wc __ARGS((int c));
    2525int vim_isprintc __ARGS((int c));
    2626int vim_isprintc_strict __ARGS((int c));
    27 int lbr_chartabsize __ARGS((unsigned char *s, colnr_T col));
    28 int lbr_chartabsize_adv __ARGS((char_u **s, colnr_T col));
    29 int win_lbr_chartabsize __ARGS((win_T *wp, char_u *s, colnr_T col, int *headp));
     27int lbr_chartabsize __ARGS((unsigned char *s, colnr_T col, linenr_T lnum));
     28int lbr_chartabsize_adv __ARGS((char_u **s, colnr_T col, linenr_T lnum));
     29int win_lbr_chartabsize __ARGS((win_T *wp, char_u *s, colnr_T col, int *headp, linenr_T lnum));
    3030int in_win_border __ARGS((win_T *wp, colnr_T vcol));
    3131void getvcol __ARGS((win_T *wp, pos_T *pos, colnr_T *start, colnr_T *cursor, colnr_T *end));
    3232colnr_T getvcol_nolist __ARGS((pos_T *posp));
  • src/proto/misc1.pro

    diff -urN vim72.orig/src/proto/misc1.pro vim72.work/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));
    1011int plines __ARGS((linenr_T lnum));
  • src/regexp.c

    diff -urN vim72.orig/src/regexp.c vim72.work/src/regexp.c
    old new  
    39943994                    if (top.col == MAXCOL || bot.col == MAXCOL)
    39953995                        end = MAXCOL;
    39963996                    cols = win_linetabsize(wp,
    3997                                       regline, (colnr_T)(reginput - regline));
     3997                                      regline, (colnr_T)(reginput - regline), reglnum + reg_firstlnum);
    39983998                    if (cols < start || cols > end - (*p_sel == 'e'))
    39993999                        status = RA_NOMATCH;
    40004000                }
     
    40184018          case RE_VCOL:
    40194019            if (!re_num_cmp((long_u)win_linetabsize(
    40204020                            reg_win == NULL ? curwin : reg_win,
    4021                             regline, (colnr_T)(reginput - regline)) + 1, scan))
     4021                            regline, (colnr_T)(reginput - regline), reglnum + reg_firstlnum ) + 1, scan))
    40224022                status = RA_NOMATCH;
    40234023            break;
    40244024
  • src/screen.c

    diff -urN vim72.orig/src/screen.c vim72.work/src/screen.c
    old new  
    26982698# define WL_SIGN        WL_FOLD         /* column for signs */
    26992699#endif
    27002700#define WL_NR           WL_SIGN + 1     /* line number */
     2701#ifdef FEAT_LINEBREAK
     2702# define WL_BRI         WL_NR + 1       /* 'breakindent' */
     2703#else
     2704# define WL_BRI         WL_NR
     2705#endif
    27012706#if defined(FEAT_LINEBREAK) || defined(FEAT_DIFF)
    2702 # define WL_SBR         WL_NR + 1       /* 'showbreak' or 'diff' */
     2707# define WL_SBR         WL_BRI + 1      /* 'showbreak' or 'diff' */
    27032708#else
    2704 # define WL_SBR         WL_NR
     2709# define WL_SBR         WL_BRI
    27052710#endif
    27062711#define WL_LINE         WL_SBR + 1      /* text in the line */
    27072712    int         draw_state = WL_START;  /* what to draw next */
     
    30103015#endif
    30113016        while (vcol < v && *ptr != NUL)
    30123017        {
    3013             c = win_lbr_chartabsize(wp, ptr, (colnr_T)vcol, NULL);
     3018            c = win_lbr_chartabsize(wp, ptr, (colnr_T)vcol, NULL, lnum);
    30143019            vcol += c;
    30153020#ifdef FEAT_MBYTE
    30163021            prev_ptr = ptr;
     
    33683373                }
    33693374            }
    33703375
     3376#ifdef FEAT_LINEBREAK
     3377            /* draw 'breakindent': indent wrapped text accordingly */
     3378            if (draw_state == WL_BRI -1 && n_extra == 0){
     3379                draw_state = WL_BRI;
     3380# ifdef FEAT_DIFF
     3381                /* FIXME: handle (filler_todo > 0): or modify showbreak so that ---- vim/lines are shorter by the amount needed? */
     3382# endif
     3383                if (wp->w_p_bri && row != startrow){ /* FIXME: what is startrow? Don't we need it as well?? */
     3384                    p_extra = NUL;
     3385                    c_extra = ' ';
     3386                    n_extra = get_breakindent_win(wp,lnum);
     3387                    char_attr = 0; /* was: hl_attr(HLF_AT); */
     3388                    /* FIXME: why do we need to adjust vcol if showbreak does not?? */
     3389                    vcol += n_extra;
     3390                    /* FIXME: is this relevant here? copied shamelessly from showbreak */
     3391                    /* Correct end of highlighted area for 'breakindent',
     3392                     * required when 'linebreak' is also set. */
     3393                    if (tocol == vcol)
     3394                        tocol += n_extra;
     3395                }
     3396            }
     3397#endif
     3398
     3399
    33713400#if defined(FEAT_LINEBREAK) || defined(FEAT_DIFF)
    33723401            if (draw_state == WL_SBR - 1 && n_extra == 0)
    33733402            {
     
    40654094# ifdef FEAT_MBYTE
    40664095                                has_mbyte ? mb_l :
    40674096# endif
    4068                                 1), (colnr_T)vcol, NULL) - 1;
     4097                                1), (colnr_T)vcol, NULL, lnum) - 1;
    40694098                    c_extra = ' ';
    40704099                    if (vim_iswhite(c))
    40714100                        c = ' ';
  • src/structs.h

    diff -urN vim72.orig/src/structs.h vim72.work/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 -urN vim72.orig/src/ui.c vim72.work/src/ui.c
    old new  
    30623062    start = ptr = ml_get_buf(wp->w_buffer, lnum, FALSE);
    30633063    while (count <= vcol && *ptr != NUL)
    30643064    {
    3065         count += win_lbr_chartabsize(wp, ptr, count, NULL);
     3065        count += win_lbr_chartabsize(wp, ptr, count, NULL, lnum);
    30663066        mb_ptr_adv(ptr);
    30673067    }
    30683068    return (int)(ptr - start);