ok,
  sorry bothering so much and beeing too dumb as it seems....

  just to test (and maybe that would be a better code snippet (once
        commented..) for the man page script is at the bottom of this
      mail...

set up the smallest possible sample program that uses readline...

but here too, as soon as i run it, it blocks on the first char i type...
  so seems i missed something somewhere....

this example is surely easier to parse than the other stuff...

--------------------- cut here  readLine.pl ----------------------
#!/usr/bin/perl

use warnings;
use strict;

use POE;
use POE::Filter::Reference;
use POE::Wheel::ReadLine;

POE::Session->create( 
      #Alias => "leveShell",
      inline_states =>
      {  _start => \&_start,
      _stop  => \&_stop,
      got_input  => \&got_input_handler,
      },

);
$poe_kernel->run();
# Input handler.  If $input is defined, then it contains a line of
# input.  Otherwise $exception contains a word describing some kind
# of user exception.  Currently these are 'interrupt' and 'cancel'.
sub got_input_handler {
  my ($heap, $input, $exception) = @_[HEAP, ARG0, ARG1];
  if (defined $input) {
    $heap->{wheel}->addhistory($input);
    $heap->{wheel}->put("\tGot: $input");
    $heap->{wheel}->get('Prompt: '); # get another line
  }
  else {
    $heap->{wheel}->put("\tException: $exception");
  }
}


##############################################################################
=pod

=item start of the poe session


=cut

######################################################################
sub _start 
{
  my ($this, $kernel, $heap, $dsn, $queries,$session) = @_[OBJECT, KERNEL, HEAP, ARG0, 
ARG1,SESSION];
  $kernel->alias_set("leveShell");
# Create the wheel.
  $heap->{wheel} = POE::Wheel::ReadLine->new( InputEvent => "got_input" );

# Trigger the wheel to read a line of input.
  $heap->{wheel}->get( 'Prompt: ' );

}#sub _start
##############################################################################
=pod

=item stop of the poe session


=cut

######################################################################
sub _stop 
{
  my ($this, $kernel, $heap) = @_[OBJECT, KERNEL, HEAP];
# Clear the terminal.
  $heap->{wheel}->clear();
}#sub _stop 
--------------------- cut here  ------------------------------------------


-- 
ciao bboett
==============================================================
[EMAIL PROTECTED]
http://inforezo.u-strasbg.fr/~bboett
===============================================================

Reply via email to