SDLx-Coro-REPL

 view release on metacpan or  search on metacpan

lib/SDLx/Coro/REPL.pm  view on Meta::CPAN

package SDLx::Coro::REPL;

=head1 NAME

SDLx::Coro::REPL - A REPL for your SDL

=head1 SYNOPSIS

  use SDLx::Controller::Coro;
  use SDLx::Coro::REPL;
  SDLx::Coro::REPL::start();
  my $controller = SDLx::Controller::Coro->new;
  $controller->run();

  # More coming soon!
  # Also see eg/sdl_coro_repl.pl

=cut

BEGIN { $ENV{PERL_RL} = 'Perl' }

use Devel::REPL;
use Coro;
use SDLx::Controller::Coro;

our $VERSION = '0.03';

use Term::ReadLine::readline;
{
  package readline;

  no warnings 'redefine';
  sub rl_getc {
    my $key;
    # $Term::ReadLine::Perl::term->Tk_loop if $Term::ReadLine::toloop && defined &Tk::DoOneEvent;
    until(defined ($key = Term::ReadKey::ReadKey(-1, $readline::term_IN))) {
      # print "Waiting for key...\n";
      SDLx::Controller::Coro::yield();
    }
    return $key;
  }

  $readline::rl_getc = \&rl_getc;
}


sub start {
  # use perl5i;
  use vars qw( $repl );
  $repl = Devel::REPL->new;
  $repl->load_plugin($_) for qw(
    History DumpHistory
    OutputCache
    LexEnv
    Colors
    MultiLine::PPI
    FancyPrompt
    DDS
    Refresh
    Interrupt
    Packages
    ShowClass
    Completion CompletionDriver::LexEnv CompletionDriver::Keywords
  );
    # Completion CompletionDriver::LexEnv
    # CompletionDriver::Keywords

  $repl->fancy_prompt(sub {
    my $self = shift;
    sprintf '%s:%03d%s> ',
      $self->can('current_package') ? $self->current_package : 'main',
      $self->lines_read,
      $self->can('line_depth') ? ':' . $self->line_depth : '';
  });

  $repl->fancy_continuation_prompt(sub {



( run in 1.033 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )