1POE::Wheel::Curses(3) User Contributed Perl DocumentationPOE::Wheel::Curses(3)
2
3
4

NAME

6       POE::Wheel::Curses - non-blocking input for Curses
7

SYNOPSIS

9         use Curses;
10         use POE qw(Wheel::Curses);
11
12         POE::Session->create(
13           inline_states => {
14             _start => sub {
15               $_[HEAP]{console} = POE::Wheel::Curses->new(
16                 InputEvent => 'got_keystroke',
17               );
18             },
19             got_keystroke => sub {
20               my $keystroke = $_[ARG0];
21
22               # Make control and extended keystrokes printable.
23               if ($keystroke lt ' ') {
24                 $keystroke = '<' . uc(unctrl($keystroke)) . '>';
25               }
26               elsif ($keystroke =~ /^\d{2,}$/) {
27                 $keystroke = '<' . uc(keyname($keystroke)) . '>';
28               }
29
30               # Just display it.
31               addstr($keystroke);
32               noutrefresh();
33               doupdate;
34
35               # Gotta exit somehow.
36               delete $_[HEAP]{console} if $keystroke eq "<^C>";
37             },
38           }
39         );
40
41         POE::Kernel->run();
42         exit;
43

DESCRIPTION

45       POE::Wheel::Curses implements non-blocking input for Curses programs.
46
47       POE::Wheel::Curses will emit an "InputEvent" of your choosing whenever
48       an input event is registered on a recognized input device (keyboard and
49       sometimes mouse, depending on the curses library).  Meanwhile,
50       applications can be doing other things like monitoring network
51       connections or child processes, or managing timers and stuff.
52

PUBLIC METHODS

54       POE::Wheel::Curses is rather simple.
55
56   new
57       new() creates a new POE::Wheel::Curses object.  During construction,
58       the wheel registers an input watcher for STDIN (via select_read()) and
59       registers an internal handler to preprocess keystrokes.
60
61       new() accepts only one parameter "InputEvent".  "InputEvent" contains
62       the name of the event that the wheel will emit whenever there is input
63       on the console or terminal.  As with all wheels, the event will be sent
64       to the session that was active when the wheel was constructed.
65
66       It should be noted that an application may only have one active
67       POE::Wheel::Curses object.
68

EVENTS AND PARAMETERS

70       These are the events sent by POE::Wheel::Curses.
71
72   InputEvent
73       "InputEvent" defines the event that will be emitted when
74       POE::Wheel::Curses detects and reads console input.  This event
75       includes two parameters:
76
77       $_[ARG0] contains the raw keystroke as received by Curses::getch().  An
78       application may process the keystroke using Curses::unctrl() and
79       Curses::keyname() on the keystroke.
80
81       $_[ARG1] contains the POE::Wheel::Curses object's ID.
82
83       Mouse events aren't portable.  As of October 2009, it's up to the
84       application to decide whether to call mousemask().
85

SEE ALSO

87       Curses documents what can be done with Curses.  Also see the man page
88       for whichever version of libcurses happens to be installed (curses,
89       ncurses, etc.).
90
91       POE::Wheel describes wheels in general.
92
93       The SEE ALSO section in POE contains a table of contents covering the
94       entire POE distribution.
95

BUGS

97       None known, although curses implementations vary widely.
98

AUTHORS & COPYRIGHTS

100       Please see POE for more information about authors and contributors.
101
102
103
104perl v5.32.0                      2020-07-28             POE::Wheel::Curses(3)
Impressum