screen size in the environment

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Sat, Sep 18 2004 at 05:15:07AM -0400, Chuck Hallenbeck wrote:
> If anyone has any ideas about this one, I would appreciate hearing them:
> 
> My environment seems to have two variables called "COLUMNS" and "LINES"
> that give the size of the text console screen. I can display them from a
> prompt with
> 
> echo $COLUMNS
> 
> and
> 
> echo $LINES
> 
> and their values seem correct. I don't have the foggiest notion of who
> set them, it wasn't me.
> 
> However, in a C program which could really benefit from knowing those
> values, the "getenv" function cannot find them. It returns NULL for each
> variable, caps and quotes are correctly given, and the same function
> "getenv" retrieves other environment variables just fine.
> 
> How come my program can't locate COLUMNS and LINES in the environment?

I believe that these are set by your shell probably bash, but don't know
if they are exported. If you are using ncurses in your programs you can
use getmaxyx() to get the maximum screen size. It is a macro and just
puts the maximum y and x coordinates in two parameters. If this won't
work for your purposes, then maybe you can export LINES and COLUMNS
before running your program.

HTH

- -- 
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it." - Brian W. Kernighan

Thomas Stivers	e-mail: stivers_t at tomass.dyndns.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)

iD8DBQFBTBs25JK61UXLur0RAuFGAJ9zhO8OIXrz1XTkl9XiT3z7uLM/iACfcsY/
3k8jCNVrUWuSKFco5B1TRQc=
=n84y
-----END PGP SIGNATURE-----




[Index of Archives]     [Linux for the Blind]     [Fedora Discussioin]     [Linux Kernel]     [Yosemite News]     [Big List of Linux Books]
  Powered by Linux