line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Term::Completion::_termsize;
|
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
6
|
use strict;
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
361
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
my $get_term_size;
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# try to load Term::Size
|
8
|
|
|
|
|
|
|
if( eval { require Term::Size; 1; } && !$@) {
|
9
|
|
|
|
|
|
|
$get_term_size = sub {
|
10
|
|
|
|
|
|
|
return Term::Size::chars($_[0]);
|
11
|
|
|
|
|
|
|
};
|
12
|
|
|
|
|
|
|
}
|
13
|
|
|
|
|
|
|
# we try poor man's ioctl - stolen from perlfaq8
|
14
|
|
|
|
|
|
|
else {
|
15
|
|
|
|
|
|
|
eval { require 'sys/ioctl.ph'; 1; };
|
16
|
|
|
|
|
|
|
eval { require 'sys/termios.ph'; 1; };
|
17
|
|
|
|
|
|
|
if(defined &TIOCGWINSZ) {
|
18
|
|
|
|
|
|
|
$get_term_size = sub {
|
19
|
|
|
|
|
|
|
my $winsize = '';
|
20
|
|
|
|
|
|
|
unless(ioctl($_[0], &TIOCGWINSZ, $winsize) =~ /^0/) {
|
21
|
|
|
|
|
|
|
return;
|
22
|
|
|
|
|
|
|
}
|
23
|
|
|
|
|
|
|
my ($row, $col, $xpixel, $ypixel) = unpack('S4', $winsize);
|
24
|
|
|
|
|
|
|
return($col,$row);
|
25
|
|
|
|
|
|
|
};
|
26
|
|
|
|
|
|
|
} else {
|
27
|
|
|
|
|
|
|
# we don't have a way to get the terminal size
|
28
|
|
|
|
|
|
|
$get_term_size = sub {
|
29
|
|
|
|
|
|
|
return (undef, undef);
|
30
|
|
|
|
|
|
|
}
|
31
|
|
|
|
|
|
|
}
|
32
|
|
|
|
|
|
|
}
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub get_term_size
|
35
|
|
|
|
|
|
|
{
|
36
|
1
|
|
|
1
|
1
|
445
|
my __PACKAGE__ $this = shift;
|
37
|
1
|
|
|
|
|
3
|
my ($c,$r);
|
38
|
1
|
50
|
|
|
|
5
|
if(defined $get_term_size) {
|
39
|
1
|
|
|
|
|
5
|
($c,$r) = &$get_term_size($this->{out});
|
40
|
|
|
|
|
|
|
} else {
|
41
|
0
|
|
|
|
|
0
|
($c,$r) = ($Term::Completion::DEFAULTS{columns},
|
42
|
|
|
|
|
|
|
$Term::Completion::DEFAULTS{rows});
|
43
|
|
|
|
|
|
|
}
|
44
|
|
|
|
|
|
|
return (
|
45
|
1
|
50
|
|
|
|
7
|
(defined $this->{columns} ? $this->{columns} : $c),
|
|
|
50
|
|
|
|
|
|
46
|
|
|
|
|
|
|
(defined $this->{rows} ? $this->{rows} : $r)
|
47
|
|
|
|
|
|
|
);
|
48
|
|
|
|
|
|
|
}
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1;
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
__END__
|