UI-Various
view release on metacpan or search on metacpan
lib/UI/Various/PoorTerm/Listbox.pm view on Meta::CPAN
{
$_++;
if (0 <= $i && $i < $entries)
{
if ($selection)
{
print $self->_cut(sprintf($pre_active, $_),
$self->{_selected}[$i], ' ',
$self->{texts}[$i]), "\n";
}
else
{ print $self->_cut($self->{texts}[$i]), "\n"; }
$i++;
}
else
{
print "\n" unless $empty > 2;
$empty++;
}
}
print sprintf($pre_active, 0), ' ', msg('leave_listbox'), "\n";
$_ = '';
while ($_ eq '')
{
print $prompt;
$_ = <STDIN>;
print $_;
s/\s+$//;
unless (($entries > $h and m/^[-+]$/) or
(m/^$re_selection$/ and $1 <= $h))
{ error('invalid_selection'); $_ = ''; next; }
}
if ($_ eq '+')
{
$self->{first} += $h;
$self->{first} + $h <= $entries or $self->{first} = $entries - $h;
}
elsif ($_ eq '-')
{
$self->{first} -= $h;
$self->{first} >= 0 or $self->{first} = 0;
}
else
{
my $changes = 0;
if ($selection == 1)
{
if ($_ > 0)
{
foreach my $i (0..$#{$self->texts})
{
$self->{_selected}[$i] =
$i != $self->{first} + $_ - 1 ? ' ' :
$self->{_selected}[$i] eq ' ' ? '*' : ' ';
$changes++;
}
}
}
else
{
foreach (split m/,\s*/, $_)
{
$_ > 0 or next;
$i = $self->{first} + $_ - 1;
$self->{_selected}[$i] =
$self->{_selected}[$i] eq ' ' ? '*' : ' ';
$changes++;
}
}
defined $self->{on_select} and $changes > 0 and
&{$self->{on_select}};
}
}
}
#########################################################################
=head2 B<_add> - add new element
C<PoorTerm>'s specific implementation of
L<UI::Various::Listbox::add|UI::Various::Listbox/add - add new element>
=cut
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
sub _add($@)
{ $_[0]->{_modified} = 1; }
#########################################################################
=head2 B<_remove> - remove element
C<PoorTerm>'s specific implementation of
L<UI::Various::Listbox::remove|UI::Various::Listbox/remove - remove element>
=cut
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
sub _remove($$)
{ $_[0]->{_modified} = 1; }
#########################################################################
=head2 B<_replace> - replace all elements
C<PoorTerm>'s specific implementation of
L<UI::Various::Listbox::replace|UI::Various::Listbox/replace - replace all
elements>
=cut
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
sub _replace($@)
{ $_[0]->{_modified} = 1; }
1;
#########################################################################
( run in 1.525 second using v1.01-cache-2.11-cpan-71847e10f99 )