1 package Term::UI::History;
5 use base 'Log::Message::Simple';
15 use Term::UI::History qw[history];
17 history("Some message");
19 ### retrieve the history in printable form
20 $hist = Term::UI::History->history_as_string;
23 local $Term::UI::History::HISTORY_FH = \*STDERR;
27 This module provides the C<history> function for C<Term::UI>,
28 printing and saving all the C<UI> interaction.
30 Refer to the C<Term::UI> manpage for details on usage from
33 This module subclasses C<Log::Message::Simple>. Refer to its
34 manpage for additional functionality available via this package.
38 =head2 history("message string" [,VERBOSE])
40 Records a message on the stack, and prints it to C<STDOUT>
41 (or actually C<$HISTORY_FH>, see the C<GLOBAL VARIABLES> section
42 below), if the C<VERBOSE> option is true.
44 The C<VERBOSE> option defaults to true.
49 use Log::Message private => 0;
51 use vars qw[ @EXPORT $HISTORY_FH ];
52 @EXPORT = qw[ history ];
53 my $log = new Log::Message;
54 $HISTORY_FH = \*STDOUT;
56 for my $func ( @EXPORT ) {
59 *$func = sub { my $msg = shift;
69 sub history_as_string {
72 return join $/, map { $_->message } __PACKAGE__->stack;
77 { package Log::Message::Handlers;
82 $verbose = 1 unless defined $verbose; # default to true
84 ### so you don't want us to print the msg? ###
85 return if defined $verbose && $verbose == 0;
88 my $old_fh = select $Term::UI::History::HISTORY_FH;
90 print $self->message . "\n";
98 =head1 GLOBAL VARIABLES
104 This is the filehandle all the messages sent to C<history()> are being
105 printed. This defaults to C<*STDOUT>.
111 C<Log::Message::Simple>, C<Term::UI>
116 Jos Boumans E<lt>kane@cpan.orgE<gt>.
121 copyright (c) 2005 Jos Boumans E<lt>kane@cpan.orgE<gt>.
124 This library is free software;
125 you may redistribute and/or modify it under the same
126 terms as Perl itself.
133 # c-indentation-style: bsd
135 # indent-tabs-mode: nil
137 # vim: expandtab shiftwidth=4: