Blog: Better line wrapping in Vim: vim-7.2-breakindent.patch
File vim-7.2-breakindent.patch, 31.2 KB (added by retracile, 15 years ago) |
---|
-
runtime/doc/eval.txt
vim72/runtime/doc/eval.txt | 4 +-- vim72/runtime/doc/options.txt | 42 ++++++++++++++++++++++++++++--- vim72/runtime/optwin.vim | 9 ++++++ vim72/src/charset.c | 51 ++++++++++++++++++++++++-------------- vim72/src/edit.c | 21 ++++++++------- vim72/src/ex_cmds.c | 2 - vim72/src/getchar.c | 2 - vim72/src/gui_beval.c | 2 - vim72/src/misc1.c | 56 ++++++++++++++++++++++++++++++++++++------ vim72/src/misc2.c | 8 +++--- vim72/src/normal.c | 4 +-- vim72/src/ops.c | 14 +++++----- vim72/src/option.c | 41 ++++++++++++++++++++++++++++++ vim72/src/option.h | 5 +++ vim72/src/proto/charset.pro | 10 +++---- vim72/src/proto/misc1.pro | 1 vim72/src/regexp.c | 4 +-- vim72/src/screen.c | 37 ++++++++++++++++++++++++--- vim72/src/structs.h | 8 ++++++ vim72/src/ui.c | 2 - 20 files changed, 253 insertions(+), 70 deletions(-)
old new jumplist Compiled with |jumplist| suppo 5822 5822 keymap Compiled with 'keymap' support. 5823 5823 langmap Compiled with 'langmap' support. 5824 5824 libcall Compiled with |libcall()| support. 5825 linebreak Compiled with 'linebreak', 'breakat' and 'showbreak'5826 support.5825 linebreak Compiled with 'linebreak', 'breakat', 'showbreak' and 5826 'breakindent' support. 5827 5827 lispindent Compiled with support for lisp indenting. 5828 5828 listcmds Compiled with commands for the buffer list |:files| 5829 5829 and the argument list |arglist|. -
runtime/doc/options.txt
old new A jump table for the options with a shor 1160 1160 break if 'linebreak' is on. Only works for ASCII and also for 8-bit 1161 1161 characters when 'encoding' is an 8-bit encoding. 1162 1162 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 1163 1196 *'browsedir'* *'bsdir'* 1164 1197 'browsedir' 'bsdir' string (default: "last") 1165 1198 global … … A jump table for the options with a shor 4255 4288 {not in Vi} 4256 4289 {not available when compiled without the |+linebreak| 4257 4290 feature} 4258 If on Vim will wrap long lines at a character in 'breakat' rather4291 If on, Vim will wrap long lines at a character in 'breakat' rather 4259 4292 than at the last character that fits on the screen. Unlike 4260 4293 'wrapmargin' and 'textwidth', this does not insert <EOL>s in the file, 4261 it only affects the way the file is displayed, not its contents. The 4262 value of 'showbreak' is used to put in front of wrapped lines. 4263 This option is not used when the 'wrap' option is off or 'list' is on. 4294 it only affects the way the file is displayed, not its contents. 4295 If 'breakindent' is set, line is visually indented. Then, the value 4296 of 'showbreak' is used to put in front of wrapped lines. This option 4297 is not used when the 'wrap' option is off or 'list' is on. 4264 4298 Note that <Tab> characters after an <EOL> are mostly not displayed 4265 4299 with the right amount of white space. 4266 4300 -
runtime/optwin.vim
old new call <SID>BinOptionG("wrap", &wrap) 329 329 call append("$", "linebreak\twrap long lines at a character in 'breakat'") 330 330 call append("$", "\t(local to window)") 331 331 call <SID>BinOptionL("lbr") 332 call append("$", "breakindent\tpreserve indentation in wrapped text") 333 call append("$", "\t(local to window)") 334 call <SID>BinOptionL("bri") 335 call append("$", "breakindentmin\tminimum text width after indent in 'breakindent'") 336 call append("$", "\t(local to window)") 337 call <SID>OptionL("brimin") 338 call append("$", "breakindentshift\tshift beginning of 'breakindent'ed line by this number of characters (negative left)") 339 call append("$", "\t(local to window)") 340 call <SID>OptionL("brishift") 332 341 call append("$", "breakat\twhich characters might cause a line break") 333 342 call <SID>OptionG("brk", &brk) 334 343 call append("$", "showbreak\tstring to put before wrapped screen lines") -
src/charset.c
old new win_chartabsize(wp, p, col) 833 833 * taking into account the size of a tab 834 834 */ 835 835 int 836 linetabsize(s )836 linetabsize(s, lnum) 837 837 char_u *s; 838 linenr_T lnum; 838 839 { 839 840 colnr_T col = 0; 840 841 841 842 while (*s != NUL) 842 col += lbr_chartabsize_adv(&s, col );843 col += lbr_chartabsize_adv(&s, col, lnum); 843 844 return (int)col; 844 845 } 845 846 … … linetabsize(s) 847 848 * Like linetabsize(), but for a given window instead of the current one. 848 849 */ 849 850 int 850 win_linetabsize(wp, p, len )851 win_linetabsize(wp, p, len, lnum) 851 852 win_T *wp; 852 853 char_u *p; 853 854 colnr_T len; 855 linenr_T lnum; 854 856 { 855 857 colnr_T col = 0; 856 858 char_u *s; 857 859 858 860 for (s = p; *s != NUL && (len == MAXCOL || s < p + len); mb_ptr_adv(s)) 859 col += win_lbr_chartabsize(wp, s, col, NULL );861 col += win_lbr_chartabsize(wp, s, col, NULL, lnum); 860 862 return (int)col; 861 863 } 862 864 … … vim_isprintc_strict(c) 985 987 * like chartabsize(), but also check for line breaks on the screen 986 988 */ 987 989 int 988 lbr_chartabsize(s, col )990 lbr_chartabsize(s, col, lnum) 989 991 unsigned char *s; 990 992 colnr_T col; 993 linenr_T lnum; 991 994 { 992 995 #ifdef FEAT_LINEBREAK 993 if (!curwin->w_p_lbr && *p_sbr == NUL )996 if (!curwin->w_p_lbr && *p_sbr == NUL && !curwin->w_p_bri) 994 997 { 995 998 #endif 996 999 #ifdef FEAT_MBYTE … … lbr_chartabsize(s, col) 1000 1003 RET_WIN_BUF_CHARTABSIZE(curwin, curbuf, s, col) 1001 1004 #ifdef FEAT_LINEBREAK 1002 1005 } 1003 return win_lbr_chartabsize(curwin, s, col, NULL );1006 return win_lbr_chartabsize(curwin, s, col, NULL, lnum); 1004 1007 #endif 1005 1008 } 1006 1009 … … lbr_chartabsize(s, col) 1008 1011 * Call lbr_chartabsize() and advance the pointer. 1009 1012 */ 1010 1013 int 1011 lbr_chartabsize_adv(s, col )1014 lbr_chartabsize_adv(s, col, lnum) 1012 1015 char_u **s; 1013 1016 colnr_T col; 1017 linenr_T lnum; 1014 1018 { 1015 1019 int retval; 1016 1020 1017 retval = lbr_chartabsize(*s, col );1021 retval = lbr_chartabsize(*s, col, lnum); 1018 1022 mb_ptr_adv(*s); 1019 1023 return retval; 1020 1024 } … … lbr_chartabsize_adv(s, col) 1025 1029 * If "headp" not NULL, set *headp to the size of what we for 'showbreak' 1026 1030 * string at start of line. Warning: *headp is only set if it's a non-zero 1027 1031 * value, init to 0 before calling. 1032 * 1033 * linenr argument needed if in visual highlighting and breakindent=on, then 1034 * the line calculated is not current; if 0, normal functionality is preserved. 1028 1035 */ 1029 1036 /*ARGSUSED*/ 1030 1037 int 1031 win_lbr_chartabsize(wp, s, col, headp )1038 win_lbr_chartabsize(wp, s, col, headp, lnum) 1032 1039 win_T *wp; 1033 1040 char_u *s; 1034 1041 colnr_T col; 1035 1042 int *headp; 1043 linenr_T lnum; 1036 1044 { 1037 1045 #ifdef FEAT_LINEBREAK 1038 1046 int c; … … win_lbr_chartabsize(wp, s, col, headp) 1051 1059 int n; 1052 1060 1053 1061 /* 1054 * No 'linebreak' and 'showbreak' : return quickly.1062 * No 'linebreak' and 'showbreak' and 'breakindent': return quickly. 1055 1063 */ 1056 if (!wp->w_p_lbr && *p_sbr == NUL)1064 if (!wp->w_p_lbr && !wp->w_p_bri && *p_sbr == NUL) 1057 1065 #endif 1058 1066 { 1059 1067 #ifdef FEAT_MBYTE … … win_lbr_chartabsize(wp, s, col, headp) 1128 1136 # endif 1129 1137 1130 1138 /* 1131 * May have to add something for 'showbreak' string at start of line 1139 * May have to add something for 'breakindent' and/or 'showbreak' 1140 * string at start of line. 1132 1141 * Set *headp to the size of what we add. 1133 1142 */ 1134 1143 added = 0; 1135 if ( *p_sbr != NUL&& wp->w_p_wrap && col != 0)1144 if ((*p_sbr != NUL || wp->w_p_bri) && wp->w_p_wrap && col != 0) 1136 1145 { 1137 1146 numberextra = win_col_off(wp); 1138 1147 col += numberextra + mb_added; … … win_lbr_chartabsize(wp, s, col, headp) 1145 1154 } 1146 1155 if (col == 0 || col + size > (colnr_T)W_WIDTH(wp)) 1147 1156 { 1148 added = vim_strsize(p_sbr); 1157 added = 0; 1158 if (*p_sbr != NUL) 1159 added += vim_strsize(p_sbr); 1160 if (wp->w_p_bri) 1161 added += get_breakindent_win(wp,lnum); 1162 1149 1163 if (tab_corr) 1150 1164 size += (added / wp->w_buffer->b_p_ts) * wp->w_buffer->b_p_ts; 1151 1165 else … … getvcol(wp, pos, start, cursor, end) 1248 1262 1249 1263 /* 1250 1264 * This function is used very often, do some speed optimizations. 1251 * When 'list', 'linebreak' and 'showbreak' are not set use a simple loop. 1265 * When 'list', 'linebreak', 'showbreak' and 'breakindent' are not set 1266 * use a simple loop. 1252 1267 * Also use this when 'list' is set but tabs take their normal size. 1253 1268 */ 1254 1269 if ((!wp->w_p_list || lcs_tab1 != NUL) 1255 1270 #ifdef FEAT_LINEBREAK 1256 && !wp->w_p_lbr && *p_sbr == NUL 1271 && !wp->w_p_lbr && *p_sbr == NUL && !wp->w_p_bri 1257 1272 #endif 1258 1273 ) 1259 1274 { … … getvcol(wp, pos, start, cursor, end) 1315 1330 { 1316 1331 /* A tab gets expanded, depending on the current column */ 1317 1332 head = 0; 1318 incr = win_lbr_chartabsize(wp, ptr, vcol, &head );1333 incr = win_lbr_chartabsize(wp, ptr, vcol, &head, pos->lnum); 1319 1334 /* make sure we don't go past the end of the line */ 1320 1335 if (*ptr == NUL) 1321 1336 { -
src/edit.c
old new edit(cmdchar, startln, count) 387 387 if (startln) 388 388 Insstart.col = 0; 389 389 } 390 Insstart_textlen = linetabsize(ml_get_curline() );390 Insstart_textlen = linetabsize(ml_get_curline(), Insstart.lnum); 391 391 Insstart_blank_vcol = MAXCOL; 392 392 if (!did_ai) 393 393 ai_col = 0; … … change_indent(type, amount, round, repla 1790 1790 else 1791 1791 #endif 1792 1792 ++new_cursor_col; 1793 vcol += lbr_chartabsize(ptr + new_cursor_col, (colnr_T)vcol );1793 vcol += lbr_chartabsize(ptr + new_cursor_col, (colnr_T)vcol, curwin->w_cursor.lnum); 1794 1794 } 1795 1795 vcol = last_vcol; 1796 1796 … … stop_arrow() 6320 6320 ins_need_undo = FALSE; 6321 6321 } 6322 6322 Insstart = curwin->w_cursor; /* new insertion starts here */ 6323 Insstart_textlen = linetabsize(ml_get_curline() );6323 Insstart_textlen = linetabsize(ml_get_curline(),curwin->w_cursor.lnum); 6324 6324 ai_col = 0; 6325 6325 #ifdef FEAT_VREPLACE 6326 6326 if (State & VREPLACE_FLAG) … … oneleft() 6673 6673 for (;;) 6674 6674 { 6675 6675 coladvance(v - width); 6676 /* getviscol() is slow, skip it when 'showbreak' is empty and 6677 * there are no multi-byte characters */ 6678 if ((*p_sbr == NUL 6676 /* getviscol() is slow, skip it when 'showbreak' is empty, 6677 * 'breakindent' is not set and there are no multi-byte 6678 * characters */ 6679 if ((*p_sbr == NUL && !curwin->w_p_bri 6679 6680 # ifdef FEAT_MBYTE 6680 6681 && !has_mbyte 6681 6682 # endif … … ins_tab() 9307 9308 getvcol(curwin, &fpos, &vcol, NULL, NULL); 9308 9309 getvcol(curwin, cursor, &want_vcol, NULL, NULL); 9309 9310 9310 /* Use as many TABs as possible. Beware of ' showbreak' and9311 /* Use as many TABs as possible. Beware of 'breakindent', 'showbreak' and 9311 9312 * 'linebreak' adding extra virtual columns. */ 9312 9313 while (vim_iswhite(*ptr)) 9313 9314 { 9314 i = lbr_chartabsize((char_u *)"\t", vcol );9315 i = lbr_chartabsize((char_u *)"\t", vcol, cursor->lnum); 9315 9316 if (vcol + i > want_vcol) 9316 9317 break; 9317 9318 if (*ptr != TAB) … … ins_tab() 9337 9338 /* Skip over the spaces we need. */ 9338 9339 while (vcol < want_vcol && *ptr == ' ') 9339 9340 { 9340 vcol += lbr_chartabsize(ptr, vcol );9341 vcol += lbr_chartabsize(ptr, vcol, cursor->lnum); 9341 9342 ++ptr; 9342 9343 ++repl_off; 9343 9344 } … … ins_copychar(lnum) 9585 9586 while ((colnr_T)temp < curwin->w_virtcol && *ptr != NUL) 9586 9587 { 9587 9588 prev_ptr = ptr; 9588 temp += lbr_chartabsize_adv(&ptr, (colnr_T)temp );9589 temp += lbr_chartabsize_adv(&ptr, (colnr_T)temp, lnum); 9589 9590 } 9590 9591 if ((colnr_T)temp > curwin->w_virtcol) 9591 9592 ptr = prev_ptr; -
src/ex_cmds.c
old new linelen(has_tab) 266 266 ; 267 267 save = *last; 268 268 *last = NUL; 269 len = linetabsize(line );/* get line length */269 len = linetabsize(line, curwin->w_cursor.lnum); /* get line length */ 270 270 if (has_tab != NULL) /* check for embedded TAB */ 271 271 *has_tab = (vim_strrchr(first, TAB) != NULL); 272 272 *last = save; -
src/getchar.c
old new vgetorpeek(advance) 2557 2557 if (!vim_iswhite(ptr[col])) 2558 2558 curwin->w_wcol = vcol; 2559 2559 vcol += lbr_chartabsize(ptr + col, 2560 (colnr_T)vcol );2560 (colnr_T)vcol, curwin->w_cursor.lnum); 2561 2561 #ifdef FEAT_MBYTE 2562 2562 if (has_mbyte) 2563 2563 col += (*mb_ptr2len)(ptr + col); -
src/gui_beval.c
old new get_beval_info(beval, getword, winp, lnu 337 337 { 338 338 /* Not past end of the file. */ 339 339 lbuf = ml_get_buf(wp->w_buffer, lnum, FALSE); 340 if (col <= win_linetabsize(wp, lbuf, (colnr_T)MAXCOL ))340 if (col <= win_linetabsize(wp, lbuf, (colnr_T)MAXCOL, lnum)) 341 341 { 342 342 /* Not past end of line. */ 343 343 if (getword) -
src/misc1.c
old new get_number_indent(lnum) 451 451 return (int)col; 452 452 } 453 453 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 462 get_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 454 494 #if defined(FEAT_CINDENT) || defined(FEAT_SMARTINDENT) 455 495 456 496 static int cin_is_cinword __ARGS((char_u *line)); … … plines_win_nofold(wp, lnum) 1730 1770 s = ml_get_buf(wp->w_buffer, lnum, FALSE); 1731 1771 if (*s == NUL) /* empty line */ 1732 1772 return 1; 1733 col = win_linetabsize(wp, s, (colnr_T)MAXCOL );1773 col = win_linetabsize(wp, s, (colnr_T)MAXCOL, lnum); 1734 1774 1735 1775 /* 1736 1776 * If list mode is on, then the '$' at the end of the line may take up one … … plines_win_col(wp, lnum, column) 1786 1826 col = 0; 1787 1827 while (*s != NUL && --column >= 0) 1788 1828 { 1789 col += win_lbr_chartabsize(wp, s, (colnr_T)col, NULL );1829 col += win_lbr_chartabsize(wp, s, (colnr_T)col, NULL, lnum); 1790 1830 mb_ptr_adv(s); 1791 1831 } 1792 1832 … … plines_win_col(wp, lnum, column) 1798 1838 * 'ts') -- webb. 1799 1839 */ 1800 1840 if (*s == TAB && (State & NORMAL) && (!wp->w_p_list || lcs_tab1)) 1801 col += win_lbr_chartabsize(wp, s, (colnr_T)col, NULL ) - 1;1841 col += win_lbr_chartabsize(wp, s, (colnr_T)col, NULL, lnum) - 1; 1802 1842 1803 1843 /* 1804 1844 * Add column offset for 'number', 'foldcolumn', etc. … … get_lisp_indent() 8213 8253 amount = 0; 8214 8254 while (*that && col) 8215 8255 { 8216 amount += lbr_chartabsize_adv(&that, (colnr_T)amount );8256 amount += lbr_chartabsize_adv(&that, (colnr_T)amount, pos->lnum); 8217 8257 col--; 8218 8258 } 8219 8259 … … get_lisp_indent() 8236 8276 8237 8277 while (vim_iswhite(*that)) 8238 8278 { 8239 amount += lbr_chartabsize(that, (colnr_T)amount );8279 amount += lbr_chartabsize(that, (colnr_T)amount, pos->lnum); 8240 8280 ++that; 8241 8281 } 8242 8282 … … get_lisp_indent() 8275 8315 --parencount; 8276 8316 if (*that == '\\' && *(that+1) != NUL) 8277 8317 amount += lbr_chartabsize_adv(&that, 8278 (colnr_T)amount );8318 (colnr_T)amount, pos->lnum); 8279 8319 amount += lbr_chartabsize_adv(&that, 8280 (colnr_T)amount );8320 (colnr_T)amount, pos->lnum); 8281 8321 } 8282 8322 } 8283 8323 while (vim_iswhite(*that)) 8284 8324 { 8285 amount += lbr_chartabsize(that, (colnr_T)amount );8325 amount += lbr_chartabsize(that, (colnr_T)amount, pos->lnum); 8286 8326 that++; 8287 8327 } 8288 8328 if (!*that || *that == ';') -
src/misc2.c
old new coladvance2(pos, addspaces, finetune, wc 166 166 #ifdef FEAT_VIRTUALEDIT 167 167 if ((addspaces || finetune) && !VIsual_active) 168 168 { 169 curwin->w_curswant = linetabsize(line ) + one_more;169 curwin->w_curswant = linetabsize(line, pos->lnum) + one_more; 170 170 if (curwin->w_curswant > 0) 171 171 --curwin->w_curswant; 172 172 } … … coladvance2(pos, addspaces, finetune, wc 184 184 # endif 185 185 && wcol >= (colnr_T)width) 186 186 { 187 csize = linetabsize(line );187 csize = linetabsize(line, pos->lnum); 188 188 if (csize > 0) 189 189 csize--; 190 190 … … coladvance2(pos, addspaces, finetune, wc 206 206 { 207 207 /* Count a tab for what it's worth (if list mode not on) */ 208 208 #ifdef FEAT_LINEBREAK 209 csize = win_lbr_chartabsize(curwin, ptr, col, &head );209 csize = win_lbr_chartabsize(curwin, ptr, col, &head, pos->lnum); 210 210 mb_ptr_adv(ptr); 211 211 #else 212 csize = lbr_chartabsize_adv(&ptr, col );212 csize = lbr_chartabsize_adv(&ptr, col, pos->lnum); 213 213 #endif 214 214 col += csize; 215 215 } -
src/normal.c
old new nv_screengo(oap, dir, dist) 4321 4321 int dir; 4322 4322 long dist; 4323 4323 { 4324 int linelen = linetabsize(ml_get_curline() );4324 int linelen = linetabsize(ml_get_curline(), curwin->w_cursor.lnum); 4325 4325 int retval = OK; 4326 4326 int atend = FALSE; 4327 4327 int n; … … nv_screengo(oap, dir, dist) 4394 4394 (void)hasFolding(curwin->w_cursor.lnum, 4395 4395 &curwin->w_cursor.lnum, NULL); 4396 4396 #endif 4397 linelen = linetabsize(ml_get_curline() );4397 linelen = linetabsize(ml_get_curline(), curwin->w_cursor.lnum); 4398 4398 if (linelen > width1) 4399 4399 curwin->w_curswant += (((linelen - width1 - 1) / width2) 4400 4400 + 1) * width2; -
src/ops.c
old new shift_block(oap, amount) 428 428 } 429 429 for ( ; vim_iswhite(*bd.textstart); ) 430 430 { 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); 432 432 total += incr; 433 433 bd.start_vcol += incr; 434 434 } … … shift_block(oap, amount) 488 488 489 489 while (vim_iswhite(*non_white)) 490 490 { 491 incr = lbr_chartabsize_adv(&non_white, non_white_col );491 incr = lbr_chartabsize_adv(&non_white, non_white_col, curwin->w_cursor.lnum); 492 492 non_white_col += incr; 493 493 } 494 494 … … shift_block(oap, amount) 512 512 verbatim_copy_width -= bd.start_char_vcols; 513 513 while (verbatim_copy_width < destination_col) 514 514 { 515 incr = lbr_chartabsize(verbatim_copy_end, verbatim_copy_width );515 incr = lbr_chartabsize(verbatim_copy_end, verbatim_copy_width, curwin->w_cursor.lnum); 516 516 if (verbatim_copy_width + incr > destination_col) 517 517 break; 518 518 verbatim_copy_width += incr; … … do_put(regname, dir, count, flags) 3518 3518 for (ptr = oldp; vcol < col && *ptr; ) 3519 3519 { 3520 3520 /* Count a tab for what it's worth (if list mode not on) */ 3521 incr = lbr_chartabsize_adv(&ptr, (colnr_T)vcol );3521 incr = lbr_chartabsize_adv(&ptr, (colnr_T)vcol, lnum); 3522 3522 vcol += incr; 3523 3523 } 3524 3524 bd.textcol = (colnr_T)(ptr - oldp); … … do_put(regname, dir, count, flags) 3552 3552 /* calculate number of spaces required to fill right side of block*/ 3553 3553 spaces = y_width + 1; 3554 3554 for (j = 0; j < yanklen; j++) 3555 spaces -= lbr_chartabsize(&y_array[i][j], 0 );3555 spaces -= lbr_chartabsize(&y_array[i][j], 0, lnum); 3556 3556 if (spaces < 0) 3557 3557 spaces = 0; 3558 3558 … … block_prep(oap, bdp, lnum, is_del) 4912 4912 while (bdp->start_vcol < oap->start_vcol && *pstart) 4913 4913 { 4914 4914 /* Count a tab for what it's worth (if list mode not on) */ 4915 incr = lbr_chartabsize(pstart, (colnr_T)bdp->start_vcol );4915 incr = lbr_chartabsize(pstart, (colnr_T)bdp->start_vcol, lnum); 4916 4916 bdp->start_vcol += incr; 4917 4917 #ifdef FEAT_VISUALEXTRA 4918 4918 if (vim_iswhite(*pstart)) … … block_prep(oap, bdp, lnum, is_del) 4981 4981 { 4982 4982 /* Count a tab for what it's worth (if list mode not on) */ 4983 4983 prev_pend = pend; 4984 incr = lbr_chartabsize_adv(&pend, (colnr_T)bdp->end_vcol );4984 incr = lbr_chartabsize_adv(&pend, (colnr_T)bdp->end_vcol, lnum); 4985 4985 bdp->end_vcol += incr; 4986 4986 } 4987 4987 if (bdp->end_vcol <= oap->end_vcol … … cursor_pos_info() 6419 6419 validate_virtcol(); 6420 6420 col_print(buf1, (int)curwin->w_cursor.col + 1, 6421 6421 (int)curwin->w_virtcol + 1); 6422 col_print(buf2, (int)STRLEN(p), linetabsize(p ));6422 col_print(buf2, (int)STRLEN(p), linetabsize(p, curwin->w_cursor.lnum)); 6423 6423 6424 6424 if (char_count_cursor == byte_count_cursor 6425 6425 && char_count == byte_count) -
src/option.c
old new 186 186 #ifdef FEAT_ARABIC 187 187 # define PV_ARAB OPT_WIN(WV_ARAB) 188 188 #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 189 194 #ifdef FEAT_DIFF 190 195 # define PV_DIFF OPT_WIN(WV_DIFF) 191 196 #endif … … static struct vimoption 630 635 {(char_u *)0L, (char_u *)0L} 631 636 #endif 632 637 }, 638 {"breakindent", "bri", P_BOOL|P_VI_DEF|P_VIM|P_RWIN, 639 #ifdef FEAT_LINEBREAK 640 (char_u *)VAR_WIN, PV_BRI, 641 #else 642 (char_u *)NULL, PV_NONE, 643 #endif 644 {(char_u *)FALSE, (char_u *)0L}}, 645 {"breakindentmin", "brimin", P_NUM|P_VI_DEF|P_VIM|P_RWIN, 646 #ifdef FEAT_LINEBREAK 647 (char_u *)VAR_WIN, PV_BRIMIN, 648 #else 649 (char_u *)NULL, PV_NONE, 650 #endif 651 {(char_u *)20L, (char_u *)20L}}, 652 {"breakindentshift", "brishift", P_NUM|P_VI_DEF|P_VIM|P_RWIN, 653 #ifdef FEAT_LINEBREAK 654 (char_u *)VAR_WIN, PV_BRISHIFT, 655 #else 656 (char_u *)NULL, PV_NONE, 657 #endif 658 {(char_u *)0L, (char_u *)0L}}, 633 659 {"browsedir", "bsdir",P_STRING|P_VI_DEF, 634 660 #ifdef FEAT_BROWSE 635 661 (char_u *)&p_bsdir, PV_NONE, … … set_num_option(opt_idx, varp, value, err 7953 7979 } 7954 7980 curwin->w_nrwidth_line_count = 0; 7955 7981 } 7982 7983 /* 'breakindentmin' must be positive */ 7984 else if (pp == &curwin->w_p_brimin) 7985 { 7986 if (curwin->w_p_brimin < 1) 7987 { 7988 errmsg = e_positive; 7989 curwin->w_p_brimin = 1; 7990 } 7991 } 7956 7992 #endif 7957 7993 7958 7994 /* … … get_varp(p) 9134 9170 case PV_WRAP: return (char_u *)&(curwin->w_p_wrap); 9135 9171 #ifdef FEAT_LINEBREAK 9136 9172 case PV_LBR: return (char_u *)&(curwin->w_p_lbr); 9173 case PV_BRI: return (char_u *)&(curwin->w_p_bri); 9174 case PV_BRIMIN: return (char_u *)&(curwin->w_p_brimin); 9175 case PV_BRISHIFT: return (char_u *)&(curwin->w_p_brishift); 9137 9176 #endif 9138 9177 #ifdef FEAT_SCROLLBIND 9139 9178 case PV_SCBIND: return (char_u *)&(curwin->w_p_scb); … … copy_winopt(from, to) 9312 9351 to->wo_wrap = from->wo_wrap; 9313 9352 #ifdef FEAT_LINEBREAK 9314 9353 to->wo_lbr = from->wo_lbr; 9354 to->wo_bri = from->wo_bri; 9355 to->wo_brimin = from->wo_brimin; 9315 9356 #endif 9316 9357 #ifdef FEAT_SCROLLBIND 9317 9358 to->wo_scb = from->wo_scb; -
src/option.h
old new enum 1018 1018 #ifdef FEAT_ARABIC 1019 1019 , WV_ARAB 1020 1020 #endif 1021 #ifdef FEAT_LINEBREAK 1022 , WV_BRI 1023 , WV_BRIMIN 1024 , WV_BRISHIFT 1025 #endif 1021 1026 #ifdef FEAT_DIFF 1022 1027 , WV_DIFF 1023 1028 #endif -
src/proto/charset.pro
old new int ptr2cells __ARGS((char_u *p)); 14 14 int vim_strsize __ARGS((char_u *s)); 15 15 int vim_strnsize __ARGS((char_u *s, int len)); 16 16 int 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 ));17 int linetabsize __ARGS((char_u *s, linenr_T lnum)); 18 int win_linetabsize __ARGS((win_T *wp, char_u *p, colnr_T len, linenr_T lnum)); 19 19 int vim_isIDc __ARGS((int c)); 20 20 int vim_iswordc __ARGS((int c)); 21 21 int vim_iswordp __ARGS((char_u *p)); … … int vim_isfilec __ARGS((int c)); 24 24 int vim_isfilec_or_wc __ARGS((int c)); 25 25 int vim_isprintc __ARGS((int c)); 26 26 int 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 ));27 int lbr_chartabsize __ARGS((unsigned char *s, colnr_T col, linenr_T lnum)); 28 int lbr_chartabsize_adv __ARGS((char_u **s, colnr_T col, linenr_T lnum)); 29 int win_lbr_chartabsize __ARGS((win_T *wp, char_u *s, colnr_T col, int *headp, linenr_T lnum)); 30 30 int in_win_border __ARGS((win_T *wp, colnr_T vcol)); 31 31 void getvcol __ARGS((win_T *wp, pos_T *pos, colnr_T *start, colnr_T *cursor, colnr_T *end)); 32 32 colnr_T getvcol_nolist __ARGS((pos_T *posp)); -
src/proto/misc1.pro
old new int get_indent_buf __ARGS((buf_T *buf, l 5 5 int get_indent_str __ARGS((char_u *ptr, int ts)); 6 6 int set_indent __ARGS((int size, int flags)); 7 7 int get_number_indent __ARGS((linenr_T lnum)); 8 int get_breakindent_win __ARGS((win_T *wp, linenr_T lnum)); 8 9 int open_line __ARGS((int dir, int flags, int old_indent)); 9 10 int get_leader_len __ARGS((char_u *line, char_u **flags, int backward)); 10 11 int plines __ARGS((linenr_T lnum)); -
src/regexp.c
old new regmatch(scan) 3981 3981 if (top.col == MAXCOL || bot.col == MAXCOL) 3982 3982 end = MAXCOL; 3983 3983 cols = win_linetabsize(wp, 3984 regline, (colnr_T)(reginput - regline) );3984 regline, (colnr_T)(reginput - regline), reglnum + reg_firstlnum); 3985 3985 if (cols < start || cols > end - (*p_sel == 'e')) 3986 3986 status = RA_NOMATCH; 3987 3987 } … … regmatch(scan) 4005 4005 case RE_VCOL: 4006 4006 if (!re_num_cmp((long_u)win_linetabsize( 4007 4007 reg_win == NULL ? curwin : reg_win, 4008 regline, (colnr_T)(reginput - regline) ) + 1, scan))4008 regline, (colnr_T)(reginput - regline), reglnum + reg_firstlnum ) + 1, scan)) 4009 4009 status = RA_NOMATCH; 4010 4010 break; 4011 4011 -
src/screen.c
old new win_line(wp, lnum, startrow, endrow, noc 2690 2690 # define WL_SIGN WL_FOLD /* column for signs */ 2691 2691 #endif 2692 2692 #define WL_NR WL_SIGN + 1 /* line number */ 2693 #ifdef FEAT_LINEBREAK 2694 # define WL_BRI WL_NR + 1 /* 'breakindent' */ 2695 #else 2696 # define WL_BRI WL_NR 2697 #endif 2693 2698 #if defined(FEAT_LINEBREAK) || defined(FEAT_DIFF) 2694 # define WL_SBR WL_ NR+ 1 /* 'showbreak' or 'diff' */2699 # define WL_SBR WL_BRI + 1 /* 'showbreak' or 'diff' */ 2695 2700 #else 2696 # define WL_SBR WL_ NR2701 # define WL_SBR WL_BRI 2697 2702 #endif 2698 2703 #define WL_LINE WL_SBR + 1 /* text in the line */ 2699 2704 int draw_state = WL_START; /* what to draw next */ … … win_line(wp, lnum, startrow, endrow, noc 3002 3007 #endif 3003 3008 while (vcol < v && *ptr != NUL) 3004 3009 { 3005 c = win_lbr_chartabsize(wp, ptr, (colnr_T)vcol, NULL );3010 c = win_lbr_chartabsize(wp, ptr, (colnr_T)vcol, NULL, lnum); 3006 3011 vcol += c; 3007 3012 #ifdef FEAT_MBYTE 3008 3013 prev_ptr = ptr; … … win_line(wp, lnum, startrow, endrow, noc 3338 3343 } 3339 3344 } 3340 3345 3346 #ifdef FEAT_LINEBREAK 3347 /* draw 'breakindent': indent wrapped text accordingly */ 3348 if (draw_state == WL_BRI -1 && n_extra == 0){ 3349 draw_state = WL_BRI; 3350 # ifdef FEAT_DIFF 3351 /* FIXME: handle (filler_todo > 0): or modify showbreak so that ---- vim/lines are shorter by the amount needed? */ 3352 # endif 3353 if (wp->w_p_bri && row != startrow){ /* FIXME: what is startrow? Don't we need it as well?? */ 3354 p_extra = NUL; 3355 c_extra = ' '; 3356 n_extra = get_breakindent_win(wp,lnum); 3357 char_attr = 0; /* was: hl_attr(HLF_AT); */ 3358 /* FIXME: why do we need to adjust vcol if showbreak does not?? */ 3359 vcol += n_extra; 3360 /* FIXME: is this relevant here? copied shamelessly from showbreak */ 3361 /* Correct end of highlighted area for 'breakindent', 3362 * required when 'linebreak' is also set. */ 3363 if (tocol == vcol) 3364 tocol += n_extra; 3365 } 3366 } 3367 #endif 3368 3369 3341 3370 #if defined(FEAT_LINEBREAK) || defined(FEAT_DIFF) 3342 3371 if (draw_state == WL_SBR - 1 && n_extra == 0) 3343 3372 { … … win_line(wp, lnum, startrow, endrow, noc 4035 4064 # ifdef FEAT_MBYTE 4036 4065 has_mbyte ? mb_l : 4037 4066 # endif 4038 1), (colnr_T)vcol, NULL ) - 1;4067 1), (colnr_T)vcol, NULL, lnum) - 1; 4039 4068 c_extra = ' '; 4040 4069 if (vim_iswhite(c)) 4041 4070 c = ' '; -
src/structs.h
old new typedef struct 133 133 int wo_arab; 134 134 # define w_p_arab w_onebuf_opt.wo_arab /* 'arabic' */ 135 135 #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 136 144 #ifdef FEAT_DIFF 137 145 int wo_diff; 138 146 # define w_p_diff w_onebuf_opt.wo_diff /* 'diff' */ -
src/ui.c
old new vcol2col(wp, lnum, vcol) 3027 3027 while (count <= vcol && *ptr != NUL) 3028 3028 { 3029 3029 ++col; 3030 count += win_lbr_chartabsize(wp, ptr, count, NULL );3030 count += win_lbr_chartabsize(wp, ptr, count, NULL, lnum); 3031 3031 mb_ptr_adv(ptr); 3032 3032 } 3033 3033 return col;