line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#_{ Encoding and name |
2
|
|
|
|
|
|
|
=encoding utf8 |
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Grid::Layout::Line |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=cut |
8
|
|
|
|
|
|
|
#_} |
9
|
|
|
|
|
|
|
package Grid::Layout::Line; |
10
|
|
|
|
|
|
|
#_{ use … |
11
|
5
|
|
|
5
|
|
27
|
use warnings; |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
127
|
|
12
|
5
|
|
|
5
|
|
21
|
use strict; |
|
5
|
|
|
|
|
6
|
|
|
5
|
|
|
|
|
68
|
|
13
|
5
|
|
|
5
|
|
17
|
use utf8; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
17
|
|
14
|
|
|
|
|
|
|
|
15
|
5
|
|
|
5
|
|
76
|
use Carp; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
1836
|
|
16
|
|
|
|
|
|
|
#_} |
17
|
|
|
|
|
|
|
our $VERSION = 0.01; |
18
|
|
|
|
|
|
|
#_{ Synopsis |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 SYNOPSIS |
21
|
|
|
|
|
|
|
=cut |
22
|
|
|
|
|
|
|
#_} |
23
|
|
|
|
|
|
|
#_{ Description |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 DESCRIPTION |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
A C<< Grid::Layout::Line >> is an indefinitismal thin line that runs either |
28
|
|
|
|
|
|
|
horizontally or vertically from one end of a grid to the other. |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
The |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
Of course, when the grid is rendered, the line might become thicker than indefinitismal thin (think border). |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=cut |
35
|
|
|
|
|
|
|
#_} |
36
|
|
|
|
|
|
|
#_{ Methods |
37
|
|
|
|
|
|
|
#_{ POD |
38
|
|
|
|
|
|
|
=head1 METHODS |
39
|
|
|
|
|
|
|
=cut |
40
|
|
|
|
|
|
|
#_} |
41
|
|
|
|
|
|
|
sub new { #_{ |
42
|
|
|
|
|
|
|
#_{ POD |
43
|
|
|
|
|
|
|
=head2 new |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
my $line = Grid::Layout::Line->new($V_or_H); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
This function should not be called by a user. It is called by L<< Grid::Layout/_add_line >>. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=cut |
50
|
|
|
|
|
|
|
#_} |
51
|
|
|
|
|
|
|
|
52
|
54
|
|
|
54
|
0
|
84
|
my $class = shift; |
53
|
54
|
|
|
|
|
62
|
my $grid_layout = shift; |
54
|
54
|
|
|
|
|
60
|
my $V_or_H = shift; # TODO not used... |
55
|
54
|
|
|
|
|
59
|
my $position = shift; |
56
|
|
|
|
|
|
|
|
57
|
54
|
50
|
|
|
|
135
|
croak "need a Grid::Layout" unless $grid_layout->isa('Grid::Layout'); |
58
|
54
|
50
|
66
|
|
|
146
|
croak "need a V or an H" unless $V_or_H eq 'V' or $V_or_H eq 'H'; |
59
|
54
|
50
|
|
|
|
166
|
croak "need a position" unless $position =~ /^\d+$/; |
60
|
|
|
|
|
|
|
|
61
|
54
|
|
|
|
|
85
|
my $self = {}; |
62
|
54
|
|
|
|
|
74
|
bless $self, $class; |
63
|
|
|
|
|
|
|
|
64
|
54
|
|
|
|
|
98
|
$self->{grid_layout} = $grid_layout; |
65
|
54
|
|
|
|
|
72
|
$self->{V_or_H } = $V_or_H; |
66
|
54
|
|
|
|
|
72
|
$self->{position } = $position; |
67
|
54
|
|
|
|
|
102
|
return $self; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
} #_} |
70
|
|
|
|
|
|
|
sub _previous_track { #_{ |
71
|
|
|
|
|
|
|
|
72
|
12
|
|
|
12
|
|
2584
|
my $self = shift; |
73
|
|
|
|
|
|
|
|
74
|
12
|
100
|
|
|
|
43
|
croak 'Cannot return previous track, I am line zero' unless $self->{position}; |
75
|
|
|
|
|
|
|
|
76
|
10
|
|
|
|
|
23
|
return $self->{grid_layout}->_track($self->{V_or_H}, $self->{position}-1); |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
} #_} |
79
|
|
|
|
|
|
|
sub _next_track { #_{ |
80
|
|
|
|
|
|
|
|
81
|
13
|
|
|
13
|
|
1276
|
my $self = shift; |
82
|
|
|
|
|
|
|
|
83
|
13
|
100
|
|
|
|
34
|
croak 'Cannot return next track, I am last line' unless $self->{position} < $self->{grid_layout}->_size($self->{V_or_H}); |
84
|
|
|
|
|
|
|
|
85
|
10
|
|
|
|
|
21
|
return $self->{grid_layout}->_track($self->{V_or_H}, $self->{position}); |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
} #_} |
88
|
|
|
|
|
|
|
sub previous_line { #_{ |
89
|
|
|
|
|
|
|
|
90
|
18
|
|
|
18
|
0
|
214
|
my $self = shift; |
91
|
18
|
|
100
|
|
|
40
|
my $dist = shift // 1; |
92
|
|
|
|
|
|
|
|
93
|
18
|
100
|
|
|
|
76
|
croak "Cannot return previous line $dist, I am line $self->{position}" unless $self->{position}-$dist >= 0; |
94
|
|
|
|
|
|
|
|
95
|
14
|
|
|
|
|
31
|
return $self->{grid_layout}->_line($self->{V_or_H}, $self->{position}-$dist); |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
} #_} |
98
|
|
|
|
|
|
|
sub next_line { #_{ |
99
|
|
|
|
|
|
|
|
100
|
18
|
|
|
18
|
0
|
194
|
my $self = shift; |
101
|
18
|
|
100
|
|
|
39
|
my $dist = shift // 1; |
102
|
|
|
|
|
|
|
|
103
|
18
|
100
|
|
|
|
53
|
croak "Cannot return next line $dist, I am line $self->{position} and the size is " . $self->{grid_layout}->_size($self->{V_or_H}) unless $self->{position}+$dist <= $self->{grid_layout}->_size($self->{V_or_H}); |
104
|
|
|
|
|
|
|
|
105
|
14
|
|
|
|
|
35
|
return $self->{grid_layout}->_line($self->{V_or_H}, $self->{position}+$dist); |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
} #_} |
108
|
|
|
|
|
|
|
#_} |
109
|
|
|
|
|
|
|
#_{ POD: Copyright |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 Copyright |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Copyright © 2017 René Nyffenegger, Switzerland. All rights reserved. |
114
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
115
|
|
|
|
|
|
|
under the terms of the the Artistic License (2.0). You may obtain a |
116
|
|
|
|
|
|
|
copy of the full license at: L |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=cut |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
#_} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
'tq84'; |