summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--Src/Zle/zle.h1
-rw-r--r--Src/Zle/zle_main.c2
-rw-r--r--Src/Zle/zle_utils.c21
-rw-r--r--Src/Zle/zle_vi.c12
5 files changed, 27 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog
index de8ff2af3..fc0c16841 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2014-10-23 Oliver Kiddle <opk@zsh.org>
+
+ * 33512: Src/Zle/zle.h, Src/Zle/zle_main.c, Src/Zle/zle_utils.c,
+ Src/Zle/zle_vi.c: add support for "0 vi buffer and yank to it
+
2014-10-22 Barton E. Schaefer <schaefer@zsh.org>
* 33515: Src/Zle/compmatch.c: suppress parser error messages in
diff --git a/Src/Zle/zle.h b/Src/Zle/zle.h
index 870e2149d..860c8217c 100644
--- a/Src/Zle/zle.h
+++ b/Src/Zle/zle.h
@@ -256,6 +256,7 @@ struct modifier {
* of visible characters directly input by
* the user.
*/
+#define CUT_YANK (1<<3) /* vi yank: use register 0 instead of 1-9 */
/* undo system */
diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c
index 442c31995..8344c66be 100644
--- a/Src/Zle/zle_main.c
+++ b/Src/Zle/zle_main.c
@@ -2128,7 +2128,7 @@ finish_(UNUSED(Module m))
free(kring[i].buf);
zfree(kring, kringsize * sizeof(struct cutbuffer));
}
- for(i = 35; i--; )
+ for(i = 36; i--; )
zfree(vibuf[i].buf, vibuf[i].len);
/* editor entry points */
diff --git a/Src/Zle/zle_utils.c b/Src/Zle/zle_utils.c
index 1089e274f..1479365df 100644
--- a/Src/Zle/zle_utils.c
+++ b/Src/Zle/zle_utils.c
@@ -43,10 +43,10 @@ struct cutbuffer *kring;
int kringsize, kringnum;
/* Vi named cut buffers. 0-25 are the named buffers "a to "z, and *
- * 26-34 are the numbered buffer stack "1 to "9. */
+ * 26-35 are the numbered buffer stack "0 to "9. */
/**/
-struct cutbuffer vibuf[35];
+struct cutbuffer vibuf[36];
/* the line before last mod (for undo purposes) */
@@ -942,16 +942,23 @@ cuttext(ZLE_STRING_T line, int ct, int flags)
b->len = len + ct;
}
return;
+ } else if (flags & CUT_YANK) {
+ /* Save in "0 */
+ free(vibuf[26].buf);
+ vibuf[26].buf = (ZLE_STRING_T)zalloc(ct * ZLE_CHAR_SIZE);
+ ZS_memcpy(vibuf[26].buf, line, ct);
+ vibuf[26].len = ct;
+ vibuf[26].flags = vilinerange ? CUTBUFFER_LINE : 0;
} else {
/* Save in "1, shifting "1-"8 along to "2-"9 */
int n;
free(vibuf[34].buf);
- for(n=34; n>26; n--)
+ for(n=35; n>27; n--)
vibuf[n] = vibuf[n-1];
- vibuf[26].buf = (ZLE_STRING_T)zalloc(ct * ZLE_CHAR_SIZE);
- ZS_memcpy(vibuf[26].buf, line, ct);
- vibuf[26].len = ct;
- vibuf[26].flags = vilinerange ? CUTBUFFER_LINE : 0;
+ vibuf[27].buf = (ZLE_STRING_T)zalloc(ct * ZLE_CHAR_SIZE);
+ ZS_memcpy(vibuf[27].buf, line, ct);
+ vibuf[27].len = ct;
+ vibuf[27].flags = vilinerange ? CUTBUFFER_LINE : 0;
}
if (!cutbuf.buf) {
cutbuf.buf = (ZLE_STRING_T)zalloc(ZLE_CHAR_SIZE);
diff --git a/Src/Zle/zle_vi.c b/Src/Zle/zle_vi.c
index 9e39143d0..2555c6a00 100644
--- a/Src/Zle/zle_vi.c
+++ b/Src/Zle/zle_vi.c
@@ -453,7 +453,7 @@ viyank(UNUSED(char **args))
startvichange(1);
if ((c2 = getvirange(0)) != -1) {
- cut(zlecs, c2 - zlecs, 0);
+ cut(zlecs, c2 - zlecs, CUT_YANK);
ret = 0;
}
vichgflag = 0;
@@ -470,7 +470,7 @@ viyankeol(UNUSED(char **args))
startvichange(-1);
if (x == zlecs)
return 1;
- cut(zlecs, x - zlecs, 0);
+ cut(zlecs, x - zlecs, CUT_YANK);
return 0;
}
@@ -492,7 +492,7 @@ viyankwholeline(UNUSED(char **args))
zlecs = findeol() + 1;
}
vilinerange = 1;
- cut(bol, zlecs - bol - 1, 0);
+ cut(bol, zlecs - bol - 1, CUT_YANK);
zlecs = oldcs;
return 0;
}
@@ -910,7 +910,7 @@ visetbuffer(UNUSED(char **args))
ZLE_INT_T ch;
if ((zmod.flags & MOD_VIBUF) ||
- (((ch = getfullchar(0)) < ZWC('1') || ch > ZWC('9')) &&
+ (((ch = getfullchar(0)) < ZWC('0') || ch > ZWC('9')) &&
(ch < ZWC('a') || ch > ZWC('z')) &&
(ch < ZWC('A') || ch > ZWC('Z'))))
return 1;
@@ -920,8 +920,8 @@ visetbuffer(UNUSED(char **args))
zmod.flags &= ~MOD_VIAPP;
/* FIXME how portable is it for multibyte encoding? */
zmod.vibuf = ZC_tolower(ch);
- if (ch >= ZWC('1') && ch <= ZWC('9'))
- zmod.vibuf += - (int)ZWC('1') + 26;
+ if (ch >= ZWC('0') && ch <= ZWC('9'))
+ zmod.vibuf += - (int)ZWC('0') + 26;
else
zmod.vibuf += - (int)ZWC('a');
zmod.flags |= MOD_VIBUF;