zsh-workers
 help / color / mirror / code / Atom feed
* Re: Saving the zle display stuff
@ 2000-03-13  9:22 Sven Wischnowsky
  2000-03-14 13:21 ` Oliver Kiddle
  0 siblings, 1 reply; 6+ messages in thread
From: Sven Wischnowsky @ 2000-03-13  9:22 UTC (permalink / raw)
  To: zsh-workers


Oliver Kiddle wrote:

> Sven Wischnowsky wrote:
> > 
> > It would be relatively easy to make it remember how long the list
> > below the prompt is (it should already know about the presence of a
> > list -- at least in most cases).
> > So, are you suggesting a zle-option to make it put the prompt `below
> > the list if there is one'?
> 
> Yes: a zle-widget that puts the prompt below the list if there is one.
> That allows me to keep the current list for later reference if I decide
> that I want to.

Hmhm. Dunno if/when I find the time... (or anyone else).

> ...
> 
> Out of interest, why does _setup use zstyle -s followed by [[ "$val" =
> (yes|true|1|on) ]] for various things including last-prompt instead of
> just using zstyle -b (or -t or -T)?

Because it has to distinguish three cases: style not set, style set to 
`true', style set to `false'.

> And in a separate message, Sven wrote:
> > Oliver Kiddle wrote:
> > > Is there a better way for me to have done the equivalent of :*:nothing:_nothing for the -r option?
> >
> > Can't think of a better way... never thought about that. Hm. Is it
> > worth to make _arguments support this directly, i.e. add a syntax
> > saying: `no more arguments after this option'?
> 
> There's probably quite a lot of commands like zpty where they can be
> used in a few separate ways (each with their own set of arguments) and
> for these commands it is useful to avoid the final arguments for some
> forms so if it is fairly simple to do and there is a clear way of
> representing it in the _arguments parameters then it is probably worth
> doing.

Any suggestions for the syntax? (A trailing colon with no description
after it?)

Bye
 Sven


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


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

* Re: Saving the zle display stuff
  2000-03-13  9:22 Saving the zle display stuff Sven Wischnowsky
@ 2000-03-14 13:21 ` Oliver Kiddle
  0 siblings, 0 replies; 6+ messages in thread
From: Oliver Kiddle @ 2000-03-14 13:21 UTC (permalink / raw)
  To: Zsh workers

Sven Wischnowsky wrote:
> > > > Is there a better way for me to have done the equivalent of :*:nothing:_nothing for the -r option?
> > >
> > > Can't think of a better way... never thought about that. Hm. Is it
> > > worth to make _arguments support this directly, i.e. add a syntax
> > > saying: `no more arguments after this option'?
> >
> > There's probably quite a lot of commands like zpty where they can be
> > used in a few separate ways (each with their own set of arguments) and
> > for these commands it is useful to avoid the final arguments for some
> > forms so if it is fairly simple to do and there is a clear way of
> > representing it in the _arguments parameters then it is probably worth
> > doing.
> 
> Any suggestions for the syntax? (A trailing colon with no description
> after it?)

That would be fine.

An alternative which might be worth thinking about is to allow all lines
in _arguments to specify a list of options with which they are mutually
exclusive. So in the vase of _zpty, I would use:
  '(-r)*::args:_normal'
as the last line.

I think this might be more useful. For example consider the case of
AIX's lsvg command for which I recently wrote a completion function.
It's syntax is of the following form:

Usage: lsvg [-o] [-n PVname]
       lsvg [-i] [-M|-l|-p] VGname...

So basically it has two different forms. The trouble is that I can't use
my _nothing trick for -o or -n because I might want to complete a -n
option after a -o option or vice-versa. It worked for zpty's -r option
because -r can only be used on its own. What I would like to do for lsvg
is to use something like:
  '(-o -n)*:volume groups:_volume_groups'
for the last line.

I seem to have some fairly long option exclusion lists in some of my
completions so it might also be worth thinking if there are any better
ways of doing the completion when there are separate forms of the
command. I experimented with a few things like using two calls to
_arguments without much success.

Oliver


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

* Re: Saving the zle display stuff
@ 2000-03-14  9:38 Sven Wischnowsky
  0 siblings, 0 replies; 6+ messages in thread
From: Sven Wischnowsky @ 2000-03-14  9:38 UTC (permalink / raw)
  To: zsh-workers


Oliver Kiddle wrote:

> Sven Wischnowsky wrote:
> > 
> > It would be relatively easy to make it remember how long the list
> > below the prompt is (it should already know about the presence of a
> > list -- at least in most cases).
> > So, are you suggesting a zle-option to make it put the prompt `below
> > the list if there is one'?
> 
> Yes: a zle-widget that puts the prompt below the list if there is one.
> That allows me to keep the current list for later reference if I decide
> that I want to.

