blib/lib/Term/ReadLine/Perl5/TermCap.pm untested

filter: Statementstmt 0.0% 0 / 24 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 4 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 3 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 45 CC 7 SCAR 33.9
CC
7
Cov
0%
ornaments
42.0
LoadTermCap
6.0
BEGIN
2.0
CRAP 29.6
1 =encoding utf8
2  
3 =head1 Term::ReadLine::Perl5::TermCap
4  
5 This is copied from L<Term::ReadLine> to remove the cyclic dependency
6 I<Term::ReadLine> -> I<Term::ReadLine::Perl5> -> I<Term::ReadLine>
7 With this, I have modifed I<Term::ReadLine::Perl5> to no longer depend
8 on I<Term::Readline>.
9  
10 =cut
11 package Term::ReadLine::Perl5::TermCap;
12  
13 # Prompt-start, prompt-end, command-line-start, command-line-end
14 # -- zero-width beautifies to emit around prompt and the command line.
15 our @rl_term_set = ("","","","");
16 # string encoded:
17 our $rl_term_set = ',,,';
18  
19 our $terminal;
20 sub LoadTermCap {
21 return if defined $terminal;
22  
23 require Term::Cap;
24 $terminal = Tgetent Term::Cap ({OSPEED => 9600}); # Avoid warning.
25 }
26  
27 sub ornaments {
28 shift;
29 return $rl_term_set unless @_;
30 $rl_term_set = shift;
31 $rl_term_set ||= ',,,';
32 $rl_term_set = 'us,ue,md,me' if $rl_term_set eq '1';
33 my @ts = split /,/, $rl_term_set, 4;
34 eval { LoadTermCap };
35 unless (defined $terminal) {
36 warn("Cannot find termcap: $@\n") unless $Term::ReadLine::termcap_nowarn;
37 $rl_term_set = ',,,';
38 return;
39 }
40 @rl_term_set = map {$_ ? $terminal->Tputs($_,1) || '' : ''} @ts;
41 return $rl_term_set;
42 }
43  
44 1;