* vi-replace-chars and vi-repeat-last-change
@ 1996-07-18 14:24 Zefram
0 siblings, 0 replies; only message in thread
From: Zefram @ 1996-07-18 14:24 UTC (permalink / raw)
To: Z Shell workers mailing list
-----BEGIN PGP SIGNED MESSAGE-----
The patch below makes vi-replace-chars repeat correctly with
vi-repeat-change. The comment added explains the details.
-zefram
Index: Src/zle_vi.c
===================================================================
RCS file: /home/zefram/usr/cvsroot/zsh/Src/zle_vi.c,v
retrieving revision 1.11
diff -c -r1.11 zle_vi.c
*** zle_vi.c 1996/07/17 16:12:28 1.11
--- zle_vi.c 1996/07/18 12:44:13
***************
*** 442,468 ****
startvitext(0);
}
/**/
void
vireplacechars(void)
{
int ch;
! /* check argument range */
! if (zmult < 0)
! return;
! if (zmult + cs > findeol()) {
feep();
return;
}
! /* get key */
! if((ch = vigetkey()) == -1) {
feep();
return;
}
- ungetkey(ch);
- startvichange(1);
- getkey(0);
/* do change */
if (ch == '\r' || ch == '\n') {
/* <return> handled specially */
--- 442,476 ----
startvitext(0);
}
+ /* vi-replace-chars has some oddities relating to vi-repeat-change. In *
+ * the real vi, if one does 3r at the end of a line, it feeps without *
+ * reading the argument. A successful rx followed by 3. at the end of *
+ * a line (or 3rx followed by . at the end of a line) will obviously *
+ * feep after the ., even though it has the argument available. Here *
+ * repeating is tied very closely to argument reading, such that we *
+ * can't do that. The solution is to just read the argument even if *
+ * the command will fail -- not exactly vi compatible, but it is more *
+ * consistent (consider dd in an empty file in vi). */
+
/**/
void
vireplacechars(void)
{
int ch;
! startvichange(1);
! /* get key */
! if((ch = vigetkey()) == -1) {
! vichgflag = 0;
feep();
return;
}
! /* check argument range */
! if (zmult < 0 || zmult + cs > findeol()) {
! vichgflag = 0;
feep();
return;
}
/* do change */
if (ch == '\r' || ch == '\n') {
/* <return> handled specially */
-----BEGIN PGP SIGNATURE-----
Version: 2.6.2
iQCVAwUBMe4yjnD/+HJTpU/hAQHcfwP/aLd1MTv3VEbFfH/6cCVEgUXWmFMgsOvK
RJOiYSKyagqOTjCuRJn+Klf+lVqRC3W59B21JkQr8L8FgNM9G/pKw7ea/fYiTyiY
Kehm34n4hW1eEBfZQPJXO3YmesNIrKfmDRWB0yKQNvnCPLQ7hGdcC3Bgo9GiBSp6
PM6HqjJtmyE=
=As9e
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~1996-07-18 14:31 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-07-18 14:24 vi-replace-chars and vi-repeat-last-change Zefram
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).