#!/usr/bin/perl # resize - a perl version of the resize(1) program # # erco@3dsite.com (Greg Ercolano) # # This software is public domain. Please maintain version history. # Please notify me of bugs. Do not remove this header. # Use at your own risk. # # VERS DATE AUTHOR COMMENTS # 1.00 10/22/98 Greg Ercolano Initial version # 1.10 10/27/99 Greg Ercolano open /dev/tty for ctrl codes # x.xx - - - # $|=1; $rows = -1; system("stty -icanon -echo"); unless ( open(FD, ">/dev/tty") ) { print STDERR "/dev/tty: $!\n"; exit(1); } print FD "\x1b[999;999H\x1b[6n\n"; close(FD); while(1) { $c.=getc(STDIN); if ($c=~/R$/) {last;} } if ($c=~/\[(\d+);(\d+)R/) { $rows = $1; $cols = $2; if ( $ENV{SHELL} =~ /csh/ ) { print "setenv LINES $rows; setenv COLUMNS $cols\n"; } else { print "LINES=$rows; COLUMNS=$cols; export LINES COLUMNS;\n"; } } if ( $rows != -1 ) { system("stty icanon echo rows $rows cols $cols"); }