in reply to handling terminal window resizing
Here's a little test program I built a while back to try this out. Run it in a terminal window such xterm and it will report the terminal size as you change it.
use strict; use warnings; use feature qw{ say }; $SIG{ WINCH } = \ &winch; winch(); while ( 1 ) { sleep 200; } sub winch { my( $rows, $cols ) = getRowsCols(); say qq{Rows = $rows - Columns = $cols}; } sub getRowsCols { my $sttyOut = do { open my $sttyFH, q{-|}, qw{ /bin/stty size } or die qq{fork: /bin/stty size: $!\n}; local $/; <$sttyFH>; }; die qq{/bin/stty size: Unexpected output: $sttyOut} unless $sttyOut =~ m{^(\d+)\s+(\d+)$}; return $1, $2; }
I hope this is helpful.
Cheers,
JohnGG
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: handling terminal window resizing
by morgon (Priest) on Dec 30, 2016 at 14:11 UTC | |
by LanX (Saint) on Dec 30, 2016 at 15:44 UTC |