about summary refs log tree commit diff
path: root/Src/Zle/compresult.c
diff options
context:
space:
mode:
authorSven Wischnowsky <wischnow@users.sourceforge.net>2001-05-28 11:42:00 +0000
committerSven Wischnowsky <wischnow@users.sourceforge.net>2001-05-28 11:42:00 +0000
commit1d5fbf228d4c40432a1d5dcc27dad0c20d9dbcd7 (patch)
treec8b0924a0f413f9ad7321a336f03ecdd3747572c /Src/Zle/compresult.c
parent5fe19241552613eba49534a9749df84dbfeb4575 (diff)
downloadzsh-1d5fbf228d4c40432a1d5dcc27dad0c20d9dbcd7.tar.gz
zsh-1d5fbf228d4c40432a1d5dcc27dad0c20d9dbcd7.tar.xz
zsh-1d5fbf228d4c40432a1d5dcc27dad0c20d9dbcd7.zip
fix for cursor positioning with that -y option of compctl (display strings) (14507)
Diffstat (limited to 'Src/Zle/compresult.c')
-rw-r--r--Src/Zle/compresult.c35
1 files changed, 22 insertions, 13 deletions
diff --git a/Src/Zle/compresult.c b/Src/Zle/compresult.c
index 74bc577e7..c1da0fbff 100644
--- a/Src/Zle/compresult.c
+++ b/Src/Zle/compresult.c
@@ -1398,9 +1398,12 @@ calclist(int showall)
 	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 @@ calclist(int showall)
 		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 @@ calclist(int showall)
 			g->width = 1;
 			
 			while (*pp)
-			    glines += 1 + (strlen(*pp++) / columns);
+			    glines += 1 + (ztrlen(*pp++) / columns);
 		    }
 		}
 	    } else {
@@ -1566,7 +1569,7 @@ calclist(int showall)
 		    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 @@ printlist(int over, CLPrintFunc printm, int showall)
 		}
 	    }
 	    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;