Compare commits

...

13 Commits

Author SHA1 Message Date
Bram Moolenaar
b6da44ae82 updated for version 7.4.344
Problem:    Unessecary initializations and other things related to
            matchaddpos().
Solution:   Code cleanup. (Alexey Radkov)
2014-06-25 18:15:22 +02:00
Bram Moolenaar
41d7523986 updated for version 7.4.343
Problem:    matchdelete() does not always update the right lines.
Solution:   Fix off-by-one error.  (Ozaki Kiichi)
2014-06-25 17:58:11 +02:00
Bram Moolenaar
db5ffaab5a updated for version 7.4.342
Problem:    Clang gives warnings.
Solution:   Add an else block. (Dominique Pelle)
2014-06-25 17:44:49 +02:00
Bram Moolenaar
e8a3492548 updated for version 7.4.341
Problem:    sort() doesn't handle numbers well.
Solution:   Add an argument to specify sorting on numbers. (Christian Brabandt)
2014-06-25 17:31:09 +02:00
Bram Moolenaar
72e8f0bcc1 updated for version 7.4.340
Problem:    Error from sed about illegal bytes when installing Vim.
Solution:   Prepend LC_ALL=C. (Itchyny)
2014-06-25 15:02:33 +02:00
Bram Moolenaar
8dc907d7d3 updated for version 7.4.339
Problem:    Local function is available globally.
Solution:   Add "static".
2014-06-25 14:44:10 +02:00
Bram Moolenaar
597a422416 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)
2014-06-25 14:39:50 +02:00
Bram Moolenaar
15a35c4f4a updated for version 7.4.337
Problem:    When there is an error preparing to edit the command line, the
            command won't be executed. (Hirohito Higashi)
Solution:   Reset did_emsg before editing.
2014-06-25 12:26:46 +02:00
Bram Moolenaar
78159bbf9e updated for version 7.4.336
Problem:    Setting 'history' to a big value causes out-of-memory errors.
Solution:   Limit the value to 10000. (Hirohito Higashi)
2014-06-25 11:48:54 +02:00
Bram Moolenaar
e8d1f20cbd updated for version 7.4.335
Problem:    No digraph for the new rouble sign.
Solution:   Add the digraphs =R and =P.
2014-06-18 21:38:18 +02:00
Bram Moolenaar
deae0f2566 updated for version 7.4.334
Problem:    Unitialized variables, causing some problems.
Solution:   Initialize the variables. (Dominique Pelle)
2014-06-18 21:20:11 +02:00
Bram Moolenaar
de993ea629 updated for version 7.4.333
Problem:    Compiler warning for unused function.
Solution:   Put the function inside the #ifdef.
2014-06-17 23:18:01 +02:00
Bram Moolenaar
58cbc914ea updated for version 7.4.332
Problem:    GTK: When a sign icon doesn't fit exactly there can be ugly gaps.
Solution:   Scale the sign to fit when the aspect ratio is not too far off.
            (Christian Brabandt)
2014-06-17 18:47:02 +02:00
35 changed files with 617 additions and 130 deletions

View File

@@ -4391,17 +4391,17 @@ matchaddpos({group}, {pos}[, {priority}[, {id}]]) *matchaddpos()*
required, for example to highlight matching parentheses.
The list {pos} can contain one of these items:
- A number. This while line will be highlighted. The first
- A number. This whole line will be highlighted. The first
line has number 1.
- A list with one number, e.g., [23]. The whole line with this
number will be highlighted.
- A list with two numbers, e.g., [23, 11]. The first number is
the line number, the second one the column number (first
column is 1). The character at this position will be
highlighted.
the line number, the second one is the column number (first
column is 1, the value must correspond to the byte index as
|col()| would return). The character at this position will
be highlighted.
- A list with three numbers, e.g., [23, 11, 3]. As above, but
the third number gives the length of the highlight in screen
cells.
the third number gives the length of the highlight in bytes.
The maximum number of positions is 8.
@@ -6651,8 +6651,8 @@ jumplist Compiled with |jumplist| support.
keymap Compiled with 'keymap' support.
langmap Compiled with 'langmap' support.
libcall Compiled with |libcall()| support.
linebreak Compiled with 'linebreak', 'breakat' and 'showbreak'
support.
linebreak Compiled with 'linebreak', 'breakat', 'showbreak' and
'breakindent' support.
lispindent Compiled with support for lisp indenting.
listcmds Compiled with commands for the buffer list |:files|
and the argument list |arglist|.

View File

@@ -3920,12 +3920,13 @@ A jump table for the options with a short description can be found at |Q_op|.
NOTE: This option is reset when 'compatible' is set.
*'history'* *'hi'*
'history' 'hi' number (Vim default: 20, Vi default: 0)
'history' 'hi' number (Vim default: 50, Vi default: 0)
global
{not in Vi}
A history of ":" commands, and a history of previous search patterns
are remembered. This option decides how many entries may be stored in
is remembered. This option decides how many entries may be stored in
each of these histories (see |cmdline-editing|).
The maximum value is 10000.
NOTE: This option is set to the Vi default value when 'compatible' is
set and to the Vim default value when 'compatible' is reset.

View File

@@ -324,6 +324,12 @@ call <SID>BinOptionG("wrap", &wrap)
call append("$", "linebreak\twrap long lines at a character in 'breakat'")
call append("$", "\t(local to window)")
call <SID>BinOptionL("lbr")
call append("$", "breakindent\tpreserve indentation in wrapped text")
call append("$", "\t(local to window)")
call <SID>BinOptionL("bri")
call append("$", "breakindentopt\tadjust breakindent behaviour")
call append("$", "\t(local to window)")
call <SID>OptionL("briopt")
call append("$", "breakat\twhich characters might cause a line break")
call <SID>OptionG("brk", &brk)
call append("$", "showbreak\tstring to put before wrapped screen lines")

View File

