diff options
author | Oliver Kiddle <opk@zsh.org> | 2016-11-24 16:05:00 +0100 |
---|---|---|
committer | Oliver Kiddle <opk@zsh.org> | 2016-11-24 16:05:00 +0100 |
commit | 3570172d3be4e10549a9966b39f8cae762975bcd (patch) | |
tree | 3e792eb74e51d29c4e8aa0bccb92148b18cc1a51 | |
parent | fe2d87767ddf4f6d325dbc76a0b6e6dc624ce556 (diff) | |
download | zsh-3570172d3be4e10549a9966b39f8cae762975bcd.tar.gz zsh-3570172d3be4e10549a9966b39f8cae762975bcd.tar.xz zsh-3570172d3be4e10549a9966b39f8cae762975bcd.zip |
40003: include "0-"9 vi buffers in the registers associative array
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | Doc/Zsh/zle.yo | 2 | ||||
-rw-r--r-- | Src/Zle/zle_params.c | 35 |
3 files changed, 30 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog index 007b05457..0bf059098 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ + * 40003: Src/Zle/zle_params.c, Doc/Zsh/zle.yo: include "0-"9 + vi buffers in the registers associative array + 2016-11-24 Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp> * 40005: Completion/Unix/Command/_date, diff --git a/Doc/Zsh/zle.yo b/Doc/Zsh/zle.yo index ff3144802..d68365b94 100644 --- a/Doc/Zsh/zle.yo +++ b/Doc/Zsh/zle.yo @@ -1000,7 +1000,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 cb8dac867..78e78354f 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; } |