AnyEvent-ReadLine-Gnu

 view release on metacpan or  search on metacpan

Gnu.pm  view on Meta::CPAN


 # works always, prints message to stdout
 AnyEvent::ReadLine::Gnu->print ("message\n");

 # now initialise readline
 my $rl = new AnyEvent::ReadLine::Gnu prompt => "hi> ", on_line => sub {
    # called for each line entered by the user
    AnyEvent::ReadLine::Gnu->print ("you entered: $_[0]\n");
 };

 # asynchronously print something
 my $t = AE::timer 1, 1, sub {
    $rl->hide;
    print "async message 1\n"; # mind the \n
    $rl->show;

    # the same, but shorter:
    $rl->print ("async message 2\n");
 };

 # do other eventy stuff...
 AE::cv->recv;

=head1 DESCRIPTION

The L<Term::ReadLine> module family is bizarre (and you are encouraged not
to look at its sources unless you want to go blind). It does support
event-based operations, somehow, but it's hard to figure out.

It also has some utility functions for printing messages asynchronously,
something that, again, isn't obvious how to do.

This module has figured it all out for you, once and for all.

=over 4

=cut

package AnyEvent::ReadLine::Gnu;

README  view on Meta::CPAN


     # works always, prints message to stdout
     AnyEvent::ReadLine::Gnu->print ("message\n");

     # now initialise readline
     my $rl = new AnyEvent::ReadLine::Gnu prompt => "hi> ", on_line => sub {
        # called for each line entered by the user
        AnyEvent::ReadLine::Gnu->print ("you entered: $_[0]\n");
     };

     # asynchronously print something
     my $t = AE::timer 1, 1, sub {
        $rl->hide;
        print "async message 1\n"; # mind the \n
        $rl->show;

        # the same, but shorter:
        $rl->print ("async message 2\n");
     };

     # do other eventy stuff...
     AE::cv->recv;

DESCRIPTION
    The Term::ReadLine module family is bizarre (and you are encouraged not
    to look at its sources unless you want to go blind). It does support
    event-based operations, somehow, but it's hard to figure out.

    It also has some utility functions for printing messages asynchronously,
    something that, again, isn't obvious how to do.

    This module has figured it all out for you, once and for all.

    $rl = new AnyEvent::ReadLine::Gnu key => value...
        Creates a new AnyEvent::ReadLine object.

        Actually, it only configures readline and provides a convenient way
        to call the show and hide methods, as well as readline methods -
        this is a singleton.



( run in 0.689 second using v1.01-cache-2.11-cpan-0d8aa00de5b )