zsh-workers
 help / color / mirror / code / Atom feed
* Re: When does single_line_zle get set?
       [not found] <199506260246.VAA18308@cyclone.xnet.com>
@ 1995-06-26 10:19 ` P.Stephenson
  1995-11-17 16:38   ` Peter Stephenson
  0 siblings, 1 reply; 2+ messages in thread
From: P.Stephenson @ 1995-06-26 10:19 UTC (permalink / raw)
  To: Zsh hackers list

dnelson@xnet.com wrote:
> I just compiled zsh-2.6beta9 (was using 2.6beta-3), and now, on initial
> login shells, single_line_zle mode gets set on me.  I login to an ISP via
> modem, and my terminal defaults to 'unknown'.  It seems that zsh notices
> this and sets single_line_zle (-M) on me.

Looks like the problem is that there is a termcap entry for unknown,
but it can't go up.  The following patch introduces a new state for
the termok flag: it becomes -1 if there is a termcap entry but the
terminal doesn't have up-line capability.  The shell then functions in
single line mode until a better terminal comes along, so in practice
this does what the manual page says.

*** Src/params.c.slz	Mon Jun 26 11:02:48 1995
--- Src/params.c	Mon Jun 26 11:05:39 1995
***************
*** 1662,1672 ****
  	    }
  	}
  
!     /* if there's no termcap entry for cursor up, use single line mode. */
  
  	if (!tccan(TCUP)) {
  		tcstr[TCUP] = NULL;
! 		opts[SINGLELINEZLE] = OPT_SET;
  	}
  	hasam = tgetflag("am");
      /* if there's no termcap entry for cursor left, use \b. */
--- 1662,1675 ----
  	    }
  	}
  
!     /*
!      * If there's no termcap entry for cursor up, use single line mode.
!      * termok is set to -1 to flag this.
!      */
  
  	if (!tccan(TCUP)) {
  		tcstr[TCUP] = NULL;
! 		termok = -1;
  	}
  	hasam = tgetflag("am");
      /* if there's no termcap entry for cursor left, use \b. */
