Term-Size-0.211/000755 000765 000024 00000000000 14000113200 014253 5ustar00ferreirastaff000000 000000 Term-Size-0.211/Size.xs000644 000765 000024 00000001526 14000112712 015554 0ustar00ferreirastaff000000 000000 #ifdef __cplusplus extern "C" { #endif #include "EXTERN.h" #include "perl.h" #include "XSUB.h" #if !defined(_AIX) && !defined(__DragonFly__) #include #else #include #endif #ifdef __cplusplus } #endif MODULE = Term::Size PACKAGE = Term::Size PROTOTYPES: DISABLE void chars( f = PerlIO_stdin() ) PerlIO *f; PREINIT: struct winsize w = { 0, 0, 0, 0 }; PPCODE: if (ioctl(PerlIO_fileno(f), TIOCGWINSZ, &w) == -1) XSRETURN(0); XPUSHs(sv_2mortal(newSViv(w.ws_col))); if (GIMME != G_SCALAR) XPUSHs(sv_2mortal(newSViv(w.ws_row))); void pixels( f = PerlIO_stdin() ) PerlIO *f; PREINIT: struct winsize w = { 0, 0, 0, 0 }; PPCODE: if (ioctl(PerlIO_fileno(f), TIOCGWINSZ, &w) == -1) XSRETURN(0); XPUSHs(sv_2mortal(newSViv(w.ws_xpixel))); if (GIMME != G_SCALAR) XPUSHs(sv_2mortal(newSViv(w.ws_ypixel))); Term-Size-0.211/INSTALL000644 000765 000024 00000001512 13336657721 015343 0ustar00ferreirastaff000000 000000 You need Perl 5.002 or later. 1. Create a Makefile. perl Makefile.PL 2. Build the Term::Size extension. make 3. Test it (please don't omit this step). make test You should see `ok 1' through to `ok 6', followed by a description of the size of the terminal you are using. If any tests fail, please get in touch so we can sort out the problem. 4. Install the extension. If you have built Term::Size as a dynamic extension, it's as simple as this. make install If you have built Term::Size as a static extension, follow the instructions given during the build process. 5. If you have any problems, questions, or ideas for future enhancements, please contact me. I'm particularly keen to hear from people who can help me make Term::Size work on systems other than Unix. Tim Goodwin 1997-05-13 Term-Size-0.211/Changes000644 000765 000024 00000004741 14000113062 015562 0ustar00ferreirastaff000000 000000 Revision history for Perl extension Term::Size. 0.211 2021-01-14 Term-Size - Promote to a stable release 0.210 2021-01-07 Term-Size ( TRIAL VERSION ) - Attempt to fix build at DragonFly BSD: include (like for AIX) rather than - Rewrite Makefile.PL 0.209 2018-08-21 Term-Size - Tweak documentation - Promote to a stable release 0.208 2018-08-20 Term-Size ( TRIAL VERSION ) - use PerlIO instead of FILE* RT#38594 - On error, Term::Size functions now return undef in scalar context, or an empty list on list context RT#76292 0.207 2008-08-16 Term-Size - the original code for retrieving terminal size via XS ioctl is back -- and this dist is again Unix-centric - use Term::Size::Any for platform independency 0.205 2008-02-27 Term-Size-Unix - disabled prototypes in XS code - too misleading to be useful - borrowed rewritten test from Term::Size::Any (which should fix most test failures) - NOTE: this distribution will disappear soon, merging back to the original Term-Size dist 0.204 2006-09-13 Term-Size-Unix - included license in Makefile.PL 0.203.2 2006-05-21 Term-Size-Unix - moved sources from Term-Size to this distribution - bug fixed: &pixels always used fd 0 rather than fileno(f) - added test scripts "t/00_use.t" and "t/99_pod.t" 0.203.1 2006-05-21 Term-Size - bug fixed: &pixels always used fd 0 rather than fileno(f) - experimental support for Win32 was introduced by adding a dependency on Term::Size::Win32 - added test scripts "t/00_use.t" and "t/99_pod.t" - the XS code moved to distribution Term::Size::Unix - this module is now a thin skin to call the appropriate module Term::Size::Unix or Term::Size::Win32 0.202 2006-05-19 Term-Size - inserted a note to say this is an UNOFFICIAL distribution 0.201 2006-05-18 Term-Size - 'test.pl' rewritten with Test::More and renamed to 't/01_basic.t' - an initializer is now used when creating a struct winsize to avoid what looks like a bug on Cygwin: ioctl(., TIOCGWINSZ, .) does not set ws_xpixel and ws_ypixel fields, leaving them untouched. If they contained garbage, they kept the garbage - attempt to restore AIX compatibility according to suggestion in CPAN RT #11539 (by jydawg [at] xs4all.nl): "termios.h" is not where Unix thinks it should 0.2 1997-05-13 Term-Size - support filehandle arguments 0.1 1997-04-23 Term-Size - original version Term-Size-0.211/MANIFEST000644 000765 000024 00000000403 14000113200 015401 0ustar00ferreirastaff000000 000000 Changes MANIFEST Makefile.PL README INSTALL Size.pm Size.xs t/00_use.t t/01_basic.t t/99_pod.t META.yml Module meta-data (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker) Term-Size-0.211/Size.pm000644 000765 000024 00000005322 14000113051 015531 0ustar00ferreirastaff000000 000000 package Term::Size; use strict; use vars qw(@EXPORT_OK @ISA $VERSION); use DynaLoader (); use Exporter (); @ISA = qw(Exporter DynaLoader); @EXPORT_OK = qw(chars pixels); $VERSION = '0.211'; bootstrap Term::Size $VERSION; 1; =encoding utf8 =head1 NAME Term::Size - Retrieve terminal size on Unix =head1 SYNOPSIS use Term::Size; ($columns, $rows) = Term::Size::chars *STDOUT{IO}; ($x, $y) = Term::Size::pixels; =head1 DESCRIPTION L is a Perl module which provides a straightforward way to retrieve the terminal size. Both functions take an optional filehandle argument, which defaults to C<*STDIN{IO}>. They both return a list of two values, which are the current width and height, respectively, of the terminal associated with the specified filehandle. C returns the size in units of characters, whereas C uses units of pixels. In a scalar context, both functions return the first element of the list, that is, the terminal width. The functions may be imported. If you need to pass a filehandle to either of the L functions, beware that the C<*STDOUT{IO}> syntax is only supported in Perl 5.004 and later. If you have an earlier version of Perl, or are interested in backwards compatibility, use C<*STDOUT> instead. =head1 EXAMPLES 1. Refuse to run in a too narrow window. use Term::Size; die "Need 80 column screen" if Term::Size::chars *STDOUT{IO} < 80; 2. Track window size changes. use Term::Size 'chars'; my $changed = 1; while (1) { local $SIG{'WINCH'} = sub { $changed = 1 }; if ($changed) { ($cols, $rows) = chars; # Redraw, or whatever. $changed = 0; } } =head1 RETURN VALUES If there is an error, both functions return C in scalar context, or an empty list in list context. If the terminal size information is not available, the functions will normally return C<(0, 0)>, but this depends on your system. On character only terminals, C will normally return C<(0, 0)>. =head1 CAVEATS L only works on Unix systems, as it relies on the C function to retrieve the terminal size. If you need terminal size in Windows, see L. Before version 0.208, C and C used to return false on error. =head1 SEE ALSO L, L, L, L. =head1 AUTHOR Tim Goodwin, , 1997-04-23. =head1 MANTAINER Adriano Ferreira, , 2006-05-19. =head1 COPYRIGHT AND LICENSE Copyright (C) 1997-05-13 by Tim Goodwin. You may redistribute them under the same terms as Perl itself. =cut Term-Size-0.211/t/000755 000765 000024 00000000000 14000113200 014516 5ustar00ferreirastaff000000 000000 Term-Size-0.211/README000644 000765 000024 00000000360 13337131322 015153 0ustar00ferreirastaff000000 000000 Term::Size is a Perl module which provides a straightforward way to get the size of the terminal (or window) on which a script is running. For installation instructions, see the file INSTALL. Tim Goodwin 1997-05-13 Term-Size-0.211/META.yml000644 000765 000024 00000001434 14000113200 015526 0ustar00ferreirastaff000000 000000 --- abstract: 'Retrieve terminal size on Unix' author: - 'Tim Goodwin ' - 'Adriano Ferreira ' build_requires: ExtUtils::MakeMaker: '0' Test::More: '0' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 0 generated_by: 'ExtUtils::MakeMaker version 7.34, CPAN::Meta::Converter version 2.150010' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Term-Size no_index: directory: - t - inc requires: DynaLoader: '0' Exporter: '0' strict: '0' vars: '0' resources: bugtracker: https://github.com/aferreira/cpan-Term-Size/issues repository: git://github.com/aferreira/cpan-Term-Size.git version: '0.211' x_serialization_backend: 'CPAN::Meta::YAML version 0.018' Term-Size-0.211/Makefile.PL000644 000765 000024 00000002574 13337130770 016264 0ustar00ferreirastaff000000 000000 use 5; use ExtUtils::MakeMaker; my $EUMM_VERSION = eval $ExtUtils::MakeMaker::VERSION; die q{OS unsupported\n} if $^O =~ /MSWin/i; my %META = ( 'dynamic_config' => 0, 'meta-spec' => { version => 2 }, 'prereqs' => { develop => { requires => { # author tests 'Test::Pod' => '1.18', } }, }, 'resources' => { repository => { type => 'git', url => 'git://github.com/aferreira/cpan-Term-Size.git', web => 'https://github.com/aferreira/cpan-Term-Size' }, bugtracker => { web => 'https://github.com/aferreira/cpan-Term-Size/issues', }, }, ); WriteMakefile( NAME => 'Term::Size', AUTHOR => [ 'Tim Goodwin ', 'Adriano Ferreira ' ], VERSION_FROM => 'Size.pm', ($] >= 5.005 ? ( ABSTRACT_FROM => 'Size.pm', ) : ()), ($EUMM_VERSION >= 6.3001 ? ( LICENSE => 'perl', ) : ()), ($EUMM_VERSION >= 6.4501 ? ( META_MERGE => \%META, ) : ()), ($EUMM_VERSION >= 6.6303 ? ( TEST_REQUIRES => { 'Test::More' => 0, }, ) : ()), PREREQ_PM => { 'strict' => 0, 'DynaLoader' => 0, 'Exporter' => 0, 'vars' => 0, ($EUMM_VERSION < 6.6303 ? ( 'Test::More' => 0, # test ) : ()), }, ); Term-Size-0.211/META.json000644 000765 000024 00000003032 14000113200 015672 0ustar00ferreirastaff000000 000000 { "abstract" : "Retrieve terminal size on Unix", "author" : [ "Tim Goodwin ", "Adriano Ferreira " ], "dynamic_config" : 0, "generated_by" : "ExtUtils::MakeMaker version 7.34, CPAN::Meta::Converter version 2.150010", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "Term-Size", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "develop" : { "requires" : { "Test::Pod" : "1.18" } }, "runtime" : { "requires" : { "DynaLoader" : "0", "Exporter" : "0", "strict" : "0", "vars" : "0" } }, "test" : { "requires" : { "Test::More" : "0" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/aferreira/cpan-Term-Size/issues" }, "repository" : { "type" : "git", "url" : "git://github.com/aferreira/cpan-Term-Size.git", "web" : "https://github.com/aferreira/cpan-Term-Size" } }, "version" : "0.211", "x_serialization_backend" : "JSON::PP version 4.02" } Term-Size-0.211/t/99_pod.t000644 000765 000024 00000000353 13337037247 016043 0ustar00ferreirastaff000000 000000 use Test::More; plan skip_all => "No Developer Tests for non-developers" unless $ENV{AUTHOR_TESTING}; eval "use Test::Pod 1.18"; plan skip_all => "Test::Pod 1.18 required for testing POD" if $@; all_pod_files_ok(all_pod_files(".")); Term-Size-0.211/t/00_use.t000644 000765 000024 00000000177 13336657721 016043 0ustar00ferreirastaff000000 000000 use Test::More tests => 1; BEGIN { use_ok('Term::Size'); } diag( "Testing Term::Size $Term::Size::VERSION, Perl $], $^X" ); Term-Size-0.211/t/01_basic.t000644 000765 000024 00000002751 13337037247 016325 0ustar00ferreirastaff000000 000000 use Test::More tests => 21; # this script is for testing Term::Size default behavior BEGIN { use_ok('Term::Size', qw( chars pixels )); } my @handles = ( # name args handle [ 'implicit STDIN', [], *STDIN ], # default: implicit STDIN [ 'STDIN', [*STDIN], *STDIN ], [ 'STDERR', [*STDERR], *STDERR ], [ 'STDOUT', [*STDOUT], *STDOUT ], ); for (@handles) { my $h_name = $_->[0]; my @args = @{$_->[1]}; my $h = $_->[2]; SKIP: { skip "$h_name is not tty", 4 unless -t $h; my @chars = chars @args; is(scalar @chars, 2, "$h_name: chars return (cols, rows) - $h_name"); my $cols = chars @args; is($cols, $chars[0], "$h_name: chars return cols"); my @pixels = pixels @args; is(scalar @pixels, 2, "$h_name: pixels return (x, y)"); my $x = pixels @args; is($x, $pixels[0], "$h_name: pixels return x"); } } { pipe my $rd, my $wr; my @chars = chars $rd; ok(!@chars, 'chars return () on error (list context)'); my $chars = chars $rd; is($chars, undef, 'chars return undef on error (scalar context)'); my @pixels = pixels $rd; ok(!@pixels, 'pixels return () on error (list context)'); my $pixels = pixels $rd; is($pixels, undef, 'pixels return undef on error (scalar context)'); } if (-t STDIN) { # this is not at test, only a show-off my @chars = chars; my @pixels = pixels; diag("This terminal is $chars[0]x$chars[1] characters," . " and $pixels[0]x$pixels[1] pixels." ); }