in reply to Failing to get current TTY's rows & columns...
See also Pack/Unpack Tutorial (aka How the System Stores Data), s!* looks suspicious, what I'd usually do is try every option :)
update: Oh look, this is a perlfaq8 item
How do I get the screen size?If you have Term::ReadKey module installed from CPAN, you can use it to fetch the width and height in characters and in pixels:
This is more portable than the raw ioctl, but not as illustrative:use Term::ReadKey; ($wchar, $hchar, $wpixels, $hpixels) = GetTerminalSize();require 'sys/ioctl.ph'; die "no TIOCGWINSZ " unless defined &TIOCGWINSZ; open(TTY, "+</dev/tty") or die "No tty: $!"; unless (ioctl(TTY, &TIOCGWINSZ, $winsize='')) { die sprintf "$0: ioctl TIOCGWINSZ (%08x: $!)\n", &TIOCGWIN +SZ; } ($row, $col, $xpixel, $ypixel) = unpack('S4', $winsize); print "(row,col) = ($row,$col)"; print " (xpixel,ypixel) = ($xpixel,$ypixel)" if $xpixel || $ypixe +l; print "\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Failing to get current TTY's rows & columns...
by perl-diddler (Chaplain) on Apr 14, 2011 at 02:10 UTC | |
by Anonymous Monk on Apr 14, 2011 at 08:13 UTC | |
by perl-diddler (Chaplain) on Apr 15, 2011 at 22:08 UTC | |
by Anonymous Monk on Apr 15, 2011 at 22:29 UTC | |
by perl-diddler (Chaplain) on Apr 16, 2011 at 04:58 UTC | |
| |
|
Re^2: Failing to get current TTY's rows & columns...
by perl-diddler (Chaplain) on Apr 15, 2011 at 22:00 UTC | |
by Anonymous Monk on Apr 15, 2011 at 22:20 UTC |