in reply to Re: bulletproof way of finding size of terminal?
in thread bulletproof way of finding size of terminal?

Here's a litle sub I wrote a while back. For once, I kept some decent comments on where I found it to work, and not work.
# $ENV{COLUMNS} isn't set when running through putty (unless from with +in emacs) # GetTerminalSize returns 0 from emacs, but ok from putty # fallback to 72 if the other two methods fail sub get_terminal_width { -t STDOUT && return (GetTerminalSize)[0] || $ENV{COLUMNS} || 72; return 72; }

The FAQ postings are the only thing I miss from clpmisc

Replies are listed 'Best First'.
Re^3: bulletproof way of finding size of terminal?
by bcrowell2 (Friar) on Aug 31, 2007 at 22:25 UTC
    Hnmn...that doesn't work for me. The $ENV{COLUMNS} is, I think, guaranteed never to work, since COLUMNS isn't an environment variable. The (GetTerminalSize)[0] is, I assume, depending on some module?
      GetTerminalSize comes from Term::ReadKey that you've already mentioned.

      I wasn't proposing a solution, just stating some steps, and the problems that I faced, while trying to solve a similar problem.

      I was really trying to point out things that didn't work.