FILE: C:\Program Files\Git\usr\lib\perl5\vendor_perl\Term\ReadKey.pm
--
# -*- buffer-read-only: t -*-
#
# This file is auto-generated. ***ANY*** changes here will be lost
#
package Term::ReadKey;
use strict;
use warnings;
=head1 NAME
Term::ReadKey - A perl module for simple terminal control
=head1 SYNOPSIS
use Term::ReadKey;
ReadMode 4; # Turn off controls keys
while (not defined ($key = ReadKey(-1))) {
# No key yet
}
print "Get key $key\n";
ReadMode 0; # Reset tty mode before exiting
=head1 DESCRIPTION
Term::ReadKey is a compiled perl module dedicated to providing simple
control over terminal driver modes (cbreak, raw, cooked, etc.,) support for
non-blocking reads, if the architecture allows, and some generalized handy
functions for working with terminals. One of the main goals is to have the
functions as portable as possible, so you can just plug in "use
Term::ReadKey" on any architecture and have a good likelihood of it working.
Version 2.30.01:
Added handling of arrows, page up/down, home/end, insert/delete keys
under Win32. These keys emit xterm-compatible sequences.
Works with Term::ReadLine::Perl.
=over 4
=item ReadMode MODE [, Filehandle]
Takes an integer argument or a string synonym (case insensitive), which
can currently be one of the following values:
INT SYNONYM DESCRIPTION
0 'restore' Restore original settings.
1 'normal' Change to what is commonly the default mode,
echo on, buffered, signals enabled, Xon/Xoff
possibly enabled, and 8-bit mode possibly disabled.
2 'noecho' Same as 1, just with echo off. Nice for
reading passwords.
3 'cbreak' Echo off, unbuffered, signals enabled, Xon/Xoff
possibly enabled, and 8-bit mode possibly enabled.
4 'raw' Echo off, unbuffered, signals disabled, Xon/Xoff
disabled, and 8-bit mode possibly disabled.
5 'ultra-raw' Echo off, unbuffered, signals disabled, Xon/Xoff
disabled, 8-bit mode enabled if parity permits,
and CR to CR/LF translation turned off.
These functions are automatically applied to the STDIN handle if no
other handle is supplied. Modes 0 and 5 have some special properties
worth mentioning: not only will mode 0 restore original settings, but it
cause the next ReadMode call to save a new set of default settings. Mode
5 is similar to mode 4, except no CR/LF translation is performed, and if
possible, parity will be disabled (only if not being used by the terminal,
however. It is no different from mode 4 under Windows.)
If you just need to read a key at a time, then modes 3 or 4 are probably
sufficient. Mode 4 is a tad more flexible, but needs a bit more work to
control. If you use ReadMode 3, then you should install a SIGINT or END
handler to reset the terminal (via ReadMode 0) if the user aborts the
program via C<^C>. (For any mode, an END handler consisting of "ReadMode 0"
is actually a good idea.)
If you are executing another program that may be changing the terminal mode,
you will either want to say
ReadMode 1; # same as ReadMode 'normal'
system('someprogram');
ReadMode 1;
which resets the settings after the program has run, or:
$somemode=1;
ReadMode 0; # same as ReadMode 'restore'
system('someprogram');
ReadMode 1;
which records any changes the program may have made, before resetting the
mode.
=item ReadKey MODE [, Filehandle]
Takes an integer argument, which can currently be one of the following
values:
0 Perform a normal read using getc
-1 Perform a non-blocked read
>0 Perform a timed read
If the filehandle is not supplied, it will default to STDIN. If there is
nothing waiting in the buffer during a non-blocked read, then undef will be
returned. In most situations, you will probably want to use C.
I that if the OS does not provide any known mechanism for non-blocking
reads, then a C can die with a fatal error. This will hopefully
not be common.
If MODE is greater then zero, then ReadKey will use it as a timeout value in
seconds (fractional seconds are allowed), and won't return C until
that time expires.
I, again, that some OS's may not support this timeout behaviour.
If MODE is less then zero, then this is treated as a timeout
of zero, and thus will return immediately if no character is waiting. A MODE
of zero, however, will act like a normal getc.
I, there are currently some limitations with this call under Windows.
It may be possible that non-blocking reads will fail when reading repeating
keys from more then one console.
=item ReadLine MODE [, Filehandle]
Takes an integer argument, which can currently be one of the following
values:
0 Perform a normal read using scalar()
-1 Perform a non-blocked read
>0 Perform a timed read
If there is nothing waiting in the buffer during a non-blocked read, then
undef will be returned.
I, that if the OS does not provide any known mechanism for
non-blocking reads, then a C can die with a fatal
error. This will hopefully not be common.
I that a non-blocking test is only performed for the first character
in the line, not the entire line. This call will probably B do what
you assume, especially with C MODE values higher then 1. For
example, pressing Space and then Backspace would appear to leave you
where you started, but any timeouts would now be suspended.
B.
=item GetTerminalSize [Filehandle]
Returns either an empty array if this operation is unsupported, or a four
element array containing: the width of the terminal in characters, the
height of the terminal in character, the width in pixels, and the height in
pixels. (The pixel size will only be valid in some environments.)
I, under Windows, this function must be called with an B