*** Src/zle_misc.c.slz	Mon Jun 26 11:02:48 1995
--- Src/zle_misc.c	Mon Jun 26 11:05:37 1995
***************
*** 678,684 ****
  void
  tsetcap(int cap, int flag)
  {
!     if (termok && !isset(SINGLELINEZLE) && tcstr[cap]) {
  	if (flag == 0) 
  	    tputs(tcstr[cap], 1, putshout);
  	else {
--- 678,684 ----
  void
  tsetcap(int cap, int flag)
  {
!     if (termok == 1 && !isset(SINGLELINEZLE) && tcstr[cap]) {
  	if (flag == 0) 
  	    tputs(tcstr[cap], 1, putshout);
  	else {
*** Src/zle_refresh.c.slz	Mon Jun 26 11:02:48 1995
--- Src/zle_refresh.c	Mon Jun 26 11:05:36 1995
***************
*** 66,72 ****
      static int lwinw = -1, lwinh = -1;	/* last window width & height */
   
      winw = (columns < 1) ? (columns = 80) : columns;  /* terminal width */
!     if (isset(SINGLELINEZLE) || !termok)
  	winh = 1;
      else
  	winh = (lines < 2) ? 24 : lines;
--- 66,72 ----
      static int lwinw = -1, lwinh = -1;	/* last window width & height */
   
      winw = (columns < 1) ? (columns = 80) : columns;  /* terminal width */
!     if (isset(SINGLELINEZLE) || termok != 1)
  	winh = 1;
      else
  	winh = (lines < 2) ? 24 : lines;
***************
*** 191,197 ****
                  cleareol = 1;   /* set */
          if (t0 > -1)
              olnct = t0;
!         if (isset(SINGLELINEZLE) || !termok)
              vcs = 0;
          else if (pptlen && !clearflag) {
              fwrite(pptbuf, pptlen, 1, shout);
--- 191,197 ----
                  cleareol = 1;   /* set */
          if (t0 > -1)
              olnct = t0;
!         if (isset(SINGLELINEZLE) || termok != 1)
              vcs = 0;
          else if (pptlen && !clearflag) {
              fwrite(pptbuf, pptlen, 1, shout);
***************
*** 205,211 ****
  
  /* now winw equals columns; now all width comparisons can be made to winw */
  
!     if (isset(SINGLELINEZLE) || !termok) {
  	singlerefresh();
  	return;
      }
--- 205,211 ----
  
  /* now winw equals columns; now all width comparisons can be made to winw */
  
!     if (isset(SINGLELINEZLE) || termok != 1) {
  	singlerefresh();
  	return;
      }

-- 
Peter Stephenson <P.Stephenson@swansea.ac.uk>  Tel: +44 1792 205678 extn. 4461
WWW:  http://python.swan.ac.uk/~pypeters/      Fax: +44 1792 295324
Department of Physics, University of Wales, Swansea,
Singleton Park, Swansea, SA2 8PP, U.K.


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: When does single_line_zle get set?
  1995-06-26 10:19 ` When does single_line_zle get set? P.Stephenson
@ 1995-11-17 16:38   ` Peter Stephenson
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Stephenson @ 1995-11-17 16:38 UTC (permalink / raw)
  To: Zsh hackers list

Here's a repeat of a patch fixing the following problem:  if the shell
starts with TERM set to something which exists but doesn't have
up-line, SINGLE_LINE_ZLE gets set.  The problem is that it stays set
if the TERM gets changed (unlike if the initial setting was complete
nonsense).  As this happens for an initial setting of `unknown' on a
lot of machines, this is bad news for users.

The new patch is necessary because the termcap code has been moved
around.  I've made it smarter with some definitions, but it does
exactly the same thing it did before.

*** Src/init.c.sl	Fri Nov 17 17:15:16 1995
--- Src/init.c	Fri Nov 17 17:21:40 1995
***************
*** 427,433 ****
  init_term(void)
  {
      if (!*term)
! 	return termok = 0;
  
      /* unset zle if using zsh under emacs */
      if (!strcmp(term, "emacs"))
--- 427,433 ----
  init_term(void)
  {
      if (!*term)
! 	return termok = TERM_BAD;
  
      /* unset zle if using zsh under emacs */
      if (!strcmp(term, "emacs"))
***************
*** 437,448 ****
  	if (isset(INTERACTIVE))
  	    zerr("can't find termcap info for %s", term, 0);
  	errflag = 0;
! 	return termok = 0;
      } else {
  	char tbuf[1024], *pp;
  	int t0;
  
! 	termok = 1;
  	for (t0 = 0; t0 != TC_COUNT; t0++) {
  	    pp = tbuf;
  	    zsfree(tcstr[t0]);
--- 437,448 ----
  	if (isset(INTERACTIVE))
  	    zerr("can't find termcap info for %s", term, 0);
  	errflag = 0;
! 	return termok = TERM_BAD;
      } else {
  	char tbuf[1024], *pp;
  	int t0;
  
! 	termok = TERM_OK;
  	for (t0 = 0; t0 != TC_COUNT; t0++) {
  	    pp = tbuf;
  	    zsfree(tcstr[t0]);
***************
*** 458,467 ****
  	/* check whether terminal has automargin (wraparound) capability */
  	hasam = tgetflag("am");
  
! 	/* if there's no termcap entry for cursor up, use single line mode. */
  	if (!tccan(TCUP)) {
  		tcstr[TCUP] = NULL;
! 		opts[SINGLELINEZLE] = OPT_SET;
  	}
  
  	/* if there's no termcap entry for cursor left, use \b. */
--- 458,469 ----
  	/* check whether terminal has automargin (wraparound) capability */
  	hasam = tgetflag("am");
  
! 	/* if there's no termcap entry for cursor up, use single line mode: *
! 	 * this is flagged by termok which is examined in zle_refresh.c     *
! 	 */
  	if (!tccan(TCUP)) {
  		tcstr[TCUP] = NULL;
! 		termok = TERM_NOUP;
  	}
  
  	/* if there's no termcap entry for cursor left, use \b. */
***************
*** 515,521 ****
      bangchar = '!';
      hashchar = '#';
      hatchar = '^';
!     termok = 0;
      curjob = prevjob = coprocin = coprocout = -1;
      gettimeofday(&shtimer, &dummy_tz);	/* init $SECONDS */
      srand((unsigned int)(shtimer.tv_sec + shtimer.tv_usec)); /* seed $RANDOM */
--- 517,523 ----
      bangchar = '!';
      hashchar = '#';
      hatchar = '^';
!     termok = TERM_BAD;
      curjob = prevjob = coprocin = coprocout = -1;
      gettimeofday(&shtimer, &dummy_tz);	/* init $SECONDS */
      srand((unsigned int)(shtimer.tv_sec + shtimer.tv_usec)); /* seed $RANDOM */
*** Src/params.c.sl	Fri Nov 17 17:24:05 1995
--- Src/params.c	Fri Nov 17 17:22:28 1995
***************
*** 1691,1697 ****
  
      /* If non-interactive, delay setting up term till we need it. */
      if (unset(INTERACTIVE) || !*term)
! 	termok = 0;
      else 
  	init_term();
  }
--- 1691,1697 ----
  
      /* If non-interactive, delay setting up term till we need it. */
      if (unset(INTERACTIVE) || !*term)
! 	termok = TERM_BAD;
      else 
  	init_term();
  }
*** Src/zle_refresh.c.sl	Fri Nov 17 17:18:24 1995
--- Src/zle_refresh.c	Fri Nov 17 17:19:25 1995
***************
*** 66,72 ****
      static int lwinw = -1, lwinh = -1;	/* last window width & height */
   
      winw = (columns < 1) ? (columns = 80) : columns;  /* terminal width */
!     if (isset(SINGLELINEZLE) || !termok)
  	winh = 1;
      else
  	winh = (lines < 2) ? 24 : lines;
--- 66,72 ----
      static int lwinw = -1, lwinh = -1;	/* last window width & height */
   
      winw = (columns < 1) ? (columns = 80) : columns;  /* terminal width */
!     if (isset(SINGLELINEZLE) || termok != TERM_OK)
  	winh = 1;
      else
  	winh = (lines < 2) ? 24 : lines;
***************
*** 196,202 ****
                  cleareol = 1;   /* set */
          if (t0 > -1)
              olnct = t0;
!         if (isset(SINGLELINEZLE) || !termok)
              vcs = 0;
          else if (!clearflag && lpptlen) {
              fwrite(lpptbuf, lpptlen, 1, shout);
--- 196,202 ----
                  cleareol = 1;   /* set */
          if (t0 > -1)
              olnct = t0;
!         if (isset(SINGLELINEZLE) || termok != TERM_OK)
              vcs = 0;
          else if (!clearflag && lpptlen) {
              fwrite(lpptbuf, lpptlen, 1, shout);
***************
*** 210,216 ****
  
  /* now winw equals columns; now all width comparisons can be made to winw */
  
!     if (isset(SINGLELINEZLE) || !termok) {
  	singlerefresh();
  	return;
      }
--- 210,216 ----
  
  /* now winw equals columns; now all width comparisons can be made to winw */
  
!     if (isset(SINGLELINEZLE) || termok != TERM_OK) {
  	singlerefresh();
  	return;
      }
*** Src/zsh.h.sl	Fri Nov 17 17:15:26 1995
--- Src/zsh.h	Fri Nov 17 17:23:31 1995
***************
*** 1130,1135 ****
--- 1130,1142 ----
  #define txtchangeisset(X)	(txtchange & (X))
  #define txtchangeset(X, Y)	(txtchange |= (X), txtchange &= ~(Y))
  
+ /* flags for termok state: usually the test for whether termok is set is
+  * enough: in the refresh code we need to know whether the terminal has
+  * an up capability.
+  */
+ #define TERM_BAD	0
+ #define TERM_OK		1
+ #define TERM_NOUP	2
  
  /*********************/
  /* Definitions for ? */

-- 
Peter Stephenson <pws@ifh.de>       Tel: +49 33762 77366
WWW:  http://www.ifh.de/~pws/       Fax: +49 33762 77330
Deutches Electronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen
DESY-IfH, 15735 Zeuthen, Germany.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1995-11-17 16:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <199506260246.VAA18308@cyclone.xnet.com>
1995-06-26 10:19 ` When does single_line_zle get set? P.Stephenson
1995-11-17 16:38   ` Peter Stephenson

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).