about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--Functions/Misc/nslookup59
2 files changed, 37 insertions, 25 deletions
diff --git a/ChangeLog b/ChangeLog
index 34b5d21aa..215cd6fc5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/Functions/Misc/nslookup b/Functions/Misc/nslookup
index 15afb2ff1..e03e55cd5 100644
--- a/Functions/Misc/nslookup
+++ b/Functions/Misc/nslookup
@@ -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"
-
-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=''
+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 '> ')
+
+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'