Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Shift-Insert overwrites ZLE CUTBUFFER
- X-seq: zsh-workers 40003
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: Shift-Insert overwrites ZLE CUTBUFFER
- Date: Sun, 20 Nov 2016 23:32:56 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1479681176; bh=wUe0jWHf5Ro2ldv7yxuSJHy435U9w9stUycWybBNYLI=; h=In-reply-to:From:References:To:Subject:Date:From:Subject; b=N61jE4h5mfBiJ3aBxKjZspkuLvaTyHb4ByMRRqMdSZvEMHaMMJ5Gx3kSwTrq6NBD/8N/MkvWbRfF0Sg8ij0DstF+CtIsLsDoWaQ7XSX9bUo1UJ9WxjMml9pOH/A2btdOpio/gbID2KXsNNFBPVgzbVhjZUAuopvPRr+dsYJiYk0UTLV4R6vXQ3PAnomzNs8gj9OWSPMHwVwjKZydJhLvp9PBE8UDrliChQYYigyLqnXesFxPFaJ75Bk4QjsV6UOewI4OIiZbvoJmD23fxbrPQqgCrnLuOjFLF/ACoarYipe1rVUhfvfftNzInQyKZydqUqymBniZxQcw/gV35UtBgA==
- In-reply-to: <161117191641.ZM7944@torch.brasslantern.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CAMtVo_PG_fd62V1FZ4r7fRUragzzS6H4McN5sO1=hhY=6DR6Yg@mail.gmail.com> <161025091249.ZM7232@torch.brasslantern.com> <CAMtVo_N6qOQr++Amzn11+m3pkOxjc908mwFUerur77+OWd92uw@mail.gmail.com> <161026090133.ZM11120@torch.brasslantern.com> <CAMtVo_P09j6fyJytA21iu_qOom6bCTvJEWn-dXTBX97Bp00Sdg@mail.gmail.com> <161026165138.ZM12130@torch.brasslantern.com> <87h97x36sa.fsf@lwm.klanderman.net> <161027133523.ZM15655@torch.brasslantern.com> <43312.1477929414@hydra.kiddle.eu> <CGME20161031160350epcas3p4849616fbcc05783a9966320a28ed731c@epcas3p4.samsung.com> <20161031161605.23af1751@pwslap01u.europe.root.pri> <161109092745.ZM2477@torch.brasslantern.com> <4446.1478794906@hydra.kiddle.eu> <161110091736.ZM20932@torch.brasslantern.com> <22835.1479246117@hydra.kiddle.eu> <161115140723.ZM11274@torch.brasslantern.com> <92342.1479401635@hydra.kiddle.eu> <161117191641.ZM7944@torch.brasslantern.com>
On 17 Nov, Bart wrote:
> } Coming back to the original point of this thread, would it make
> } sense to instead put the bracketed-paste text in a register?
>
> ..., so it makes sense to me to put it there on the paste
> action (the first real chance we have to sync up with the global
> clipboard state). It's more that people aren't used to having a
> copy-paste affect their shell that way that is causing an issue,
> than the logic of the operation (I think, someone will probably
> contradict me).
Let's leave it as it is then. We can always come back to it if it really
ends up bothering a lot of people. And even that might reduce as more
programs support bracketed-paste and expectations change.
> I'm not going to respond in detail to your musings about emacs
> register operations; my only thought is that we're supposed to be
> maintaining a shell here, not re-implementing several editors.
I take your point. The emacs register widgets don't take much more than
about three lines each to do as shell widgets anyway. The main thing I
actually care about is that if we were to add emacs register widgets,
that it should use the same buffers (and marks) so that people can mix
and match with the vi widgets.
Anyway, as the 0-9 vi registers are quite separate from the emacs
killring (yanks only go into "0), they should be added to the new
associative array - patch for that follows.
Oliver
diff --git a/Doc/Zsh/zle.yo b/Doc/Zsh/zle.yo
index fe6a7e9..e6b315a 100644
--- a/Doc/Zsh/zle.yo
+++ b/Doc/Zsh/zle.yo
@@ -993,7 +993,7 @@ ifnzman(noderef(Character Highlighting)) for details.
)
vindex(registers)
item(tt(registers) (associative array))(
-The contents of each of the `named' vi register buffers. These are
+The contents of each of the vi register buffers. These are
typically set using tt(vi-set-buffer) followed by a delete, change or
yank command.
)
diff --git a/Src/Zle/zle_params.c b/Src/Zle/zle_params.c
index cb8dac8..78e7835 100644
--- a/Src/Zle/zle_params.c
+++ b/Src/Zle/zle_params.c
@@ -729,15 +729,22 @@ static void
set_register(Param pm, char *value)
{
int n = 0;
+ int offset = -1;
Cutbuffer reg;
- if (!pm->node.nam || *pm->node.nam < 'a' || *pm->node.nam > 'z' ||
- pm->node.nam[1]) {
+ if (!pm->node.nam || pm->node.nam[1])
+ ;
+ else if (*pm->node.nam >= '0' && *pm->node.nam <= '9')
+ offset = '0' - 26;
+ else if (*pm->node.nam >= 'a' && *pm->node.nam <= 'z')
+ offset = 'a';
+
+ if (offset == -1) {
zerr("invalid zle register: %s", pm->node.nam);
return;
}
- reg = &vibuf[*pm->node.nam - 'a'];
+ reg = &vibuf[*pm->node.nam - offset];
if (*value)
reg->buf = stringaszleline(value, 0, &n, NULL, NULL);
reg->len = n;
@@ -755,18 +762,21 @@ static void
scan_registers(UNUSED(HashTable ht), ScanFunc func, int flags)
{
int i;
+ char ch;
struct param pm;
memset((void *)&pm, 0, sizeof(struct param));
pm.node.flags = PM_SCALAR | PM_READONLY;
pm.gsu.s = &nullsetscalar_gsu;
- for (i = 0; i < 26; i++) {
+ for (i = 0, ch = 'a'; i < 36; i++) {
pm.node.nam = zhalloc(2);
- *pm.node.nam = 'a' + i;
+ *pm.node.nam = ch;
pm.node.nam[1] = '\0';
pm.u.str = zlelineasstring(vibuf[i].buf, vibuf[i].len, 0, NULL, NULL, 1);
func(&pm.node, flags);
+ if (ch++ == 'z')
+ ch = '0';
}
}
@@ -775,17 +785,24 @@ static HashNode
get_registers(UNUSED(HashTable ht), const char *name)
{
Param pm = (Param) hcalloc(sizeof(struct param));
+ int reg = -1;
pm->node.nam = dupstring(name);
pm->node.flags = PM_SCALAR;
pm->gsu.s = ®ister_gsu;
- if (*name < 'a' || *name > 'z' || name[1]) {
+ if (name[1])
+ ;
+ else if (*name >= '0' && *name <= '9')
+ reg = *name - '0' + 26;
+ else if (*name >= 'a' && *name <= 'z')
+ reg = *name - 'a';
+
+ if (reg == -1) {
pm->u.str = dupstring("");
pm->node.flags |= (PM_UNSET|PM_SPECIAL);
- } else {
- int reg = *name - 'a';
+ } else
pm->u.str = zlelineasstring(vibuf[reg].buf, vibuf[reg].len, 0, NULL, NULL, 1);
- }
+
return &pm->node;
}
Messages sorted by:
Reverse Date,
Date,
Thread,
Author