diff options
author | Oliver Kiddle <opk@zsh.org> | 2014-10-23 17:00:31 +0200 |
---|---|---|
committer | Oliver Kiddle <opk@zsh.org> | 2014-10-23 17:00:31 +0200 |
commit | a39c3adecee0998e61b340c84581dd7744de2cc4 (patch) | |
tree | 79458f86cfd38db86e37d60397efd7d5db1bd2ef /Src/Zle/zle_utils.c | |
parent | b6921a2b443faa92415cd8fb02befa3a0a8d353a (diff) | |
download | zsh-a39c3adecee0998e61b340c84581dd7744de2cc4.tar.gz zsh-a39c3adecee0998e61b340c84581dd7744de2cc4.tar.xz zsh-a39c3adecee0998e61b340c84581dd7744de2cc4.zip |
33512: add support for "0 vi buffer and yank to it
Diffstat (limited to 'Src/Zle/zle_utils.c')
-rw-r--r-- | Src/Zle/zle_utils.c | 21 |
1 files changed, 14 insertions, 7 deletions
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); |