I wonder why I never tried to write this before... having wanted that
sometimes, too.


So, this adds the `end-of-list' widget. If the shell knows that there
is a list displayed below the prompt, it puts the prompt below the
list. The name `end-of-list' is modelled after some of the movement
commands, obviously, although this isn't really a movement command, is 
it ok for everyone?

I hope the way how it tries to find out if there is still a list is
correct, please tell me if you find a case where end-of-list has no
effect even though there is still a list or where it moves the prompt
down even though there isn't a list.

There is one case I know about: if you use `zle -R' to display both a
status line and a list and then call `zle end-of-list' directly after
it, the prompt is moved below the list, but where once was the status
line is now an empty line. We would have to save the statusline
displayed with -R, make it be reset whenever needed and make it be
re-used in end-of-list. This didn't seem worth it.


The patch also contains the docs for $MARK, which I had plainly
forgotten, sorry.

Bye
 Sven

diff -ru ../z.old/Doc/Zsh/zle.yo Doc/Zsh/zle.yo
--- ../z.old/Doc/Zsh/zle.yo	Mon Mar 13 17:49:48 2000
+++ Doc/Zsh/zle.yo	Tue Mar 14 09:15:29 2000
@@ -129,6 +129,10 @@
 Attempts to move the cursor outside the buffer will result in the
 cursor being moved to the appropriate end of the buffer.
 )
+vindex(MARK)
+item(tt(MARK) (integer))(
+Like tt(CURSOR), but for the mark.
+)
 vindex(LBUFFER)
 item(tt(LBUFFER) (scalar))(
 The part of the buffer that lies to the left of the cursor position.
@@ -937,6 +941,11 @@
 Perform menu completion, like tt(menu-complete), except that if
 a menu completion is already in progress, move to the em(previous)
 completion rather than the next.
+)
+tindex(end-of-list)
+item(tt(end-of-list))(
+When a previous completion displayed a list below the prompt, this
+widget can be used to move the prompt below the list.
 )
 enditem()
 texinode(Miscellaneous)()(Completion)(Zsh Line Editor)
diff -ru ../z.old/Src/Zle/compresult.c Src/Zle/compresult.c
--- ../z.old/Src/Zle/compresult.c	Tue Mar 14 09:12:32 2000
+++ Src/Zle/compresult.c	Tue Mar 14 09:15:29 2000
@@ -1528,6 +1528,7 @@
     showinglist = listshown = 0;
 
     clearflag = (isset(USEZLE) && !termflags && dolastprompt);
+    lastlistlen = 0;
 
     /* Maybe we have to ask if the user wants to see the list. */
     if ((!minfo.cur || !minfo.asked) &&
@@ -1756,16 +1757,20 @@
 	    pnl = 1;
 	g = g->next;
     }
+    lastlistlen = 0;
     if (clearflag) {
 	/* Move the cursor up to the prompt, if always_last_prompt *
 	 * is set and all that...                                  */
 	if ((ml = listdat.nlines + nlnct - 1) < lines) {
 	    tcmultout(TCUP, TCMULTUP, ml);
 	    showinglist = -1;
+
+	    lastlistlen = listdat.nlines;
 	} else
 	    clearflag = 0, putc('\n', shout);
     } else
 	putc('\n', shout);
+
     listshown = (clearflag ? 1 : -1);
 
     return printed;
diff -ru ../z.old/Src/Zle/iwidgets.list Src/Zle/iwidgets.list
--- ../z.old/Src/Zle/iwidgets.list	Tue Mar 14 10:37:16 2000
+++ Src/Zle/iwidgets.list	Tue Mar 14 10:37:21 2000
@@ -44,6 +44,7 @@
 "end-of-history", endofhistory, 0
 "end-of-line", endofline, 0
 "end-of-line-hist", endoflinehist, 0
+"end-of-list", endoflist, ZLE_MENUCMP | ZLE_KEEPSUFFIX | ZLE_LASTCOL
 "exchange-point-and-mark", exchangepointandmark, 0
 "execute-last-named-cmd", NULL, 0
 "execute-named-cmd", NULL, 0
diff -ru ../z.old/Src/Zle/zle_main.c Src/Zle/zle_main.c
--- ../z.old/Src/Zle/zle_main.c	Tue Mar 14 09:12:33 2000
+++ Src/Zle/zle_main.c	Tue Mar 14 09:15:30 2000
@@ -593,7 +593,7 @@
     trashzle();
     free(lpromptbuf);
     free(rpromptbuf);
-    zleactive = zlereadflags = 0;
+    zleactive = zlereadflags = lastlistlen = 0;
     alarm(0);
 
     freeundo();
