Term-Size-0.207/0000755000175000017500000000000011051560511013514 5ustar ferreiraferreiraTerm-Size-0.207/README0000644000175000017500000000043111051557026014401 0ustar ferreiraferreiraThis 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.207/t/0000755000175000017500000000000011051560511013757 5ustar ferreiraferreiraTerm-Size-0.207/t/01_basic.t0000644000175000017500000000212011051557220015523 0ustar ferreiraferreira use Test::More tests => 17; # 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"); } } 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-0.207/t/00_use.t0000644000175000017500000000017711051557164015256 0ustar ferreiraferreira use Test::More tests => 1; BEGIN { use_ok('Term::Size'); } diag( "Testing Term::Size $Term::Size::VERSION, Perl $], $^X" ); Term-Size-0.207/t/99_pod.t0000644000175000017500000000022511051557026015255 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-0.207/INSTALL0000644000175000017500000000151211051557026014553 0ustar ferreiraferreiraYou 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.207/Makefile.PL0000644000175000017500000000110711051557417015500 0ustar ferreiraferreira use 5; use ExtUtils::MakeMaker; my $EUMM_VERSION = eval $ExtUtils::MakeMaker::VERSION; my $is_win32 = ($^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 ) : ()), ) unless $is_win32; ExtUtils::MakeMaker::WriteEmptyMakefile( 'NAME' => 'Term::Size', 'VERSION_FROM' => 'Size.pm', ) if $is_win32; Term-Size-0.207/Changes0000644000175000017500000000370111051560376015021 0ustar ferreiraferreiraRevision history for Perl extension Term::Size. 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.207/Size.xs0000644000175000017500000000142111051557260015007 0ustar ferreiraferreira#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 = stdin ) FILE *f; PREINIT: struct winsize w = { 0, 0, 0, 0 }; PPCODE: if (ioctl(fileno(f), TIOCGWINSZ, &w) == -1) XSRETURN_NO; XPUSHs(sv_2mortal(newSViv(w.ws_col))); if (GIMME != G_SCALAR) XPUSHs(sv_2mortal(newSViv(w.ws_row))); void pixels( f = stdin ) FILE *f; PREINIT: struct winsize w = { 0, 0, 0, 0 }; PPCODE: if (ioctl(fileno(f), TIOCGWINSZ, &w) == -1) XSRETURN_NO; XPUSHs(sv_2mortal(newSViv(w.ws_xpixel))); if (GIMME != G_SCALAR) XPUSHs(sv_2mortal(newSViv(w.ws_ypixel))); Term-Size-0.207/Copyright0000644000175000017500000000026111051557026015415 0ustar ferreiraferreiraThe 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.207/META.yml0000644000175000017500000000063311051560511014767 0ustar ferreiraferreira--- #YAML:1.0 name: Term-Size version: 0.207 abstract: Retrieve terminal size (Unix version) license: perl author: ~ generated_by: ExtUtils::MakeMaker version 6.44 distribution_type: module requires: Test::More: 0 meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.3.html version: 1.3 Term-Size-0.207/MANIFEST0000644000175000017500000000027111051560511014645 0ustar ferreiraferreiraCopyright 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) Term-Size-0.207/Size.pm0000644000175000017500000000576711051560317015007 0ustar ferreiraferreirapackage Term::Size; use strict; use Carp; use vars qw(@EXPORT_OK @ISA $VERSION); use AutoLoader (); use DynaLoader (); use Exporter (); @ISA = qw(Exporter DynaLoader); @EXPORT_OK = qw(chars pixels); $VERSION = '0.207'; =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 THIS IS AN UNOFFICIAL PATCH AGAINST Term-Size 0.2 DISTRIBUTION FOUND ON CPAN (http://search.cpan.org/~timpx/Term-Size-0.2/). IT IS UNOFFICIAL IN THE SENSE THAT THE AUTHOR Tim Goodwin HASN'T APPROVED IT (YET, I HOPE). BECAUSE OF THIS, THIS DISTRIBUTION IS NOT INDEXED AND AVAILABLE VIA cpan OR cpanp SHELLS UNLESS YOU EXPLICITLY SAY "install FERREIRA/Term-Size-0.203.tar.gz". THIS IS UNDELICATE? I THINK IT IS IN A CERTAIN SENSE. BUT IT IS A WAY TO UNFREEZE THE CURRENT DISTRIBUTION STATUS. IF TIM DISAPPROVES, I WILL REMOVE THIS DISTRIBUTION RIGHT AWAY. IF HE APPROVES, I WILL REMOVE THIS DISTRIBUTION RIGHT AWAY AND WORK OUT (AFTER BEEN GIVEN MAINTAINERSHIP STATUS) A DISTRIBUTION WITHOUT THIS NOTE AND WHICH INDEXES CORRECTLY. B 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 C 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 Both functions return C if there is an error. 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 BUGS It only works on Unix systems. =head1 AUTHOR Tim Goodwin, , 1997-04-23. Candidate for maintainership: Adriano Ferreira, , 2006-05-19. =cut bootstrap Term::Size $VERSION; 1; __END__