/usr/share/perl5/Test2/Util/Term.pm is in libtest2-suite-perl 0.000063-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | package Test2::Util::Term;
use strict;
use warnings;
our $VERSION = '0.000063';
use Test2::Util qw/try/;
use Importer Importer => 'import';
our @EXPORT_OK = qw/term_size USE_GCS USE_TERM_READKEY uni_length/;
sub DEFAULT_SIZE() { 80 }
my ($trk) = try { require Term::ReadKey };
$trk &&= Term::ReadKey->can('GetTerminalSize');
if ($trk) {
*USE_TERM_READKEY = sub() { 1 };
*term_size = sub {
return $ENV{T2_TERM_SIZE} if $ENV{T2_TERM_SIZE};
my $total;
try {
my @warnings;
{
local $SIG{__WARN__} = sub { push @warnings => @_ };
($total) = Term::ReadKey::GetTerminalSize(*STDOUT);
}
@warnings = grep { $_ !~ m/Unable to get Terminal Size/ } @warnings;
warn @warnings if @warnings;
};
return DEFAULT_SIZE if !$total;
return DEFAULT_SIZE if $total < DEFAULT_SIZE;
return $total;
};
}
else {
*USE_TERM_READKEY = sub() { 0 };
*term_size = sub {
return $ENV{T2_TERM_SIZE} if $ENV{T2_TERM_SIZE};
return DEFAULT_SIZE;
};
}
my ($gcs, $err) = try { require Unicode::GCString };
if ($gcs) {
*USE_GCS = sub() { 1 };
*uni_length = sub { Unicode::GCString->new($_[0])->columns };
}
else {
*USE_GCS = sub() { 0 };
*uni_length = sub { length($_[0]) };
}
1;
|