1 #####################################################################
3 # The Perl::Tidy::VerticalAligner::Line class supplies an object to
4 # contain a single output line. It allows manipulation of the
5 # alignment columns on that line.
7 #####################################################################
9 package Perl::Tidy::VerticalAligner::Line;
12 use English qw( -no_match_vars );
13 our $VERSION = '20230309';
17 # Catch any undefined sub calls so that we are sure to get
18 # some diagnostic information. This sub should never be called
19 # except for a programming error.
21 return if ( $AUTOLOAD =~ /\bDESTROY$/ );
22 my ( $pkg, $fname, $lno ) = caller();
23 my $my_package = __PACKAGE__;
25 ======================================================================
26 Error detected in package '$my_package', version $VERSION
27 Received unexpected AUTOLOAD call for sub '$AUTOLOAD'
28 Called from package: '$pkg'
29 Called from File '$fname' at line '$lno'
30 This error is probably due to a recent programming change
31 ======================================================================
38 # Constructor may be called as a class method
40 my ( $class, $ri ) = @_;
41 my $self = bless $ri, $class;
46 my ( $self, $j ) = @_;
47 my $alignment = $self->{ralignments}->[$j];
48 return unless defined($alignment);
49 return $alignment->get_column();
50 } ## end sub get_column
52 sub current_field_width {
53 my ( $self, $j ) = @_;
57 my $alignment_j = $self->{ralignments}->[$j];
58 $col_j = $alignment_j->get_column() if defined($alignment_j);
61 my $alignment_jm = $self->{ralignments}->[ $j - 1 ];
62 $col_jm = $alignment_jm->get_column() if defined($alignment_jm);
64 return $col_j - $col_jm;
65 } ## end sub current_field_width
67 sub increase_field_width {
69 my ( $self, $j, $pad ) = @_;
70 my $jmax = $self->{jmax};
71 foreach ( $j .. $jmax ) {
72 my $alignment = $self->{ralignments}->[$_];
73 if ( defined($alignment) ) {
74 $alignment->increment_column($pad);
78 } ## end sub increase_field_width
80 sub get_available_space_on_right {
81 my $jmax = $_[0]->{jmax};
82 return $_[0]->{maximum_line_length} - $_[0]->get_column($jmax);