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

Patch for long minibuffers



-----BEGIN PGP SIGNED MESSAGE-----

The patch below adds support in zle_refresh.c for a status line
(minibuffer) exceeding one line in length.  It is currently possible to
exceed that length (though only by entering control characters in a
minibuffer, or by making the window narrow), and it messes up the
screen.  After this patch, I think there will only be a problem if the
minibuffer fills the entire screen, and even then I think it will be
handled gracefully.

 -zefram

      *** 1.6	1995/07/21 22:18:29
      --- zle_refresh.c	1995/07/22 21:38:51
      ***************
      *** 109,117 ****
        
        /**/
        int
      ! scrollwindow(void)
        {
      !     int t0, hwinh = winh / 2;
            char *s;
        
            for (t0 = 0; t0 != winh - hwinh; t0++) {
      --- 109,117 ----
        
        /**/
        int
      ! scrollwindow(int hwinh)
        {
      !     int t0;
            char *s;
        
            for (t0 = 0; t0 != winh - hwinh; t0++) {
      ***************
      *** 136,148 ****
        	if (nvln != -1)				\
        	    break;				\
        	else					\
      ! 	    ln = scrollwindow() - 1;		\
            if (!nbuf[++ln])				\
        	nbuf[ln] = (char *)zalloc(winw + 1);	\
            s = (unsigned char *)nbuf[ln];		\
            sen = s + winw;				\
        }
        
        #ifdef TIOCGWINSZ
        int winchanged;			/* window size changed */
        #endif
      --- 136,168 ----
        	if (nvln != -1)				\
        	    break;				\
        	else					\
      ! 	    ln = scrollwindow(winh / 2) - 1;	\
            if (!nbuf[++ln])				\
        	nbuf[ln] = (char *)zalloc(winw + 1);	\
            s = (unsigned char *)nbuf[ln];		\
            sen = s + winw;				\
        }
        
      + #define snextline				\
      + {						\
      +     *s = (unsigned char)'\0';			\
      +     if (ln == winh - 1 && tosln <= nvln + 1) {	\
      + 	ln = scrollwindow(1) - 1;		\
      + 	if(nvln)				\
      + 	    nvln--, tosln--;			\
      +     } else if(ln == winh - 1) {			\
      + 	char *sav = nbuf[--tosln];		\
      + 	for(t0 = tosln; t0 < winh - 1; t0++)	\
      + 	    nbuf[t0] = nbuf[t0 + 1];		\
      + 	nbuf[winh - 1] = sav;			\
      + 	ln--;					\
      +     }						\
      +     if (!nbuf[++ln])				\
      + 	nbuf[ln] = (char *)zalloc(winw + 1);	\
      +     s = (unsigned char *)nbuf[ln];		\
      +     sen = s + winw;				\
      + }
      + 
        #ifdef TIOCGWINSZ
        int winchanged;			/* window size changed */
        #endif
      ***************
      *** 255,299 ****
        	nvcs = 0;
        	nvln++;
            }
      -     *s = '\0';
      -     nlnct = ln + 1;
        
            if (statusline) {
      ! 	if (nvln == winh - 1) {
      ! 	/* cursor is on the last line which is also to be the status line,
      ! 	   so we'll have to scroll, though no need to scroll half screen */
      ! 	    s = (unsigned char *)(nbuf[1]);
      ! 	    for (t0 = 2; t0 < winh; t0++)
      ! 		nbuf[t0 - 1] = nbuf[t0];
      ! 	    nbuf[winh - 1] = (char *)s;
      ! 	    nvln--;
      ! 	    memset(nbuf[0], ' ', pptw);
      ! 	    t0 = winw - pptw;
      ! 	    memset(nbuf[0] + pptw, '\0', t0 + 1);
      ! 	    strncpy(nbuf[0] + pptw, ">....", t0 > 5 ? 5 : t0);
      ! 
      ! 	}
      ! 	if (!nbuf[(nlnct == winh) ? winh - 1 : nlnct++])
      ! 	    nbuf[nlnct - 1] = (char *)zalloc(winw + 1);
      ! 	s = (unsigned char *)nbuf[nlnct - 1];
        	t = (unsigned char *)statusline;
      - 	sen = (unsigned char *)(*nbuf + winw);
        	for (; *t; t++) {
        	    if (icntrl(*t)) {	/* simplified processing in the status line */
      - 		if (s == sen)
      - 		    nextline;
        		*s++ = '^';
        		if (s == sen)
      ! 		    nextline
        		*s++ = (*t == 127) ? '?' : (*t | '@');
      ! 	    } else {
      ! 		if (s == sen)
      ! 		    nextline
        		*s++ = *t;
      ! 	    }
        	}
      - 	*s = '\0';
            }
            for (ln = nlnct; ln < winh; ln++)
        	zfree(nbuf[ln], winw + 1), nbuf[ln] = NULL;
        
      --- 275,300 ----
        	nvcs = 0;
        	nvln++;
            }
        
            if (statusline) {
      ! 	int tosln = ln + 1;
      ! 	snextline
        	t = (unsigned char *)statusline;
        	for (; *t; t++) {
        	    if (icntrl(*t)) {	/* simplified processing in the status line */
        		*s++ = '^';
        		if (s == sen)
      ! 		    snextline
        		*s++ = (*t == 127) ? '?' : (*t | '@');
      ! 	    } else
        		*s++ = *t;
      ! 	    if (s == sen)
      ! 		snextline
        	}
            }
      + 
      +     *s = '\0';
      +     nlnct = ln + 1;
            for (ln = nlnct; ln < winh; ln++)
        	zfree(nbuf[ln], winw + 1), nbuf[ln] = NULL;
        

-----BEGIN PGP SIGNATURE-----
Version: 2.6.i

iQBVAgUBMBF0pWWJ8JfKi+e9AQHNFwH/bgp+BiCQq2+YII3zEECo3OGAD2ZlzXBZ
LZ9lgNdqc57EF501NjM91zkRGs2b5zTGoSNkiVX7lLLXbXsWhrMYog==
=Ifhr
-----END PGP SIGNATURE-----



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