<<< Date Index >>>     <<< Thread Index >>>

Re: wrap long lines



On 2006-08-28, cga2000 <cga2000@xxxxxxxxxxxxx> wrote:

> I was pretty sure COLUMNS was an environment variable but I nevertheless
> tested it issuing an "env" command .. not realizing that since I run
> "permanent" shells under gnu/screen anything could have happened to that
> particular shell since I last booted .. including an "export COLUMNS" ..
> 
> Did the same in a "fresh" shell and naturally COLUMNS wasn't listed.

This behavior depends on the OS and the shell.  HP-UX's /usr/bin/sh 
does a really nice job of maintaining the correct values of $LINES 
and $COLUMNS as the window size is changed.  For SunOS and Red Hat 
Linux, I have to execute

    eval $(resize)

after each terminal window resizing to keep the $LINES and $COLUMNS 
values correct.   (Hmm.  I wonder if, as a user, you can trap 
SIGWINCH in a shell.)

> The reason I assumed that it was an environment variable without having
> given it too much thought .. was that I must have imagined that
> full-screen apps such as Vim etc, used this together with LINES to
> determine the underlying terminal's size.

It depends on the application.  From the vim source (os_unix.c):

 * Try to get the current window size:
 * 1. with an ioctl(), most accurate method
 * 2. from the environment variables LINES and COLUMNS
 * 3. from the termcap
 * 4. keep using the old values

Regards,
Gary

-- 
Gary Johnson                               | Agilent Technologies
garyjohn@xxxxxxxxxxxxxxx                   | Wireless Division
http://www.spocom.com/users/gjohnson/mutt/ | Spokane, Washington, USA