zsh-workers
 help / color / mirror / code / Atom feed
From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.dk
Subject: Re: compctl -y problem.
Date: Mon, 28 May 2001 13:39:59 +0200 (MET DST)	[thread overview]
Message-ID: <200105281139.NAA08249@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: <1010525151112.ZM14441@candle.brasslantern.com>

Bart Schaefer wrote:

> ...
> 
> I know Sven won't be thrilled about being asked to fix anything in the
> old compctl code ...

Indeed, though the patch below seems to fix it for me.

> perhaps we should just remove the `-y' option, as
> it's new since 3.0 anyway,

I think I suggested this some time ago. It would be really nice because
currently it's the biggest piece of code dangling in the base completion
code (`complete' module) that's specific to compctl.

> and document the correct way to achieve the
> same effect by using the new completion system (which, incidentally, I
> don't know how to do ... `compadd -d' doesn't quite cut it).

You already mentioned `compadd -ld' in another mail. I prefer this a lot
because there we have a one-to-one correspondence between matches and
strings to display, meaning that things like menu selection work
properly.  If there are other strings one want to have displayed
together with the list one can always use `compadd -X' or `compadd -x'.

Bye
  Sven

Index: Src/Zle/compresult.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/compresult.c,v
retrieving revision 1.36
diff -u -r1.36 compresult.c
--- Src/Zle/compresult.c	2001/03/27 09:14:52	1.36
+++ Src/Zle/compresult.c	2001/05/28 11:40:13
@@ -1398,9 +1398,12 @@
 	if (!onlyexpl && pp) {
 	    /* We have an ylist, lets see, if it contains newlines. */
 	    hidden = 1;
-	    while (!nl && *pp)
-		nl = !!strchr(*pp++, '\n');
-
+	    while (!nl && *pp) {
+                if (ztrlen(*pp) >= columns)
+                    nl = 1;
+                else
+                    nl = !!strchr(*pp++, '\n');
+            }
 	    pp = g->ylist;
 	    if (nl || !pp[1]) {
 		/* Yup, there are newlines, count lines. */
@@ -1411,17 +1414,17 @@
 		while ((sptr = *pp)) {
 		    while (sptr && *sptr) {
 			nlines += (nlptr = strchr(sptr, '\n'))
-			    ? 1 + (nlptr-sptr) / columns
-			    : strlen(sptr) / columns;
+			    ? 1 + (nlptr - sptr - 1) / columns
+			    : (ztrlen(sptr) - 1) / columns;
 			sptr = nlptr ? nlptr+1 : NULL;
 		    }
 		    nlines++;
 		    pp++;
 		}
-		nlines--;
+		/*** nlines--; */
 	    } else {
 		while (*pp) {
-		    l = strlen(*pp);
+		    l = ztrlen(*pp);
 		    ndisp++;
 		    if (l > glong)
 			glong = l;
@@ -1524,7 +1527,7 @@
 			g->width = 1;
 			
 			while (*pp)
-			    glines += 1 + (strlen(*pp++) / columns);
+			    glines += 1 + (ztrlen(*pp++) / columns);
 		    }
 		}
 	    } else {
@@ -1566,7 +1569,7 @@
 		    VARARR(int, ylens, yl);
 
 		    for (i = 0; *pp; i++, pp++)
-			ylens[i] = strlen(*pp) + add;
+			ylens[i] = ztrlen(*pp) + add;
 
 		    if (g->flags & CGF_ROWS) {
 			int count, tcol, first, maxlines = 0, llines;
@@ -1913,10 +1916,16 @@
 		}
 	    }
 	    if (g->flags & CGF_LINES) {
-		while (*pp) {
-		    zputs(*pp, shout);
-		    if (*++pp)
-			putc('\n', shout);
+                char *p;
+
+		while ((p = *pp++)) {
+		    zputs(p, shout);
+		    if (*pp) {
+                        if (ztrlen(p) % columns)
+                            putc('\n', shout);
+                        else
+                            fputs(" \010", shout);
+                    }
 		}
 	    } else {
 		int n = g->lcount, nl, nc, i, a;

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


      parent reply	other threads:[~2001-05-28 11:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <E15305g-0002SP-00@sevilla>
2001-05-25 15:11 ` Bart Schaefer
2001-05-25 16:35   ` Bart Schaefer
2001-05-28 11:39   ` Sven Wischnowsky [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200105281139.NAA08249@beta.informatik.hu-berlin.de \
    --to=wischnow@informatik.hu-berlin.de \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).