Skip to content

Commit

Permalink
ioctl.ph is not often installed; do a better job of loading modules f…
Browse files Browse the repository at this point in the history
…or term size detection
  • Loading branch information
Kyle Wheeler committed Jan 20, 2017
1 parent 1252345 commit fad68f2
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions extract_url.pl
Expand Up @@ -53,20 +53,21 @@ sub VERSION_MESSAGE {
}

my $term_cols = 80;
my ($term_rows, $term_wpix, $term_hpix);
if (eval "use Term::Readkey") {
my ($term_rows, $term_wpix, $term_hpix, $list_width);
if (eval "use Term::ReadKey qw(GetTerminalSize); 1") {
($term_cols, $term_rows, $term_wpix, $term_hpix) = GetTerminalSize();
} else {
require 'sys/ioctl.ph';
} elsif (eval "use 'sys/ioctl.ph'; 1") {
if (defined &TIOCGWINSZ and open(TTY, "+</dev/tty")) {
my $winsize = '';
unless (ioctl(TTY, &TIOCGWINSZ, $winsize)) {
die sprintf "$0: ioctl TIOCGWINSZ (%08x: $!)\n", &TIOCGWINSZ;
}
($term_rows, $term_cols, $term_wpix, $term_hpix) = unpack('S4', $winsize);
}
} elsif (defined $ENV{COLUMNS}) {
$term_cols = $ENV{COLUMNS};
}
my $list_width = $term_cols - 4; # 4 is for the border width on either side
$list_width = $term_cols - 4; # 4 is for the border width on either side

my %options;
if (eval "use Getopt::Long; 1") {
Expand Down

0 comments on commit fad68f2

Please sign in to comment.