zsh-users
 help / color / mirror / code / Atom feed
* zsh always resets LINES to 24.
@ 1997-09-03  2:55 Jahwan Kim
  1997-09-03  4:40 ` Zoltan Hidvegi
  0 siblings, 1 reply; 6+ messages in thread
From: Jahwan Kim @ 1997-09-03  2:55 UTC (permalink / raw)
  To: zsh-users

Hi all,
    Maybe my post didn't propagated well...
    
    My environment is 31x80 vt-100 (pseudo-)emulator, OSTYPE=solaris2.5.1, and
TERM=vt100.  Of course, the terminfo entry of vt100 specifies that it
has 24 lines.  So in my .zshrc, I detect where I login from, and reset LINES
if I login from home:  export LINES=31.
    Then at the very first prompt, echo $LINES gives me 24.
    
    So I set out to read man pages, faq, and dejanews.  Found out ttyctl
might have something.  Added ttyctl -f in my .zshrc:
export LINES=31; ttyctl -f.  Nope.  ttyctl -f; export LINES=31.  Again
LINES goes back to 24.

    I experimented a bit more.  I typeset LINES read-only.  Well,
surprisingly or not-so-surprisingly, something is always trying to reset
LINES=24.  I get the error message: 
zsh: read-only variable: LINES
after every external commands.  Nowhere in the man page could I found a
explanation  (I typed /LINES in man zshall.) 
	
    What gives?  This is not a correct behaviour, is it?  Am I missing
something obvious?
	    
TIA,
Jahwan	    


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

* Re: zsh always resets LINES to 24.
  1997-09-03  2:55 zsh always resets LINES to 24 Jahwan Kim
@ 1997-09-03  4:40 ` Zoltan Hidvegi
  1997-09-03  8:27   ` Andrew Main
  1997-09-04  1:15   ` Jahwan Kim
  0 siblings, 2 replies; 6+ messages in thread
From: Zoltan Hidvegi @ 1997-09-03  4:40 UTC (permalink / raw)
  To: Jahwan Kim; +Cc: zsh-users

> Hi all,
>     Maybe my post didn't propagated well...

Well, that's the first time I read it.

>     
>     My environment is 31x80 vt-100 (pseudo-)emulator, OSTYPE=solaris2.5.1, and
> TERM=vt100.  Of course, the terminfo entry of vt100 specifies that it
> has 24 lines.  So in my .zshrc, I detect where I login from, and reset LINES
> if I login from home:  export LINES=31.
>     Then at the very first prompt, echo $LINES gives me 24.

Zsh sets LINES and columns to the value obtained from the TIOCGWINSZ
ioctl.  This way, when you resize you xterm, the LINES parameter will
change too.  Normally, when you resize your window, xterm sends SIGWINCH
to the process group of its terminal.  Zsh catches this signal, and
adjusts the window size.  So far so good, you do not resize you terminal,
so zsh does not get SIGWINCH, LINES should not change.  Unfortunately,
it's not that simple.  When zsh runs interactively, the MONITOR option is
enabled to allow you to use fg, bg, ^Z etc.  But this means that when you
start a foreground process, it will run in a separate process group from
zsh, and the terminal's process group is set to the foreground job's
process group.  As a consequence, zsh cannot handle the SIGWINCH signals
xterm sends when you resize the window, so when a foreground process
terminates, zsh goes and asks the terminal for its size.  If the terminal
says that it has 24 lines, zsh just assumes that it was resized, and
sets LINES to 24 even if you had set it to 31 before.

This really means that assigning LINES does not make too much sense.  It
is usefull only on systems which do not have TIOCGWINSZ.

The patch below is an attempt to cure this.  When you manually set
LINES or COLUMNS to something which is different from the last value
returned by TIOCGWINSZ, zsh will not touch it unless it receives a real
SIGWINCH signal.  I hope this helps.  If anyone has a better solution,
please tell me.

Zoltan


*** Src/init.c	1997/07/13 05:24:42	3.1.3.1
--- Src/init.c	1997/09/03 04:28:04
***************
*** 523,533 ****
      createparamtable();     /* create paramater hash table             */
  
  #ifdef TIOCGWINSZ
