zsh-workers
 help / color / mirror / code / Atom feed
* vared and history
@ 2000-01-21  9:36 Sven Wischnowsky
  2000-01-22 19:52 ` Peter Stephenson
  0 siblings, 1 reply; 2+ messages in thread
From: Sven Wischnowsky @ 2000-01-21  9:36 UTC (permalink / raw)
  To: zsh-workers


Again no `PATCH:' in the subject because I'm not sure about this at
all...

The patch just makes bin_vared() call hbegin(1) and hend() when given
the -h option. That's the same loop() does, so it seemed sensible...

Peter: does this look like the right thing for you? It seems to work.

Aside: for functions like nslookup it would be nice if we could have
multiple histories and switch to a separate one in such functions.
Preferably with saving (into another file than the one for the normal
history) and so on...

Another thing is that in functions like nslookup one probably wants to 
be able to use ^D on an empty line to leave vared. I couldn't find a
way to make this possible, so I added the -e option (making it accept
EOF). Is that right? Was there really no way?


The stuff in nslookup just makes it use -e and history and improves
the prompt styles.


Bye
 Sven

diff -ru ../z.old/Doc/Zsh/mod_zle.yo Doc/Zsh/mod_zle.yo
--- ../z.old/Doc/Zsh/mod_zle.yo	Fri Jan 21 10:12:19 2000
+++ Doc/Zsh/mod_zle.yo	Fri Jan 21 10:36:14 2000
@@ -144,7 +144,7 @@
 findex(vared)
 cindex(parameters, editing)
 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
 buffer, and the line editor is invoked.  When the editor exits,
 var(name) is set to the string value returned by the editor.
@@ -161,7 +161,9 @@
 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 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)
 cindex(widgets, rebinding)
diff -ru ../z.old/Functions/Misc/nslookup Functions/Misc/nslookup
--- ../z.old/Functions/Misc/nslookup	Fri Jan 21 10:12:55 2000
+++ Functions/Misc/nslookup	Fri Jan 21 10:32:06 2000
@@ -8,19 +8,23 @@
 trap 'return 130' INT
 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 -r nslookup line '*> '
 print -nr "$line"
 
-while line=''; vared -p "$pmpt" line; do
+while line=''; vared -he "$pmpt[@]" line; do
+  print -s "$line"
   [[ "$line" = exit ]] && break
 
   zpty -w nslookup "$line"
 
-  zpty -r nslookup line '*> '
+  zpty -r nslookup line '*> ' || break
   print -nr "$line"
 done
 
diff -ru ../z.old/Src/Zle/zle_main.c Src/Zle/zle_main.c
--- ../z.old/Src/Zle/zle_main.c	Fri Jan 21 10:12:12 2000
+++ Src/Zle/zle_main.c	Fri Jan 21 10:28:36 2000
@@ -734,7 +734,7 @@
     char *s, *t, *ova = varedarg;
     Value v;
     Param pm = 0;
-    int create = 0;
+    int create = 0, ifl;
     int type = PM_SCALAR, obreaks = breaks, haso = 0;
     char *p1 = NULL, *p2 = NULL;
     FILE *oshout = NULL;
@@ -787,6 +787,10 @@
 		/* -h option -- enable history */
 		ops['h'] = 1;
 		break;
+	    case 'e':
+		/* -e option -- enable EOF */
+		ops['e'] = 1;
+		break;
 	    default:
 		/* unrecognised option character */
 		zwarnnam(name, "unknown option: %s", *args, 0);
@@ -834,7 +838,15 @@
 	pushnode(bufstack, ztrdup(s));
     } LASTALLOC;
     varedarg = *args;
+    ifl = isfirstln;
+    if (ops['e'])
+	isfirstln = 1;
+    if (ops['h'])
+	hbegin(1);
     t = (char *) zleread(p1, p2, ops['h'] ? ZLRF_HISTORY : 0);
+    if (ops['h'])
+	hend();
+    isfirstln = ifl;
     varedarg = ova;
     if (haso) {
 	close(SHTTY);

--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: vared and history
  2000-01-21  9:36 vared and history Sven Wischnowsky
@ 2000-01-22 19:52 ` Peter Stephenson
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Stephenson @ 2000-01-22 19:52 UTC (permalink / raw)
  To: zsh-workers

Sven Wischnowsky wrote:
> 
> Again no `PATCH:' in the subject because I'm not sure about this at
> all...
> 
> The patch just makes bin_vared() call hbegin(1) and hend() when given
> the -h option. That's the same loop() does, so it seemed sensible...
> 
> Peter: does this look like the right thing for you? It seems to work.

Looks all right.  I had the hbegin/hend somewhere else and I still didn't
get the right line, but this way it seems to work.  The other question is
whether we leave it up to the user to add it to the history with print -s.
I suppose that's all right here.

> Another thing is that in functions like nslookup one probably wants to 
> be able to use ^D on an empty line to leave vared. I couldn't find a
> way to make this possible, so I added the -e option (making it accept
> EOF). Is that right? Was there really no way?

The point was probably to allow the editor to get hold of all the
characters.  You could probably bind ^D to accept-line to get pretty much
the same effect, but if you only wanted that on an empty line you would
need your own widget.

> The stuff in nslookup just makes it use -e and history and improves
> the prompt styles.

I missed the nslookup part out because I haven't applied the zpty patch.
I haven't applied that because I don't know if it's going to fail to
compile on some systems.  This may require some more configure tests.  But
it would be a nice library to have.

-- 
Peter Stephenson <pws@pwstephenson.fsnet.co.uk>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2000-01-22 19:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-01-21  9:36 vared and history Sven Wischnowsky
2000-01-22 19:52 ` Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).