mirror of
https://github.com/vim/vim.git
synced 2025-09-26 04:04:07 -04:00
updated for version 7.4.338
Problem: Cannot wrap lines taking indent into account. Solution: Add the 'breakindent' option. (many authors, final improvements by Christian Brabandt)
This commit is contained in:
@@ -867,9 +867,10 @@ linetabsize_col(startcol, s)
|
||||
char_u *s;
|
||||
{
|
||||
colnr_T col = startcol;
|
||||
char_u *line = s; /* pointer to start of line, for breakindent */
|
||||
|
||||
while (*s != NUL)
|
||||
col += lbr_chartabsize_adv(&s, col);
|
||||
col += lbr_chartabsize_adv(line, &s, col);
|
||||
return (int)col;
|
||||
}
|
||||
|
||||
@@ -877,16 +878,17 @@ linetabsize_col(startcol, s)
|
||||
* Like linetabsize(), but for a given window instead of the current one.
|
||||
*/
|
||||
int
|
||||
win_linetabsize(wp, p, len)
|
||||
win_linetabsize(wp, line, len)
|
||||
win_T *wp;
|
||||
char_u *p;
|
||||
char_u *line;
|
||||
colnr_T len;
|
||||
{
|
||||
colnr_T col = 0;
|
||||
char_u *s;
|
||||
|
||||
for (s = p; *s != NUL && (len == MAXCOL || s < p + len); mb_ptr_adv(s))
|
||||
col += win_lbr_chartabsize(wp, s, col, NULL);
|
||||
for (s = line; *s != NUL && (len == MAXCOL || s < line + len);
|
||||
mb_ptr_adv(s))
|
||||
col += win_lbr_chartabsize(wp, line, s, col, NULL);
|
||||
return (int)col;
|
||||
}
|
||||
|
||||
@@ -1021,12 +1023,13 @@ vim_isprintc_strict(c)
|
||||
* like chartabsize(), but also check for line breaks on the screen
|
||||
*/
|
||||
int
|
||||
lbr_chartabsize(s, col)
|
||||
lbr_chartabsize(line, s, col)
|
||||
char_u *line; /* start of the line */
|
||||
unsigned char *s;
|
||||
colnr_T col;
|
||||
{
|
||||
#ifdef FEAT_LINEBREAK
|
||||
if (!curwin->w_p_lbr && *p_sbr == NUL)
|
||||
if (!curwin->w_p_lbr && *p_sbr == NUL && !curwin->w_p_bri)
|
||||
{
|
||||
#endif
|
||||
#ifdef FEAT_MBYTE
|
||||
@@ -1036,7 +1039,7 @@ lbr_chartabsize(s, col)
|
||||
RET_WIN_BUF_CHARTABSIZE(curwin, curbuf, s, col)
|
||||
#ifdef FEAT_LINEBREAK
|
||||
}
|
||||
return win_lbr_chartabsize(curwin, s, col, NULL);
|
||||
return win_lbr_chartabsize(curwin, line == NULL ? s : line, s, col, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1044,13 +1047,14 @@ lbr_chartabsize(s, col)
|
||||
* Call lbr_chartabsize() and advance the pointer.
|
||||
*/
|
||||
int
|
||||
lbr_chartabsize_adv(s, col)
|
||||
lbr_chartabsize_adv(line, s, col)
|
||||
char_u *line; /* start of the line */
|
||||
char_u **s;
|
||||
colnr_T col;
|
||||
{
|
||||
int retval;
|
||||
|
||||
retval = lbr_chartabsize(*s, col);
|
||||
retval = lbr_chartabsize(line, *s, col);
|
||||
mb_ptr_adv(*s);
|
||||
return retval;
|
||||
}
|
||||
@@ -1063,8 +1067,9 @@ lbr_chartabsize_adv(s, col)
|
||||
* value, init to 0 before calling.
|
||||
*/
|
||||
int
|
||||
win_lbr_chartabsize(wp, s, col, headp)
|
||||
win_lbr_chartabsize(wp, line, s, col, headp)
|
||||
win_T *wp;
|
||||
char_u *line; /* start of the line */
|
||||
char_u *s;
|
||||
colnr_T col;
|
||||
int *headp UNUSED;
|
||||
@@ -1086,9 +1091,9 @@ win_lbr_chartabsize(wp, s, col, headp)
|
||||
int n;
|
||||
|
||||
/*
|
||||
* No 'linebreak' and 'showbreak': return quickly.
|
||||
* No 'linebreak', 'showbreak' and 'breakindent': return quickly.
|
||||
*/
|
||||
if (!wp->w_p_lbr && *p_sbr == NUL)
|
||||
if (!wp->w_p_lbr && !wp->w_p_bri && *p_sbr == NUL)
|
||||
#endif
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
@@ -1163,11 +1168,12 @@ win_lbr_chartabsize(wp, s, col, headp)
|
||||
# endif
|
||||
|
||||
/*
|
||||
* May have to add something for 'showbreak' string at start of line
|
||||
* May have to add something for 'breakindent' and/or 'showbreak'
|
||||
* string at start of line.
|
||||
* Set *headp to the size of what we add.
|
||||
*/
|
||||
added = 0;
|
||||
if (*p_sbr != NUL && wp->w_p_wrap && col != 0)
|
||||
if ((*p_sbr != NUL || wp->w_p_bri) && wp->w_p_wrap && col != 0)
|
||||
{
|
||||
numberextra = win_col_off(wp);
|
||||
col += numberextra + mb_added;
|
||||
@@ -1180,7 +1186,12 @@ win_lbr_chartabsize(wp, s, col, headp)
|
||||
}
|
||||
if (col == 0 || col + size > (colnr_T)W_WIDTH(wp))
|
||||
{
|
||||
added = vim_strsize(p_sbr);
|
||||
added = 0;
|
||||
if (*p_sbr != NUL)
|
||||
added += vim_strsize(p_sbr);
|
||||
if (wp->w_p_bri)
|
||||
added += get_breakindent_win(wp, line);
|
||||
|
||||
if (tab_corr)
|
||||
size += (added / wp->w_buffer->b_p_ts) * wp->w_buffer->b_p_ts;
|
||||
else
|
||||
@@ -1274,13 +1285,14 @@ getvcol(wp, pos, start, cursor, end)
|
||||
colnr_T vcol;
|
||||
char_u *ptr; /* points to current char */
|
||||
char_u *posptr; /* points to char at pos->col */
|
||||
char_u *line; /* start of the line */
|
||||
int incr;
|
||||
int head;
|
||||
int ts = wp->w_buffer->b_p_ts;
|
||||
int c;
|
||||
|
||||
vcol = 0;
|
||||
ptr = ml_get_buf(wp->w_buffer, pos->lnum, FALSE);
|
||||
line = ptr = ml_get_buf(wp->w_buffer, pos->lnum, FALSE);
|
||||
if (pos->col == MAXCOL)
|
||||
posptr = NULL; /* continue until the NUL */
|
||||
else
|
||||
@@ -1288,12 +1300,13 @@ getvcol(wp, pos, start, cursor, end)
|
||||
|
||||
/*
|
||||
* This function is used very often, do some speed optimizations.
|
||||
* When 'list', 'linebreak' and 'showbreak' are not set use a simple loop.
|
||||
* When 'list', 'linebreak', 'showbreak' and 'breakindent' are not set
|
||||
* use a simple loop.
|
||||
* Also use this when 'list' is set but tabs take their normal size.
|
||||
*/
|
||||
if ((!wp->w_p_list || lcs_tab1 != NUL)
|
||||
#ifdef FEAT_LINEBREAK
|
||||
&& !wp->w_p_lbr && *p_sbr == NUL
|
||||
&& !wp->w_p_lbr && *p_sbr == NUL && !wp->w_p_bri
|
||||
#endif
|
||||
)
|
||||
{
|
||||
@@ -1355,7 +1368,7 @@ getvcol(wp, pos, start, cursor, end)
|
||||
{
|
||||
/* A tab gets expanded, depending on the current column */
|
||||
head = 0;
|
||||
incr = win_lbr_chartabsize(wp, ptr, vcol, &head);
|
||||
incr = win_lbr_chartabsize(wp, line, ptr, vcol, &head);
|
||||
/* make sure we don't go past the end of the line */
|
||||
if (*ptr == NUL)
|
||||
{
|
||||
|
Reference in New Issue
Block a user