!     adjustwinsize();
  #else
!     /* Using zero below sets the defaults from termcap */
!     setiparam("COLUMNS", 0);
!     setiparam("LINES", 0);
  #endif
  
  #ifdef HAVE_GETRLIMIT
--- 523,535 ----
      createparamtable();     /* create paramater hash table             */
  
  #ifdef TIOCGWINSZ
!     adjustwinsize(0);
  #else
!     /* columns and lines are normally zero, unless something different *
!      * was inhereted from the environment.  If either of them are zero *
!      * the setiparam calls below set them to the defaults from termcap */
!     setiparam("COLUMNS", columns);
!     setiparam("LINES", lines);
  #endif
  
  #ifdef HAVE_GETRLIMIT
*** Src/jobs.c	1997/06/30 04:48:17	3.1.3.6
--- Src/jobs.c	1997/09/03 03:58:04
***************
*** 167,173 ****
  	if (mypgrp != pgrp && inforeground &&
  	    (jn->gleader == pgrp || (pgrp > 1 && kill(-pgrp, 0) == -1))) {
  	    attachtty(mypgrp);
! 	    adjustwinsize();   /* check window size and adjust if necessary */
  	}
      }
  
--- 167,173 ----
  	if (mypgrp != pgrp && inforeground &&
  	    (jn->gleader == pgrp || (pgrp > 1 && kill(-pgrp, 0) == -1))) {
  	    attachtty(mypgrp);
! 	    adjustwinsize(0);   /* check window size and adjust if necessary */
  	}
      }
  
*** Src/signals.c	1997/06/05 04:44:57	3.1.3.0
--- Src/signals.c	1997/09/03 03:58:10
***************
*** 489,495 ****
  
  #ifdef SIGWINCH
      case SIGWINCH:
!         adjustwinsize();  /* check window size and adjust */
  	if (sigtrapped[SIGWINCH])
  	    dotrap(SIGWINCH);
          break;
--- 489,495 ----
  
  #ifdef SIGWINCH
      case SIGWINCH:
!         adjustwinsize(1);  /* check window size and adjust */
  	if (sigtrapped[SIGWINCH])
  	    dotrap(SIGWINCH);
          break;
*** Src/utils.c	1997/08/02 20:00:18	3.1.3.3
--- Src/utils.c	1997/09/03 04:33:09
***************
*** 790,810 ****
  
  /**/
  void
! adjustwinsize(void)
  {
  #ifdef TIOCGWINSZ
!     int oldcols = columns, oldrows = lines;
  
!     if (SHTTY == -1)
  	return;
  
      ioctl(SHTTY, TIOCGWINSZ, (char *)&shttyinfo.winsize);
      setiparam("COLUMNS", shttyinfo.winsize.ws_col);
      setiparam("LINES", shttyinfo.winsize.ws_row);
!     if (zleactive && (oldcols != columns || oldrows != lines)) {
  	resetneeded = winchanged = 1;
  	refresh();
      }
  #endif   /* TIOCGWINSZ */
  }
  
--- 790,812 ----
  
  /**/
  void
! adjustwinsize(int fromsig)
  {
  #ifdef TIOCGWINSZ
!     static int oldcols, oldrows;
  
!     if (SHTTY == -1 || (!fromsig && (columns != oldcols || lines != oldrows)))
  	return;
  
      ioctl(SHTTY, TIOCGWINSZ, (char *)&shttyinfo.winsize);
      setiparam("COLUMNS", shttyinfo.winsize.ws_col);
      setiparam("LINES", shttyinfo.winsize.ws_row);
!     if (zleactive && (fromsig || oldcols != columns || oldrows != lines)) {
  	resetneeded = winchanged = 1;
  	refresh();
      }
+     oldcols = columns;
+     oldrows = lines;
  #endif   /* TIOCGWINSZ */
  }
  


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

* Re: zsh always resets LINES to 24.
  1997-09-03  4:40 ` Zoltan Hidvegi
@ 1997-09-03  8:27   ` Andrew Main
  1997-09-03 15:44     ` Bart Schaefer
  1997-09-04  1:15   ` Jahwan Kim
  1 sibling, 1 reply; 6+ messages in thread
