Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: 3.1.5-pws-15: multiline prompt



Heyla,
see discussion under "yet another undesired 3.1.5-pws-15 change"

This should do what you want:

*** prompt.c.org	Thu Nov 12 03:04:38 1998
--- prompt.c	Mon Apr 26 01:15:25 1999
***************
*** 232,238 ****
  		    break;
  		case 'l':
  		    *bp = '\0';
! 		    countprompt(bufline, &t0, 0);
  		    if (t0 >= arg)
  			test = 1;
  		    break;
--- 232,238 ----
  		    break;
  		case 'l':
  		    *bp = '\0';
! 		    countprompt(bufline, &t0, 0, 0);
  		    if (t0 >= arg)
  			test = 1;
  		    break;
***************
*** 678,688 ****
  
  /**/
  void
! countprompt(char *str, int *wp, int *hp)
  {
      int w = 0, h = 1;
      int s = 1;
      for(; *str; str++) {
  	if(*str == Meta)
  	    str++;
  	if(*str == Inpar)
--- 678,692 ----
  
  /**/
  void
! 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,705 ****
  	else if(s) {
  	    if(*str == '\t')
  		w = (w | 7) + 1;
! 	    else if(*str == '\n')
! 		w = columns;
! 	    else
  		w++;
  	}
! 	if(w >= columns) {
  	    w = 0;
  	    h++;
  	}
--- 698,712 ----
  	else if(s) {
  	    if(*str == '\t')
  		w = (w | 7) + 1;
! 	    else if(*str == '\n') {
! 		w = 0;
! 		h++;
! 	    } else
  		w++;
  	}
!     }
!     if(w >= columns) {
! 	if (!overf || w > columns) {
  	    w = 0;
  	    h++;
  	}
*** Zle/zle_refresh.c.org	Tue Apr 13 18:07:18 1999
--- Zle/zle_refresh.c	Mon Apr 26 01:11:29 1999
***************
*** 96,101 ****
--- 96,102 ----
      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,148 ****
  	    *obuf[ln] = '\0';
      }
  
!     countprompt(lpromptbuf, &lpromptw, &lprompth);
!     countprompt(rpromptbuf, &rpromptw, &rprompth);
  
      if (lpromptw) {
      	memset(nbuf[0], ' ', lpromptw);
--- 142,155 ----
  	    *obuf[ln] = '\0';
      }
  
!     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,333 ****
              vcs = 0;
          else if (!clearflag && lpromptbuf[0]) {
              zputs(lpromptbuf, shout);
! 	    if (lpromptw == 0)
  		zputs("\n", shout);	/* works with both hasam and !hasam */
  	}
  	if (clearflag) {
--- 334,340 ----
              vcs = 0;
          else if (!clearflag && lpromptbuf[0]) {
              zputs(lpromptbuf, shout);
! 	    if (lpromptwof == winw)
  		zputs("\n", shout);	/* works with both hasam and !hasam */
  	}
  	if (clearflag) {
***************
*** 947,953 ****
  		zputc('\r', shout);
  	    tc_upcurs(lprompth - 1);
  	    zputs(lpromptbuf, shout);
! 	    if (lpromptw == 0)
  		zputs("\n", shout);	/* works with both hasam and !hasam */
  	}
  	i = lpromptw;
--- 954,960 ----
  		zputc('\r', shout);
  	    tc_upcurs(lprompth - 1);
  	    zputs(lpromptbuf, shout);
! 	    if (lpromptwof == winw)
  		zputs("\n", shout);	/* works with both hasam and !hasam */
  	}
  	i = lpromptw;

-- 
Geoff Wing   <gcw@xxxxxxxxx>            Mobile : (Australia) 0413 431 874 <<<new
Work URL: http://www.primenet.com.au/   Ego URL: http://pobox.com/~gcw/



Messages sorted by: Reverse Date, Date, Thread, Author