about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-04-28 22:02:24 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-04-28 22:02:24 +0000
commit9d0a98e05f93c3618191f0bb40270663937b8de6 (patch)
tree3ffe13b9979c2767a7d3e0b6ae00a5aa84ac2580
parentcb801a01033e4b00f3181f956194502a53dbcccd (diff)
downloadzsh-9d0a98e05f93c3618191f0bb40270663937b8de6.tar.gz
zsh-9d0a98e05f93c3618191f0bb40270663937b8de6.tar.xz
zsh-9d0a98e05f93c3618191f0bb40270663937b8de6.zip
zsh-workers:6104
-rw-r--r--Src/Zle/zle_refresh.c15
-rw-r--r--Src/prompt.c19
2 files changed, 24 insertions, 10 deletions
diff --git a/Src/Zle/zle_refresh.c b/Src/Zle/zle_refresh.c
index 6b0239961..0e2cd5601 100644
--- a/Src/Zle/zle_refresh.c
+++ b/Src/Zle/zle_refresh.c
@@ -96,6 +96,7 @@ static int more_start,		/* more text before start of screen?	    */
     olnct,			/* previous number of lines		    */
     ovln,			/* previous video cursor position line	    */
     lpromptw, rpromptw,		/* prompt widths on screen                  */
+    lpromptwof,			/* left prompt width with real end position */
     lprompth,			/* lines taken up by the prompt		    */
     rprompth,			/* right prompt height                      */
     vcs, vln,			/* video cursor position column & line	    */
@@ -141,8 +142,14 @@ resetvideo(void)
 	    *obuf[ln] = '\0';
     }
 
-    countprompt(lpromptbuf, &lpromptw, &lprompth);
-    countprompt(rpromptbuf, &rpromptw, &rprompth);
+    countprompt(lpromptbuf, &lpromptwof, &lprompth, 1);
+    countprompt(rpromptbuf, &rpromptw, &rprompth, 0);
+    if (lpromptwof != winw)
+	lpromptw = lpromptwof;
+    else {
+	lpromptw = 0;
+	lprompth++;
+    }
 
     if (lpromptw) {
     	memset(nbuf[0], ' ', lpromptw);
@@ -327,7 +334,7 @@ zrefresh(void)
             vcs = 0;
         else if (!clearflag && lpromptbuf[0]) {
             zputs(lpromptbuf, shout);
-	    if (lpromptw == 0 && lprompth == 1)
+	    if (lpromptwof == winw)
 		zputs("\n", shout);	/* works with both hasam and !hasam */
 	}
 	if (clearflag) {
@@ -947,7 +954,7 @@ tc_rightcurs(int cl)
 		zputc('\r', shout);
 	    tc_upcurs(lprompth - 1);
 	    zputs(lpromptbuf, shout);
-	    if (lpromptw == 0 && lprompth == 1)
+	    if (lpromptwof == winw)
 		zputs("\n", shout);	/* works with both hasam and !hasam */
 	}
 	i = lpromptw;
diff --git a/Src/prompt.c b/Src/prompt.c
index 69823a5e3..ad7cdbc31 100644
--- a/Src/prompt.c
+++ b/Src/prompt.c
@@ -232,7 +232,7 @@ putpromptchar(int doprint, int endchar)
 		    break;
 		case 'l':
 		    *bp = '\0';
-		    countprompt(bufline, &t0, 0);
+		    countprompt(bufline, &t0, 0, 0);
 		    if (t0 >= arg)
 			test = 1;
 		    break;
@@ -678,11 +678,15 @@ putstr(int d)
 
 /**/
 void
-countprompt(char *str, int *wp, int *hp)
+countprompt(char *str, int *wp, int *hp, int overf)
 {
     int w = 0, h = 1;
     int s = 1;
     for(; *str; str++) {
+	if(w >= columns) {
+	    w = 0;
+	    h++;
+	}
 	if(*str == Meta)
 	    str++;
 	if(*str == Inpar)
@@ -694,12 +698,15 @@ countprompt(char *str, int *wp, int *hp)
 	else if(s) {
 	    if(*str == '\t')
 		w = (w | 7) + 1;
-	    else if(*str == '\n')
-		w = columns;
-	    else
+	    else if(*str == '\n') {
+		w = 0;
+		h++;
+	    } else
 		w++;
 	}
-	if(w >= columns) {
+    }
+    if(w >= columns) {
+	if (!overf || w > columns) {
 	    w = 0;
 	    h++;
 	}