From: Andrew Main @ 1997-09-03  8:27 UTC (permalink / raw)
  To: Zoltan Hidvegi; +Cc: jahwan, zsh-users

Zoltan Hidvegi wrote:
>The patch below is an attempt to cure this.  When you manually set
>LINES or COLUMNS to something which is different from the last value
>returned by TIOCGWINSZ, zsh will not touch it unless it receives a real
>SIGWINCH signal.  I hope this helps.  If anyone has a better solution,
>please tell me.

Better solution: when setting LINES or COLUMNS, use the appropriate
ioctl to set the tty window size to the user-specified value.

-zefram


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

* Re: zsh always resets LINES to 24.
  1997-09-03  8:27   ` Andrew Main
@ 1997-09-03 15:44     ` Bart Schaefer
  1997-09-03 16:13       ` Andrew Main
  0 siblings, 1 reply; 6+ messages in thread
From: Bart Schaefer @ 1997-09-03 15:44 UTC (permalink / raw)
  To: zsh-users

On Sep 3,  9:27am, Andrew Main wrote:
} Subject: Re: zsh always resets LINES to 24.
}
} Better solution: when setting LINES or COLUMNS, use the appropriate
} ioctl to set the tty window size to the user-specified value.

I'm not sure that's really a good idea.  If I start an xterm with one
geometry from inside an xterm with a different geometry, I don't want
zsh trying to change the size of the second one to match the first.

Just believe what the user tells you and leave the rest alone.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


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

* Re: zsh always resets LINES to 24.
  1997-09-03 15:44     ` Bart Schaefer
@ 1997-09-03 16:13       ` Andrew Main
  0 siblings, 0 replies; 6+ messages in thread
From: Andrew Main @ 1997-09-03 16:13 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-users

Bart Schaefer wrote:
>} Better solution: when setting LINES or COLUMNS, use the appropriate
>} ioctl to set the tty window size to the user-specified value.
>
>I'm not sure that's really a good idea.  If I start an xterm with one
>geometry from inside an xterm with a different geometry, I don't want
>zsh trying to change the size of the second one to match the first.

That would be silly.  I meant for it only to apply when setting the
variable from within the shell, not when importing.

>Just believe what the user tells you and leave the rest alone.

Exactly.

-zefram


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

* Re: zsh always resets LINES to 24.
  1997-09-03  4:40 ` Zoltan Hidvegi
  1997-09-03  8:27   ` Andrew Main
@ 1997-09-04  1:15   ` Jahwan Kim
  1 sibling, 0 replies; 6+ messages in thread
From: Jahwan Kim @ 1997-09-04  1:15 UTC (permalink / raw)
  To: zsh-users

Quoting Zoltan Hidvegi (hzoli@frontiernet.net):
[snip]
[snip the clear explanation he gave]
[snip the patch]

    Thank you for the wonderful explanation.  I, as a user, want to point two
facts: 
    
    (1) The current behavior of zsh w.r.t. LINES and COLUMNS is not what it
should be.  As far as I experienced, bash and zsh don't have any problem
with LINES and COLUMNS.  I don't have their sources at hand, but zsh-workers
can take a look at them and tell us what's the deal.

    (2) Also the manual doesn't describe the situation properly.  The manual 
lists LINES under 'The following parameters are used by the shell:', not
under 'The following parameters are automatically set by the shell:', where
I think it should be.  And the sentences 'The number of lines for this
terminal session.  Used for printing select lists and for the line editor'
doesn't say anything about zsh resetting LINES.  Hopefully, this should be
fixed in the next release, IMHO.

    I agree with what others have suggested.  Treat LINES and COLUMNS as
magical variables, and whenever those are set by users within a shell, call
appropriate ioctl.

Cheers,
Jahwan


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

end of thread, other threads:[~1997-09-04  1:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-09-03  2:55 zsh always resets LINES to 24 Jahwan Kim
1997-09-03  4:40 ` Zoltan Hidvegi
1997-09-03  8:27   ` Andrew Main
1997-09-03 15:44     ` Bart Schaefer
1997-09-03 16:13       ` Andrew Main
1997-09-04  1:15   ` Jahwan Kim

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