diff -ru ../z.old/Src/Zle/zle_misc.c Src/Zle/zle_misc.c
--- ../z.old/Src/Zle/zle_misc.c	Tue Mar 14 09:12:33 2000
+++ Src/Zle/zle_misc.c	Tue Mar 14 09:15:30 2000
@@ -641,7 +641,7 @@
 {
     Thingy cmd;
     int len, l = strlen(prmt), feep = 0, listed = 0, curlist = 0;
-    int ols = (listshown && validlist);
+    int ols = (listshown && validlist), olll = lastlistlen;
     char *ptr;
     char *okeymap = curkeymapname;
 
@@ -659,9 +659,10 @@
 	if (!(cmd = getkeycmd()) || cmd == Th(z_sendbreak)) {
 	    statusline = NULL;
 	    selectkeymap(okeymap, 1);
-	    if ((listshown = ols))
+	    if ((listshown = ols)) {
 		showinglist = -2;
-	    else if (listed)
+		lastlistlen = olll;
+	    } else if (listed)
 		clearlist = listshown = 1;
 
 	    return NULL;
@@ -725,9 +726,10 @@
 		    unrefthingy(r);
 		    statusline = NULL;
 		    selectkeymap(okeymap, 1);
-		    if ((listshown = ols))
+		    if ((listshown = ols)) {
 			showinglist = -2;
-		    else if (listed)
+			lastlistlen = olll;
+		    } else if (listed)
 			clearlist = listshown = 1;
 		    return r;
 		}
diff -ru ../z.old/Src/Zle/zle_refresh.c Src/Zle/zle_refresh.c
--- ../z.old/Src/Zle/zle_refresh.c	Tue Mar 14 09:12:33 2000
+++ Src/Zle/zle_refresh.c	Tue Mar 14 09:15:30 2000
@@ -59,6 +59,11 @@
 /**/
 mod_export int listshown;
 
+/* Length of last list displayed (if it is below the prompt). */
+
+/**/
+mod_export int lastlistlen;
+
 /* Non-zero if ALWAYS_LAST_PROMPT has been used, meaning that the *
  * screen below the buffer display should not be cleared by       *
  * zrefresh(), but should be by trashzle().                       */
@@ -282,7 +287,7 @@
 	    clearflag = 0;
 	    resetneeded = 1;
 	}
-	listshown = 0;
+	listshown = lastlistlen = 0;
 	if (showinglist != -2)
 	    showinglist = 0;
     }
diff -ru ../z.old/Src/Zle/zle_thingy.c Src/Zle/zle_thingy.c
--- ../z.old/Src/Zle/zle_thingy.c	Tue Mar 14 09:12:33 2000
+++ Src/Zle/zle_thingy.c	Tue Mar 14 10:32:29 2000
@@ -416,12 +416,18 @@
 
 	    zmult = 1;
 	    listlist(l);
+	    if (statusline)
+		lastlistlen++;
 	    showinglist = clearlist = 0;
 	    zmult = zmultsav;
-	} else if (ops['c'])
+	} else if (ops['c']) {
 	    clearlist = 1;
-    } else if (ops['c'])
+	    lastlistlen = 0;
+	}
+    } else if (ops['c']) {
 	clearlist = listshown = 1;
+	lastlistlen = 0;
+    }
     zrefresh();
 
     clearlist = ocl;
diff -ru ../z.old/Src/Zle/zle_tricky.c Src/Zle/zle_tricky.c
--- ../z.old/Src/Zle/zle_tricky.c	Tue Mar 14 09:12:34 2000
+++ Src/Zle/zle_tricky.c	Tue Mar 14 10:30:08 2000
@@ -2009,6 +2009,8 @@
 	    putc('\n', shout);
 	settyinfo(&shttyinfo);
     }
