lib/Term/ReadLine/Perl5/Dumb.pm

filter: Statementstmt 45.1% 14 / 31 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 66.6% 4 / 6 Podpod 50.0% 1 / 2 totaltotal 42.2% 19 / 45 CC 4 SCAR 22.6
CC
4
Cov
38%
readline
20.0
get_line
2.0
BEGIN
1.0
CRAP 9.6
« blib/lib/Term/ReadLine/Perl5/Dumb.pm ↑ Summary lib/Term/ReadLine/Perl5/Keymap.pm »
1 package Term::ReadLine::Perl5::Dumb;
2 11 ▶use strict; use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
3 =head1 NAME
4  
5 Term::ReadLine::Perl5::Dumb
6  
7 =head1 DESCRIPTION
8  
9 A non-OO package for dumb terminals similar to GNU's readline. The
10 preferred OO Package is L<Term::ReadLine::Perl5>.
11  
12 Since L<Term::ReadLine::Perl5::readline> currently has global state,
13 when more than one interface is created, we fallback to this code.
14  
15 =cut
16  
17 11 ▶eval "use rlib '.' "; # rlib is now optional
Subroutine BEGIN: called CC=1 SCAR=0.0
18 11 ▶use Term::ReadLine::Perl5::History;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 sub get_line($) {
21 0 ▶ my $term_IN = shift;
Subroutine get_line: not called CC=1 SCAR=6.9
Pod undocumented
22 0 scalar <$term_IN>;
23 }
24  
25 =head1 SUBROUTINES
26  
27 =head2 readline
28  
29 B<readline>(I<$prompt>, [I<$in>, [I<$out>]])
30  
31 A version readline for a dumb terminal, that is one that doesn't have
32 many terminal editing capabilities. I<$prompt> is the prompt to
33 display; optional arguments I<$in> and I<$out> specify input and
34 output file handles. I<STDIN> and I<STDOUT> are used when the
35 corresponding file handles are not given.
36  
37 =cut
38  
39 sub readline($;$$)
40 {
41 0 ▶ my ($prompt, $term_IN, $term_OUT) = @_;
Subroutine readline: not called CC=4 SCAR=30.0
Pod documented
42 0 ▶ $term_IN = \*STDIN unless defined $term_IN;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $term_IN 0 0 0
43 0 ▶ $term_OUT = \*STDOUT unless defined $term_OUT;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $term_OUT 0 0 0
44 0 my $old = select $term_OUT;
45 0 local $\ = '';
46 0 local $| = 1;
47 0 print $term_OUT $prompt;
48 0 local $/ = "\n";
49 0 my $line;
50 0 ▶ if (!defined($line = get_line($term_IN))) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined($line = &get_line($term_IN))) 0 0 0
51 0 select $old;
52 0 return undef;
53 }
54 0 select $old;
55 0 chomp($line);
56 0 return $line;
57 }
58  
59 =head1 SEE ALSO
60  
61 L<Term::ReadLine::Perl5>
62 =cut
63  
64 11 1;
« blib/lib/Term/ReadLine/Perl5/Dumb.pm ↑ Summary lib/Term/ReadLine/Perl5/Keymap.pm »