# POE::Wheel::Curses - non-blocking input for Curses - perldoc - [phpMan]

## NAME
    [POE::Wheel::Curses](https://www.chedong.com/phpMan.php/perldoc/POE%3A%3AWheel%3A%3ACurses/markdown) - non-blocking input for Curses

## SYNOPSIS
      use Curses;
      use POE qw([Wheel::Curses](https://www.chedong.com/phpMan.php/perldoc/Wheel%3A%3ACurses/markdown));

      [POE::Session](https://www.chedong.com/phpMan.php/perldoc/POE%3A%3ASession/markdown)->create(
        inline_states => {
          _start => sub {
            $_[HEAP]{console} = [POE::Wheel::Curses](https://www.chedong.com/phpMan.php/perldoc/POE%3A%3AWheel%3A%3ACurses/markdown)->new(
              InputEvent => 'got_keystroke',
            );
          },
          got_keystroke => sub {
            my $keystroke = $_[ARG0];

            # Make control and extended keystrokes printable.
            if ($keystroke lt ' ') {
              $keystroke = '<' . uc(unctrl($keystroke)) . '>';
            }
            elsif ($keystroke =~ /^\d{2,}$/) {
              $keystroke = '<' . uc(keyname($keystroke)) . '>';
            }

            # Just display it.
            addstr($keystroke);
            noutrefresh();
            doupdate;

            # Gotta exit somehow.
            delete $_[HEAP]{console} if $keystroke eq "<^C>";
          },
        }
      );

      [POE::Kernel](https://www.chedong.com/phpMan.php/perldoc/POE%3A%3AKernel/markdown)->run();
      exit;

## DESCRIPTION
    [POE::Wheel::Curses](https://www.chedong.com/phpMan.php/perldoc/POE%3A%3AWheel%3A%3ACurses/markdown) implements non-blocking input for Curses programs.

    [POE::Wheel::Curses](https://www.chedong.com/phpMan.php/perldoc/POE%3A%3AWheel%3A%3ACurses/markdown) will emit an "InputEvent" of your choosing whenever an input event is
    registered on a recognized input device (keyboard and sometimes mouse, depending on the curses
    library). Meanwhile, applications can be doing other things like monitoring network connections
    or child processes, or managing timers and stuff.

## PUBLIC METHODS
    [POE::Wheel::Curses](https://www.chedong.com/phpMan.php/perldoc/POE%3A%3AWheel%3A%3ACurses/markdown) is rather simple.

  new
### new
    watcher for STDIN (via select_read()) and registers an internal handler to preprocess
    keystrokes.

### new
    the wheel will emit whenever there is input on the console or terminal. As with all wheels, the
    event will be sent to the session that was active when the wheel was constructed.

    It should be noted that an application may only have one active [POE::Wheel::Curses](https://www.chedong.com/phpMan.php/perldoc/POE%3A%3AWheel%3A%3ACurses/markdown) object.

## EVENTS AND PARAMETERS
    These are the events sent by [POE::Wheel::Curses](https://www.chedong.com/phpMan.php/perldoc/POE%3A%3AWheel%3A%3ACurses/markdown).

### InputEvent
    "InputEvent" defines the event that will be emitted when [POE::Wheel::Curses](https://www.chedong.com/phpMan.php/perldoc/POE%3A%3AWheel%3A%3ACurses/markdown) detects and reads
    console input. This event includes two parameters:

    $_[ARG0] contains the raw keystroke as received by [Curses::getch](https://www.chedong.com/phpMan.php/perldoc/Curses%3A%3Agetch/markdown)(). An application may process
    the keystroke using [Curses::unctrl](https://www.chedong.com/phpMan.php/perldoc/Curses%3A%3Aunctrl/markdown)() and [Curses::keyname](https://www.chedong.com/phpMan.php/perldoc/Curses%3A%3Akeyname/markdown)() on the keystroke.

    $_[ARG1] contains the [POE::Wheel::Curses](https://www.chedong.com/phpMan.php/perldoc/POE%3A%3AWheel%3A%3ACurses/markdown) object's ID.

    Mouse events aren't portable. As of October 2009, it's up to the application to decide whether
    to call mousemask().

## SEE ALSO
    Curses documents what can be done with Curses. Also see the man page for whichever version of
    libcurses happens to be installed (curses, ncurses, etc.).

    [POE::Wheel](https://www.chedong.com/phpMan.php/perldoc/POE%3A%3AWheel/markdown) describes wheels in general.

    The SEE ALSO section in POE contains a table of contents covering the entire POE distribution.

## BUGS
    None known, although curses implementations vary widely.

AUTHORS & COPYRIGHTS
    Please see POE for more information about authors and contributors.

