Blog: Better line wrapping in Vim, 4th iteration: breakindent-20101112-vim7.3.diff

File breakindent-20101112-vim7.3.diff, 33.0 KB (added by retracile, 13 years ago)

updated breakindent patch

  • vim-7.3.000+hg~ee53a39d5896

    diff -ru vim-7.3.000+hg~ee53a39d5896/runtime/doc/eval.txt vim-7.3.000+hg~ee53a39d5896~bri/runtime/doc/eval.txt
    old new  
    61436143keymap                  Compiled with 'keymap' support.
    61446144langmap                 Compiled with 'langmap' support.
    61456145libcall                 Compiled with |libcall()| support.
    6146 linebreak               Compiled with 'linebreak', 'breakat' and 'showbreak'
    6147                         support.
     6146linebreak               Compiled with 'linebreak', 'breakat', 'showbreak' and
     6147                        'breakindent' support.
    61486148lispindent              Compiled with support for lisp indenting.
    61496149listcmds                Compiled with commands for the buffer list |:files|
    61506150                        and the argument list |arglist|.
  • vim-7.3.000+hg~ee53a39d5896

    diff -ru vim-7.3.000+hg~ee53a39d5896/runtime/doc/options.txt vim-7.3.000+hg~ee53a39d5896~bri/runtime/doc/options.txt
    old new  
    11651165        break if 'linebreak' is on.  Only works for ASCII and also for 8-bit
    11661166        characters when 'encoding' is an 8-bit encoding.
    11671167
     1168       
     1169                                                *'breakindent'* *'bri'*
     1170'breakindent' 'bri'     boolean (default off)
     1171                        local to window
     1172                        {not in Vi}
     1173                        {not available when compiled without the |+linebreak|
     1174                        feature}
     1175        Every wrapped line will continue visually indented (same amount of
     1176        space as the beginning of that line), thus preserving horizontal blocks
     1177        of text.
     1178
     1179                                                *'breakindentmin'* *'brimin'*
     1180'breakindentmin' 'brimin' number (default 20)
     1181                        local to window
     1182                        {not in Vi}
     1183                        {not available when compiled without the |+linebreak|
     1184                        feature}
     1185        Minimum text width that will be kept after applying 'breakindent',
     1186        even if the resulting text should normally be narrower. This prevents
     1187        text indented almost to the right window border oocupying lot of
     1188        vertical space when broken.
     1189
     1190                                                *'breakindentshift'* *'brishift'*
     1191'breakindentshift' 'brishift' number (default 20)
     1192                        local to window
     1193                        {not in Vi}
     1194                        {not available when compiled without the |+linebreak|
     1195                        feature}
     1196        After applying 'breakindent', wrapped line beginning will be shift by
     1197        given number of characters. It permits dynamic French paragraph
     1198        indentation (negative) or emphasizing the line continuation
     1199        (positive).
     1200
    11681201                                                *'browsedir'* *'bsdir'*
    11691202'browsedir' 'bsdir'     string  (default: "last")
    11701203                        global
     
    44094442                        {not in Vi}
    44104443                        {not available when compiled without the |+linebreak|
    44114444                        feature}
    4412         If on Vim will wrap long lines at a character in 'breakat' rather
     4445        If on, Vim will wrap long lines at a character in 'breakat' rather
    44134446        than at the last character that fits on the screen.  Unlike
    44144447        'wrapmargin' and 'textwidth', this does not insert <EOL>s in the file,
    4415         it only affects the way the file is displayed, not its contents.  The
    4416         value of 'showbreak' is used to put in front of wrapped lines.
    4417         This option is not used when the 'wrap' option is off or 'list' is on.
     4448        it only affects the way the file is displayed, not its contents.
     4449        If 'breakindent' is set, line is visually indented. Then, the value
     4450        of 'showbreak' is used to put in front of wrapped lines. This option
     4451        is not used when the 'wrap' option is off or 'list' is on.
    44184452        Note that <Tab> characters after an <EOL> are mostly not displayed
    44194453        with the right amount of white space.
    44204454
  • vim-7.3.000+hg~ee53a39d5896

    diff -ru vim-7.3.000+hg~ee53a39d5896/runtime/doc/tags vim-7.3.000+hg~ee53a39d5896~bri/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'*
  • vim-7.3.000+hg~ee53a39d5896

    diff -ru vim-7.3.000+hg~ee53a39d5896/runtime/optwin.vim vim-7.3.000+hg~ee53a39d5896~bri/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")
  • vim-7.3.000+hg~ee53a39d5896

    diff -ru vim-7.3.000+hg~ee53a39d5896/src/edit.c vim-7.3.000+hg~ee53a39d5896~bri/src/edit.c
    old new  
    394394        if (startln)
    395395            Insstart.col = 0;
    396396    }
    397     Insstart_textlen = (colnr_T)linetabsize(ml_get_curline());
     397    Insstart_textlen = (colnr_T)linetabsize(ml_get_curline(), Insstart.lnum);
    398398    Insstart_blank_vcol = MAXCOL;
    399399    if (!did_ai)
    400400        ai_col = 0;
     
    18521852            else
    18531853#endif
    18541854                ++new_cursor_col;
    1855             vcol += lbr_chartabsize(ptr + new_cursor_col, (colnr_T)vcol);
     1855            vcol += lbr_chartabsize(ptr + new_cursor_col, (colnr_T)vcol, curwin->w_cursor.lnum);
    18561856        }
    18571857        vcol = last_vcol;
    18581858
     
    64246424            ins_need_undo = FALSE;
    64256425        }
    64266426        Insstart = curwin->w_cursor;    /* new insertion starts here */
    6427         Insstart_textlen = (colnr_T)linetabsize(ml_get_curline());
     6427        Insstart_textlen = (colnr_T)linetabsize(ml_get_curline(), curwin->w_cursor.lnum);
    64286428        ai_col = 0;
    64296429#ifdef FEAT_VREPLACE
    64306430        if (State & VREPLACE_FLAG)
     
    67836783        for (;;)
    67846784        {
    67856785            coladvance(v - width);
    6786             /* getviscol() is slow, skip it when 'showbreak' is empty and
    6787              * there are no multi-byte characters */
    6788             if ((*p_sbr == NUL
     6786            /* getviscol() is slow, skip it when 'showbreak' is empty,
     6787             * 'breakindent' is not set and there are no multi-byte
     6788             * characters */
     6789            if ((*p_sbr == NUL && !curwin->w_p_bri
    67896790#  ifdef FEAT_MBYTE
    67906791                        && !has_mbyte
    67916792#  endif
     
    94219422        getvcol(curwin, &fpos, &vcol, NULL, NULL);
    94229423        getvcol(curwin, cursor, &want_vcol, NULL, NULL);
    94239424
    9424         /* Use as many TABs as possible.  Beware of 'showbreak' and
     9425        /* Use as many TABs as possible.  Beware of 'breakindent', 'showbreak' and
    94259426         * 'linebreak' adding extra virtual columns. */
    94269427        while (vim_iswhite(*ptr))
    94279428        {
    9428             i = lbr_chartabsize((char_u *)"\t", vcol);
     9429            i = lbr_chartabsize((char_u *)"\t", vcol, cursor->lnum);
    94299430            if (vcol + i > want_vcol)
    94309431                break;
    94319432            if (*ptr != TAB)
     
    94519452            /* Skip over the spaces we need. */
    94529453            while (vcol < want_vcol && *ptr == ' ')
    94539454            {
    9454                 vcol += lbr_chartabsize(ptr, vcol);
     9455                vcol += lbr_chartabsize(ptr, vcol, cursor->lnum);
    94559456                ++ptr;
    94569457                ++repl_off;
    94579458            }
     
    97029703    while ((colnr_T)temp < curwin->w_virtcol && *ptr != NUL)
    97039704    {
    97049705        prev_ptr = ptr;
    9705         temp += lbr_chartabsize_adv(&ptr, (colnr_T)temp);
     9706        temp += lbr_chartabsize_adv(&ptr, (colnr_T)temp, lnum);
    97069707    }
    97079708    if ((colnr_T)temp > curwin->w_virtcol)
    97089709        ptr = prev_ptr;
  • vim-7.3.000+hg~ee53a39d5896

    diff -ru vim-7.3.000+hg~ee53a39d5896/src/eval.c vim-7.3.000+hg~ee53a39d5896~bri/src/eval.c
    old new  
    1685716857
    1685816858    if (argvars[1].v_type != VAR_UNKNOWN)
    1685916859        col = get_tv_number(&argvars[1]);
    16860 
    16861     rettv->vval.v_number = (varnumber_T)(linetabsize_col(col, s) - col);
     16860    /*
     16861     * FIXME: passing 0 as 3rd argument to linetabsize_col, instead of real line number;
     16862     * (can we get it from here somehow?); might give incorrect result with breakindent!
     16863     */
     16864    rettv->vval.v_number = (varnumber_T)(linetabsize_col(col, s, 0) - col);
    1686216865}
    1686316866
    1686416867/*
  • vim-7.3.000+hg~ee53a39d5896

    diff -ru vim-7.3.000+hg~ee53a39d5896/src/ex_cmds.c vim-7.3.000+hg~ee53a39d5896~bri/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;
  • vim-7.3.000+hg~ee53a39d5896

    diff -ru vim-7.3.000+hg~ee53a39d5896/src/getchar.c vim-7.3.000+hg~ee53a39d5896~bri/src/getchar.c
    old new  
    26022602                                    if (!vim_iswhite(ptr[col]))
    26032603                                        curwin->w_wcol = vcol;
    26042604                                    vcol += lbr_chartabsize(ptr + col,
    2605                                                                (colnr_T)vcol);
     2605                                                               (colnr_T)vcol, curwin->w_cursor.lnum);
    26062606#ifdef FEAT_MBYTE
    26072607                                    if (has_mbyte)
    26082608                                        col += (*mb_ptr2len)(ptr + col);
  • vim-7.3.000+hg~ee53a39d5896

    diff -ru vim-7.3.000+hg~ee53a39d5896/src/gui_beval.c vim-7.3.000+hg~ee53a39d5896~bri/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)
  • vim-7.3.000+hg~ee53a39d5896

    diff -ru vim-7.3.000+hg~ee53a39d5896/src/charset.c vim-7.3.000+hg~ee53a39d5896~bri/src/charset.c
    old new  
    846846 * taking into account the size of a tab.
    847847 */
    848848    int
    849 linetabsize(s)
     849linetabsize(s, lnum)
    850850    char_u      *s;
     851    linenr_T    lnum;
    851852{
    852     return linetabsize_col(0, s);
     853    return linetabsize_col(0, s, lnum);
    853854}
    854855
    855856/*
    856857 * Like linetabsize(), but starting at column "startcol".
    857858 */
    858859    int
    859 linetabsize_col(startcol, s)
     860linetabsize_col(startcol, s, lnum)
    860861    int         startcol;
    861862    char_u      *s;
     863    linenr_T    lnum;
    862864{
    863865    colnr_T     col = startcol;
    864866
    865867    while (*s != NUL)
    866         col += lbr_chartabsize_adv(&s, col);
     868        col += lbr_chartabsize_adv(&s, col, lnum);
    867869    return (int)col;
    868870}
    869871
     
    871873 * Like linetabsize(), but for a given window instead of the current one.
    872874 */
    873875    int
    874 win_linetabsize(wp, p, len)
     876win_linetabsize(wp, p, len, lnum)
    875877    win_T       *wp;
    876878    char_u      *p;
    877879    colnr_T     len;
     880    linenr_T    lnum;
    878881{
    879882    colnr_T     col = 0;
    880883    char_u      *s;
    881884
    882885    for (s = p; *s != NUL && (len == MAXCOL || s < p + len); mb_ptr_adv(s))
    883         col += win_lbr_chartabsize(wp, s, col, NULL);
     886        col += win_lbr_chartabsize(wp, s, col, NULL, lnum);
    884887    return (int)col;
    885888}
    886889
     
    10091012 * like chartabsize(), but also check for line breaks on the screen
    10101013 */
    10111014    int
    1012 lbr_chartabsize(s, col)
     1015lbr_chartabsize(s, col, lnum)
    10131016    unsigned char       *s;
    10141017    colnr_T             col;
     1018    linenr_T            lnum;
    10151019{
    10161020#ifdef FEAT_LINEBREAK
    1017     if (!curwin->w_p_lbr && *p_sbr == NUL)
     1021    if (!curwin->w_p_lbr && *p_sbr == NUL && !curwin->w_p_bri)
    10181022    {
    10191023#endif
    10201024#ifdef FEAT_MBYTE
     
    10241028        RET_WIN_BUF_CHARTABSIZE(curwin, curbuf, s, col)
    10251029#ifdef FEAT_LINEBREAK
    10261030    }
    1027     return win_lbr_chartabsize(curwin, s, col, NULL);
     1031    return win_lbr_chartabsize(curwin, s, col, NULL, lnum);
    10281032#endif
    10291033}
    10301034
     
    10321036 * Call lbr_chartabsize() and advance the pointer.
    10331037 */
    10341038    int
    1035 lbr_chartabsize_adv(s, col)
     1039lbr_chartabsize_adv(s, col, lnum)
    10361040    char_u      **s;
    10371041    colnr_T     col;
     1042    linenr_T    lnum;
    10381043{
    10391044    int         retval;
    10401045
    1041     retval = lbr_chartabsize(*s, col);
     1046    retval = lbr_chartabsize(*s, col, lnum);
    10421047    mb_ptr_adv(*s);
    10431048    return retval;
    10441049}
     
    10491054 * If "headp" not NULL, set *headp to the size of what we for 'showbreak'
    10501055 * string at start of line.  Warning: *headp is only set if it's a non-zero
    10511056 * value, init to 0 before calling.
     1057 *
     1058 * linenr argument needed if in visual highlighting and breakindent=on, then
     1059 * the line calculated is not current; if 0, normal functionality is preserved.
    10521060 */
    10531061    int
    1054 win_lbr_chartabsize(wp, s, col, headp)
     1062win_lbr_chartabsize(wp, s, col, headp, lnum)
    10551063    win_T       *wp;
    10561064    char_u      *s;
    10571065    colnr_T     col;
    10581066    int         *headp UNUSED;
     1067    linenr_T    lnum;
    10591068{
    10601069#ifdef FEAT_LINEBREAK
    10611070    int         c;
     
    10741083    int         n;
    10751084
    10761085    /*
    1077      * No 'linebreak' and 'showbreak': return quickly.
     1086     * No 'linebreak' and 'showbreak' and 'breakindent': return quickly.
    10781087     */
    1079     if (!wp->w_p_lbr && *p_sbr == NUL)
     1088    if (!wp->w_p_lbr && !wp->w_p_bri && *p_sbr == NUL)
    10801089#endif
    10811090    {
    10821091#ifdef FEAT_MBYTE
     
    11511160# endif
    11521161
    11531162    /*
    1154      * May have to add something for 'showbreak' string at start of line
     1163     * May have to add something for 'breakindent' and/or 'showbreak'
     1164     * string at start of line.
    11551165     * Set *headp to the size of what we add.
    11561166     */
    11571167    added = 0;
    1158     if (*p_sbr != NUL && wp->w_p_wrap && col != 0)
     1168    if ((*p_sbr != NUL || wp->w_p_bri) && wp->w_p_wrap && col != 0)
    11591169    {
    11601170        numberextra = win_col_off(wp);
    11611171        col += numberextra + mb_added;
     
    11681178        }
    11691179        if (col == 0 || col + size > (colnr_T)W_WIDTH(wp))
    11701180        {
    1171             added = vim_strsize(p_sbr);
     1181            added = 0;
     1182            if (*p_sbr != NUL)
     1183                added += vim_strsize(p_sbr);
     1184            if (wp->w_p_bri)
     1185                added += get_breakindent_win(wp,lnum);
     1186
    11721187            if (tab_corr)
    11731188                size += (added / wp->w_buffer->b_p_ts) * wp->w_buffer->b_p_ts;
    11741189            else
     
    12761291
    12771292    /*
    12781293     * This function is used very often, do some speed optimizations.
    1279      * When 'list', 'linebreak' and 'showbreak' are not set use a simple loop.
     1294     * When 'list', 'linebreak', 'showbreak' and 'breakindent' are not set
     1295     * use a simple loop.
    12801296     * Also use this when 'list' is set but tabs take their normal size.
    12811297     */
    12821298    if ((!wp->w_p_list || lcs_tab1 != NUL)
    12831299#ifdef FEAT_LINEBREAK
    1284             && !wp->w_p_lbr && *p_sbr == NUL
     1300            && !wp->w_p_lbr && *p_sbr == NUL && !wp->w_p_bri
    12851301#endif
    12861302       )
    12871303    {
     
    13431359        {
    13441360            /* A tab gets expanded, depending on the current column */
    13451361            head = 0;
    1346             incr = win_lbr_chartabsize(wp, ptr, vcol, &head);
     1362            incr = win_lbr_chartabsize(wp, ptr, vcol, &head, pos->lnum);
    13471363            /* make sure we don't go past the end of the line */
    13481364            if (*ptr == NUL)
    13491365            {
  • vim-7.3.000+hg~ee53a39d5896

    diff -ru vim-7.3.000+hg~ee53a39d5896/src/misc1.c vim-7.3.000+hg~ee53a39d5896~bri/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#endif
     490
     491
    454492#if defined(FEAT_CINDENT) || defined(FEAT_SMARTINDENT)
    455493
    456494static int cin_is_cinword __ARGS((char_u *line));
     
    17321770    s = ml_get_buf(wp->w_buffer, lnum, FALSE);
    17331771    if (*s == NUL)              /* empty line */
    17341772        return 1;
    1735     col = win_linetabsize(wp, s, (colnr_T)MAXCOL);
     1773    col = win_linetabsize(wp, s, (colnr_T)MAXCOL, lnum);
    17361774
    17371775    /*
    17381776     * If list mode is on, then the '$' at the end of the line may take up one
     
    17881826    col = 0;
    17891827    while (*s != NUL && --column >= 0)
    17901828    {
    1791         col += win_lbr_chartabsize(wp, s, (colnr_T)col, NULL);
     1829        col += win_lbr_chartabsize(wp, s, (colnr_T)col, NULL, lnum);
    17921830        mb_ptr_adv(s);
    17931831    }
    17941832
     
    18001838     * 'ts') -- webb.
    18011839     */
    18021840    if (*s == TAB && (State & NORMAL) && (!wp->w_p_list || lcs_tab1))
    1803         col += win_lbr_chartabsize(wp, s, (colnr_T)col, NULL) - 1;
     1841        col += win_lbr_chartabsize(wp, s, (colnr_T)col, NULL, lnum) - 1;
    18041842
    18051843    /*
    18061844     * Add column offset for 'number', 'relativenumber', 'foldcolumn', etc.
     
    83168354                amount = 0;
    83178355                while (*that && col)
    83188356                {
    8319                     amount += lbr_chartabsize_adv(&that, (colnr_T)amount);
     8357                    amount += lbr_chartabsize_adv(&that, (colnr_T)amount, pos->lnum);
    83208358                    col--;
    83218359                }
    83228360
     
    83398377
    83408378                    while (vim_iswhite(*that))
    83418379                    {
    8342                         amount += lbr_chartabsize(that, (colnr_T)amount);
     8380                        amount += lbr_chartabsize(that, (colnr_T)amount, pos->lnum);
    83438381                        ++that;
    83448382                    }
    83458383
     
    83788416                                    --parencount;
    83798417                                if (*that == '\\' && *(that+1) != NUL)
    83808418                                    amount += lbr_chartabsize_adv(&that,
    8381                                                              (colnr_T)amount);
     8419                                                             (colnr_T)amount, pos->lnum);
    83828420                                amount += lbr_chartabsize_adv(&that,
    8383                                                              (colnr_T)amount);
     8421                                                             (colnr_T)amount, pos->lnum);
    83848422                            }
    83858423                        }
    83868424                        while (vim_iswhite(*that))
    83878425                        {
    8388                             amount += lbr_chartabsize(that, (colnr_T)amount);
     8426                            amount += lbr_chartabsize(that, (colnr_T)amount, pos->lnum);
    83898427                            that++;
    83908428                        }
    83918429                        if (!*that || *that == ';')
  • vim-7.3.000+hg~ee53a39d5896

    diff -ru vim-7.3.000+hg~ee53a39d5896/src/misc2.c vim-7.3.000+hg~ee53a39d5896~bri/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        }
  • vim-7.3.000+hg~ee53a39d5896

    diff -ru vim-7.3.000+hg~ee53a39d5896/src/normal.c vim-7.3.000+hg~ee53a39d5896~bri/src/normal.c
    old new  
    43984398    int         dir;
    43994399    long        dist;
    44004400{
    4401     int         linelen = linetabsize(ml_get_curline());
     4401    int         linelen = linetabsize(ml_get_curline(), curwin->w_cursor.lnum);
    44024402    int         retval = OK;
    44034403    int         atend = FALSE;
    44044404    int         n;
     
    44714471                    (void)hasFolding(curwin->w_cursor.lnum,
    44724472                                                &curwin->w_cursor.lnum, NULL);
    44734473#endif
    4474                 linelen = linetabsize(ml_get_curline());
     4474                linelen = linetabsize(ml_get_curline(), curwin->w_cursor.lnum);
    44754475                if (linelen > width1)
    44764476                    curwin->w_curswant += (((linelen - width1 - 1) / width2)
    44774477                                                                + 1) * width2;
  • vim-7.3.000+hg~ee53a39d5896

    Pouze v vim-7.3.000+hg~ee53a39d5896~bri/src: objects
    diff -ru vim-7.3.000+hg~ee53a39d5896/src/ops.c vim-7.3.000+hg~ee53a39d5896~bri/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;
     
    35273527            for (ptr = oldp; vcol < col && *ptr; )
    35283528            {
    35293529                /* Count a tab for what it's worth (if list mode not on) */
    3530                 incr = lbr_chartabsize_adv(&ptr, (colnr_T)vcol);
     3530                incr = lbr_chartabsize_adv(&ptr, (colnr_T)vcol, lnum);
    35313531                vcol += incr;
    35323532            }
    35333533            bd.textcol = (colnr_T)(ptr - oldp);
     
    35613561            /* calculate number of spaces required to fill right side of block*/
    35623562            spaces = y_width + 1;
    35633563            for (j = 0; j < yanklen; j++)
    3564                 spaces -= lbr_chartabsize(&y_array[i][j], 0);
     3564                spaces -= lbr_chartabsize(&y_array[i][j], 0, lnum);
    35653565            if (spaces < 0)
    35663566                spaces = 0;
    35673567
     
    49174917    while (bdp->start_vcol < oap->start_vcol && *pstart)
    49184918    {
    49194919        /* Count a tab for what it's worth (if list mode not on) */
    4920         incr = lbr_chartabsize(pstart, (colnr_T)bdp->start_vcol);
     4920        incr = lbr_chartabsize(pstart, (colnr_T)bdp->start_vcol, lnum);
    49214921        bdp->start_vcol += incr;
    49224922#ifdef FEAT_VISUALEXTRA
    49234923        if (vim_iswhite(*pstart))
     
    49864986            {
    49874987                /* Count a tab for what it's worth (if list mode not on) */
    49884988                prev_pend = pend;
    4989                 incr = lbr_chartabsize_adv(&pend, (colnr_T)bdp->end_vcol);
     4989                incr = lbr_chartabsize_adv(&pend, (colnr_T)bdp->end_vcol, lnum);
    49904990                bdp->end_vcol += incr;
    49914991            }
    49924992            if (bdp->end_vcol <= oap->end_vcol
     
    64766476            validate_virtcol();
    64776477            col_print(buf1, sizeof(buf1), (int)curwin->w_cursor.col + 1,
    64786478                    (int)curwin->w_virtcol + 1);
    6479             col_print(buf2, sizeof(buf2), (int)STRLEN(p), linetabsize(p));
     6479            col_print(buf2, sizeof(buf2), (int)STRLEN(p), linetabsize(p, curwin->w_cursor.lnum));
    64806480
    64816481            if (char_count_cursor == byte_count_cursor
    64826482                    && char_count == byte_count)
  • vim-7.3.000+hg~ee53a39d5896

    diff -ru vim-7.3.000+hg~ee53a39d5896/src/option.c vim-7.3.000+hg~ee53a39d5896~bri/src/option.c
    old new  
    190190#ifdef FEAT_ARABIC
    191191# define PV_ARAB        OPT_WIN(WV_ARAB)
    192192#endif
     193#ifdef FEAT_LINEBREAK
     194# define PV_BRI         OPT_WIN(WV_BRI)
     195# define PV_BRIMIN      OPT_WIN(WV_BRIMIN)
     196# define PV_BRISHIFT    OPT_WIN(WV_BRISHIFT)
     197#endif
    193198#ifdef FEAT_DIFF
    194199# define PV_DIFF        OPT_WIN(WV_DIFF)
    195200#endif
     
    650655                            {(char_u *)0L, (char_u *)0L}
    651656#endif
    652657                            SCRIPTID_INIT},
     658    {"breakindent",   "bri",  P_BOOL|P_VI_DEF|P_VIM|P_RWIN,
     659#ifdef FEAT_LINEBREAK
     660                            (char_u *)VAR_WIN, PV_BRI,
     661                            {(char_u *)FALSE, (char_u *)0L}
     662#else
     663                            (char_u *)NULL, PV_NONE,
     664                            {(char_u *)0L, (char_u *)0L}
     665#endif
     666                            SCRIPTID_INIT},
     667    {"breakindentmin", "brimin", P_NUM|P_VI_DEF|P_VIM|P_RWIN,
     668#ifdef FEAT_LINEBREAK
     669                            (char_u *)VAR_WIN, PV_BRIMIN,
     670                            {(char_u *)20L, (char_u *)20L}
     671#else
     672                            (char_u *)NULL, PV_NONE,
     673                            {(char_u *)0L, (char_u *)0L}
     674#endif
     675                            SCRIPTID_INIT},
     676    {"breakindentshift", "brishift", P_NUM|P_VI_DEF|P_VIM|P_RWIN,
     677#ifdef FEAT_LINEBREAK
     678                            (char_u *)VAR_WIN, PV_BRISHIFT,
     679                            {(char_u *)0L, (char_u *)0L}
     680#else
     681                            (char_u *)NULL, PV_NONE,
     682                            {(char_u *)0L, (char_u *)0L}
     683#endif
     684                            SCRIPTID_INIT},
    653685    {"browsedir",   "bsdir",P_STRING|P_VI_DEF,
    654686#ifdef FEAT_BROWSE
    655687                            (char_u *)&p_bsdir, PV_NONE,
     
    83348366        }
    83358367        curwin->w_nrwidth_line_count = 0;
    83368368    }
     8369
     8370    /* 'breakindentmin' must be positive */
     8371    else if (pp == &curwin->w_p_brimin)
     8372    {
     8373        if (curwin->w_p_brimin < 1)
     8374        {
     8375            errmsg = e_positive;
     8376            curwin->w_p_brimin = 1;
     8377        }
     8378    }
    83378379#endif
    83388380
    83398381    else if (pp == &curbuf->b_p_tw)
     
    95639605        case PV_WRAP:   return (char_u *)&(curwin->w_p_wrap);
    95649606#ifdef FEAT_LINEBREAK
    95659607        case PV_LBR:    return (char_u *)&(curwin->w_p_lbr);
     9608        case PV_BRI:    return (char_u *)&(curwin->w_p_bri);
     9609        case PV_BRIMIN: return (char_u *)&(curwin->w_p_brimin);
     9610        case PV_BRISHIFT: return (char_u *)&(curwin->w_p_brishift);
    95669611#endif
    95679612#ifdef FEAT_SCROLLBIND
    95689613        case PV_SCBIND: return (char_u *)&(curwin->w_p_scb);
     
    97529797    to->wo_wrap = from->wo_wrap;
    97539798#ifdef FEAT_LINEBREAK
    97549799    to->wo_lbr = from->wo_lbr;
     9800    to->wo_bri = from->wo_bri;
     9801    to->wo_brimin = from->wo_brimin;
    97559802#endif
    97569803#ifdef FEAT_SCROLLBIND
    97579804    to->wo_scb = from->wo_scb;
  • vim-7.3.000+hg~ee53a39d5896

    diff -ru vim-7.3.000+hg~ee53a39d5896/src/option.h vim-7.3.000+hg~ee53a39d5896~bri/src/option.h
    old new  
    10391039#ifdef FEAT_CURSORBIND
    10401040    , WV_CRBIND
    10411041#endif
     1042#ifdef FEAT_LINEBREAK
     1043    , WV_BRI
     1044    , WV_BRIMIN
     1045    , WV_BRISHIFT
     1046#endif
    10421047#ifdef FEAT_DIFF
    10431048    , WV_DIFF
    10441049#endif
  • vim-7.3.000+hg~ee53a39d5896

    diff -ru vim-7.3.000+hg~ee53a39d5896/src/proto/charset.pro vim-7.3.000+hg~ee53a39d5896~bri/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));
  • vim-7.3.000+hg~ee53a39d5896

    diff -ru vim-7.3.000+hg~ee53a39d5896/src/proto/misc1.pro vim-7.3.000+hg~ee53a39d5896~bri/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));
  • vim-7.3.000+hg~ee53a39d5896

    diff -ru vim-7.3.000+hg~ee53a39d5896/src/regexp.c vim-7.3.000+hg~ee53a39d5896~bri/src/regexp.c
    old new  
    40354035                    if (top.col == MAXCOL || bot.col == MAXCOL)
    40364036                        end = MAXCOL;
    40374037                    cols = win_linetabsize(wp,
    4038                                       regline, (colnr_T)(reginput - regline));
     4038                                      regline, (colnr_T)(reginput - regline), reglnum + reg_firstlnum);
    40394039                    if (cols < start || cols > end - (*p_sel == 'e'))
    40404040                        status = RA_NOMATCH;
    40414041                }
     
    40594059          case RE_VCOL:
    40604060            if (!re_num_cmp((long_u)win_linetabsize(
    40614061                            reg_win == NULL ? curwin : reg_win,
    4062                             regline, (colnr_T)(reginput - regline)) + 1, scan))
     4062                            regline, (colnr_T)(reginput - regline), reglnum + reg_firstlnum ) + 1, scan))
    40634063                status = RA_NOMATCH;
    40644064            break;
    40654065
  • vim-7.3.000+hg~ee53a39d5896

    diff -ru vim-7.3.000+hg~ee53a39d5896/src/screen.c vim-7.3.000+hg~ee53a39d5896~bri/src/screen.c
    old new  
    28022802# define WL_SIGN        WL_FOLD         /* column for signs */
    28032803#endif
    28042804#define WL_NR           WL_SIGN + 1     /* line number */
     2805#ifdef FEAT_LINEBREAK
     2806# define WL_BRI         WL_NR + 1       /* 'breakindent' */
     2807#else
     2808# define WL_BRI         WL_NR
     2809#endif
    28052810#if defined(FEAT_LINEBREAK) || defined(FEAT_DIFF)
    2806 # define WL_SBR         WL_NR + 1       /* 'showbreak' or 'diff' */
     2811# define WL_SBR         WL_BRI + 1      /* 'showbreak' or 'diff' */
    28072812#else
    2808 # define WL_SBR         WL_NR
     2813# define WL_SBR         WL_BRI
    28092814#endif
    28102815#define WL_LINE         WL_SBR + 1      /* text in the line */
    28112816    int         draw_state = WL_START;  /* what to draw next */
     
    31333138#endif
    31343139        while (vcol < v && *ptr != NUL)
    31353140        {
    3136             c = win_lbr_chartabsize(wp, ptr, (colnr_T)vcol, NULL);
     3141            c = win_lbr_chartabsize(wp, ptr, (colnr_T)vcol, NULL, lnum);
    31373142            vcol += c;
    31383143#ifdef FEAT_MBYTE
    31393144            prev_ptr = ptr;
     
    35033508                }
    35043509            }
    35053510
     3511#ifdef FEAT_LINEBREAK
     3512            /* draw 'breakindent': indent wrapped text accordingly */
     3513            if (draw_state == WL_BRI -1 && n_extra == 0){
     3514                draw_state = WL_BRI;
     3515# ifdef FEAT_DIFF
     3516                /* FIXME: handle (filler_todo > 0): or modify showbreak so that ---- lines are shorter by the amount needed? */
     3517# endif
     3518                if (wp->w_p_bri && row != startrow){ /* FIXME: what is startrow? Don't we need it as well?? */
     3519                    p_extra = NUL;
     3520                    c_extra = ' ';
     3521                    n_extra = get_breakindent_win(wp,lnum);
     3522                    char_attr = 0; /* was: hl_attr(HLF_AT); */
     3523                    /* FIXME: why do we need to adjust vcol if showbreak does not?? */
     3524                    // vcol += n_extra;
     3525                    /* FIXME: is this relevant here? copied shamelessly from showbreak */
     3526                    /* Correct end of highlighted area for 'breakindent',
     3527                     * required when 'linebreak' is also set. */
     3528                    if (tocol == vcol)
     3529                        tocol += n_extra;
     3530                }
     3531            }
     3532#endif
     3533           
     3534
    35063535#if defined(FEAT_LINEBREAK) || defined(FEAT_DIFF)
    35073536            if (draw_state == WL_SBR - 1 && n_extra == 0)
    35083537            {
     
    42094238# ifdef FEAT_MBYTE
    42104239                                has_mbyte ? mb_l :
    42114240# endif
    4212                                 1), (colnr_T)vcol, NULL) - 1;
     4241                                1), (colnr_T)vcol, NULL, lnum) - 1;
    42134242                    c_extra = ' ';
    42144243                    if (vim_iswhite(c))
    42154244                        c = ' ';
  • vim-7.3.000+hg~ee53a39d5896

    diff -ru vim-7.3.000+hg~ee53a39d5896/src/structs.h vim-7.3.000+hg~ee53a39d5896~bri/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' */
  • vim-7.3.000+hg~ee53a39d5896

    diff -ru vim-7.3.000+hg~ee53a39d5896/src/ui.c vim-7.3.000+hg~ee53a39d5896~bri/src/ui.c
    old new  
    30663066    start = ptr = ml_get_buf(wp->w_buffer, lnum, FALSE);
    30673067    while (count <= vcol && *ptr != NUL)
    30683068    {
    3069         count += win_lbr_chartabsize(wp, ptr, count, NULL);
     3069        count += win_lbr_chartabsize(wp, ptr, count, NULL, lnum);
    30703070        mb_ptr_adv(ptr);
    30713071    }
    30723072    return (int)(ptr - start);