Term-Size-0.209/000755 000765 000024 00000000000 13337122024 014302 5ustar00ferreirastaff000000 000000 Term-Size-0.209/Size.xs000644 000765 000024 00000001465 13337042625 015606 0ustar00ferreirastaff000000 000000 #ifdef __cplusplus extern "C" { #endif #include "EXTERN.h" #include "perl.h" #include "XSUB.h" #ifndef _AIX #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.209/INSTALL000644 000765 000024 00000001512 13336657721 015352 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.209/Changes000644 000765 000024 00000004365 13337121406 015610 0ustar00ferreirastaff000000 000000 Revision history for Perl extension Term::Size. 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 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 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.209/MANIFEST000644 000765 000024 00000000415 13337122024 015433 0ustar00ferreirastaff000000 000000 Copyright 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.209/Size.pm000644 000765 000024 00000005121 13337121422 015552 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.209'; bootstrap Term::Size $VERSION; 1; =encoding utf8 =head1 NAME Term::Size - Retrieve terminal size (Unix version) =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. =cut Term-Size-0.209/t/000755 000765 000024 00000000000 13337122024 014545 5ustar00ferreirastaff000000 000000 Term-Size-0.209/README000644 000765 000024 00000000431 13336657721 015200 0ustar00ferreirastaff000000 000000 This is alpha release 0.2 of Term::Size. 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.209/META.yml000644 000765 000024 00000000740 13337122024 015554 0ustar00ferreirastaff000000 000000 --- abstract: 'Retrieve terminal size (Unix version)' author: - unknown build_requires: ExtUtils::MakeMaker: '0' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 7.0401, CPAN::Meta::Converter version 2.150001' 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: Test::More: '0' version: '0.209' Term-Size-0.209/Makefile.PL000644 000765 000024 00000000704 13337037247 016271 0ustar00ferreirastaff000000 000000 use 5; use ExtUtils::MakeMaker; my $EUMM_VERSION = eval $ExtUtils::MakeMaker::VERSION; die q{OS unsupported\n} if $^O =~ /MSWin/i; WriteMakefile( 'NAME' => 'Term::Size', 'VERSION_FROM' => 'Size.pm', 'PREREQ_PM' => { 'Test::More' => 0, # build }, ($] >= 5.005 ? ( 'ABSTRACT_FROM' => 'Size.pm', ) : ()), ($EUMM_VERSION >= 6.30_01 ? ( LICENSE => 'perl', # needs EEUU > 6.30_01 ) : ()), ); Term-Size-0.209/Copyright000644 000765 000024 00000000261 13336657721 016214 0ustar00ferreirastaff000000 000000 The files in this directory are Copyright 1997-05-13, Tim Goodwin. You may redistribute them under the same terms as Perl itself. Tim Goodwin 1997-05-13 Term-Size-0.209/META.json000644 000765 000024 00000001534 13337122024 015726 0ustar00ferreirastaff000000 000000 { "abstract" : "Retrieve terminal size (Unix version)", "author" : [ "unknown" ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 7.0401, CPAN::Meta::Converter version 2.150001", "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" } }, "runtime" : { "requires" : { "Test::More" : "0" } } }, "release_status" : "stable", "version" : "0.209" } Term-Size-0.209/t/99_pod.t000644 000765 000024 00000000353 13337037247 016052 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.209/t/00_use.t000644 000765 000024 00000000177 13336657721 016052 0ustar00ferreirastaff000000 000000 use Test::More tests => 1; BEGIN { use_ok('Term::Size'); } diag( "Testing Term::Size $Term::Size::VERSION, Perl $], $^X" ); Term-Size-0.209/t/01_basic.t000644 000765 000024 00000002751 13337037247 016334 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." ); }