Term-Size-Any-0.001/0000755000175000017500000000000010747434075014251 5ustar ferreiraferreiraTerm-Size-Any-0.001/README0000644000175000017500000000465310747431060015130 0ustar ferreiraferreiraNAME Term::Size::Any - Retrieve terminal size SYNOPSIS # the traditional way use Term::Size::Any qw( chars pixels ); ($columns, $rows) = chars *STDOUT{IO}; ($x, $y) = pixels; DESCRIPTION This is a unified interface to retrieve terminal size. It loads one module of a list of known alternatives, each implementing some way to get the desired terminal information. This loaded module will actually do the job on behalf of `Term::Size::Any'. Thus, `Term::Size::Any' depends on the availability of one of these modules: Term::Size (soon to be supported) Term::Size::Perl Term::Size::ReadKey (soon to be supported) Term::Size::Win32 This release fallbacks to Term::Size::Win32 if running in Windows 32 systems. For other platforms, it uses the first of Term::Size::Perl, Term::Size or Term::Size::ReadKey which loads successfully. (To be honest, I disabled the fallback to Term::Size and Term::Size::ReadKey which are buggy by now.) FUNCTIONS The traditional interface is by importing functions `chars' and `pixels' into the caller's space. chars ($columns, $rows) = chars($h); $columns = chars($h); `chars' returns the terminal size in units of characters corresponding to the given filehandle `$h'. If the argument is ommitted, `*STDIN{IO}' is used. In scalar context, it returns the terminal width. pixels ($x, $y) = pixels($h); $x = pixels($h); `pixels' returns the terminal size in units of pixels corresponding to the given filehandle `$h'. If the argument is ommitted, `*STDIN{IO}' is used. In scalar context, it returns the terminal width. Many systems with character-only terminals will return `(0, 0)'. SEE ALSO It all began with Term::Size by Tim Goodwin. You may want to have a look at: Term::Size Term::Size::Perl Term::Size::Win32 Term::Size::ReadKey BUGS Please reports bugs via CPAN RT, via web http://rt.cpan.org/NoAuth/Bugs.html?Dist=Term-Size-Any or e-mail to bug-Term-Size-Any@rt.cpan.org. AUTHOR Adriano R. Ferreira, COPYRIGHT AND LICENSE Copyright (C) 2008 by Adriano R. Ferreira This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Term-Size-Any-0.001/t/0000755000175000017500000000000010747434075014514 5ustar ferreiraferreiraTerm-Size-Any-0.001/t/98pod-coverage.t0000644000175000017500000000024410747427745017443 0ustar ferreiraferreira use Test::More; eval "use Test::Pod::Coverage 1.04"; plan skip_all => "Test::Pod::Coverage 1.04 required for testing POD coverage" if $@; all_pod_coverage_ok(); Term-Size-Any-0.001/t/99pod.t0000644000175000017500000000022510747430057015640 0ustar ferreiraferreira use Test::More; 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-Any-0.001/t/05perl.t0000644000175000017500000000210410747423223015776 0ustar ferreiraferreira use Test::More; # this script is for testing Term::Size::Any default behavior use Module::Load::Conditional qw( can_load ); BEGIN { if ( can_load( modules => { 'Term::Size::Perl' => 0 } ) ) { plan( tests => 17 ); } else { plan( skip_all => 'Term::Size::Perl not found' ); } } BEGIN { use_ok('Term::Size::Any', 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"); } } Term-Size-Any-0.001/t/08win32.t0000644000175000017500000000210610747425307016010 0ustar ferreiraferreira use Test::More; # this script is for testing Term::Size::Any default behavior use Module::Load::Conditional qw( can_load ); BEGIN { if ( can_load( modules => { 'Term::Size::Win32' => 0 } ) ) { plan( tests => 17 ); } else { plan( skip_all => 'Term::Size::Win32 not found' ); } } BEGIN { use_ok('Term::Size::Any', 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"); } } Term-Size-Any-0.001/t/02basic.t0000644000175000017500000000213210747405544016121 0ustar ferreiraferreira use Test::More tests => 17; # this script is for testing Term::Size::Any default behavior BEGIN { use_ok('Term::Size::Any', 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"); } } 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." ); } Term-Size-Any-0.001/t/01use.t0000644000175000017500000000021610747361573015637 0ustar ferreiraferreira use Test::More tests => 1; BEGIN { use_ok('Term::Size::Any'); } diag( "Testing Term::Size::Any $Term::Size::Any::VERSION, Perl $], $^X" ); Term-Size-Any-0.001/lib/0000755000175000017500000000000010747434075015017 5ustar ferreiraferreiraTerm-Size-Any-0.001/lib/Term/0000755000175000017500000000000010747434075015726 5ustar ferreiraferreiraTerm-Size-Any-0.001/lib/Term/Size/0000755000175000017500000000000010747434075016640 5ustar ferreiraferreiraTerm-Size-Any-0.001/lib/Term/Size/Any.pod0000644000175000017500000000515210747427464020102 0ustar ferreiraferreira =head1 NAME Term::Size::Any - Retrieve terminal size =head1 SYNOPSIS # the traditional way use Term::Size::Any qw( chars pixels ); ($columns, $rows) = chars *STDOUT{IO}; ($x, $y) = pixels; =head1 DESCRIPTION This is a unified interface to retrieve terminal size. It loads one module of a list of known alternatives, each implementing some way to get the desired terminal information. This loaded module will actually do the job on behalf of C. Thus, C depends on the availability of one of these modules: Term::Size (soon to be supported) Term::Size::Perl Term::Size::ReadKey (soon to be supported) Term::Size::Win32 This release fallbacks to L if running in Windows 32 systems. For other platforms, it uses the first of L, L or L which loads successfully. (To be honest, I disabled the fallback to Term::Size and Term::Size::ReadKey which are buggy by now.) =begin comment HOW Term::Size MODULES WORK? Term::Size - XS which does ioctl( IOCGWINSZ ) Term::Size::Perl - Perl which does ioctl( IOCGWINSZ ) - needs compiled probe at build time Term::Size::ReadKey - uses Term::ReadKey Term::Size::Win32 - uses Win32::Console HISTORY Tell the story. =end comment =head2 FUNCTIONS The traditional interface is by importing functions C and C into the caller's space. =over 4 =item B ($columns, $rows) = chars($h); $columns = chars($h); C returns the terminal size in units of characters corresponding to the given filehandle C<$h>. If the argument is ommitted, C<*STDIN{IO}> is used. In scalar context, it returns the terminal width. =item B ($x, $y) = pixels($h); $x = pixels($h); C returns the terminal size in units of pixels corresponding to the given filehandle C<$h>. If the argument is ommitted, C<*STDIN{IO}> is used. In scalar context, it returns the terminal width. Many systems with character-only terminals will return C<(0, 0)>. =back =head1 SEE ALSO It all began with L by Tim Goodwin. You may want to have a look at: Term::Size Term::Size::Perl Term::Size::Win32 Term::Size::ReadKey =head1 BUGS Please reports bugs via CPAN RT, via web http://rt.cpan.org/NoAuth/Bugs.html?Dist=Term-Size-Any or e-mail to bug-Term-Size-Any@rt.cpan.org. =head1 AUTHOR Adriano R. Ferreira, Eferreira@cpan.orgE =head1 COPYRIGHT AND LICENSE Copyright (C) 2008 by Adriano R. Ferreira This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut Term-Size-Any-0.001/lib/Term/Size/Any.pm0000644000175000017500000000140310747426566017731 0ustar ferreiraferreira package Term::Size::Any; use strict; use vars qw( $VERSION ); $VERSION = '0.001'; sub _require_any { my $package; if ( $^O eq 'MSWin32' ) { require Term::Size::Win32; $package = 'Term::Size::Win32'; } else { #require Best; #my @modules = qw( Term::Size::Perl Term::Size Term::Size::ReadKey ); #Best->import( @modules ); #$package = Best->which( @modules ); require Term::Size::Perl; $package = 'Term::Size::Perl'; } $package->import( qw( chars pixels ) ); # allows Term::Size::Any::chars return $package; } sub import { my $self = shift; my $package = _require_any; unshift @_, $package; my $import_sub = $package->can('import'); goto &$import_sub; } 1; Term-Size-Any-0.001/Makefile.PL0000644000175000017500000000210710747430261016214 0ustar ferreiraferreira use 5.006; use strict; use warnings; use ExtUtils::MakeMaker 6.31; # XXX yes, that's not a nice thing to do # one of Term::Size, Term::Size::Perl, Term::Size::ReadKey, # or Term::Size::Win32 should be available my %prereqs; if ( $^O eq 'MSWin32' ) { %prereqs = ( 'Term::Size::Win32' => 0 ); } else { #my @modules = qw( Term::Size::Perl Term::Size Term::Size::ReadKey ); my @modules = qw( Term::Size::Perl ); %prereqs = map { $_ => 0 } @modules; ## FIXME yep, I know - we don't need all these three } WriteMakefile( NAME => 'Term::Size::Any', VERSION_FROM => 'lib/Term/Size/Any.pm', PREREQ_PM => { #Best => 0, %prereqs, # build_requires 'Test::More' => 0, 'Module::Load::Conditional' => 0, 'Devel::Hide' => 0, }, #recommends => { # 'Test::Pod::Coverage' => 1.04, # 'Test::Pod' => 1.18, #} ABSTRACT_FROM => 'lib/Term/Size/Any.pod', AUTHOR => 'Adriano R. Ferreira ', LICENSE => 'perl', ); Term-Size-Any-0.001/Changes0000644000175000017500000000030610747431016015533 0ustar ferreiraferreiraRevision history for Perl extension Term-Size-Any. 0.001 Mon Jan 28 2008 - first release to CPAN - not using Term::Size and Term::Size::ReadKey because they are so borken Term-Size-Any-0.001/META.yml0000644000175000017500000000105410747434075015522 0ustar ferreiraferreira--- #YAML:1.0 name: Term-Size-Any version: 0.001 abstract: Retrieve terminal size license: perl author: - Adriano R. Ferreira generated_by: ExtUtils::MakeMaker version 6.42 distribution_type: module requires: Devel::Hide: 0 Module::Load::Conditional: 0 Term::Size::Perl: 0 Test::More: 0 meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.3.html version: 1.3 Term-Size-Any-0.001/MANIFEST0000644000175000017500000000050510747434075015402 0ustar ferreiraferreira Makefile.PL MANIFEST This list of files README Changes lib/Term/Size/Any.pm lib/Term/Size/Any.pod t/01use.t t/02basic.t #t/03each.t t/05perl.t #t/06size.t #t/07readkey.t t/08win32.t #t/lib/Devel/Hide/Patched.pm t/98pod-coverage.t t/99pod.t META.yml Module meta-data (added by MakeMaker)