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