1
0
forked from aniani/vim

updated for version 7.1-240

This commit is contained in:
Bram Moolenaar
2008-01-22 15:02:31 +00:00
parent 9a31f881f2
commit b44df0af83
2 changed files with 46 additions and 20 deletions

View File

@@ -2184,6 +2184,8 @@ op_replace(oap, c)
}
#endif
static int swapchars __ARGS((int op_type, pos_T *pos, int length));
/*
* Handle the (non-standard vi) tilde operator. Also for "gu", "gU" and "g?".
*/
@@ -2194,9 +2196,8 @@ op_tilde(oap)
pos_T pos;
#ifdef FEAT_VISUAL
struct block_def bd;
int todo;
#endif
int did_change = 0;
int did_change;
if (u_save((linenr_T)(oap->start.lnum - 1),
(linenr_T)(oap->end.lnum + 1)) == FAIL)
@@ -2210,16 +2211,8 @@ op_tilde(oap)
{
block_prep(oap, &bd, pos.lnum, FALSE);
pos.col = bd.textcol;
for (todo = bd.textlen; todo > 0; --todo)
{
# ifdef FEAT_MBYTE
if (has_mbyte)
todo -= (*mb_ptr2len)(ml_get_pos(&pos)) - 1;
# endif
did_change |= swapchar(oap->op_type, &pos);
if (inc(&pos) == -1) /* at end of file */
break;
}
did_change = swapchars(oap->op_type, &pos, bd.textlen);
# ifdef FEAT_NETBEANS_INTG
if (usingNetbeans && did_change)
{
@@ -2249,13 +2242,7 @@ op_tilde(oap)
else if (!oap->inclusive)
dec(&(oap->end));
while (ltoreq(pos, oap->end))
{
did_change |= swapchar(oap->op_type, &pos);
if (inc(&pos) == -1) /* at end of file */
break;
}
did_change = swapchars(oap->op_type, &pos, oap->end.col - pos.col + 1);
if (did_change)
{
changed_lines(oap->start.lnum, oap->start.col, oap->end.lnum + 1,
@@ -2308,6 +2295,42 @@ op_tilde(oap)
}
}
/*
* Invoke swapchar() on "length" bytes at position "pos".
* "pos" is advanced to just after the changed characters.
* "length" is rounded up to include the whole last multi-byte character.
* Also works correctly when the number of bytes changes.
* Returns TRUE if some character was changed.
*/
static int
swapchars(op_type, pos, length)
int op_type;
pos_T *pos;
int length;
{
int todo;
int did_change = 0;
for (todo = length; todo > 0; --todo)
{
# ifdef FEAT_MBYTE
int pos_col = pos->col;
if (has_mbyte)
/* we're counting bytes, not characters */
todo -= (*mb_ptr2len)(ml_get_pos(pos)) - 1;
# endif
did_change |= swapchar(op_type, pos);
# ifdef FEAT_MBYTE
/* Changing German sharp s to SS increases the column. */
todo += pos->col - pos_col;
# endif
if (inc(pos) == -1) /* at end of file */
break;
}
return did_change;
}
/*
* If op_type == OP_UPPER: make uppercase,
* if op_type == OP_LOWER: make lowercase,
@@ -2330,7 +2353,8 @@ swapchar(op_type, pos)
return FALSE;
#ifdef FEAT_MBYTE
if (op_type == OP_UPPER && enc_latin1like && c == 0xdf)
if (op_type == OP_UPPER && c == 0xdf
&& (enc_latin1like || STRCMP(p_enc, "iso-8859-2") == 0))
{
pos_T sp = curwin->w_cursor;