1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-01 09:41:44 +02:00

make nslookup page it's output if too long for screen (11177)

This commit is contained in:
Sven Wischnowsky 2000-05-05 08:52:40 +00:00
parent c844ad8712
commit d4d35a114c
2 changed files with 36 additions and 24 deletions

View file

@ -1,5 +1,8 @@
2000-05-05 Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
* 11177: Functions/Misc/nslookup: make nslookup page it's output
if too long for screen
* Wayne: 11171: Src/builtin.c, Src/hist.c: fix for print -s when
called from widget; added lines are not immediately available,
though

View file

@ -1,34 +1,43 @@
# Simple wrapper function for `nslookup'. With completion if you are using
# the function based completion system.
setopt localoptions completealiases
setopt localoptions localtraps completealiases
local char line compcontext=nslookup pid
local tmp line compcontext=nslookup curcontext='nslookup:::' pmpt
local pager opager="$PAGER"
typeset +g -x PAGER=cat
trap 'print -p exit;return' INT
zmodload -e zsh/zpty || zmodload -i zsh/zpty
coproc command nslookup
pid=$!
trap 'return 130' INT
trap 'zpty -d nslookup' EXIT
while read -pk1 char; do
line="$line$char"
[[ "$line" = *'
> ' ]] && break
done
print -nr - "$line"
pmpt=()
zstyle -s ':nslookup' prompt tmp && pmpt=(-p "$tmp")
zstyle -s ':nslookup' rprompt tmp && pmpt=("$pmpt[@]" -r "$tmp")
zstyle -s ':nslookup' pager tmp &&
[[ -z "$pager" ]] && pager="${opager:-more}"
(( $#pmpt )) || pmpt=(-p '> ')
line=''
while vared -p '> ' line; do
print -p "$line"
line=''
while read -pk1 char; do
line="$line$char"
[[ "$line" = *'
> ' ]] && break
done
print -nr - "$line"
line=''
zpty nslookup nslookup
zpty -r nslookup line '*
> '
print -nr "$line"
while line=''; vared -he "$pmpt[@]" line; do
print -s "$line"
[[ "$line" = exit ]] && break
zpty -w nslookup "$line"
zpty -r nslookup line '*
> '
if [[ -n "$pager" && ${#${(f)line}} -gt LINES ]]; then
print -nr "$line" | "$pager"
else
print -nr "$line"
fi
done
print -p exit
wait $pid
zpty -w nslookup 'exit'