1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-10-23 04:30:24 +02:00

24860: better overwrite mode

This commit is contained in:
Peter Stephenson 2008-04-21 17:58:58 +00:00
parent f9224e5a04
commit a58d02fd2e
3 changed files with 33 additions and 6 deletions

View file

@ -1,5 +1,8 @@
2008-04-21 Peter Stephenson <pws@csr.com>
* 24860: Src/Zle/zle_misc.c, Src/Zle/zle_utils.c: better
overwrite mode.
* 24859: Src/Zle/zle_misc.c, Src/Zle/zle_vi.c, Src/Zle/zle_word.c:
overwriting combining characters and replacing them and appending
after them in vi mode.

View file

@ -50,19 +50,43 @@ doinsert(ZLE_STRING_T zstr, int len)
if (insmode)
spaceinline(m * len);
else {
int pos = zlecs, count = m * len, i = count, diff;
int pos = zlecs, diff, i;
/*
* Calculate the number of character positions we are
* going to be using. The algorithm is that
* anything that shows up as a logical single character
* (i.e. even if control, or double width, or with combining
* characters) is treated as 1 for the purpose of replacing
* what's there already.
*/
for (i = 0, count = 0; i < len; i++) {
int width = wcwidth(zstr[i]);
count += (width != 0) ? 1 : 0;
}
/*
* Ensure we replace a complete combining character
* for each character we overwrite.
*/
while (pos < zlell && i--) {
for (i = count; pos < zlell && i--; ) {
INCPOS(pos);
}
diff = pos - zlecs - count;
/*
* Calculate how many raw line places we need.
* pos - zlecs is the raw line distance we're replacing,
* m * len the number we're inserting.
*/
diff = pos - zlecs - m * len;
if (diff < 0) {
spaceinline(-diff);
} else if (diff > 0)
foredel(diff, CUT_RAW);
} else if (diff > 0) {
/*
* We use shiftchars() here because we don't
* want combining char alignment fixed up: we
* are going to write over any that remain.
*/
shiftchars(zlecs, diff);
}
}
while (m--)
for (s = zstr, count = len; count; s++, count--)

View file

@ -450,7 +450,7 @@ spaceinline(int ct)
}
/**/
static void
void
shiftchars(int to, int cnt)
{
if (mark >= to + cnt)