1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-10-08 21:51:15 +02:00

24859: combining chars: overwriting and vi replace and append

This commit is contained in:
Peter Stephenson 2008-04-21 17:30:34 +00:00
parent 5a0c547e91
commit f9224e5a04
4 changed files with 43 additions and 17 deletions

View file

@ -1,5 +1,9 @@
2008-04-21 Peter Stephenson <pws@csr.com> 2008-04-21 Peter Stephenson <pws@csr.com>
* 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.
* 24856: Src/utils.c, Src/zsh.h, Src/Zle/zle_move.c, * 24856: Src/utils.c, Src/zsh.h, Src/Zle/zle_move.c,
Src/Zle/zle_refresh.c: use IS_COMBINING() and IS_BASECHAR() Src/Zle/zle_refresh.c: use IS_COMBINING() and IS_BASECHAR()
tests for combining characters. Widen definitions of characters tests for combining characters. Widen definitions of characters

View file

@ -49,8 +49,21 @@ doinsert(ZLE_STRING_T zstr, int len)
if (insmode) if (insmode)
spaceinline(m * len); spaceinline(m * len);
else if(zlecs + m * len > zlell) else {
spaceinline(zlecs + m * len - zlell); int pos = zlecs, count = m * len, i = count, diff;
/*
* Ensure we replace a complete combining character
* for each character we overwrite.
*/
while (pos < zlell && i--) {
INCPOS(pos);
}
diff = pos - zlecs - count;
if (diff < 0) {
spaceinline(-diff);
} else if (diff > 0)
foredel(diff, CUT_RAW);
}
while (m--) while (m--)
for (s = zstr, count = len; count; s++, count--) for (s = zstr, count = len; count; s++, count--)
zleline[zlecs++] = *s; zleline[zlecs++] = *s;

View file

@ -498,18 +498,19 @@ int
vireplacechars(UNUSED(char **args)) vireplacechars(UNUSED(char **args))
{ {
ZLE_INT_T ch; ZLE_INT_T ch;
int n = zmult, origcs = zlecs, fail = 0; int n = zmult, fail = 0, newchars = 0;
if (n > 0) { if (n > 0) {
int pos = zlecs;
while (n-- > 0) { while (n-- > 0) {
if (zlecs == zlell || zleline[zlell] == ZWC('\n')) { if (pos == zlell || zleline[pos] == ZWC('\n')) {
fail = 1; fail = 1;
break; break;
} }
INCCS(); newchars++;
INCPOS(pos);
} }
n = zlecs - origcs; n = pos - zlecs;
zlecs = origcs;
} }
startvichange(1); startvichange(1);
/* check argument range */ /* check argument range */
@ -535,8 +536,16 @@ vireplacechars(UNUSED(char **args))
backkill(n - 1, CUT_RAW); backkill(n - 1, CUT_RAW);
zleline[zlecs++] = '\n'; zleline[zlecs++] = '\n';
} else { } else {
/* HERE: we shouldn't replace combining chars, we should delete them */ /*
while (n--) * Make sure we delete displayed characters, including
* attach combining characters. n includes this as a raw
* buffer offset.
*/
if (n > newchars)
foredel(n - newchars, CUT_RAW);
else if (n < newchars)
spaceinline(newchars - n);
while (newchars--)
zleline[zlecs++] = ch; zleline[zlecs++] = ch;
zlecs--; zlecs--;
} }
@ -792,14 +801,14 @@ viputafter(UNUSED(char **args))
vifirstnonblank(zlenoargs); vifirstnonblank(zlenoargs);
} else { } else {
if (zlecs != findeol()) if (zlecs != findeol())
zlecs++; INCCS();
while (n--) { while (n--) {
spaceinline(buf->len); spaceinline(buf->len);
ZS_memcpy(zleline + zlecs, buf->buf, buf->len); ZS_memcpy(zleline + zlecs, buf->buf, buf->len);
zlecs += buf->len; zlecs += buf->len;
} }
if (zlecs) if (zlecs)
zlecs--; DECCS();
} }
return 0; return 0;
} }

View file

@ -441,7 +441,7 @@ vibackwardkillword(UNUSED(char **args))
} }
} }
} }
backkill(zlecs - x, CUT_FRONT); backkill(zlecs - x, CUT_FRONT|CUT_RAW);
return 0; return 0;
} }
@ -475,7 +475,7 @@ backwardkillword(char **args)
x = pos; x = pos;
} }
} }
backkill(zlecs - x, CUT_FRONT); backkill(zlecs - x, CUT_FRONT|CUT_RAW);
return 0; return 0;
} }