summaryrefslogtreecommitdiffstats
path: root/Src/Zle/zle_misc.c
diff options
context:
space:
mode:
authorOliver Kiddle <opk@zsh.org>2025-11-10 21:02:27 +0100
committerOliver Kiddle <opk@zsh.org>2025-11-10 21:02:27 +0100
commit5b66e3614f288f6ca87c2acde9188550669ad257 (patch)
treed0b53487dc05b6afcf425d6d3bc84fef9cdfc9fc /Src/Zle/zle_misc.c
parent53372, 53375: query terminal properties on ZLE startup (diff)
downloadzsh-5b66e3614f288f6ca87c2acde9188550669ad257.tar
zsh-5b66e3614f288f6ca87c2acde9188550669ad257.tar.gz
zsh-5b66e3614f288f6ca87c2acde9188550669ad257.tar.bz2
zsh-5b66e3614f288f6ca87c2acde9188550669ad257.tar.lz
zsh-5b66e3614f288f6ca87c2acde9188550669ad257.tar.xz
zsh-5b66e3614f288f6ca87c2acde9188550669ad257.tar.zst
zsh-5b66e3614f288f6ca87c2acde9188550669ad257.zip
53377: support OSC52 paste sequence with the "* and "+ vi registers
Diffstat (limited to 'Src/Zle/zle_misc.c')
-rw-r--r--Src/Zle/zle_misc.c59
1 files changed, 48 insertions, 11 deletions
diff --git a/Src/Zle/zle_misc.c b/Src/Zle/zle_misc.c
index 60982d92e..3e50d5d4b 100644
--- a/Src/Zle/zle_misc.c
+++ b/Src/Zle/zle_misc.c
@@ -554,7 +554,8 @@ yank(UNUSED(char **args))
}
/* position: 0 is before, 1 after, 2 split the line */
-static void pastebuf(Cutbuffer buf, int mult, int position)
+static void
+pastebuf(Cutbuffer buf, int mult, int position)
{
int cc;
if (buf->flags & CUTBUFFER_LINE) {
@@ -613,7 +614,20 @@ viputbefore(UNUSED(char **args))
return 1;
if (zmod.flags & MOD_NULL)
return 0;
- if (zmod.flags & MOD_VIBUF)
+ if (zmod.flags & MOD_OSSEL) {
+ struct cutbuffer kbuf;
+ int x;
+ char *pbuf = system_clipget(zmod.flags & MOD_CLIP ? 'c' : 'p');
+ if (!pbuf || !*pbuf)
+ return 1;
+ kbuf.buf = stringaszleline(pbuf, 0, &x, NULL, NULL);
+ kbuf.len = x;
+ kbuf.flags = 0;
+ kct = -1;
+ yankcs = zlecs;
+ pastebuf(&kbuf, n, 0);
+ return 0;
+ } else if (zmod.flags & MOD_VIBUF)
kctbuf = &vibuf[zmod.vibuf];
else
kctbuf = &cutbuf;
@@ -636,7 +650,20 @@ viputafter(UNUSED(char **args))
return 1;
if (zmod.flags & MOD_NULL)
return 0;
- if (zmod.flags & MOD_VIBUF)
+ if (zmod.flags & MOD_OSSEL) {
+ struct cutbuffer kbuf;
+ int x;
+ char *pbuf = system_clipget(zmod.flags & MOD_CLIP ? 'c' : 'p');
+ if (!pbuf || !*pbuf)
+ return 1;
+ kbuf.buf = stringaszleline(pbuf, 0, &x, NULL, NULL);
+ kbuf.len = x;
+ kbuf.flags = 0;
+ kct = -1;
+ yankcs = zlecs;
+ pastebuf(&kbuf, n, 1);
+ return 0;
+ } else if (zmod.flags & MOD_VIBUF)
kctbuf = &vibuf[zmod.vibuf];
else
kctbuf = &cutbuf;
@@ -661,15 +688,25 @@ putreplaceselection(UNUSED(char **args))
startvichange(-1);
if (n < 0 || zmod.flags & MOD_NULL)
return 1;
- putbuf = (zmod.flags & MOD_VIBUF) ? &vibuf[zmod.vibuf] : &cutbuf;
- if (!putbuf->buf)
- return 1;
- memcpy(&prevbuf, putbuf, sizeof(prevbuf));
+ if (zmod.flags & MOD_OSSEL) {
+ int x;
+ char *pbuf = system_clipget(zmod.flags & MOD_CLIP ? 'c' : 'p');
+ if (!pbuf || !*pbuf)
+ return 1;
+ prevbuf.buf = stringaszleline(pbuf, 0, &x, NULL, NULL);
+ prevbuf.len = x;
+ prevbuf.flags = 0;
+ } else {
+ putbuf = (zmod.flags & MOD_VIBUF) ? &vibuf[zmod.vibuf] : &cutbuf;
+ if (!putbuf->buf)
+ return 1;
+ memcpy(&prevbuf, putbuf, sizeof(prevbuf));
- /* if "9 was specified, prevent killregion from freeing it */
- if (zmod.vibuf == 35) {
- putbuf->buf = 0;
- clear = 1;
+ /* if "9 was specified, prevent killregion from freeing it */
+ if (zmod.vibuf == 35) {
+ putbuf->buf = 0;
+ clear = 1;
+ }
}
zmod.flags = 0; /* flags apply to paste not kill */