line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Term::ReadLine::EditLine; |
2
|
2
|
|
|
2
|
|
31237
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
77
|
|
3
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
64
|
|
4
|
2
|
|
|
2
|
|
73
|
use 5.008005; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
111
|
|
5
|
|
|
|
|
|
|
our $VERSION = '1.1.1'; |
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
937
|
use Term::EditLine; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use Term::ReadLine; |
9
|
|
|
|
|
|
|
use Carp (); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our @ISA = qw(Term::ReadLine::Stub); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub ReadLine { __PACKAGE__ } |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub new { |
16
|
|
|
|
|
|
|
my $class = shift; |
17
|
|
|
|
|
|
|
unless (@_ > 0) { |
18
|
|
|
|
|
|
|
Carp::croak("Usage: Term::ReadLine::EditLine->new(\$program[, IN, OUT])"); |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
my $editline = Term::EditLine->new(@_); |
21
|
|
|
|
|
|
|
$editline->set_editor('emacs'); # set emacs as default mode. |
22
|
|
|
|
|
|
|
my $self = bless { |
23
|
|
|
|
|
|
|
editline => $editline, |
24
|
|
|
|
|
|
|
IN => $_[1] || *STDIN, |
25
|
|
|
|
|
|
|
OUT => $_[2] || *STDOUT, |
26
|
|
|
|
|
|
|
}, $class; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub editline { $_[0]->{editline} } |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub readline { |
32
|
|
|
|
|
|
|
my ($self, $prompt) = @_; |
33
|
|
|
|
|
|
|
if (defined($prompt)) { |
34
|
|
|
|
|
|
|
$self->editline->set_prompt($prompt); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
$self->editline->gets(); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub addhistory { |
40
|
|
|
|
|
|
|
my ($self, $history) = @_; |
41
|
|
|
|
|
|
|
$self->editline->history_enter($history); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub IN { $_[0]->{IN} } |
45
|
|
|
|
|
|
|
sub OUT { $_[0]->{OUT} } |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub MinLine { undef } |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub findConsole { |
50
|
|
|
|
|
|
|
my $console; |
51
|
|
|
|
|
|
|
my $consoleOUT; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
if (-e "/dev/tty" and $^O ne 'MSWin32') { |
54
|
|
|
|
|
|
|
$console = "/dev/tty"; |
55
|
|
|
|
|
|
|
} elsif (-e "con" or $^O eq 'MSWin32') { |
56
|
|
|
|
|
|
|
$console = 'CONIN$'; |
57
|
|
|
|
|
|
|
$consoleOUT = 'CONOUT$'; |
58
|
|
|
|
|
|
|
} else { |
59
|
|
|
|
|
|
|
$console = "sys\$command"; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
if (($^O eq 'amigaos') || ($^O eq 'beos') || ($^O eq 'epoc')) { |
63
|
|
|
|
|
|
|
$console = undef; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
elsif ($^O eq 'os2') { |
66
|
|
|
|
|
|
|
if ($DB::emacs) { |
67
|
|
|
|
|
|
|
$console = undef; |
68
|
|
|
|
|
|
|
} else { |
69
|
|
|
|
|
|
|
$console = "/dev/con"; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
$consoleOUT = $console unless defined $consoleOUT; |
74
|
|
|
|
|
|
|
$console = "&STDIN" unless defined $console; |
75
|
|
|
|
|
|
|
if ($console eq "/dev/tty" && !open(my $fh, "<", $console)) { |
76
|
|
|
|
|
|
|
$console = "&STDIN"; |
77
|
|
|
|
|
|
|
undef($consoleOUT); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
if (!defined $consoleOUT) { |
80
|
|
|
|
|
|
|
$consoleOUT = defined fileno(STDERR) && $^O ne 'MSWin32' ? "&STDERR" : "&STDOUT"; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
($console,$consoleOUT); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub Attribs { +{ } } |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub Features { |
88
|
|
|
|
|
|
|
+{ } |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
1; |
92
|
|
|
|
|
|
|
__END__ |