+    lastlistlen = (clearflag ? nlines : 0);
+
     if (ncols) {
 	if (isset(LISTROWSFIRST)) {
 	    for (col = 1, p = data, lenp = lens; *p;
@@ -2252,4 +2254,27 @@
     ret = expandorcomplete(args);
     comppref = 0;
     return ret;
+}
+
+/**/
+int
+endoflist(char **args)
+{
+    if (lastlistlen > 0) {
+	int i;
+
+	clearflag = 0;
+	trashzle();
+
+	for (i = lastlistlen; i > 0; i--)
+	    putc('\n', shout);
+
+	showinglist = lastlistlen = 0;
+
+	if (sfcontext)
+	    zrefresh();
+
+	return 0;
+    }
+    return 1;
 }

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


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

* Re: Saving the zle display stuff
  2000-03-09 14:45 Sven Wischnowsky
@ 2000-03-10 16:47 ` Oliver Kiddle
  0 siblings, 0 replies; 6+ messages in thread
From: Oliver Kiddle @ 2000-03-10 16:47 UTC (permalink / raw)
  To: Sven Wischnowsky; +Cc: zsh-workers

Sven Wischnowsky wrote:
> 
> It would be relatively easy to make it remember how long the list
> below the prompt is (it should already know about the presence of a
> list -- at least in most cases).
> So, are you suggesting a zle-option to make it put the prompt `below
> the list if there is one'?

Yes: a zle-widget that puts the prompt below the list if there is one.
That allows me to keep the current list for later reference if I decide
that I want to.

> If you are only concerned about completion: there is the last-prompt
> style. But unfortunately, this doesn't work with _complete_help
> because that doesn't set up it's own $curcontext, and, I think, it
> shouldn't because we call it to get information about normal
> completion in the same context. Hm. We could make _complete_help test
> the last-prompt style directly with a context like
> `:completion:complete-help::::' and if it is true, set
> `compstate[last_prompt]=yes'.

That would be useful, though the widget would be better.
I couldn't actually get this to work. Even just putting
compstate[last_prompt]='yes' before the compadd in _complete_word didn't
work.

Out of interest, why does _setup use zstyle -s followed by [[ "$val" =
(yes|true|1|on) ]] for various things including last-prompt instead of
just using zstyle -b (or -t or -T)?

And in a separate message, Sven wrote:
> Oliver Kiddle wrote:
> > Is there a better way for me to have done the equivalent of :*:nothing:_nothing for the -r option?
>
> Can't think of a better way... never thought about that. Hm. Is it
> worth to make _arguments support this directly, i.e. add a syntax
> saying: `no more arguments after this option'?

There's probably quite a lot of commands like zpty where they can be
used in a few separate ways (each with their own set of arguments) and
for these commands it is useful to avoid the final arguments for some
forms so if it is fairly simple to do and there is a clear way of
representing it in the _arguments parameters then it is probably worth
doing.

Oliver


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

* Re: Saving the zle display stuff
@ 2000-03-09 14:45 Sven Wischnowsky
  2000-03-10 16:47 ` Oliver Kiddle
  0 siblings, 1 reply; 6+ messages in thread
From: Sven Wischnowsky @ 2000-03-09 14:45 UTC (permalink / raw)
  To: zsh-workers


Oliver Kiddle wrote:

> Is it possible to have a zle widget which saves any text (completion
> list etc) which is below the prompt (as if ALWAYS_LAST_PROMPT was set
> when the list was generated). The nearest I can get to this is:
> save_list() {
>   unsetopt alwayslastprompt
>   zle list-choices
>   setopt alwasylastprompt
> }
> 
> This would be particularly useful with _complete_help where I often want
> to cut-and-paste to a zstyle command or refer back to the information
> later.
> 
> I'd guess that zle prints lists and doesn't remember where it finished
> so this isn't easy to do. If this is correct, the solution may relate to
> the stuff with calling zle from traps and establishing if there is a
> completion list from there.

It would be relatively easy to make it remember how long the list
below the prompt is (it should already know about the presence of a
list -- at least in most cases).

So, are you suggesting a zle-option to make it put the prompt `below
the list if there is one'?


If you are only concerned about completion: there is the last-prompt
style. But unfortunately, this doesn't work with _complete_help
because that doesn't set up it's own $curcontext, and, I think, it
shouldn't because we call it to get information about normal
completion in the same context. Hm. We could make _complete_help test
the last-prompt style directly with a context like
`:completion:complete-help::::' and if it is true, set
`compstate[last_prompt]=yes'.


Bye
 Sven


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


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

* Saving the zle display stuff
@ 2000-03-09 12:52 Oliver Kiddle
  0 siblings, 0 replies; 6+ messages in thread
From: Oliver Kiddle @ 2000-03-09 12:52 UTC (permalink / raw)
  To: Zsh workers

Is it possible to have a zle widget which saves any text (completion
list etc) which is below the prompt (as if ALWAYS_LAST_PROMPT was set
when the list was generated). The nearest I can get to this is:
save_list() {
  unsetopt alwayslastprompt
  zle list-choices
  setopt alwasylastprompt
}

This would be particularly useful with _complete_help where I often want
to cut-and-paste to a zstyle command or refer back to the information
later.

I'd guess that zle prints lists and doesn't remember where it finished
so this isn't easy to do. If this is correct, the solution may relate to
the stuff with calling zle from traps and establishing if there is a
completion list from there.

Oliver Kiddle


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

end of thread, other threads:[~2000-03-14 13:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-03-13  9:22 Saving the zle display stuff Sven Wischnowsky
2000-03-14 13:21 ` Oliver Kiddle
  -- strict thread matches above, loose matches on Subject: below --
2000-03-14  9:38 Sven Wischnowsky
2000-03-09 14:45 Sven Wischnowsky
2000-03-10 16:47 ` Oliver Kiddle
2000-03-09 12:52 Oliver Kiddle

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).