Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / perl-5.8.0 / man / man3 / Term::ReadKey.3
CommitLineData
86530b38
AT
1.\" Automatically generated by Pod::Man v1.34, Pod::Parser v1.13
2.\"
3.\" Standard preamble:
4.\" ========================================================================
5.de Sh \" Subsection heading
6.br
7.if t .Sp
8.ne 5
9.PP
10\fB\\$1\fR
11.PP
12..
13.de Sp \" Vertical space (when we can't use .PP)
14.if t .sp .5v
15.if n .sp
16..
17.de Vb \" Begin verbatim text
18.ft CW
19.nf
20.ne \\$1
21..
22.de Ve \" End verbatim text
23.ft R
24.fi
25..
26.\" Set up some character translations and predefined strings. \*(-- will
27.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
28.\" double quote, and \*(R" will give a right double quote. | will give a
29.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
30.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
31.\" expand to `' in nroff, nothing in troff, for use with C<>.
32.tr \(*W-|\(bv\*(Tr
33.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
34.ie n \{\
35. ds -- \(*W-
36. ds PI pi
37. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
38. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
39. ds L" ""
40. ds R" ""
41. ds C` ""
42. ds C' ""
43'br\}
44.el\{\
45. ds -- \|\(em\|
46. ds PI \(*p
47. ds L" ``
48. ds R" ''
49'br\}
50.\"
51.\" If the F register is turned on, we'll generate index entries on stderr for
52.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
53.\" entries marked with X<> in POD. Of course, you'll have to process the
54.\" output yourself in some meaningful fashion.
55.if \nF \{\
56. de IX
57. tm Index:\\$1\t\\n%\t"\\$2"
58..
59. nr % 0
60. rr F
61.\}
62.\"
63.\" For nroff, turn off justification. Always turn off hyphenation; it makes
64.\" way too many mistakes in technical documents.
65.hy 0
66.if n .na
67.\"
68.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
69.\" Fear. Run. Save yourself. No user-serviceable parts.
70. \" fudge factors for nroff and troff
71.if n \{\
72. ds #H 0
73. ds #V .8m
74. ds #F .3m
75. ds #[ \f1
76. ds #] \fP
77.\}
78.if t \{\
79. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
80. ds #V .6m
81. ds #F 0
82. ds #[ \&
83. ds #] \&
84.\}
85. \" simple accents for nroff and troff
86.if n \{\
87. ds ' \&
88. ds ` \&
89. ds ^ \&
90. ds , \&
91. ds ~ ~
92. ds /
93.\}
94.if t \{\
95. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
96. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
97. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
98. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
99. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
100. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
101.\}
102. \" troff and (daisy-wheel) nroff accents
103.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
104.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
105.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
106.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
107.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
108.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
109.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
110.ds ae a\h'-(\w'a'u*4/10)'e
111.ds Ae A\h'-(\w'A'u*4/10)'E
112. \" corrections for vroff
113.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
114.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
115. \" for low resolution devices (crt and lpr)
116.if \n(.H>23 .if \n(.V>19 \
117\{\
118. ds : e
119. ds 8 ss
120. ds o a
121. ds d- d\h'-1'\(ga
122. ds D- D\h'-1'\(hy
123. ds th \o'bp'
124. ds Th \o'LP'
125. ds ae ae
126. ds Ae AE
127.\}
128.rm #[ #] #H #V #F C
129.\" ========================================================================
130.\"
131.IX Title "ReadKey 3"
132.TH ReadKey 3 "2002-07-28" "perl v5.8.0" "User Contributed Perl Documentation"
133.SH "NAME"
134Term::ReadKey \- A perl module for simple terminal control
135.SH "SYNOPSIS"
136.IX Header "SYNOPSIS"
137.Vb 7
138\& use Term::ReadKey;
139\& ReadMode 4; # Turn off controls keys
140\& while (not defined ($key = ReadKey(-1)) {
141\& # No key yet
142\& }
143\& print "Get key $key\en";
144\& ReadMode 0; # Reset tty mode before exiting
145.Ve
146.SH "DESCRIPTION"
147.IX Header "DESCRIPTION"
148Term::ReadKey is a compiled perl module dedicated to providing simple
149control over terminal driver modes (cbreak, raw, cooked, etc.,) support for
150non-blocking reads, if the architecture allows, and some generalized handy
151functions for working with terminals. One of the main goals is to have the
152functions as portable as possible, so you can just plug in \*(L"use
153Term::ReadKey\*(R" on any architecture and have a good likelyhood of it working.
154.IP "ReadMode \s-1MODE\s0 [, Filehandle]" 8
155.IX Item "ReadMode MODE [, Filehandle]"
156Takes an integer argument, which can currently be one of the following
157values:
158.Sp
159.Vb 8
160\& 0 Restore original settings.
161\& 1 Change to cooked mode.
162\& 2 Change to cooked mode with echo off.
163\& (Good for passwords)
164\& 3 Change to cbreak mode.
165\& 4 Change to raw mode.
166\& 5 Change to ultra-raw mode.
167\& (LF to CR/LF translation turned off)
168.Ve
169.Sp
170.Vb 1
171\& Or, you may use the synonyms:
172.Ve
173.Sp
174.Vb 6
175\& restore
176\& normal
177\& noecho
178\& cbreak
179\& raw
180\& ultra-raw
181.Ve
182.Sp
183These functions are automatically applied to the \s-1STDIN\s0 handle if no
184other handle is supplied. Modes 0 and 5 have some special properties
185worth mentioning: not only will mode 0 restore original settings, but it
186cause the next ReadMode call to save a new set of default settings. Mode
1875 is similar to mode 4, except no \s-1CR/LF\s0 translation is performed, and if
188possible, parity will be disabled (only if not being used by the terminal,
189however. It is no different from mode 4 under Windows.)
190.Sp
191If you are executing another program that may be changing the terminal mode,
192you will either want to say
193.Sp
194.Vb 3
195\& ReadMode 1
196\& system('someprogram');
197\& ReadMode 1;
198.Ve
199.Sp
200which resets the settings after the program has run, or:
201.Sp
202.Vb 4
203\& $somemode=1;
204\& ReadMode 0;
205\& system('someprogram');
206\& ReadMode 1;
207.Ve
208.Sp
209which records any changes the program may have made, before resetting the
210mode.
211.IP "ReadKey \s-1MODE\s0 [, Filehandle]" 8
212.IX Item "ReadKey MODE [, Filehandle]"
213Takes an integer argument, which can currently be one of the following
214values:
215.Sp
216.Vb 3
217\& 0 Perform a normal read using getc
218\& -1 Perform a non-blocked read
219\& >0 Perform a timed read
220.Ve
221.Sp
222(If the filehandle is not supplied, it will default to \s-1STDIN\s0.) If there is
223nothing waiting in the buffer during a non-blocked read, then undef will be
224returned. Note that if the \s-1OS\s0 does not provide any known mechanism for
225non-blocking reads, then a \f(CW\*(C`ReadKey \-1\*(C'\fR can die with a fatal error. This
226will hopefully not be common.
227.Sp
228If \s-1MODE\s0 is greater then zero, then ReadKey will use it as a timeout value in
229seconds (fractional seconds are allowed), and won't return \f(CW\*(C`undef\*(C'\fR until
230that time expires. (Note, again, that some \s-1OS\s0's may not support this timeout
231behaviour.) If \s-1MODE\s0 is less then zero, then this is treated as a timeout
232of zero, and thus will return immediately if no character is waiting. A \s-1MODE\s0
233of zero, however, will act like a normal getc.
234.Sp
235There are currently some limitations with this call under Windows. It may be
236possible that non-blocking reads will fail when reading repeating keys from
237more then one console.
238.IP "ReadLine \s-1MODE\s0 [, Filehandle]" 8
239.IX Item "ReadLine MODE [, Filehandle]"
240Takes an integer argument, which can currently be one of the following
241values:
242.Sp
243.Vb 3
244\& 0 Perform a normal read using scalar(<FileHandle>)
245\& -1 Perform a non-blocked read
246\& >0 Perform a timed read
247.Ve
248.Sp
249If there is nothing waiting in the buffer during a non-blocked read, then
250undef will be returned. Note that if the \s-1OS\s0 does not provide any known
251mechanism for non-blocking reads, then a \f(CW\*(C`ReadLine 1\*(C'\fR can die with a fatal
252error. This will hopefully not be common. Note that a non-blocking test is
253only performed for the first character in the line, not the entire line.
254This call will probably \fBnot\fR do what you assume, especially with
255ReadMode's higher then 1. For example, pressing Space and then Backspace
256would appear to leave you where you started, but any timeouts would now
257be suspended.
258.Sp
259This call is currently not available under Windows.
260.IP "GetTerminalSize [Filehandle]" 8
261.IX Item "GetTerminalSize [Filehandle]"
262Returns either an empty array if this operation is unsupported, or a four
263element array containing: the width of the terminal in characters, the
264height of the terminal in character, the width in pixels, and the height in
265pixels. (The pixel size will only be valid in some environments.)
266.Sp
267Under Windows, this function must be called with an \*(L"output\*(R" filehandle,
268such as \s-1STDOUT\s0, or a handle opened to \s-1CONOUT$\s0.
269.IP "SetTerminalSize \s-1WIDTH\s0,HEIGHT,XPIX,YPIX [, Filehandle]" 8
270.IX Item "SetTerminalSize WIDTH,HEIGHT,XPIX,YPIX [, Filehandle]"
271Return \-1 on failure, 0 otherwise. Note that this terminal size is only for
272\&\fBinformative\fR value, and changing the size via this mechanism will \fBnot\fR
273change the size of the screen. For example, XTerm uses a call like this when
274it resizes the screen. If any of the new measurements vary from the old, the
275\&\s-1OS\s0 will probably send a \s-1SIGWINCH\s0 signal to anything reading that tty or pty.
276.Sp
277This call does not work under Windows.
278.IP "GetSpeeds [, Filehandle]" 8
279.IX Item "GetSpeeds [, Filehandle]"
280Returns either an empty array if the operation is unsupported, or a two
281value array containing the terminal in and out speeds, in \fBdecimal\fR. E.g,
282an in speed of 9600 baud and an out speed of 4800 baud would be returned as
283(9600,4800). Note that currently the in and out speeds will always be
284identical in some \s-1OS\s0's. No speeds are reported under Windows.
285.IP "GetControlChars [, Filehandle]" 8
286.IX Item "GetControlChars [, Filehandle]"
287Returns an array containing key/value pairs suitable for a hash. The pairs
288consist of a key, the name of the control character/signal, and the value
289of that character, as a single character. This call does nothing under Windows.
290.Sp
291Each key will be an entry from the following list:
292.Sp
293.Vb 19
294\& DISCARD
295\& DSUSPEND
296\& EOF
297\& EOL
298\& EOL2
299\& ERASE
300\& ERASEWORD
301\& INTERRUPT
302\& KILL
303\& MIN
304\& QUIT
305\& QUOTENEXT
306\& REPRINT
307\& START
308\& STATUS
309\& STOP
310\& SUSPEND
311\& SWITCH
312\& TIME
313.Ve
314.Sp
315Thus, the following will always return the current interrupt character,
316regardless of platform.
317.Sp
318.Vb 2
319\& %keys = GetControlChars;
320\& $int = $keys{INTERRUPT};
321.Ve
322.IP "SetControlChars [, Filehandle]" 8
323.IX Item "SetControlChars [, Filehandle]"
324Takes an array containing key/value pairs, as a hash will produce. The pairs
325should consist of a key that is the name of a legal control
326character/signal, and the value should be either a single character, or a
327number in the range 0\-255. SetControlChars will die with a runtime error if
328an invalid character name is passed or there is an error changing the
329settings. The list of valid names is easily available via
330.Sp
331.Vb 2
332\& %cchars = GetControlChars();
333\& @cnames = keys %cchars;
334.Ve
335.Sp
336This call does nothing under Windows.
337.SH "AUTHOR"
338.IX Header "AUTHOR"
339Kenneth Albanowski <kjahds@kjahds.com>
340.PP
341Currently maintained by Jonathan Stowe <jns@gellyfish.com>