Re: definitely a POE::Wheel::ReadLine understanding problem....

2003-06-14 Thread Rocco Caputo
On Fri, Jun 13, 2003 at 08:01:16PM +0200, Bruno Boettcher wrote:
> 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 --
[...]
> - cut here  --

I tried the example, and it works here.  It does not block on the first
keystroke like you report.

I must conclude that there is a difference between our systems.
POE::Wheel::ReadLine needs to be updated to handle that difference.
Which OS are you using?  Which version of Perl?  Are you using the most
recent version of POE?

-- Rocco Caputo - [EMAIL PROTECTED] - http://poe.perl.org/


RE: definitely a POE::Wheel::ReadLine understanding problem....

2003-06-13 Thread Erick Calder
Bruno,

just as a side comment, the

inline_states => { method => \&method }

can also be expressed as:

package_states => [ "method" ]

which allows for something like:

package_states => [ qw/_start _stop got_input/ ]

-Original Message-
From: Bruno Boettcher [mailto:[EMAIL PROTECTED]
Sent: Friday, June 13, 2003 11:01 AM
To: [EMAIL PROTECTED]
Subject: definitely a POE::Wheel::ReadLine understanding problem


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
===