View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
David Mertens > PDL-Graphics-Prima-0.17 > PDL::Graphics::Prima::ReadLine



Annotate this POD

View/Report Bugs
Module Version: 0.17   Source  


PDL::Graphics::Prima::ReadLine - allowing Prima and Term::ReadLine to play together


 # This pulls in PDL::Graphics::Prima::ReadLine, and
 # associate's the PDL Shell's readline object if it
 # exists:
 use PDL::Graphics::Prima;
 # Did it set up the readline event loop callback?
 print "Set up Prima/ReadLine interaction\n"
     if PDL::Graphics::Prima::ReadLine->is_setup;
 # If you are not in the PDL shell, you can supply
 # your own ReadLine object.
 if (PDL::Graphics::Prima::ReadLine->is_happy_with($my_readline) {
 # If you don't validate first, setup() may croak.
 # In other words, instead of this:
 if (PDL::Graphics::Prima::ReadLine->is_happy_with($my_readline) {
 else {
     die "Unable to setup Prima/ReadLine interaction\n";
 # You could just say this instead:


This module's job is to encapsulate the vagaries of setting up interaction between the Prima event loop and Term::ReadLine's event loop. Loading the module does not have any side-effects, and it is always loaded by PDL::Graphics::Prima. Furthermore, PDL::Graphics::Prima will set up the event loop interaction with the PDL shell if it detects the shell's ReadLine object.

Generally speaking, if you intend to have user interaction and want to use PDL::Graphics::Prima, you should probably just use Prima to build a simple interactive application. (Docmentation for getting started with this is coming soon, I promise.) However, if you want to integrate PDL::Graphics::Prima into a pluggable application that already uses Term::ReadLine, this module should make that procedure as straight-forward as one can hope.

PDL::Graphics::Prima::ReadLine can only hook into the event loop for newer versions of Term::ReadLine (specifically, versions that support event_loop). Also, due to current limitations in my knowledge of Prima's monitoring of STDIN, this module cannot hook into the event loop on Windows operating systems, both Cygwin and Strawberry Perl.


If you want to set up the event loop interaction on your own ReadLine object, you can ask PDL::Graphics::Prima::ReadLine if it can work with your object by calling the is_happy_with class method and supplying your objects. This method returns a boolean value indicating whether or not the object can do what PDL::Graphics::Prima::ReadLine needs:

 if (PDL::Graphics::Prima::ReadLine->is_happy_with($my_readline) {
     print "Setting up Prima/ReadLine interaction\n";


To hook Prima's event loop into your ReadLine's event loop, you can call the setup class method:


This method may (should) fail if the ReadLine object provided cannot support the functionality needed for hooking Prima into ReadLine. This could happen either because your version of ReadLine is too old or because you are running on Windows, which is not (yet) supported by PDL::Graphics::Prima::ReadLine.


For purposes of this module, you should check out Term::ReadLine. This module is implemented using Prima::File.


David Mertens (


Here is the full list of modules in this distribution:


Defines the Plot widget for use in Prima applications


Specifies the behavior of axes (but not the scaling)


Specifies the behavior of DataSets


Defines the lm:: namespace


Specifies a collection of different color palettes


Defines the different ways to visualize your data


Encapsulates all interaction with the Term::ReadLine family of modules.


Specifies different kinds of scaling, including linear and logarithmic


Defines a number of useful functions for generating simple and not-so-simple plots


Unless otherwise stated, all contributions in code and documentation are copyright (c) their respective authors, all rights reserved.

Portions of this module's code are copyright (c) 2011 The Board of Trustees at the University of Illinois.

Portions of this module's code are copyright (c) 2011-2013 Northwestern University.

Portions of this module's code are copyright (c) 2013-2014 Dickinson College.

This module's documentation is copyright (c) 2011-2014 David Mertens.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: