| 1 | 34 | ▶ | use strict; use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 2 | package Lingy::ReadLine; | ||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||
| 4 | 34 | ▶ | use Lingy::Common; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||
| 6 | 34 | ▶ | BEGIN { $ENV{PERL_RL} = 'Gnu' } | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 7 | 34 | ▶ | use Term::ReadLine; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||
| 9 | my $history_file = "$ENV{HOME}/.lingy_history"; | ||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||
| 11 | my $tty; | ||||||||||||||||||||||||||||||||
| 12 | { | ||||||||||||||||||||||||||||||||
| 13 | local @ENV{qw(HOME EDITOR)}; | ||||||||||||||||||||||||||||||||
| 14 | local $^W; | ||||||||||||||||||||||||||||||||
| 15 | $tty = Term::ReadLine->new('Lingy'); | ||||||||||||||||||||||||||||||||
| 16 | } | ||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||
| 18 | die "Please install Term::ReadLine::Gnu from CPAN\n" | ||||||||||||||||||||||||||||||||
| 19 | if $tty->ReadLine ne 'Term::ReadLine::Gnu'; | ||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||
| 21 | my $tested = 0; | ||||||||||||||||||||||||||||||||
| 22 | our $input; | ||||||||||||||||||||||||||||||||
| 23 | sub readline { | ||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | if (my $input = $ENV{LINGY_TEST_INPUT}) { | ||||||||||||||||||||||||||||||
|
Subroutine
readline: not called CC=7 SCAR=37.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 25 | 0 | ▶ | return if $tested++; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 26 | 0 | return $input; | |||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||
| 29 | 0 | my ($continue) = @_; | |||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | my $prompt = RT->current_ns_name or die; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | if ($continue) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 33 | 34 | ▶ | no warnings 'numeric'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 34 | 0 | $prompt = (' ' x (length($prompt) - 2)) . '#_'; | |||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||
| 36 | else { | ||||||||||||||||||||||||||||||||
| 37 | 0 | $input = ''; | |||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||
| 39 | 0 | $prompt .= '=> '; | |||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||
| 41 | 0 | $tty->ornaments(0); | |||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||
| 43 | local $SIG{INT} = sub { | ||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | print("\n"); | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 45 | 0 | $tty->replace_line('', 0); | |||||||||||||||||||||||||||||||
| 46 | 0 | $tty->on_new_line; | |||||||||||||||||||||||||||||||
| 47 | 0 | $tty->redisplay; | |||||||||||||||||||||||||||||||
| 48 | 0 | }; | |||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||
| 50 | 0 | $tty->parse_and_bind($_) for ( | |||||||||||||||||||||||||||||||
| 51 | 'set blink-matching-paren on', | ||||||||||||||||||||||||||||||||
| 52 | 'set show-all-if-ambiguous on', | ||||||||||||||||||||||||||||||||
| 53 | ); | ||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||
| 55 | 0 | $tty->Attribs->{completion_query_items} = 1000; | |||||||||||||||||||||||||||||||
| 56 | 0 | $tty->Attribs->{completion_function} = \&complete; | |||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||
| 58 | 0 | my $line = $tty->readline($prompt); | |||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | return unless defined $line; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 60 | 0 | $input .= $line; | |||||||||||||||||||||||||||||||
| 61 | 0 | return $line; | |||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||
| 64 | sub complete { | ||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | my ($text, $line, $start) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
complete: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | if ($text =~ m{^(\w+(\.\w+)*)/}) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 68 | 0 | my $prefix = $1; | |||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | if (my $ns = RT->namespaces->{$prefix}) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 70 | 0 | return map "$prefix/$_", keys %$ns; | |||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||
| 72 | # if (defined (my $class = RT->classes->{$prefix})) { | ||||||||||||||||||||||||||||||||
| 73 | # return map "$prefix/$_", $class->_method_names; | ||||||||||||||||||||||||||||||||
| 74 | # } | ||||||||||||||||||||||||||||||||
| 75 | 0 | return; | |||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||
| 78 | 0 | my $space = RT->env->space; | |||||||||||||||||||||||||||||||
| 79 | my @names = | ||||||||||||||||||||||||||||||||
| 80 | 0 | grep {not /^ /} ( | |||||||||||||||||||||||||||||||
| 81 | keys(%$space), | ||||||||||||||||||||||||||||||||
| 82 | 0 | keys(%{RT->namespaces}), | |||||||||||||||||||||||||||||||
| 83 | 0 | keys(%{RT->ns_refers->{$space->NAME}}), | |||||||||||||||||||||||||||||||
| 84 | map { | ||||||||||||||||||||||||||||||||
| 85 | 0 | my $name = $_; | |||||||||||||||||||||||||||||||
| 86 | 0 | $name =~ s/::/./g; | |||||||||||||||||||||||||||||||
| 87 | 0 | $name =~ s/^Lingy\.Lang\./lingy.lang./; | |||||||||||||||||||||||||||||||
| 88 | 0 | my $long = $name; | |||||||||||||||||||||||||||||||
| 89 | 0 | $name =~ s/.*\.//; | |||||||||||||||||||||||||||||||
| 90 | 0 | ($long, $name); | |||||||||||||||||||||||||||||||
| 91 | 0 | } @{RT->class_names}, | |||||||||||||||||||||||||||||||
| 92 | ); | ||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||
| 94 | grep /^\Q$text/, | ||||||||||||||||||||||||||||||||
| 95 | map { | ||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | /^-\w/ ? () : | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$text eq "" and /^(\w+\.)/
MC/DC0%0/2
$text eq "" and /^(\w+\.)/
$text eq ""
/^(\w+\.)/
Truth table0%0/3
A and B
A= $text eq ""B= /^(\w+\.)/
| |||||||||||||||||||||||||||||||||
| 97 | ($text eq '' and /^(\w+\.)/) ? $1 : | ||||||||||||||||||||||||||||||||
| 98 | $_ | ||||||||||||||||||||||||||||||||
| 99 | } ( | ||||||||||||||||||||||||||||||||
| 100 | @names, | ||||||||||||||||||||||||||||||||
| 101 | Lingy::Eval->special_symbols, | ||||||||||||||||||||||||||||||||
| 102 | ); | ||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||
| 105 | $tty->ReadHistory($history_file); | ||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||
| 107 | END { | ||||||||||||||||||||||||||||||||
| 108 | $tty->WriteHistory($history_file) | ||||||||||||||||||||||||||||||||
| 109 | 34 | ▶ | unless $ENV{LINGY_TEST}; | ||||||||||||||||||||||||||||||
|
Subroutine
END: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||
| 112 | 1; | ||||||||||||||||||||||||||||||||