| 1 | package Term::ReadLine::TTYtter; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | @ISA = qw(Term::ReadLine::Stub Term::ReadLine::TTYtter::Compa Term::ReadLine::TTYtter::AU); | |||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | $VERSION = $VERSION = 1.4; | |||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 0 | ▶ | sub readline { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
readline: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 0 | shift; | |||||||||||||||||||||||||||||||||||||||||
| 9 | 0 | &readline_ttytter::readline(@_); | |||||||||||||||||||||||||||||||||||||||||
| 10 | } | ||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | *addhistory = \&AddHistory; | |||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | *settophistory = \&SetTopHistory; | |||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | $readline_ttytter::minlength = 1; # To pacify -w | |||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | $readline_ttytter::rl_readline_name = undef; # To pacify -w | |||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | $readline_ttytter::rl_basic_word_break_characters = undef; # To pacify -w | |||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=19 SCAR=59.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | ▶ | if (defined $term) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | warn "Cannot create second readline interface, falling back to dumb.\n"; | |||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | return Term::ReadLine::Stub::new(@_); | |||||||||||||||||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | shift; # Package | |||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | ▶ | if ($term) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | warn "Ignoring name of second readline interface.\n" if defined $term; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | shift; | |||||||||||||||||||||||||||||||||||||||||
| 29 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | $readline_ttytter::rl_readline_name = shift; # Name | |||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | if (!@_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | if (!defined $term) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | ($IN,$OUT) = Term::ReadLine->findConsole(); | |||||||||||||||||||||||||||||||||||||||||
| 36 | # Old Term::ReadLine did not have a workaround for a bug in Win devdriver | ||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | ▶ | $IN = 'CONIN$' if $^O eq 'MSWin32' and "\U$IN" eq 'CON'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$^O eq "MSWin32" and uc $IN eq "CON"
MC/DC0%0/2
$^O eq "MSWin32" and uc $IN eq "CON"
$^O eq "MSWin32"
uc $IN eq "CON"
Truth table0%0/3
A and B
A= $^O eq "MSWin32"B= uc $IN eq "CON"
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | open IN, | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$IN eq "CONIN\$" and $^O eq "MSWin32"
MC/DC0%0/2
$IN eq "CONIN\$" and $^O eq "MSWin32"
$IN eq "CONIN\$"
$^O eq "MSWin32"
Truth table0%0/3
A and B
A= $IN eq "CONIN\$"B= $^O eq "MSWin32"
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | # A workaround for another bug in Win device driver | ||||||||||||||||||||||||||||||||||||||||||
| 40 | (($IN eq 'CONIN$' and $^O eq 'MSWin32') ? "+< $IN" : "< $IN") | ||||||||||||||||||||||||||||||||||||||||||
| 41 | or croak "Cannot open $IN for read"; | ||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | open(OUT,">$OUT") || croak "Cannot open $OUT for write"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | $readline_ttytter::term_IN = \*IN; | |||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | $readline_ttytter::term_OUT = \*OUT; | |||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||
| 46 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | if (defined $term and ($term->IN ne $_[0] or $term->OUT ne $_[1]) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $term and $term->IN ne $_[0] || $term->OUT ne $_[1]
$term->IN ne $_[0] or $term->OUT ne $_[1]
MC/DC0%0/3
defined $term and $term->IN ne $_[0] || $term->OUT ne $_[1]
defined $term
$term->IN ne $_[0]
$term->OUT ne $_[1]
Truth table0%0/4
A and B or C
A= defined $termB= $term->IN ne $_[0]C= $term->OUT ne $_[1]
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | croak "Request for a second readline interface with different terminal"; | |||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | $readline_ttytter::term_IN = shift; | |||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | $readline_ttytter::term_OUT = shift; | |||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | eval {require Term::ReadLine::readline_ttytter}; die $@ if $@; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | # The following is here since it is mostly used for perl input: | ||||||||||||||||||||||||||||||||||||||||||
| 55 | # $readline_ttytter::rl_basic_word_break_characters .= '-:+/*,[])}'; | ||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | $term = bless [$readline_ttytter::term_IN,$readline_ttytter::term_OUT]; | |||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | unless ($ENV{PERL_RL} and $ENV{PERL_RL} =~ /\bo\w*=0/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$ENV{"PERL_RL"} and $ENV{"PERL_RL"} =~ /\bo\w*=0/
MC/DC0%0/2
$ENV{"PERL_RL"} and $ENV{"PERL_RL"} =~ /\bo\w*=0/
$ENV{"PERL_RL"}
$ENV{"PERL_RL"} =~ /\bo\w*=0/
Truth table0%0/3
A and B
A= $ENV{"PERL_RL"}B= $ENV{"PERL_RL"} =~ /\bo\w*=0/
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | local $Term::ReadLine::termcap_nowarn = 1; # With newer Perls | |||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | local $SIG{__WARN__} = sub {}; # With older Perls | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | $term->ornaments(1); | |||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | return $term; | |||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | sub newTTY { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
newTTY: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | my ($self, $in, $out) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | $readline_ttytter::term_IN = $self->[0] = $in; | |||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | $readline_ttytter::term_OUT = $self->[1] = $out; | |||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | my $sel = select($out); | |||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | $| = 1; # for DB::OUT | |||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | select($sel); | |||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | sub ReadLine {'Term::ReadLine::TTYtter'} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ReadLine: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | sub Version { $Term::ReadLine::TTYtter::VERSION } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Version: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | sub MinLine { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
MinLine: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | my $old = $readline_ttytter::minlength; | |||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | $readline_ttytter::minlength = $_[1] if @_ == 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | return $old; | |||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | sub SetHistory { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
SetHistory: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | shift; | |||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | @readline_ttytter::rl_History = @_; | |||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | $readline_ttytter::rl_HistoryIndex = @readline_ttytter::rl_History; | |||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | ▶ | sub GetHistory { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
GetHistory: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | @readline_ttytter::rl_History; | |||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | sub AddHistory { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AddHistory: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | shift; | |||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | push @readline_ttytter::rl_History, @_; | |||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | $readline_ttytter::rl_HistoryIndex = @readline_ttytter::rl_History + @_; | |||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | sub SetTopHistory { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
SetTopHistory: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | shift; | |||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | pop @readline_ttytter::rl_History; | |||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | push @readline_ttytter::rl_History, @_; | |||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | $readline_ttytter::rl_HistoryIndex = @readline_ttytter::rl_History; | |||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||
| 98 | %features = (appname => 1, minline => 1, autohistory => 1, getHistory => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 99 | setHistory => 1, addHistory => 1, preput => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 100 | attribs => 1, 'newTTY' => 1, canRemoveReadline => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 101 | canRepaint => 1, canSetTopHistory => 1, canBackgroundSignal => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 102 | canHookUseAnsi => 1, canHookNoCounter => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 103 | tkRunning => Term::ReadLine::Stub->Features->{'tkRunning'}, | ||||||||||||||||||||||||||||||||||||||||||
| 104 | 1 | ornaments => Term::ReadLine::Stub->Features->{'ornaments'}, | |||||||||||||||||||||||||||||||||||||||||
| 105 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | sub Features { \%features; } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Features: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | # my %attribs; | ||||||||||||||||||||||||||||||||||||||||||
| 108 | 1 | ▶ | tie %attribs, 'Term::ReadLine::TTYtter::Tie' or die ; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | sub Attribs { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Attribs: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | \%attribs; | |||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | sub DESTROY {} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | package Term::ReadLine::TTYtter::AU; | ||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | ▶ | sub AUTOLOAD { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AUTOLOAD: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | { $AUTOLOAD =~ s/.*:://; } # preserve match data | |||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | my $name = "readline_ttytter::rl_$AUTOLOAD"; | |||||||||||||||||||||||||||||||||||||||||
| 119 | die "Cannot do `$AUTOLOAD' in Term::ReadLine::TTYtter" | ||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | ▶ | unless exists $readline_ttytter::{"rl_$AUTOLOAD"}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | *$AUTOLOAD = sub { shift; &$name }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | goto &$AUTOLOAD; | |||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | package Term::ReadLine::TTYtter::Tie; | ||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||
| 127 | 1 | ▶ | sub TIEHASH { bless {} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TIEHASH: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | sub DESTROY {} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | ▶ | sub STORE { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
STORE: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | my ($self, $name) = (shift, shift); | |||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | $ {'readline_ttytter::rl_' . $name} = shift; | |||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | sub FETCH { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
FETCH: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | my ($self, $name) = (shift, shift); | |||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | $ {'readline_ttytter::rl_' . $name}; | |||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||
| 139 | package Term::ReadLine::TTYtter::Compa; | ||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | sub get_c { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_c: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | getc($self->[0]); | |||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | sub get_line { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_line: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | my $fh = $self->[0]; | |||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | scalar <$fh>; | |||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||
| 152 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||