line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Term::ANSITable; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
13090
|
use 5.14.0; |
|
1
|
|
|
|
|
2
|
|
4
|
1
|
|
|
1
|
|
3
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
16
|
|
5
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
25
|
|
6
|
1
|
|
|
1
|
|
404
|
use Term::Size 'chars'; |
|
1
|
|
|
|
|
2067
|
|
|
1
|
|
|
|
|
348
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Term::ANSITable - Tool for drawing and redrawing tables on term! |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 VERSION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Version 0.010000 |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=cut |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our $VERSION = '0.010000'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head2 new |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
Constructor |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=cut |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub new { |
29
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
30
|
0
|
|
|
|
|
|
require Text::ANSITable; |
31
|
0
|
|
|
|
|
|
require Term::Cap; |
32
|
0
|
|
|
|
|
|
my $self = { |
33
|
|
|
|
|
|
|
_table => Text::ANSITable->new(@_), |
34
|
|
|
|
|
|
|
_terminal => Tgetent Term::Cap { TERM => 'cygwin', OSPEED => 9600 }, |
35
|
|
|
|
|
|
|
}; |
36
|
0
|
|
|
|
|
|
$self->{_terminal}->Trequire("up"); # move cursor up |
37
|
0
|
|
|
|
|
|
$self->{_sig_up} = $self->{_terminal}->Tputs("up"); |
38
|
0
|
|
|
|
|
|
bless $self, $class; |
39
|
0
|
|
|
|
|
|
return $self; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head2 table |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Getter/Setter for internal hash key _table. |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=cut |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub table { |
49
|
0
|
0
|
|
0
|
1
|
|
return $_[0]->{_table} unless $_[1]; |
50
|
0
|
|
|
|
|
|
$_[0]->{_table} = $_[1]; |
51
|
0
|
|
|
|
|
|
return $_[0]->{_table}; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head2 rows |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Get or set rows from Text::ANSITable object. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=cut |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub rows { |
61
|
0
|
0
|
|
0
|
1
|
|
return $_[0]->table->{rows} unless $_[1]; |
62
|
0
|
|
|
|
|
|
$_[0]->table->{rows} = $_[1]; |
63
|
0
|
|
|
|
|
|
return $_[0]->table->{rows}; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head2 add_row |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Add row to Text::ANSITable object. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=cut |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub add_row { |
73
|
0
|
|
|
0
|
1
|
|
my ( $self, $row ) = @_; |
74
|
0
|
|
|
|
|
|
$self->table->add_row($row); |
75
|
0
|
|
|
|
|
|
return $self; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head2 draw |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Draw table on term and go back to first line of row for redrawing |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=cut |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub draw { |
86
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
87
|
0
|
|
|
|
|
|
my @lines = split "\n", $self->table->draw; |
88
|
0
|
|
|
|
|
|
my $chars = chars * STDOUT { IO }; |
89
|
0
|
|
|
|
|
|
print $_, " " x ( $chars - length($_) ), $/ foreach (@lines); |
90
|
0
|
|
|
|
|
|
print $self->{_sig_up} foreach ( 1 .. scalar @lines ); |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head2 refresh_table |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Grep all empty rows from table. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=cut |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub refresh_table { |
101
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
102
|
0
|
|
|
|
|
|
$self->rows( [ grep { @$_ } @{ $self->rows } ] ); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
103
|
0
|
|
|
|
|
|
return $self; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
1; # End of Term::ANSITable |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
__END__ |