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

NAME

6       POE::Wheel::Curses - non-blocking Curses.pm input for full-screen con‐
7       sole apps
8

SYNOPSIS

10         use POE;
11         use Curses;  # for unctrl, etc
12         use POE::Wheel::Curses;
13
14         # Generate events from console input.  Sets up Curses, too.
15         $heap->{console} = POE::Wheel::Curses->new(
16           InputEvent => 'got_keystroke',
17         );
18
19         # A keystroke handler.  This is the body of the program's main input
20         # loop.
21         sub keystroke_handler {
22           my ($keystroke, $wheel_id) = @_[ARG0, ARG1];
23
24           # Control characters.  Change them into something printable via
25           # Curses' unctrl function.
26
27           if ($keystroke lt ' ') {
28             $keystroke = '<' . uc(unctrl($keystroke)) . '>';
29           }
30
31           # Extended keys get translated into their names via Curses'
32           # keyname function.
33
34           elsif ($keystroke =~ /^\d{2,}$/) {
35             $keystroke = '<' . uc(keyname($keystroke)) . '>';
36           }
37
38           # Just display it.
39           addstr( $heap->{some_window}, $keystroke );
40           noutrefresh( $heap->{some_window} );
41           doupdate;
42         }
43

DESCRIPTION

45       Many console programs work best with full-screen input: top, systat,
46       nethack, and various text editors.  POE::Wheel::Curses provides a sim‐
47       ple way to add full-screen interfaces to POE programs.
48
49       Whenever something occurs on a recognized input device-- usually just
50       the keyboard, but also sometimes the mouse, as in the case of ncurses--
51       the Curses wheel will emit a predetermined event to tell the program
52       about it.  This lets the program do other non-blocking things in
53       between keystrokes, like interact on sockets or watch log files or move
54       monsters or highlight text or something.
55

PUBLIC METHODS

57       new NOT_SO_MANY_THINGS
58         new() creates a new Curses wheel.  Note, though, that there can be
59         only one Curses wheel in any given program, since they glom onto
60         *STDIN real hard.  Maybe this will change.
61
62         new() always returns a Curses wheel reference, even if there is a
63         problem glomming onto *STDIN or otherwise initializing curses.
64
65         new() accepts only one parameter so far: InputEvent.  InputEvent con‐
66         tains the name of the event that the Curses wheel will emit whenever
67         there is input on the console or terminal.
68

EVENTS AND PARAMETERS

70       InputEvent
71         InputEvent defines the event that will be emitted when the Curses
72         wheel detects and receives input.
73
74         InputEvent is accompanied by two parameters:
75
76         "ARG0" contains the raw keystroke as received by Curses' getch()
77         function.  It may be passed to Curses' unctrl() and keyname() func‐
78         tions for further processing.
79
80         "ARG1" contains the ID of the Curses wheel.
81

SEE ALSO

83       curses, Curses, POE::Wheel.
84
85       The SEE ALSO section in POE contains a table of contents covering the
86       entire POE distribution.
87

BUGS

89       Curses implementations vary widely, and Wheel::Curses was written on a
90       system sporting ncurses.  The functions used may not be the same as
91       those used on systems with other curses implementations, and Bad Things
92       might happen.  Please send patches.
93

AUTHORS & COPYRIGHTS

95       Please see POE for more information about authors and contributors.
96
97
98
99perl v5.8.8                       2006-09-01             POE::Wheel::Curses(3)
Impressum