line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Term::UI::History; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
747
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
260
|
|
4
|
3
|
|
|
3
|
|
19
|
use vars qw[$VERSION]; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
203
|
|
5
|
3
|
|
|
3
|
|
717
|
use base 'Exporter'; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
369
|
|
6
|
3
|
|
|
3
|
|
18
|
use base 'Log::Message::Simple'; |
|
3
|
|
|
|
|
11
|
|
|
3
|
|
|
|
|
2303
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
$VERSION = '0.46'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=pod |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 NAME |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Term::UI::History - history function |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 SYNOPSIS |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
use Term::UI::History qw[history]; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
history("Some message"); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
### retrieve the history in printable form |
23
|
|
|
|
|
|
|
$hist = Term::UI::History->history_as_string; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
### redirect output |
26
|
|
|
|
|
|
|
local $Term::UI::History::HISTORY_FH = \*STDERR; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 DESCRIPTION |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
This module provides the C function for C, |
31
|
|
|
|
|
|
|
printing and saving all the C interaction. |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Refer to the C manpage for details on usage from |
34
|
|
|
|
|
|
|
C. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
This module subclasses C. Refer to its |
37
|
|
|
|
|
|
|
manpage for additional functionality available via this package. |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 FUNCTIONS |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head2 history("message string" [,VERBOSE]) |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Records a message on the stack, and prints it to C |
44
|
|
|
|
|
|
|
(or actually C<$HISTORY_FH>, see the C section |
45
|
|
|
|
|
|
|
below), if the C option is true. |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
The C option defaults to true. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=cut |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
BEGIN { |
52
|
3
|
|
|
3
|
|
108892
|
use Log::Message private => 0; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
20
|
|
53
|
|
|
|
|
|
|
|
54
|
3
|
|
|
3
|
|
946
|
use vars qw[ @EXPORT $HISTORY_FH ]; |
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
359
|
|
55
|
3
|
|
|
3
|
|
11
|
@EXPORT = qw[ history ]; |
56
|
3
|
|
|
|
|
20
|
my $log = new Log::Message; |
57
|
3
|
|
|
|
|
1185
|
$HISTORY_FH = \*STDOUT; |
58
|
|
|
|
|
|
|
|
59
|
3
|
|
|
|
|
8
|
for my $func ( @EXPORT ) { |
60
|
3
|
|
|
3
|
|
20
|
no strict 'refs'; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
525
|
|
61
|
|
|
|
|
|
|
|
62
|
2
|
|
|
2
|
|
3425
|
*$func = sub { my $msg = shift; |
63
|
2
|
|
|
|
|
23
|
$log->store( |
64
|
|
|
|
|
|
|
message => $msg, |
65
|
|
|
|
|
|
|
tag => uc $func, |
66
|
|
|
|
|
|
|
level => $func, |
67
|
|
|
|
|
|
|
extra => [@_] |
68
|
|
|
|
|
|
|
); |
69
|
3
|
|
|
|
|
587
|
}; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub history_as_string { |
73
|
3
|
|
|
3
|
0
|
1626
|
my $class = shift; |
74
|
|
|
|
|
|
|
|
75
|
3
|
|
|
|
|
22
|
return join $/, map { $_->message } __PACKAGE__->stack; |
|
2
|
|
|
|
|
554
|
|
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
{ |
81
|
|
|
|
|
|
|
package # hide this from PAUSE |
82
|
|
|
|
|
|
|
Log::Message::Handlers; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub history { |
85
|
2
|
|
|
2
|
0
|
2854
|
my $self = shift; |
86
|
2
|
|
|
|
|
5
|
my $verbose = shift; |
87
|
2
|
100
|
|
|
|
11
|
$verbose = 1 unless defined $verbose; # default to true |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
### so you don't want us to print the msg? ### |
90
|
2
|
100
|
66
|
|
|
24
|
return if defined $verbose && $verbose == 0; |
91
|
|
|
|
|
|
|
|
92
|
1
|
|
|
|
|
8
|
local $| = 1; |
93
|
1
|
|
|
|
|
6
|
my $old_fh = select $Term::UI::History::HISTORY_FH; |
94
|
|
|
|
|
|
|
|
95
|
1
|
|
|
|
|
14
|
print $self->message . "\n"; |
96
|
1
|
|
|
|
|
28
|
select $old_fh; |
97
|
|
|
|
|
|
|
|
98
|
1
|
|
|
|
|
7
|
return; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 GLOBAL VARIABLES |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=over 4 |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=item $HISTORY_FH |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
This is the filehandle all the messages sent to C are being |
110
|
|
|
|
|
|
|
printed. This defaults to C<*STDOUT>. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=back |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 See Also |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
C, C |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 AUTHOR |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
This module by |
121
|
|
|
|
|
|
|
Jos Boumans Ekane@cpan.orgE. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 COPYRIGHT |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
This module is |
126
|
|
|
|
|
|
|
copyright (c) 2005 Jos Boumans Ekane@cpan.orgE. |
127
|
|
|
|
|
|
|
All rights reserved. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
This library is free software; |
130
|
|
|
|
|
|
|
you may redistribute and/or modify it under the same |
131
|
|
|
|
|
|
|
terms as Perl itself. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=cut |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
1; |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
# Local variables: |
138
|
|
|
|
|
|
|
# c-indentation-style: bsd |
139
|
|
|
|
|
|
|
# c-basic-offset: 4 |
140
|
|
|
|
|
|
|
# indent-tabs-mode: nil |
141
|
|
|
|
|
|
|
# End: |
142
|
|
|
|
|
|
|
# vim: expandtab shiftwidth=4: |