@@ -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)
{

View File

@@ -1425,6 +1425,8 @@ static digr_T digraphdefault[] =
{'W', '=', 0x20a9},
{'=', 'e', 0x20ac}, /* euro */
{'E', 'u', 0x20ac}, /* euro */
{'=', 'R', 0x20bd}, /* rouble */
{'=', 'P', 0x20bd}, /* rouble */
{'o', 'C', 0x2103},
{'c', 'o', 0x2105},
{'o', 'F', 0x2109},

View File

@@ -1956,7 +1956,7 @@ change_indent(type, amount, round, replaced, call_changed_bytes)
else
#endif
++new_cursor_col;
vcol += lbr_chartabsize(ptr + new_cursor_col, (colnr_T)vcol);
vcol += lbr_chartabsize(ptr, ptr + new_cursor_col, (colnr_T)vcol);
}
vcol = last_vcol;
@@ -7126,9 +7126,10 @@ oneleft()
for (;;)
{
coladvance(v - width);
/* getviscol() is slow, skip it when 'showbreak' is empty and
* there are no multi-byte characters */
if ((*p_sbr == NUL
/* getviscol() is slow, skip it when 'showbreak' is empty,
* 'breakindent' is not set and there are no multi-byte
* characters */
if ((*p_sbr == NUL && !curwin->w_p_bri
# ifdef FEAT_MBYTE
&& !has_mbyte
# endif
@@ -9758,11 +9759,11 @@ ins_tab()
getvcol(curwin, &fpos, &vcol, NULL, NULL);
getvcol(curwin, cursor, &want_vcol, NULL, NULL);
/* Use as many TABs as possible. Beware of 'showbreak' and
* 'linebreak' adding extra virtual columns. */
/* Use as many TABs as possible. Beware of 'breakindent', 'showbreak'
* and 'linebreak' adding extra virtual columns. */
while (vim_iswhite(*ptr))
{
i = lbr_chartabsize((char_u *)"\t", vcol);
i = lbr_chartabsize(NULL, (char_u *)"\t", vcol);
if (vcol + i > want_vcol)
break;
if (*ptr != TAB)
@@ -9784,11 +9785,12 @@ ins_tab()
if (change_col >= 0)
{
int repl_off = 0;
char_u *line = ptr;
/* Skip over the spaces we need. */
while (vcol < want_vcol && *ptr == ' ')
{
vcol += lbr_chartabsize(ptr, vcol);
vcol += lbr_chartabsize(line, ptr, vcol);
++ptr;
++repl_off;
}
@@ -10029,6 +10031,7 @@ ins_copychar(lnum)
int c;
int temp;
char_u *ptr, *prev_ptr;
char_u *line;
if (lnum < 1 || lnum > curbuf->b_ml.ml_line_count)
{
@@ -10038,13 +10041,13 @@ ins_copychar(lnum)
/* try to advance to the cursor column */
temp = 0;
ptr = ml_get(lnum);
line = ptr = ml_get(lnum);
prev_ptr = ptr;
validate_virtcol();
while ((colnr_T)temp < curwin->w_virtcol && *ptr != NUL)
{
prev_ptr = ptr;
temp += lbr_chartabsize_adv(&ptr, (colnr_T)temp);
temp += lbr_chartabsize_adv(line, &ptr, (colnr_T)temp);
}
if ((colnr_T)temp > curwin->w_virtcol)
ptr = prev_ptr;

View File

@@ -17330,6 +17330,7 @@ static int
item_compare2 __ARGS((const void *s1, const void *s2));
static int item_compare_ic;
static int item_compare_numeric;
static char_u *item_compare_func;
static dict_T *item_compare_selfdict;
static int item_compare_func_err;
@@ -17359,10 +17360,20 @@ item_compare(s1, s2)
p1 = (char_u *)"";
if (p2 == NULL)
p2 = (char_u *)"";
if (item_compare_ic)
res = STRICMP(p1, p2);
if (!item_compare_numeric)
{
if (item_compare_ic)
res = STRICMP(p1, p2);
else
res = STRCMP(p1, p2);
}
else
res = STRCMP(p1, p2);
{
double n1, n2;
n1 = strtod((char *)p1, (char **)&p1);
n2 = strtod((char *)p2, (char **)&p2);
res = n1 == n2 ? 0 : n1 > n2 ? 1 : -1;
}
vim_free(tofree1);
vim_free(tofree2);
return res;
@@ -17439,6 +17450,7 @@ do_sort_uniq(argvars, rettv, sort)
return; /* short list sorts pretty quickly */
item_compare_ic = FALSE;
item_compare_numeric = FALSE;
item_compare_func = NULL;
item_compare_selfdict = NULL;
if (argvars[1].v_type != VAR_UNKNOWN)
@@ -17457,6 +17469,19 @@ do_sort_uniq(argvars, rettv, sort)
item_compare_ic = TRUE;
else
item_compare_func = get_tv_string(&argvars[1]);
if (item_compare_func != NULL)
{
if (STRCMP(item_compare_func, "n") == 0)
{
item_compare_func = NULL;
item_compare_numeric = TRUE;
}
else if (STRCMP(item_compare_func, "i") == 0)
{
item_compare_func = NULL;
item_compare_ic = TRUE;
}
}
}
if (argvars[2].v_type != VAR_UNKNOWN)

View File

@@ -342,6 +342,13 @@ getcmdline(firstc, count, indent)
do_digraph(-1); /* init digraph typeahead */
#endif
/* If something above caused an error, reset the flags, we do want to type
* and execute commands. Display may be messed up a bit. */
if (did_emsg)
redrawcmd();
did_emsg = FALSE;
got_int = FALSE;
/*
* Collect the command string, handling editing keys.
*/
@@ -2295,10 +2302,10 @@ getexmodeline(promptc, cookie, indent)
p = (char_u *)line_ga.ga_data;
p[line_ga.ga_len] = NUL;
indent = get_indent_str(p, 8);
indent = get_indent_str(p, 8, FALSE);
indent += sw - indent % sw;
add_indent:
while (get_indent_str(p, 8) < indent)
while (get_indent_str(p, 8, FALSE) < indent)
{
char_u *s = skipwhite(p);
@@ -2350,11 +2357,11 @@ redraw:
else
{
p[line_ga.ga_len] = NUL;
indent = get_indent_str(p, 8);
indent = get_indent_str(p, 8, FALSE);
--indent;
indent -= indent % get_sw_value(curbuf);
}
while (get_indent_str(p, 8) > indent)
while (get_indent_str(p, 8, FALSE) > indent)
{
char_u *s = skipwhite(p);

View File

@@ -2675,7 +2675,7 @@ vgetorpeek(advance)
{
if (!vim_iswhite(ptr[col]))
curwin->w_wcol = vcol;
vcol += lbr_chartabsize(ptr + col,
vcol += lbr_chartabsize(ptr, ptr + col,
(colnr_T)vcol);
#ifdef FEAT_MBYTE
if (has_mbyte)

View File

@@ -1193,11 +1193,13 @@ drawBalloon(beval)
XmFontList fl;
fl = gui_motif_fontset2fontlist(&gui.tooltip_fontset);
if (fl != NULL)
if (fl == NULL)
{
XmStringExtent(fl, s, &w, &h);
XmFontListFree(fl);
XmStringFree(s);
return;
}
XmStringExtent(fl, s, &w, &h);
XmFontListFree(fl);
}
w += gui.border_offset << 1;
h += gui.border_offset << 1;

View File

@@ -5965,27 +5965,48 @@ gui_mch_drawsign(int row, int col, int typenr)
* Decide whether we need to scale. Allow one pixel of border
* width to be cut off, in order to avoid excessive scaling for
* tiny differences in font size.
* Do scale to fit the height to avoid gaps because of linespacing.
*/
need_scale = (width > SIGN_WIDTH + 2
|| height > SIGN_HEIGHT + 2
|| height != SIGN_HEIGHT
|| (width < 3 * SIGN_WIDTH / 4
&& height < 3 * SIGN_HEIGHT / 4));
if (need_scale)
{
double aspect;
double aspect;
int w = width;
int h = height;
/* Keep the original aspect ratio */
aspect = (double)height / (double)width;
width = (double)SIGN_WIDTH * SIGN_ASPECT / aspect;
width = MIN(width, SIGN_WIDTH);
height = (double)width * aspect;
if (((double)(MAX(height, SIGN_HEIGHT)) /
(double)(MIN(height, SIGN_HEIGHT))) < 1.15)
{
/* Change the aspect ratio by at most 15% to fill the
* available space completly. */
height = (double)SIGN_HEIGHT * SIGN_ASPECT / aspect;
height = MIN(height, SIGN_HEIGHT);
}
else
height = (double)width * aspect;
/* This doesn't seem to be worth caching, and doing so
* would complicate the code quite a bit. */
sign = gdk_pixbuf_scale_simple(sign, width, height,
GDK_INTERP_BILINEAR);
if (sign == NULL)
return; /* out of memory */
if (w == width && h == height)
{
/* no change in dimensions; don't decrease reference counter
* (below) */
need_scale = FALSE;
}
else
{
/* This doesn't seem to be worth caching, and doing so would
* complicate the code quite a bit. */
sign = gdk_pixbuf_scale_simple(sign, width, height,
GDK_INTERP_BILINEAR);
if (sign == NULL)
return; /* out of memory */
}
}
/* The origin is the upper-left corner of the pixmap. Therefore

View File

@@ -43,10 +43,13 @@ if test $what = "install" -o $what = "xxd"; then
fi
fi
# Note: setting LC_ALL to C is required to avoid illegal byte errors from sed
# on some systems.
if test $what = "install"; then
# vim.1
echo installing $destdir/$exename.1
sed -e s+/usr/local/lib/vim+$vimloc+ \
LC_ALL=C sed -e s+/usr/local/lib/vim+$vimloc+ \
-e s+$vimloc/doc+$helpsubloc+ \
-e s+$vimloc/print+$printsubloc+ \
-e s+$vimloc/syntax+$synsubloc+ \
@@ -64,7 +67,7 @@ if test $what = "install"; then
# vimtutor.1
echo installing $destdir/$exename""tutor.1
sed -e s+/usr/local/lib/vim+$vimloc+ \
LC_ALL=C sed -e s+/usr/local/lib/vim+$vimloc+ \
-e s+$vimloc/tutor+$tutorsubloc+ \
$helpsource/vimtutor$langadd.1 > $destdir/$exename""tutor.1
chmod $manmod $destdir/$exename""tutor.1
@@ -76,7 +79,7 @@ if test $what = "install"; then
# evim.1
echo installing $destdir/$evimname.1
sed -e s+/usr/local/lib/vim+$vimloc+ \
LC_ALL=C sed -e s+/usr/local/lib/vim+$vimloc+ \
-e s+$vimloc/evim.vim+$scriptloc/evim.vim+ \
$helpsource/evim$langadd.1 > $destdir/$evimname.1
chmod $manmod $destdir/$evimname.1

View File

@@ -32,7 +32,7 @@ static garray_T ga_users;
int
get_indent()
{
return get_indent_str(ml_get_curline(), (int)curbuf->b_p_ts);
return get_indent_str(ml_get_curline(), (int)curbuf->b_p_ts, FALSE);
}
/*
@@ -42,7 +42,7 @@ get_indent()
get_indent_lnum(lnum)
linenr_T lnum;
{
return get_indent_str(ml_get(lnum), (int)curbuf->b_p_ts);
return get_indent_str(ml_get(lnum), (int)curbuf->b_p_ts, FALSE);
}
#if defined(FEAT_FOLDING) || defined(PROTO)
@@ -55,7 +55,7 @@ get_indent_buf(buf, lnum)
buf_T *buf;
linenr_T lnum;
{
return get_indent_str(ml_get_buf(buf, lnum, FALSE), (int)buf->b_p_ts);
return get_indent_str(ml_get_buf(buf, lnum, FALSE), (int)buf->b_p_ts, FALSE);
}
#endif
@@ -64,16 +64,23 @@ get_indent_buf(buf, lnum)
* 'tabstop' at "ts"
*/
int
get_indent_str(ptr, ts)
get_indent_str(ptr, ts, list)
char_u *ptr;
int ts;
int list; /* if TRUE, count only screen size for tabs */
{
int count = 0;
for ( ; *ptr; ++ptr)
{
if (*ptr == TAB) /* count a tab for what it is worth */
count += ts - (count % ts);
if (*ptr == TAB)
{
if (!list || lcs_tab1) /* count a tab for what it is worth */
count += ts - (count % ts);
else
/* in list mode, when tab is not set, count screen char width for Tab: ^I */
count += ptr2cells(ptr);
}
else if (*ptr == ' ')
++count; /* count a space for one */
else
@@ -476,6 +483,58 @@ get_number_indent(lnum)
return (int)col;
}
#if defined(FEAT_LINEBREAK) || defined(PROTO)
/*
* Return appropriate space number for breakindent, taking influencing
* parameters into account. Window must be specified, since it is not
* necessarily always the current one.
*/
int
get_breakindent_win(wp, line)
win_T *wp;
char_u *line; /* start of the line */
{
static int prev_indent = 0; /* cached indent value */
static long prev_ts = 0L; /* cached tabstop value */
static char_u *prev_line = NULL; /* cached pointer to line */
int bri = 0;
/* window width minus window margin space, i.e. what rests for text */
const int eff_wwidth = W_WIDTH(wp)
- ((wp->w_p_nu || wp->w_p_rnu)
&& (vim_strchr(p_cpo, CPO_NUMCOL) == NULL)
? number_width(wp) + 1 : 0);
/* used cached indent, unless pointer or 'tabstop' changed */
if (prev_line != line || prev_ts != wp->w_buffer->b_p_ts)
{
prev_line = line;
prev_ts = wp->w_buffer->b_p_ts;
prev_indent = get_indent_str(line,
(int)wp->w_buffer->b_p_ts, wp->w_p_list) + wp->w_p_brishift;
}
/* indent minus the length of the showbreak string */
bri = prev_indent;
if (wp->w_p_brisbr)
bri -= vim_strsize(p_sbr);
/* Add offset for number column, if 'n' is in 'cpoptions' */
bri += win_col_off2(wp);
/* never indent past left window margin */
if (bri < 0)
bri = 0;
/* always leave at least bri_min characters on the left,
* if text width is sufficient */
else if (bri > eff_wwidth - wp->w_p_brimin)
bri = (eff_wwidth - wp->w_p_brimin < 0)
? 0 : eff_wwidth - wp->w_p_brimin;
return bri;
}
#endif
#if defined(FEAT_CINDENT) || defined(FEAT_SMARTINDENT)
static int cin_is_cinword __ARGS((char_u *line));
@@ -678,7 +737,7 @@ open_line(dir, flags, second_line_indent)
/*
* count white space on current line
*/
newindent = get_indent_str(saved_line, (int)curbuf->b_p_ts);
newindent = get_indent_str(saved_line, (int)curbuf->b_p_ts, FALSE);
if (newindent == 0 && !(flags & OPENLINE_COM_LIST))
newindent = second_line_indent; /* for ^^D command in insert mode */
@@ -1201,7 +1260,7 @@ open_line(dir, flags, second_line_indent)
|| do_si
#endif
)
newindent = get_indent_str(leader, (int)curbuf->b_p_ts);
newindent = get_indent_str(leader, (int)curbuf->b_p_ts, FALSE);
/* Add the indent offset */
if (newindent + off < 0)
@@ -1994,6 +2053,7 @@ plines_win_col(wp, lnum, column)
char_u *s;
int lines = 0;
int width;
char_u *line;
#ifdef FEAT_DIFF
/* Check for filler lines above this buffer line. When folded the result
@@ -2009,12 +2069,12 @@ plines_win_col(wp, lnum, column)
return lines + 1;
#endif
s = ml_get_buf(wp->w_buffer, lnum, FALSE);
line = s = ml_get_buf(wp->w_buffer, lnum, FALSE);
col = 0;
while (*s != NUL && --column >= 0)
{
col += win_lbr_chartabsize(wp, s, (colnr_T)col, NULL);
col += win_lbr_chartabsize(wp, line, s, (colnr_T)col, NULL);
mb_ptr_adv(s);
}
@@ -2026,7 +2086,7 @@ plines_win_col(wp, lnum, column)
* 'ts') -- webb.
*/
if (*s == TAB && (State & NORMAL) && (!wp->w_p_list || lcs_tab1))
col += win_lbr_chartabsize(wp, s, (colnr_T)col, NULL) - 1;
col += win_lbr_chartabsize(wp, line, s, (colnr_T)col, NULL) - 1;
/*
* Add column offset for 'number', 'relativenumber', 'foldcolumn', etc.
@@ -9002,10 +9062,12 @@ get_lisp_indent()
amount = 2;
else
{
char_u *line = that;
amount = 0;
while (*that && col)
{
amount += lbr_chartabsize_adv(&that, (colnr_T)amount);
amount += lbr_chartabsize_adv(line, &that, (colnr_T)amount);
col--;
}
@@ -9028,7 +9090,7 @@ get_lisp_indent()
while (vim_iswhite(*that))
{
amount += lbr_chartabsize(that, (colnr_T)amount);
amount += lbr_chartabsize(line, that, (colnr_T)amount);
++that;
}
@@ -9066,15 +9128,16 @@ get_lisp_indent()
&& !quotecount)
--parencount;
if (*that == '\\' && *(that+1) != NUL)
amount += lbr_chartabsize_adv(&that,
(colnr_T)amount);
amount += lbr_chartabsize_adv(&that,
(colnr_T)amount);
amount += lbr_chartabsize_adv(
line, &that, (colnr_T)amount);
amount += lbr_chartabsize_adv(
line, &that, (colnr_T)amount);
}
}
while (vim_iswhite(*that))
{
amount += lbr_chartabsize(that, (colnr_T)amount);
amount += lbr_chartabsize(
line, that, (colnr_T)amount);
that++;
}
if (!*that || *that == ';')

View File

@@ -201,10 +201,10 @@ coladvance2(pos, addspaces, finetune, wcol)
{
/* Count a tab for what it's worth (if list mode not on) */
#ifdef FEAT_LINEBREAK
csize = win_lbr_chartabsize(curwin, ptr, col, &head);
csize = win_lbr_chartabsize(curwin, line, ptr, col, &head);
mb_ptr_adv(ptr);
#else
csize = lbr_chartabsize_adv(&ptr, col);
csize = lbr_chartabsize_adv(line, &ptr, col);
#endif
col += csize;
}
@@ -2156,7 +2156,8 @@ ga_append(gap, c)
}
}
#if (defined(UNIX) && !defined(USE_SYSTEM)) || defined(WIN3264)
#if (defined(UNIX) && !defined(USE_SYSTEM)) || defined(WIN3264) \
|| defined(PROTO)
/*
* Append the text in "gap" below the cursor line and clear "gap".
*/

View File

@@ -420,7 +420,9 @@ shift_block(oap, amount)
}
for ( ; vim_iswhite(*bd.textstart); )
{
incr = lbr_chartabsize_adv(&bd.textstart, (colnr_T)(bd.start_vcol));
/* TODO: is passing bd.textstart for start of the line OK? */
incr = lbr_chartabsize_adv(bd.textstart, &bd.textstart,
(colnr_T)(bd.start_vcol));
total += incr;
bd.start_vcol += incr;
}
@@ -480,7 +482,7 @@ shift_block(oap, amount)
while (vim_iswhite(*non_white))
{
incr = lbr_chartabsize_adv(&non_white, non_white_col);
incr = lbr_chartabsize_adv(bd.textstart, &non_white, non_white_col);
non_white_col += incr;
}
@@ -505,7 +507,11 @@ shift_block(oap, amount)
verbatim_copy_width -= bd.start_char_vcols;
while (verbatim_copy_width < destination_col)
{
incr = lbr_chartabsize(verbatim_copy_end, verbatim_copy_width);
char_u *line = verbatim_copy_end;
/* TODO: is passing verbatim_copy_end for start of the line OK? */
incr = lbr_chartabsize(line, verbatim_copy_end,
verbatim_copy_width);
if (verbatim_copy_width + incr > destination_col)
break;
verbatim_copy_width += incr;
@@ -3617,7 +3623,7 @@ do_put(regname, dir, count, flags)
for (ptr = oldp; vcol < col && *ptr; )
{
/* Count a tab for what it's worth (if list mode not on) */
incr = lbr_chartabsize_adv(&ptr, (colnr_T)vcol);
incr = lbr_chartabsize_adv(oldp, &ptr, (colnr_T)vcol);
vcol += incr;
}
bd.textcol = (colnr_T)(ptr - oldp);
@@ -3651,7 +3657,7 @@ do_put(regname, dir, count, flags)
/* calculate number of spaces required to fill right side of block*/
spaces = y_width + 1;
for (j = 0; j < yanklen; j++)
spaces -= lbr_chartabsize(&y_array[i][j], 0);
spaces -= lbr_chartabsize(NULL, &y_array[i][j], 0);
if (spaces < 0)
spaces = 0;
@@ -5203,7 +5209,7 @@ block_prep(oap, bdp, lnum, is_del)
while (bdp->start_vcol < oap->start_vcol && *pstart)
{
/* Count a tab for what it's worth (if list mode not on) */
incr = lbr_chartabsize(pstart, (colnr_T)bdp->start_vcol);
incr = lbr_chartabsize(line, pstart, (colnr_T)bdp->start_vcol);
bdp->start_vcol += incr;
#ifdef FEAT_VISUALEXTRA
if (vim_iswhite(*pstart))
@@ -5272,7 +5278,10 @@ block_prep(oap, bdp, lnum, is_del)
{
/* Count a tab for what it's worth (if list mode not on) */
prev_pend = pend;
incr = lbr_chartabsize_adv(&pend, (colnr_T)bdp->end_vcol);
/* TODO: is passing prev_pend for start of the line OK?
* perhaps it should be "line". */
incr = lbr_chartabsize_adv(prev_pend, &pend,
(colnr_T)bdp->end_vcol);
bdp->end_vcol += incr;
}
if (bdp->end_vcol <= oap->end_vcol
@@ -6882,7 +6891,8 @@ cursor_pos_info()
validate_virtcol();
col_print(buf1, sizeof(buf1), (int)curwin->w_cursor.col + 1,
(int)curwin->w_virtcol + 1);
col_print(buf2, sizeof(buf2), (int)STRLEN(p), linetabsize(p));
col_print(buf2, sizeof(buf2), (int)STRLEN(p),
linetabsize(p));
if (char_count_cursor == byte_count_cursor
&& char_count == byte_count)

View File

@@ -188,6 +188,10 @@
#ifdef FEAT_ARABIC
# define PV_ARAB OPT_WIN(WV_ARAB)
#endif
#ifdef FEAT_LINEBREAK
# define PV_BRI OPT_WIN(WV_BRI)
# define PV_BRIOPT OPT_WIN(WV_BRIOPT)
#endif
#ifdef FEAT_DIFF
# define PV_DIFF OPT_WIN(WV_DIFF)
#endif
@@ -646,6 +650,24 @@ static struct vimoption
#else
(char_u *)NULL, PV_NONE,
{(char_u *)0L, (char_u *)0L}
#endif
SCRIPTID_INIT},
{"breakindent", "bri", P_BOOL|P_VI_DEF|P_VIM|P_RWIN,
#ifdef FEAT_LINEBREAK
(char_u *)VAR_WIN, PV_BRI,
{(char_u *)FALSE, (char_u *)0L}
#else
(char_u *)NULL, PV_NONE,
{(char_u *)0L, (char_u *)0L}
#endif
SCRIPTID_INIT},
{"breakindentopt", "briopt", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF|P_COMMA|P_NODUP,
#ifdef FEAT_LINEBREAK
(char_u *)VAR_WIN, PV_BRIOPT,
{(char_u *)"", (char_u *)NULL}
#else
(char_u *)NULL, PV_NONE,
{(char_u *)"", (char_u *)NULL}
#endif
SCRIPTID_INIT},
{"browsedir", "bsdir",P_STRING|P_VI_DEF,
@@ -1392,7 +1414,7 @@ static struct vimoption
SCRIPTID_INIT},
{"history", "hi", P_NUM|P_VIM,
(char_u *)&p_hi, PV_NONE,
{(char_u *)0L, (char_u *)20L} SCRIPTID_INIT},
{(char_u *)0L, (char_u *)50L} SCRIPTID_INIT},
{"hkmap", "hk", P_BOOL|P_VI_DEF|P_VIM,
#ifdef FEAT_RIGHTLEFT
(char_u *)&p_hkmap, PV_NONE,
@@ -3052,6 +3074,7 @@ static int istermoption __ARGS((struct vimoption *));
static char_u *get_varp_scope __ARGS((struct vimoption *p, int opt_flags));
static char_u *get_varp __ARGS((struct vimoption *));
static void option_value2string __ARGS((struct vimoption *, int opt_flags));
static void check_winopt __ARGS((winopt_T *wop));
static int wc_use_keyname __ARGS((char_u *varp, long *wcp));
#ifdef FEAT_LANGMAP
static void langmap_init __ARGS((void));
@@ -5256,6 +5279,9 @@ didset_options()
/* set cedit_key */
(void)check_cedit();
#endif
#ifdef FEAT_LINEBREAK
briopt_check();
#endif
}
/*
@@ -5709,6 +5735,14 @@ did_set_string_option(opt_idx, varp, new_value_alloced, oldval, errbuf,
*p_pm == '.' ? p_pm + 1 : p_pm) == 0)
errmsg = (char_u *)N_("E589: 'backupext' and 'patchmode' are equal");
}
#ifdef FEAT_LINEBREAK
/* 'breakindentopt' */
else if (varp == &curwin->w_p_briopt)
{
if (briopt_check() == FAIL)
errmsg = e_invarg;
}
#endif
/*
* 'isident', 'iskeyword', 'isprint or 'isfname' option: refill chartab[]
@@ -8595,6 +8629,11 @@ set_num_option(opt_idx, varp, value, errbuf, errbuflen, opt_flags)
errmsg = e_positive;
p_hi = 0;
}
else if (p_hi > 10000)
{
errmsg = e_invarg;
p_hi = 10000;
}
if (p_re < 0 || p_re > 2)
{
errmsg = e_invarg;
@@ -10013,6 +10052,8 @@ get_varp(p)
case PV_WRAP: return (char_u *)&(curwin->w_p_wrap);
#ifdef FEAT_LINEBREAK
case PV_LBR: return (char_u *)&(curwin->w_p_lbr);
case PV_BRI: return (char_u *)&(curwin->w_p_bri);
case PV_BRIOPT: return (char_u *)&(curwin->w_p_briopt);
#endif
#ifdef FEAT_SCROLLBIND
case PV_SCBIND: return (char_u *)&(curwin->w_p_scb);
@@ -10202,6 +10243,8 @@ copy_winopt(from, to)
#endif
#ifdef FEAT_LINEBREAK
to->wo_lbr = from->wo_lbr;
to->wo_bri = from->wo_bri;
to->wo_briopt = vim_strsave(from->wo_briopt);
#endif
#ifdef FEAT_SCROLLBIND
to->wo_scb = from->wo_scb;
@@ -10263,7 +10306,7 @@ check_win_options(win)
/*
* Check for NULL pointers in a winopt_T and replace them with empty_option.
*/
void
static void
check_winopt(wop)
winopt_T *wop UNUSED;
{
@@ -10289,6 +10332,9 @@ check_winopt(wop)
#ifdef FEAT_CONCEAL
check_string_option(&wop->wo_cocu);
#endif
#ifdef FEAT_LINEBREAK
check_string_option(&wop->wo_briopt);
#endif
}
/*
@@ -10308,6 +10354,9 @@ clear_winopt(wop)
# endif
clear_string_option(&wop->wo_fmr);
#endif
#ifdef FEAT_LINEBREAK
clear_string_option(&wop->wo_briopt);
#endif
#ifdef FEAT_RIGHTLEFT
clear_string_option(&wop->wo_rlc);
#endif
@@ -11922,3 +11971,49 @@ find_mps_values(initc, findc, backwards, switchit)
++ptr;
}
}
#if defined(FEAT_LINEBREAK) || defined(PROTO)
/*
* This is called when 'breakindentopt' is changed and when a window is
* initialized.
*/
int
briopt_check()
{
char_u *p;
int bri_shift = 0;
long bri_min = 20;
int bri_sbr = FALSE;
p = curwin->w_p_briopt;
while (*p != NUL)
{
if (STRNCMP(p, "shift:", 6) == 0
&& ((p[6] == '-' && VIM_ISDIGIT(p[7])) || VIM_ISDIGIT(p[6])))
{
p += 6;
bri_shift = getdigits(&p);
}
else if (STRNCMP(p, "min:", 4) == 0 && VIM_ISDIGIT(p[4]))
{
p += 4;
bri_min = getdigits(&p);
}
else if (STRNCMP(p, "sbr", 3) == 0)
{
p += 3;
bri_sbr = TRUE;
}
if (*p != ',' && *p != NUL)
return FAIL;
if (*p == ',')
++p;
}
curwin->w_p_brishift = bri_shift;
curwin->w_p_brimin = bri_min;
curwin->w_p_brisbr = bri_sbr;
return OK;
}
#endif

View File

@@ -1052,6 +1052,10 @@ enum
#ifdef FEAT_CURSORBIND
, WV_CRBIND
#endif
#ifdef FEAT_LINEBREAK
, WV_BRI
, WV_BRIOPT
#endif
#ifdef FEAT_DIFF
, WV_DIFF
#endif

View File

@@ -16,7 +16,7 @@ int vim_strnsize __ARGS((char_u *s, int len));
int chartabsize __ARGS((char_u *p, colnr_T col));
int linetabsize __ARGS((char_u *s));
int linetabsize_col __ARGS((int startcol, char_u *s));
int win_linetabsize __ARGS((win_T *wp, char_u *p, colnr_T len));
int win_linetabsize __ARGS((win_T *wp, char_u *line, colnr_T len));
int vim_isIDc __ARGS((int c));
int vim_iswordc __ARGS((int c));
int vim_iswordc_buf __ARGS((int c, buf_T *buf));
@@ -26,9 +26,9 @@ int vim_isfilec __ARGS((int c));
int vim_isfilec_or_wc __ARGS((int c));
int vim_isprintc __ARGS((int c));
int vim_isprintc_strict __ARGS((int c));
int lbr_chartabsize __ARGS((unsigned char *s, colnr_T col));
int lbr_chartabsize_adv __ARGS((char_u **s, colnr_T col));
int win_lbr_chartabsize __ARGS((win_T *wp, char_u *s, colnr_T col, int *headp));
int lbr_chartabsize __ARGS((char_u *line, unsigned char *s, colnr_T col));
int lbr_chartabsize_adv __ARGS((char_u *line, char_u **s, colnr_T col));
int win_lbr_chartabsize __ARGS((win_T *wp, char_u *line, char_u *s, colnr_T col, int *headp));
int in_win_border __ARGS((win_T *wp, colnr_T vcol));
void getvcol __ARGS((win_T *wp, pos_T *pos, colnr_T *start, colnr_T *cursor, colnr_T *end));
colnr_T getvcol_nolist __ARGS((pos_T *posp));

View File

@@ -2,9 +2,10 @@
int get_indent __ARGS((void));
int get_indent_lnum __ARGS((linenr_T lnum));
int get_indent_buf __ARGS((buf_T *buf, linenr_T lnum));
int get_indent_str __ARGS((char_u *ptr, int ts));
int get_indent_str __ARGS((char_u *ptr, int ts, int list));
int set_indent __ARGS((int size, int flags));
int get_number_indent __ARGS((linenr_T lnum));
int get_breakindent_win __ARGS((win_T *wp, char_u *ptr));
int open_line __ARGS((int dir, int flags, int second_line_indent));
int get_leader_len __ARGS((char_u *line, char_u **flags, int backward, int include_space));
int get_last_leader_offset __ARGS((char_u *line, char_u **flags));

View File

@@ -40,7 +40,6 @@ char_u *get_equalprg __ARGS((void));
void win_copy_options __ARGS((win_T *wp_from, win_T *wp_to));
void copy_winopt __ARGS((winopt_T *from, winopt_T *to));
void check_win_options __ARGS((win_T *win));
void check_winopt __ARGS((winopt_T *wop));
void clear_winopt __ARGS((winopt_T *wop));
void buf_copy_options __ARGS((buf_T *buf, int flags));
void reset_modifiable __ARGS((void));
@@ -63,4 +62,5 @@ int check_ff_value __ARGS((char_u *p));
long get_sw_value __ARGS((buf_T *buf));
long get_sts_value __ARGS((void));
void find_mps_values __ARGS((int *initc, int *findc, int *backwards, int switchit));
int briopt_check __ARGS((void));
/* vim: set ft=c : */

View File

@@ -139,7 +139,7 @@ static void draw_vsep_win __ARGS((win_T *wp, int row));
static void redraw_custom_statusline __ARGS((win_T *wp));
#endif
#ifdef FEAT_SEARCH_EXTRA
#define SEARCH_HL_PRIORITY 0
# define SEARCH_HL_PRIORITY 0
static void start_search_hl __ARGS((void));
static void end_search_hl __ARGS((void));
static void init_search_hl __ARGS((win_T *wp));
@@ -2962,10 +2962,15 @@ win_line(wp, lnum, startrow, endrow, nochange)
# define WL_SIGN WL_FOLD /* column for signs */
#endif
#define WL_NR WL_SIGN + 1 /* line number */
#if defined(FEAT_LINEBREAK) || defined(FEAT_DIFF)
# define WL_SBR WL_NR + 1 /* 'showbreak' or 'diff' */
#ifdef FEAT_LINEBREAK
# define WL_BRI WL_NR + 1 /* 'breakindent' */
#else
# define WL_SBR WL_NR
# define WL_BRI WL_NR
#endif
#if defined(FEAT_LINEBREAK) || defined(FEAT_DIFF)
# define WL_SBR WL_BRI + 1 /* 'showbreak' or 'diff' */
#else
# define WL_SBR WL_BRI
#endif
#define WL_LINE WL_SBR + 1 /* text in the line */
int draw_state = WL_START; /* what to draw next */
@@ -3301,7 +3306,7 @@ win_line(wp, lnum, startrow, endrow, nochange)
#endif
while (vcol < v && *ptr != NUL)
{
c = win_lbr_chartabsize(wp, ptr, (colnr_T)vcol, NULL);
c = win_lbr_chartabsize(wp, line, ptr, (colnr_T)vcol, NULL);
vcol += c;
#ifdef FEAT_MBYTE
prev_ptr = ptr;
@@ -3670,6 +3675,44 @@ win_line(wp, lnum, startrow, endrow, nochange)
}
}
#ifdef FEAT_LINEBREAK
if (wp->w_p_brisbr && draw_state == WL_BRI - 1
&& n_extra == 0 && *p_sbr != NUL)
/* draw indent after showbreak value */
draw_state = WL_BRI;
else if (wp->w_p_brisbr && draw_state == WL_SBR && n_extra == 0)
/* After the showbreak, draw the breakindent */
draw_state = WL_BRI - 1;
/* draw 'breakindent': indent wrapped text accordingly */
if (draw_state == WL_BRI - 1 && n_extra == 0)
{
draw_state = WL_BRI;
# ifdef FEAT_DIFF
# endif
if (wp->w_p_bri && n_extra == 0 && row != startrow
#ifdef FEAT_DIFF
&& filler_lines == 0
#endif
)
{
char_attr = 0; /* was: hl_attr(HLF_AT); */
#ifdef FEAT_DIFF
if (diff_hlf != (hlf_T)0)
char_attr = hl_attr(diff_hlf);
#endif
p_extra = NUL;
c_extra = ' ';
n_extra = get_breakindent_win(wp,
ml_get_buf(wp->w_buffer, lnum, FALSE));
/* Correct end of highlighted area for 'breakindent',
* required when 'linebreak' is also set. */
if (tocol == vcol)
tocol += n_extra;
}
}
#endif
#if defined(FEAT_LINEBREAK) || defined(FEAT_DIFF)
if (draw_state == WL_SBR - 1 && n_extra == 0)
{
@@ -4382,11 +4425,14 @@ win_line(wp, lnum, startrow, endrow, nochange)
if (wp->w_p_lbr && vim_isbreak(c) && !vim_isbreak(*ptr)
&& !wp->w_p_list)
{
n_extra = win_lbr_chartabsize(wp, ptr - (
char_u *p = ptr - (
# ifdef FEAT_MBYTE
has_mbyte ? mb_l :
# endif
1), (colnr_T)vcol, NULL) - 1;
1);
/* TODO: is passing p for start of the line OK? */
n_extra = win_lbr_chartabsize(wp, p, p, (colnr_T)vcol,
NULL) - 1;
c_extra = ' ';
if (vim_iswhite(c))
{
@@ -7363,7 +7409,7 @@ next_search_hl(win, shl, lnum, mincol, cur)
match_T *shl; /* points to search_hl or a match */
linenr_T lnum;
colnr_T mincol; /* minimal column for a match */
matchitem_T *cur; /* to retrieve match postions if any */
matchitem_T *cur; /* to retrieve match positions if any */
{
linenr_T l;
colnr_T matchcol;
@@ -7458,9 +7504,9 @@ next_search_hl(win, shl, lnum, mincol, cur)
}
}
else if (cur != NULL)
{
nmatched = next_search_hl_pos(shl, lnum, &(cur->pos), matchcol);
}
else
nmatched = 0;
if (nmatched == 0)
{
shl->lnum = 0; /* no match found */
@@ -7476,7 +7522,6 @@ next_search_hl(win, shl, lnum, mincol, cur)
}
}
}
#endif
static int
next_search_hl_pos(shl, lnum, posmatch, mincol)
@@ -7486,7 +7531,7 @@ next_search_hl_pos(shl, lnum, posmatch, mincol)
colnr_T mincol; /* minimal column for a match */
{
int i;
int bot = -1;
int bot = -1;
shl->lnum = 0;
for (i = posmatch->cur; i < MAXPOSMATCH; i++)
@@ -7533,6 +7578,7 @@ next_search_hl_pos(shl, lnum, posmatch, mincol)
}
return FALSE;
}
#endif
static void
screen_start_highlight(attr)
@@ -8916,8 +8962,8 @@ windgoto(row, col)
{
if (noinvcurs)
screen_stop_highlight();
if (row == screen_cur_row && (col > screen_cur_col) &&
*T_CRI != NUL)
if (row == screen_cur_row && (col > screen_cur_col)
&& *T_CRI != NUL)
term_cursor_right(col - screen_cur_col);
else
term_windgoto(row, col);

View File

@@ -134,6 +134,12 @@ typedef struct
int wo_arab;
# define w_p_arab w_onebuf_opt.wo_arab /* 'arabic' */
#endif
#ifdef FEAT_LINEBREAK
int wo_bri;
# define w_p_bri w_onebuf_opt.wo_bri /* 'breakindent' */
char_u *wo_briopt;
# define w_p_briopt w_onebuf_opt.wo_briopt /* 'breakindentopt' */
#endif
#ifdef FEAT_DIFF
int wo_diff;
# define w_p_diff w_onebuf_opt.wo_diff /* 'diff' */
@@ -2189,6 +2195,11 @@ struct window_S
#ifdef FEAT_SYN_HL
int *w_p_cc_cols; /* array of columns to highlight or NULL */
#endif
#ifdef FEAT_LINEBREAK
int w_p_brimin; /* minimum width for breakindent */
int w_p_brishift; /* additional shift for breakindent */
int w_p_brisbr; /* sbr in 'briopt' */
#endif
/* transform a pointer to a "onebuf" option into a "allbuf" option */
#define GLOBAL_WO(p) ((char *)p + sizeof(winopt_T))

View File

@@ -37,6 +37,7 @@ SCRIPTS = test1.out test3.out test4.out test5.out test6.out \
test99.out test100.out test101.out test102.out test103.out \
test104.out test105.out test106.out test107.out \
test_autoformat_join.out \
test_breakindent.out \
test_eval.out \
test_options.out
@@ -163,5 +164,6 @@ test105.out: test105.in
test106.out: test106.in
test107.out: test107.in
test_autoformat_join.out: test_autoformat_join.in
test_breakindent.out: test_breakindent.in
test_eval.out: test_eval.in
test_options.out: test_options.in

View File

@@ -36,6 +36,7 @@ SCRIPTS = test3.out test4.out test5.out test6.out test7.out \
test100.out test101.out test102.out test103.out test104.out \
test105.out test106.out test107.out\
test_autoformat_join.out \
test_breakindent.out \
test_eval.out \
test_options.out

View File

@@ -56,6 +56,7 @@ SCRIPTS = test3.out test4.out test5.out test6.out test7.out \
test100.out test101.out test102.out test103.out test104.out \
test105.out test106.out test107.out \
test_autoformat_join.out \
test_breakindent.out \
test_eval.out \
test_options.out

View File

@@ -39,6 +39,7 @@ SCRIPTS = test1.out test3.out test4.out test5.out test6.out \
test105.out test106.out test107.out \
test_autoformat_join.out \
test_eval.out \
test_breakindent.out \
test_options.out
.SUFFIXES: .in .out

View File

@@ -97,6 +97,7 @@ SCRIPT = test1.out test2.out test3.out test4.out test5.out \
test100.out test101.out test103.out test104.out \
test105.out test106.out test107.out \
test_autoformat_join.out \
test_breakindent.out \
test_eval.out \
test_options.out

View File

@@ -34,6 +34,7 @@ SCRIPTS = test1.out test2.out test3.out test4.out test5.out test6.out \
test99.out test100.out test101.out test102.out test103.out \
test104.out test105.out test106.out test107.out \
test_autoformat_join.out \
test_breakindent.out \
test_eval.out \
test_options.out

View File

@@ -332,6 +332,11 @@ let l = [0, 1, 2, 3]
:$put =string(reverse(sort(l)))
:$put =string(sort(reverse(sort(l))))
:$put =string(uniq(sort(l)))
:let l=[7, 9, 18, 12, 22, 10.0e-16, -1, 0xff, 0, -0, 0.22, 'foo', 'FOOBAR',{}, []]
:$put =string(sort(copy(l), 'n'))
:$put =string(sort(copy(l), 1))
:$put =string(sort(copy(l), 'i'))
:$put =string(sort(copy(l)))
:"
:" splitting a string to a List
:$put =string(split(' aa bb '))

View File

@@ -101,6 +101,10 @@ caught a:000[3]
[[0, 1, 2], [0, 1, 2], 4, 2, 2, 1.5, 'xaaa', 'x8', 'foo6', 'foo', 'foo', 'A11', '-0']
['-0', 'A11', 'foo', 'foo', 'foo6', 'x8', 'xaaa', 1.5, 2, 2, 4, [0, 1, 2], [0, 1, 2]]
['-0', 'A11', 'foo', 'foo6', 'x8', 'xaaa', 1.5, 2, 4, [0, 1, 2]]
[-1, 0, 0, 'foo', 'FOOBAR', {}, [], 1.0e-15, 0.22, 7, 9, 12, 18, 22, 255]
['foo', 'FOOBAR', -1, 0, 0, 0.22, 1.0e-15, 12, 18, 22, 255, 7, 9, [], {}]
['foo', 'FOOBAR', -1, 0, 0, 0.22, 1.0e-15, 12, 18, 22, 255, 7, 9, [], {}]
['FOOBAR', 'foo', -1, 0, 0, 0.22, 1.0e-15, 12, 18, 22, 255, 7, 9, [], {}]
['aa', 'bb']
['aa', 'bb']
['', 'aa', 'bb', '']

View File

@@ -0,0 +1,79 @@
Test for breakindent
STARTTEST
:so small.vim
:if !exists("+breakindent") | e! test.ok | w! test.out | qa! | endif
:10new|:vsp|:vert resize 20
:put =\"\tabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP\"
:set ts=4 sw=4 sts=4 breakindent
:fu! ScreenChar(width)
: let c=''
: for i in range(1,a:width)
: let c.=nr2char(screenchar(line('.'), i))
: endfor
: let c.="\n"
: for i in range(1,a:width)
: let c.=nr2char(screenchar(line('.')+1, i))
: endfor
: let c.="\n"
: for i in range(1,a:width)
: let c.=nr2char(screenchar(line('.')+2, i))
: endfor
: return c
:endfu
:fu DoRecordScreen()
: wincmd l
: $put =printf(\"\n%s\", g:test)
: $put =g:line1
: wincmd p
:endfu
:let g:test="Test 1: Simple breakindent"
:let line1=ScreenChar(8)
:call DoRecordScreen()
:let g:test="Test 2: Simple breakindent + sbr=>>"
:set sbr=>>
:let line1=ScreenChar(8)
:call DoRecordScreen()
:let g:test ="Test 3: Simple breakindent + briopt:sbr"
:set briopt=sbr,min:0 sbr=++
:let line1=ScreenChar(8)
:call DoRecordScreen()
:let g:test ="Test 4: Simple breakindent + min width: 18"
:set sbr= briopt=min:18
:let line1=ScreenChar(8)
:call DoRecordScreen()
:let g:test =" Test 5: Simple breakindent + shift by 2"
:set briopt=shift:2,min:0
:let line1=ScreenChar(8)
:call DoRecordScreen()
:let g:test=" Test 6: Simple breakindent + shift by -1"
:set briopt=shift:-1,min:0
:let line1=ScreenChar(8)
:call DoRecordScreen()
:let g:test=" Test 7: breakindent + shift by +1 + nu + sbr=? briopt:sbr"
:set briopt=shift:1,sbr,min:0 nu sbr=? nuw=4
:let line1=ScreenChar(10)
:call DoRecordScreen()
:let g:test=" Test 8: breakindent + shift:1 + nu + sbr=# list briopt:sbr"
:set briopt=shift:1,sbr,min:0 nu sbr=# list
:let line1=ScreenChar(10)
:call DoRecordScreen()
:let g:test=" Test 9: breakindent + shift by +1 + 'nu' + sbr=# list"
:set briopt-=sbr
:let line1=ScreenChar(10)
:call DoRecordScreen()
:let g:test=" Test 10: breakindent + shift by +1 + 'nu' + sbr=~ cpo+=n"
:set cpo+=n sbr=~ nu nuw=4 nolist briopt=sbr,min:0
:let line1=ScreenChar(10)
:call DoRecordScreen()
:wincmd p
:let g:test="\n Test 11: strdisplaywidth when breakindent is on"
:set cpo-=n sbr=>> nu nuw=4 nolist briopt= ts=4
:let text=getline(2) "skip leading tab when calculating text width
:let width = strlen(text[1:])+indent(2)*4+strlen(&sbr)*3 " text wraps 3 times
:$put =g:test
:$put =printf(\"strdisplaywidth: %d == calculated: %d\", strdisplaywidth(text), width)
:%w! test.out
:qa!
ENDTEST
dummy text

View File

@@ -0,0 +1,55 @@
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP
Test 1: Simple breakindent
abcd
qrst
GHIJ
Test 2: Simple breakindent + sbr=>>
abcd
>>qr
>>EF
Test 3: Simple breakindent + briopt:sbr
abcd
++ qrst
++ GHIJ
Test 4: Simple breakindent + min width: 18
abcd
qrstuv
IJKLMN
Test 5: Simple breakindent + shift by 2
abcd
qr
EF
Test 6: Simple breakindent + shift by -1
abcd
qrstu
HIJKL
Test 7: breakindent + shift by +1 + nu + sbr=? briopt:sbr
2 ab
? m
? x
Test 8: breakindent + shift:1 + nu + sbr=# list briopt:sbr
2 ^Iabcd
# opq
# BCD
Test 9: breakindent + shift by +1 + 'nu' + sbr=# list
2 ^Iabcd
#op
#AB
Test 10: breakindent + shift by +1 + 'nu' + sbr=~ cpo+=n
2 ab
~ mn
~ yz
Test 11: strdisplaywidth when breakindent is on
strdisplaywidth: 46 == calculated: 64

View File

@@ -3162,15 +3162,15 @@ vcol2col(wp, lnum, vcol)
/* try to advance to the specified column */
int count = 0;
char_u *ptr;
char_u *start;
char_u *line;
start = ptr = ml_get_buf(wp->w_buffer, lnum, FALSE);
line = ptr = ml_get_buf(wp->w_buffer, lnum, FALSE);
while (count < vcol && *ptr != NUL)
{
count += win_lbr_chartabsize(wp, ptr, count, NULL);
count += win_lbr_chartabsize(wp, line, ptr, count, NULL);
mb_ptr_adv(ptr);
}
return (int)(ptr - start);
return (int)(ptr - line);
}
#endif

View File

@@ -734,6 +734,32 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
344,
/**/
343,
/**/
342,
/**/
341,
/**/
340,
/**/
339,
/**/
338,
/**/
337,
/**/
336,
/**/
335,
/**/
334,
/**/
333,
/**/
332,
/**/
331,
/**/

View File

@@ -6809,11 +6809,10 @@ match_add(wp, grp, pat, prio, id, pos_list)
}
/* Build new match. */
m = (matchitem_T *)alloc(sizeof(matchitem_T));
m = (matchitem_T *)alloc_clear(sizeof(matchitem_T));
m->id = id;
m->priority = prio;
m->pattern = pat == NULL ? NULL : vim_strsave(pat);
m->pos.cur = 0;
m->hlg_id = hlg_id;
m->match.regprog = regprog;
m->match.rmm_ic = FALSE;
@@ -6827,7 +6826,7 @@ match_add(wp, grp, pat, prio, id, pos_list)
listitem_T *li;
int i;
for (i = 0, li = pos_list->lv_first; i < MAXPOSMATCH;
for (i = 0, li = pos_list->lv_first; li != NULL && i < MAXPOSMATCH;
i++, li = li->li_next)
{
linenr_T lnum = 0;
@@ -6835,13 +6834,8 @@ match_add(wp, grp, pat, prio, id, pos_list)
int len = 1;
list_T *subl;
listitem_T *subli;
int error;
int error = FALSE;
if (li == NULL)
{
m->pos.pos[i].lnum = 0;
break;
}
if (li->li_tv.v_type == VAR_LIST)
{
subl = li->li_tv.vval.v_list;
@@ -6853,12 +6847,12 @@ match_add(wp, grp, pat, prio, id, pos_list)
lnum = get_tv_number_chk(&subli->li_tv, &error);
if (error == TRUE)
goto fail;
m->pos.pos[i].lnum = lnum;
if (lnum == 0)
{
--i;
continue;
}
m->pos.pos[i].lnum = lnum;
subli = subli->li_next;
if (subli != NULL)
{
@@ -6879,7 +6873,10 @@ match_add(wp, grp, pat, prio, id, pos_list)
else if (li->li_tv.v_type == VAR_NUMBER)
{
if (li->li_tv.vval.v_number == 0)
{
--i;
continue;
}
m->pos.pos[i].lnum = li->li_tv.vval.v_number;
m->pos.pos[i].col = 0;
m->pos.pos[i].len = 0;
@@ -6891,8 +6888,8 @@ match_add(wp, grp, pat, prio, id, pos_list)
}
if (toplnum == 0 || lnum < toplnum)
toplnum = lnum;
if (botlnum == 0 || lnum > botlnum)
botlnum = lnum;
if (botlnum == 0 || lnum >= botlnum)
botlnum = lnum + 1;
}
/* Calculate top and bottom lines for redrawing area */