line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# You may distribute under the terms of either the GNU General Public License |
2
|
|
|
|
|
|
|
# or the Artistic License (the same terms as Perl itself) |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# (C) Paul Evans, 2014 -- leonerd@leonerd.org.uk |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package Tickit::Widget::Fill; |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
797
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
30
|
|
9
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
20
|
|
10
|
1
|
|
|
1
|
|
13
|
use 5.010; # // |
|
1
|
|
|
|
|
3
|
|
11
|
1
|
|
|
1
|
|
3
|
use base qw( Tickit::Widget ); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
53
|
|
12
|
|
|
|
|
|
|
use Tickit::Style; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $VERSION = '0.25'; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
use Tickit::Utils qw( textwidth ); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 NAME |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
C - fill an area with repeated text |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 DESCRIPTION |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
This class provides a widget which displays a given piece of text repeatedly |
25
|
|
|
|
|
|
|
over its entire area. By default the text is a single space, meaning the area |
26
|
|
|
|
|
|
|
will be entirely drawn with spaces. |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 STYLE |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
The default style pen is used as the widget pen. |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
The following style keys are used: |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=over 4 |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=item text => STRING |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
The text to display in a repeating pattern on the window. |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=item skew => INT |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
If defined, successive lines will be advanced by this number of columns (which |
43
|
|
|
|
|
|
|
may be negative) to create a skewed repeating pattern. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=back |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=cut |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
style_definition base => |
50
|
|
|
|
|
|
|
text => " "; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
style_redraw_keys qw( text skew ); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
use constant WIDGET_PEN_FROM_STYLE => 1; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub lines { 1 } |
57
|
|
|
|
|
|
|
sub cols { 1 } |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub render_to_rb |
60
|
|
|
|
|
|
|
{ |
61
|
|
|
|
|
|
|
my $self = shift; |
62
|
|
|
|
|
|
|
my ( $rb, $rect ) = @_; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
my ( $text, $skew ) = $self->get_style_values(qw( text skew )); |
65
|
|
|
|
|
|
|
$skew //= 0; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
my $len = textwidth( $text ); |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
my $left = $rect->left; |
70
|
|
|
|
|
|
|
$left -= $left % $len; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
my $repeat = int( ( $rect->right - $left + $len - 1 ) / $len ); |
73
|
|
|
|
|
|
|
$repeat++ if $skew; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
foreach my $line ( $rect->linerange ) { |
76
|
|
|
|
|
|
|
my $lineskew = ( $line * $skew ) % $len; |
77
|
|
|
|
|
|
|
$lineskew -= $len if $skew; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
$rb->goto( $line, $left + $lineskew ); |
80
|
|
|
|
|
|
|
$rb->text( $text x $repeat ); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 AUTHOR |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Paul Evans |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=cut |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
0x55AA; |