line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Term::Size::Unix; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
65359
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
234
|
|
4
|
2
|
|
|
2
|
|
13
|
use Carp; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
212
|
|
5
|
2
|
|
|
2
|
|
12
|
use vars qw(@EXPORT_OK @ISA $VERSION); |
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
153
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
2744
|
use AutoLoader (); |
|
2
|
|
|
|
|
3896
|
|
|
2
|
|
|
|
|
40
|
|
8
|
2
|
|
|
2
|
|
12
|
use DynaLoader (); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
25
|
|
9
|
2
|
|
|
2
|
|
10
|
use Exporter (); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
273
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
@ISA = qw(Exporter DynaLoader); |
12
|
|
|
|
|
|
|
@EXPORT_OK = qw(chars pixels); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
$VERSION = '0.205'; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 NAME |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
Term::Size::Unix - Retrieve terminal size (Unix version) |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 SYNOPSIS |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
use Term::Size::Unix; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
($columns, $rows) = Term::Size::Unix::chars *STDOUT{IO}; |
25
|
|
|
|
|
|
|
($x, $y) = Term::Size::Unix::pixels; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 DESCRIPTION |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
THIS IS AN UNOFFICIAL PATCH AGAINST Term-Size 0.2 DISTRIBUTION |
30
|
|
|
|
|
|
|
FOUND ON CPAN (http://search.cpan.org/~timpx/Term-Size-0.2/). |
31
|
|
|
|
|
|
|
IT IS UNOFFICIAL IN THE SENSE THAT THE AUTHOR Tim Goodwin |
32
|
|
|
|
|
|
|
HASN'T APPROVED IT (YET, I HOPE). BECAUSE OF THIS, THIS |
33
|
|
|
|
|
|
|
DISTRIBUTION IS NOT INDEXED AND AVAILABLE VIA cpan OR cpanp |
34
|
|
|
|
|
|
|
SHELLS UNLESS YOU EXPLICITLY SAY |
35
|
|
|
|
|
|
|
"install FERREIRA/Term-Size-0.203.tar.gz". |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
THIS IS UNDELICATE? I THINK IT IS IN A CERTAIN SENSE. BUT IT |
38
|
|
|
|
|
|
|
IS A WAY TO UNFREEZE THE CURRENT DISTRIBUTION STATUS. IF TIM |
39
|
|
|
|
|
|
|
DISAPPROVES, I WILL REMOVE THIS DISTRIBUTION RIGHT AWAY. |
40
|
|
|
|
|
|
|
IF HE APPROVES, I WILL REMOVE THIS DISTRIBUTION RIGHT AWAY |
41
|
|
|
|
|
|
|
AND WORK OUT (AFTER BEEN GIVEN MAINTAINERSHIP STATUS) |
42
|
|
|
|
|
|
|
A DISTRIBUTION WITHOUT THIS NOTE AND WHICH INDEXES CORRECTLY. |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
B is a Perl module which provides a straightforward way to |
45
|
|
|
|
|
|
|
retrieve the terminal size. |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Both functions take an optional filehandle argument, which defaults to |
48
|
|
|
|
|
|
|
C<*STDIN{IO}>. They both return a list of two values, which are the |
49
|
|
|
|
|
|
|
current width and height, respectively, of the terminal associated with |
50
|
|
|
|
|
|
|
the specified filehandle. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
C returns the size in units of characters, whereas |
53
|
|
|
|
|
|
|
C uses units of pixels. |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
In a scalar context, both functions return the first element of the |
56
|
|
|
|
|
|
|
list, that is, the terminal width. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
The functions may be imported. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
If you need to pass a filehandle to either of the C |
61
|
|
|
|
|
|
|
functions, beware that the C<*STDOUT{IO}> syntax is only supported in |
62
|
|
|
|
|
|
|
Perl 5.004 and later. If you have an earlier version of Perl, or are |
63
|
|
|
|
|
|
|
interested in backwards compatibility, use C<*STDOUT> instead. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 EXAMPLES |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1. Refuse to run in a too narrow window. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
use Term::Size; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
die "Need 80 column screen" if Term::Size::chars *STDOUT{IO} < 80; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
2. Track window size changes. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
use Term::Size 'chars'; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
my $changed = 1; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
while (1) { |
80
|
|
|
|
|
|
|
local $SIG{'WINCH'} = sub { $changed = 1 }; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
if ($changed) { |
83
|
|
|
|
|
|
|
($cols, $rows) = chars; |
84
|
|
|
|
|
|
|
# Redraw, or whatever. |
85
|
|
|
|
|
|
|
$changed = 0; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 RETURN VALUES |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Both functions return C if there is an error. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
If the terminal size information is not available, the functions |
94
|
|
|
|
|
|
|
will normally return C<(0, 0)>, but this depends on your system. On |
95
|
|
|
|
|
|
|
character only terminals, C will normally return C<(0, 0)>. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 BUGS |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
It only works on Unix systems. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 AUTHOR |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Tim Goodwin, , 1997-04-23. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Candidate for maintainership: |
106
|
|
|
|
|
|
|
Adriano Ferreira, , 2006-05-19. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=cut |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
bootstrap Term::Size::Unix $VERSION; |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
1; |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
__END__ |