UI-Various
view release on metacpan or search on metacpan
lib/UI/Various/RichTerm/Box.pm view on Meta::CPAN
# now for the content of the fields, which are returned in correct
# size by _show (and _format):
my $hf = $self->{_heights}[$row];
# 3. concatenate fields of columns line by line in temporary array:
my @output = ();
my $border = $self->border ? $D{B5} : ' ';
foreach my $column (0..($self->columns - 1))
{
$_ = $self->field($row, $column);
my $prefix = '';
if ($self->{_active}[$column])
{
if (defined $_ and $_->can('_process'))
{
my $tl = $self->_toplevel;
if ($tl and defined $tl->{_active_index}{$_})
{
my $i = $tl->{_active_index}{$_};
$prefix = sprintf($pre_active, $i);
}
}
else
{ $prefix = $blank; }
}
my ($w, $h) = @{$self->{_sizes}[$row][$column]};
my $content = defined $_
? $_->_show($prefix, $w, $h, $pre_active)
: $self->_format($prefix, '', '', ' ', '', '', 1, 1, 1);
my $wf = $self->{_widths}[$column] + length($prefix);
my @field =
split(m/\n/,
$self->_format('', '', '', $content, '', '', $wf, $hf, 1));
if ($column > 0)
{ $output[$_] .= $border . $field[$_] foreach (0..$#field); }
else
{ $output[$_] = $field[$_] foreach (0..$#field); }
}
# 4. build complete row:
my $bl = $self->border ? $D{B4} : '';
my $br = $self->border ? $D{B6} : '';
$text .= $self->_format('', $bl, '', \@output, '', $br, 0, 0);
$text .= "\n";
}
# 5. bottom border:
if ($self->border)
{
$text .= $D{B1};
foreach my $column (0..($self->columns - 1))
{
$text .= $D{b2} if $column > 0;
$text .= $D{B2} x $self->{_widths}[$column];
$text .= $D{B2} x length($blank) if $self->{_active}[$column];
}
$text .= $D{B3} . "\n";
}
# 6. final reformatting of whole block:
$outer_prefix = ' ' x length($outer_prefix);
my @text = split m/\n/, $text;
$text =
$self->_format($outer_prefix, '', '', \@text, '', '', $width, $height);
$text = $self->_color_simplify($text);
return $text;
}
1;
#########################################################################
#########################################################################
=head1 SEE ALSO
L<UI::Various>, L<UI::Various::Box>
=head1 LICENSE
Copyright (C) Thomas Dorner.
This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself. See LICENSE file for more details.
=head1 AUTHOR
Thomas Dorner E<lt>dorner (at) cpan (dot) orgE<gt>
=cut
( run in 1.266 second using v1.01-cache-2.11-cpan-5511b514fd6 )