| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# Copyright (C) 2014 Rocky Bernstein |
|
2
|
|
|
|
|
|
|
package Term::ReadLine::Perl5::History; |
|
3
|
11
|
|
|
11
|
|
2886
|
eval "use rlib '.' "; # rlib is now optional |
|
|
11
|
|
|
|
|
5856
|
|
|
|
11
|
|
|
|
|
69
|
|
|
4
|
11
|
|
|
11
|
|
2859
|
use Term::ReadLine::Perl5::OO::History; |
|
|
11
|
|
|
|
|
34
|
|
|
|
11
|
|
|
|
|
414
|
|
|
5
|
|
|
|
|
|
|
=pod |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Term::ReadLine::Perl5::History |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Variables and functions supporting L's command |
|
14
|
|
|
|
|
|
|
history. This pretends to be OO code even though it isn't. It makes |
|
15
|
|
|
|
|
|
|
use of global package variables and wraps that up as an object to pass |
|
16
|
|
|
|
|
|
|
to the corresponding OO routine. |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
The underlying OO routines are in |
|
19
|
|
|
|
|
|
|
L. |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=cut |
|
22
|
|
|
|
|
|
|
|
|
23
|
11
|
|
|
11
|
|
74
|
use warnings; use strict; |
|
|
11
|
|
|
11
|
|
26
|
|
|
|
11
|
|
|
|
|
313
|
|
|
|
11
|
|
|
|
|
65
|
|
|
|
11
|
|
|
|
|
50
|
|
|
|
11
|
|
|
|
|
341
|
|
|
24
|
|
|
|
|
|
|
|
|
25
|
11
|
|
|
|
|
9927
|
use vars qw(@EXPORT @ISA @rl_History $rl_HistoryIndex $rl_history_length |
|
26
|
|
|
|
|
|
|
$rl_MaxHistorySize $rl_max_input_history $history_base |
|
27
|
11
|
|
|
11
|
|
63
|
$history_stifled); |
|
|
11
|
|
|
|
|
24
|
|
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
@ISA = qw(Exporter); |
|
30
|
|
|
|
|
|
|
@EXPORT = qw(@rl_History $rl_HistoryIndex $rl_history_length |
|
31
|
|
|
|
|
|
|
&add_line_to_history |
|
32
|
|
|
|
|
|
|
$rl_MaxHistorySize $rl_max_input_history $history_stifled); |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# FIXME: eventually we will remove these variables when we are fully OO. |
|
35
|
|
|
|
|
|
|
@rl_History = (); |
|
36
|
|
|
|
|
|
|
$rl_MaxHistorySize = 100; |
|
37
|
|
|
|
|
|
|
$rl_history_length = 0; |
|
38
|
|
|
|
|
|
|
$rl_max_input_history = 0; |
|
39
|
|
|
|
|
|
|
$rl_history_length = $rl_max_input_history = 0; |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
$history_stifled = 0; |
|
42
|
|
|
|
|
|
|
$history_base = 0; |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 SUBROUTINES |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head2 add_line_to_history |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
B(I<$line>, I<$minlength>) |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Insert I<$line> into history list if I<$line> is: |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=over |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=item * |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
bigger than the minimal length I<$minlength> |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=item * |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
not same as last entry |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=back |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=cut |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# Fake up a needed object using global state |
|
67
|
|
|
|
|
|
|
sub _fake_self() { |
|
68
|
|
|
|
|
|
|
{ |
|
69
|
28
|
|
|
28
|
|
204
|
rl_History => \@rl_History, |
|
70
|
|
|
|
|
|
|
rl_MaxHistorySize => $rl_MaxHistorySize, |
|
71
|
|
|
|
|
|
|
rl_HistoryIndex => $rl_HistoryIndex, |
|
72
|
|
|
|
|
|
|
rl_history_length => $rl_history_length, |
|
73
|
|
|
|
|
|
|
rl_max_input_history => $rl_max_input_history, |
|
74
|
|
|
|
|
|
|
history_stifled => $history_stifled, |
|
75
|
|
|
|
|
|
|
}; |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
# FIXME: DRY this adding a common routine to fake $self. |
|
80
|
|
|
|
|
|
|
sub add_line_to_history |
|
81
|
|
|
|
|
|
|
{ |
|
82
|
0
|
|
|
0
|
1
|
0
|
my ($line, $minlength) = @_; |
|
83
|
|
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
0
|
my $self = _fake_self(); |
|
85
|
0
|
|
|
|
|
0
|
Term::ReadLine::Perl5::OO::History::add_line_to_history( |
|
86
|
|
|
|
|
|
|
$self, $line, $minlength); |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub add_history |
|
91
|
|
|
|
|
|
|
{ |
|
92
|
3
|
|
|
3
|
0
|
11
|
shift; |
|
93
|
3
|
|
|
|
|
10
|
my $self = _fake_self(); |
|
94
|
3
|
|
|
|
|
18
|
Term::ReadLine::Perl5::OO::History::add_history($self, @_); |
|
95
|
3
|
|
|
|
|
7
|
$rl_MaxHistorySize = $self->{rl_MaxHistorySize}; |
|
96
|
3
|
|
|
|
|
6
|
$rl_HistoryIndex = $self->{rl_HistoryIndex}; |
|
97
|
3
|
|
|
|
|
10
|
$rl_history_length = $self->{rl_history_length}; |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub clear_history() |
|
101
|
|
|
|
|
|
|
{ |
|
102
|
0
|
|
|
0
|
0
|
0
|
my $self = _fake_self(); |
|
103
|
0
|
|
|
|
|
0
|
Term::ReadLine::Perl5::OO::History::clear_history($self); |
|
104
|
0
|
|
|
|
|
0
|
@rl_History = @{$self->{rl_History}}; |
|
|
0
|
|
|
|
|
0
|
|
|
105
|
0
|
|
|
|
|
0
|
$rl_MaxHistorySize = $self->{rl_MaxHistorySize}; |
|
106
|
0
|
|
|
|
|
0
|
$rl_HistoryIndex = $self->{rl_HistoryIndex}; |
|
107
|
0
|
|
|
|
|
0
|
$rl_history_length = $self->{rl_history_length}; |
|
108
|
|
|
|
|
|
|
} |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub GetHistory() |
|
112
|
|
|
|
|
|
|
{ |
|
113
|
8
|
|
|
8
|
0
|
34
|
Term::ReadLine::Perl5::OO::History::GetHistory(_fake_self()); |
|
114
|
|
|
|
|
|
|
} |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub history_is_stifled($) { |
|
117
|
5
|
|
|
5
|
0
|
8
|
shift; |
|
118
|
5
|
|
|
|
|
11
|
my $self = _fake_self(); |
|
119
|
5
|
|
|
|
|
15
|
return Term::ReadLine::Perl5::OO::History::history_is_stifled($self); |
|
120
|
|
|
|
|
|
|
} |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub read_history($$) { |
|
123
|
2
|
|
|
2
|
0
|
6
|
my ($unused, $filename) = @_; |
|
124
|
2
|
|
|
|
|
7
|
my $self = _fake_self(); |
|
125
|
2
|
|
|
|
|
11
|
my $ret = Term::ReadLine::Perl5::OO::History::read_history($self, |
|
126
|
|
|
|
|
|
|
$filename); |
|
127
|
2
|
|
|
|
|
6
|
@rl_History = @{$self->{rl_History}}; |
|
|
2
|
|
|
|
|
8
|
|
|
128
|
2
|
|
|
|
|
6
|
$rl_MaxHistorySize = $self->{rl_MaxHistorySize}; |
|
129
|
2
|
|
|
|
|
4
|
$rl_HistoryIndex = $self->{rl_HistoryIndex}; |
|
130
|
2
|
|
|
|
|
5
|
$rl_history_length = $self->{rl_history_length}; |
|
131
|
2
|
|
|
|
|
8
|
return $ret; |
|
132
|
|
|
|
|
|
|
} |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
sub ReadHistory($$) { |
|
135
|
1
|
|
|
1
|
0
|
4
|
my ($unused, $filename) = @_; |
|
136
|
1
|
|
|
|
|
7
|
! read_history($unused, $filename); |
|
137
|
|
|
|
|
|
|
} |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
sub remove_history($) |
|
140
|
|
|
|
|
|
|
{ |
|
141
|
1
|
|
|
1
|
0
|
5
|
shift; |
|
142
|
1
|
|
|
|
|
6
|
my ($which) = @_; |
|
143
|
1
|
|
|
|
|
6
|
my $self = _fake_self(); |
|
144
|
1
|
|
|
|
|
8
|
Term::ReadLine::Perl5::OO::History::remove_history($self, $which); |
|
145
|
1
|
|
|
|
|
2
|
@rl_History = @{$self->{rl_History}}; |
|
|
1
|
|
|
|
|
4
|
|
|
146
|
1
|
|
|
|
|
3
|
$rl_MaxHistorySize = $self->{rl_MaxHistorySize}; |
|
147
|
1
|
|
|
|
|
3
|
$rl_HistoryIndex = $self->{rl_HistoryIndex}; |
|
148
|
1
|
|
|
|
|
14
|
$rl_history_length = $self->{rl_history_length}; |
|
149
|
|
|
|
|
|
|
} |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
sub replace_history_entry { |
|
152
|
1
|
|
|
1
|
0
|
2
|
shift; |
|
153
|
1
|
|
|
|
|
4
|
my ($which, $data) = @_; |
|
154
|
1
|
|
|
|
|
3
|
my $self = _fake_self(); |
|
155
|
1
|
|
|
|
|
6
|
my $replaced = |
|
156
|
|
|
|
|
|
|
Term::ReadLine::Perl5::OO::History::replace_history_entry($self, |
|
157
|
|
|
|
|
|
|
$which, |
|
158
|
|
|
|
|
|
|
$data); |
|
159
|
1
|
|
|
|
|
2
|
@rl_History = @{$self->{rl_History}}; |
|
|
1
|
|
|
|
|
5
|
|
|
160
|
1
|
|
|
|
|
3
|
$rl_MaxHistorySize = $self->{rl_MaxHistorySize}; |
|
161
|
1
|
|
|
|
|
5
|
$rl_HistoryIndex = $self->{rl_HistoryIndex}; |
|
162
|
1
|
|
|
|
|
7
|
$rl_history_length = $self->{rl_history_length}; |
|
163
|
1
|
|
|
|
|
6
|
return $replaced; |
|
164
|
|
|
|
|
|
|
} |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
sub SetHistory |
|
167
|
|
|
|
|
|
|
{ |
|
168
|
5
|
|
|
5
|
0
|
858
|
shift; |
|
169
|
|
|
|
|
|
|
# Fake up a needed object using global state |
|
170
|
5
|
|
|
|
|
23
|
my $self = _fake_self(); |
|
171
|
5
|
|
|
|
|
32
|
Term::ReadLine::Perl5::OO::History::SetHistory($self, @_); |
|
172
|
5
|
|
|
|
|
14
|
@rl_History = @{$self->{rl_History}}; |
|
|
5
|
|
|
|
|
20
|
|
|
173
|
5
|
|
|
|
|
15
|
$rl_MaxHistorySize = $self->{rl_MaxHistorySize}; |
|
174
|
5
|
|
|
|
|
13
|
$rl_HistoryIndex = $self->{rl_HistoryIndex}; |
|
175
|
5
|
|
|
|
|
21
|
$rl_history_length = $self->{rl_history_length}; |
|
176
|
|
|
|
|
|
|
} |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
sub unstifle_history($) |
|
179
|
|
|
|
|
|
|
{ |
|
180
|
1
|
|
|
1
|
0
|
2
|
shift; |
|
181
|
1
|
|
|
|
|
3
|
my $self = _fake_self(); |
|
182
|
1
|
|
|
|
|
6
|
Term::ReadLine::Perl5::OO::History::unstifle_history($self); |
|
183
|
1
|
|
|
|
|
4
|
$history_stifled = $self->{history_stifled}; |
|
184
|
|
|
|
|
|
|
} |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
sub write_history($$) { |
|
187
|
1
|
|
|
1
|
0
|
4
|
my ($unused, $filename) = @_; |
|
188
|
1
|
|
|
|
|
3
|
my $self = _fake_self(); |
|
189
|
1
|
|
|
|
|
4
|
Term::ReadLine::Perl5::OO::History::write_history($self, |
|
190
|
|
|
|
|
|
|
$filename); |
|
191
|
|
|
|
|
|
|
} |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
sub WriteHistory($$) { |
|
194
|
1
|
|
|
1
|
0
|
10
|
my ($unused, $filename) = @_; |
|
195
|
1
|
|
|
|
|
5
|
my $self = _fake_self(); |
|
196
|
1
|
|
|
|
|
6
|
Term::ReadLine::Perl5::OO::History::WriteHistory($self, |
|
197
|
|
|
|
|
|
|
$filename); |
|
198
|
|
|
|
|
|
|
} |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
1; |