mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-11 13:01:28 +02:00
zsh-workers/9396
This commit is contained in:
parent
09a9a37aac
commit
b8907b986b
3 changed files with 24 additions and 6 deletions
|
@ -144,7 +144,7 @@ by `tt(bindkey -m)'.
|
||||||
findex(vared)
|
findex(vared)
|
||||||
cindex(parameters, editing)
|
cindex(parameters, editing)
|
||||||
cindex(editing parameters)
|
cindex(editing parameters)
|
||||||
item(tt(vared) [ tt(-Aach) ] [ tt(-p) var(prompt) ] [ tt(-r) var(rprompt) ] var(name))(
|
item(tt(vared) [ tt(-Aache) ] [ tt(-p) var(prompt) ] [ tt(-r) var(rprompt) ] var(name))(
|
||||||
The value of the parameter var(name) is loaded into the edit
|
The value of the parameter var(name) is loaded into the edit
|
||||||
buffer, and the line editor is invoked. When the editor exits,
|
buffer, and the line editor is invoked. When the editor exits,
|
||||||
var(name) is set to the string value returned by the editor.
|
var(name) is set to the string value returned by the editor.
|
||||||
|
@ -161,7 +161,9 @@ created automatically, even without tt(-c).
|
||||||
If the tt(-p) flag is given, the following string will be taken as
|
If the tt(-p) flag is given, the following string will be taken as
|
||||||
the prompt to display at the left. If the tt(-r) flag is given,
|
the prompt to display at the left. If the tt(-r) flag is given,
|
||||||
the following string gives the prompt to display at the right. If the
|
the following string gives the prompt to display at the right. If the
|
||||||
tt(-h) flag is specified, the history can be accessed from ZLE.
|
tt(-h) flag is specified, the history can be accessed from ZLE. If the
|
||||||
|
tt(-e) flag is given, typing tt(^D) (Control-D) on an empty line
|
||||||
|
causes tt(vared) to exit immediatly with a non-zero return value.
|
||||||
)
|
)
|
||||||
findex(zle)
|
findex(zle)
|
||||||
cindex(widgets, rebinding)
|
cindex(widgets, rebinding)
|
||||||
|
|
|
@ -8,19 +8,23 @@ local tmp line compcontext=nslookup curcontext=':nslookup' pmpt
|
||||||
trap 'return 130' INT
|
trap 'return 130' INT
|
||||||
trap 'zpty -d nslookup' EXIT
|
trap 'zpty -d nslookup' EXIT
|
||||||
|
|
||||||
zstyle -s ':nslookup' prompt pmpt || pmpt='> '
|
pmpt=()
|
||||||
|
zstyle -s ':nslookup' prompt tmp && pmpt=(-p "$tmp")
|
||||||
|
zstyle -s ':nslookup' rprompt tmp && pmpt=("$pmpt[@]" -r "$tmp")
|
||||||
|
(( $#pmpt )) || pmpt=(-p '> ')
|
||||||
|
|
||||||
zpty nslookup nslookup
|
zpty nslookup nslookup
|
||||||
|
|
||||||
zpty -r nslookup line '*> '
|
zpty -r nslookup line '*> '
|
||||||
print -nr "$line"
|
print -nr "$line"
|
||||||
|
|
||||||
while line=''; vared -p "$pmpt" line; do
|
while line=''; vared -he "$pmpt[@]" line; do
|
||||||
|
print -s "$line"
|
||||||
[[ "$line" = exit ]] && break
|
[[ "$line" = exit ]] && break
|
||||||
|
|
||||||
zpty -w nslookup "$line"
|
zpty -w nslookup "$line"
|
||||||
|
|
||||||
zpty -r nslookup line '*> '
|
zpty -r nslookup line '*> ' || break
|
||||||
print -nr "$line"
|
print -nr "$line"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
|
@ -734,7 +734,7 @@ bin_vared(char *name, char **args, char *ops, int func)
|
||||||
char *s, *t, *ova = varedarg;
|
char *s, *t, *ova = varedarg;
|
||||||
Value v;
|
Value v;
|
||||||
Param pm = 0;
|
Param pm = 0;
|
||||||
int create = 0;
|
int create = 0, ifl;
|
||||||
int type = PM_SCALAR, obreaks = breaks, haso = 0;
|
int type = PM_SCALAR, obreaks = breaks, haso = 0;
|
||||||
char *p1 = NULL, *p2 = NULL;
|
char *p1 = NULL, *p2 = NULL;
|
||||||
FILE *oshout = NULL;
|
FILE *oshout = NULL;
|
||||||
|
@ -787,6 +787,10 @@ bin_vared(char *name, char **args, char *ops, int func)
|
||||||
/* -h option -- enable history */
|
/* -h option -- enable history */
|
||||||
ops['h'] = 1;
|
ops['h'] = 1;
|
||||||
break;
|
break;
|
||||||
|
case 'e':
|
||||||
|
/* -e option -- enable EOF */
|
||||||
|
ops['e'] = 1;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
/* unrecognised option character */
|
/* unrecognised option character */
|
||||||
zwarnnam(name, "unknown option: %s", *args, 0);
|
zwarnnam(name, "unknown option: %s", *args, 0);
|
||||||
|
@ -834,7 +838,15 @@ bin_vared(char *name, char **args, char *ops, int func)
|
||||||
pushnode(bufstack, ztrdup(s));
|
pushnode(bufstack, ztrdup(s));
|
||||||
} LASTALLOC;
|
} LASTALLOC;
|
||||||
varedarg = *args;
|
varedarg = *args;
|
||||||
|
ifl = isfirstln;
|
||||||
|
if (ops['e'])
|
||||||
|
isfirstln = 1;
|
||||||
|
if (ops['h'])
|
||||||
|
hbegin(1);
|
||||||
t = (char *) zleread(p1, p2, ops['h'] ? ZLRF_HISTORY : 0);
|
t = (char *) zleread(p1, p2, ops['h'] ? ZLRF_HISTORY : 0);
|
||||||
|
if (ops['h'])
|
||||||
|
hend();
|
||||||
|
isfirstln = ifl;
|
||||||
varedarg = ova;
|
varedarg = ova;
|
||||||
if (haso) {
|
if (haso) {
|
||||||
close(SHTTY);
|
close(SHTTY);
|
||||||
|
|
Loading…
Reference in a new issue