1 .\" $NetBSD: curses_input.3,v 1.22 2012/04/21 12:27:28 roy Exp $
4 .\" Brett Lymn (blymn@NetBSD.org, brett_lymn@yahoo.com.au)
6 .\" This code is donated to the NetBSD Foundation by the Author.
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\" notice, this list of conditions and the following disclaimer.
13 .\" 2. Redistributions in binary form must reproduce the above copyright
14 .\" notice, this list of conditions and the following disclaimer in the
15 .\" documentation and/or other materials provided with the distribution.
16 .\" 3. The name of the Author may not be used to endorse or promote
17 .\" products derived from this software without specific prior written
20 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
58 .Nd curses input stream routines
66 .Fn wgetch "WINDOW *win"
68 .Fn mvgetch "int y" "int x"
70 .Fn mvwgetch "WINDOW *win" "int y" "int x"
72 .Fn keyok "int key_symbol" "bool flag"
74 .Fn define_key "char *sequence" "int key_symbol"
76 .Fn getnstr "char *str" "int limit"
78 .Fn wgetnstr "WINDOW *win" "char *str" "int limit"
80 .Fn mvgetnstr "int y" "int x" "char *str" "int limit"
82 .Fn mvwgetnstr "WINDOW *win" "int y" "int x" "char *str" "int limit"
84 .Fn getstr "char *str"
86 .Fn wgetstr "WINDOW *win" "char *str"
88 .Fn mvgetstr "int y" "int x" "char *str"
90 .Fn mvwgetstr "WINDOW *win" "int y" "int x" "char *str"
92 .Fn keypad "WINDOW *win" "boolf flag"
94 .Fn notimeout "WINDOW *win" "boolf flag"
96 .Fn timeout "int delay"
98 .Fn wtimeout "WINDOW *win" "int delay"
100 .Fn nodelay "WINDOW *win" "boolf flag"
104 .Va extern int ESCDELAY ;
106 These functions read characters and strings from the window input file
111 function reads a character from the
113 input file descriptor and returns it.
120 will assemble multi-character key sequences into key symbols,
121 If the terminal is resized,
125 regardless of the setting of
129 will cause an implicit
136 function is the same as the
138 function, excepting that it reads from the input file descriptor associated
139 with the window specified by
146 then the assembly of specific key symbols can be disabled by using the
155 will behave as if the character sequence associated with that key symbol
156 was not recognised and will return the component characters one at a time to
159 Custom associations between sequences of characters and a key symbol can
163 Normally, these associations are made by the information in the
167 function gives the capability to remove or add more associations.
170 is passed a non-NULL string in
172 it will associate that sequence with the key symbol passed in
174 The key symbol may be one of the ones listed below or a custom value that
175 is application defined.
176 It is valid to have multiple character sequences map to the same key
177 symbol and there are no constraints on the length of the sequence allowed.
178 The assembly of custom sequences follow the same rules for inter-character
179 timing and so forth as the
186 then all associations for the key symbol in
188 will be deleted, this includes any associations that were derived from
195 functions are the same as the
199 functions, respectively, excepting that
201 is called to move the cursor to the position specified by
204 before the character is read.
212 is effectively the same as calling
214 repeatedly until a newline is received or the character limit
217 Once this happens the string is
219 terminated and returned in
221 During input, the normal curses input key processing is performed and
222 affects the input buffer.
227 to move the cursor to the position given by
230 before getting the string,
232 reads the input from the designated window,
234 moves the cursor to the position given by
237 before getting the input from the designated window.
251 respectively, excepting that there is no limit on the number of characters
252 that may be inserted into
254 This may cause the buffer to be overflowed, so their use is not recommended.
258 function is used to affect how
260 processes input characters.
267 will scan the input stream looking for multi-character key sequences
268 that are emitted by some terminal function keys.
269 If a recognised sequence of characters is found, then
271 will collapse that sequence into an integer key symbol, as shown below.
272 The default setting for the flag is
277 function controls whether or not
279 will wait indefinitely between characters in a multi-character key
285 then there is no timeout applied between characters comprising a
286 multi-character key sequence.
291 then the component characters of a multi-character sequence must not
292 have an inter-character gap of more than
294 If this timing is exceeded, then the multi-character key assembly is
295 deemed to have failed and the characters read thus far are returned
299 The default setting for the flag is
306 is negative, no timeout is applied between characters comprising a
307 multi-character key sequence.
311 function affects the behaviour of
313 when reading a character from
319 will block indefinitely on a read.
324 will return immediately with
326 if there are no characters immediately available.
329 is a positive number, then
331 will wait for that many milliseconds before returning and, if no character
335 Note that for a positive number, the timeout is only accurate to the nearest
337 Also, the maximum value of
339 is 25500 milliseconds.
342 function does the same as
344 but applies to the specified window
349 function turns on and off blocking reads for
357 will not block on reads, if
361 then reads will block.
362 The default setting for the flag is
368 .Fn nodelay win FALSE
370 .Fn wtimeout win \-1 .
375 into an unsigned char and push that character back onto the input stream.
376 Only one character of push-back is guaranteed to work, more may be possible
377 depending on system resources.
385 will return the value of the key pressed or
387 in the case of an error or a timeout.
390 has been called on a window, then it may return one of the following values:
392 .Bl -column "Termcap entry" "getch Return Value" "Key Function" -offset indent
393 .It Sy "Termcap entry" Ta Sy "getch Return Value" Ta Sy "Key Function"
394 .It \&!1 Ta KEY_SSAVE Ta Shift Save
395 .It \&!2 Ta KEY_SSUSPEND Ta Shift Suspend
396 .It \&!3 Ta KEY_SUNDO Ta Shift Undo
397 .It \ Ta KEY_SHELP Ta Shift Help
398 .It \ Ta KEY_SHOME Ta Shift Home
399 .It \ Ta KEY_SIC Ta Shift Insert Character
400 .It \ Ta KEY_SLEFT Ta Shift Left Arrow
401 .It \&%0 Ta KEY_REDO Ta Redo
402 .It \&%1 Ta KEY_HELP Ta Help
403 .It \&%2 Ta KEY_MARK Ta Mark
404 .It \&%3 Ta KEY_MESSAGE Ta Message
405 .It \&%4 Ta KEY_MOVE Ta Move
406 .It \&%5 Ta KEY_NEXT Ta Next Object
407 .It \&%6 Ta KEY_OPEN Ta Open
408 .It \&%7 Ta KEY_OPTIONS Ta Options
409 .It \&%8 Ta KEY_PREVIOUS Ta Previous Object
410 .It \&%9 Ta KEY_PRINT Ta Print
411 .It \&%a Ta KEY_SMESSAGE Ta Shift Message
412 .It \&%b Ta KEY_SMOVE Ta Shift Move
413 .It \&%c Ta KEY_SNEXT Ta Shift Next Object
414 .It \&%d Ta KEY_SOPTIONS Ta Shift Options
415 .It \&%e Ta KEY_SPREVIOUS Ta Shift Previous Object
416 .It \&%f Ta KEY_SPRINT Ta Shift Print
417 .It \&%g Ta KEY_SREDO Ta Shift Redo
418 .It \&%h Ta KEY_SREPLACE Ta Shift Replace
419 .It \&%i Ta KEY_SRIGHT Ta Shift Right Arrow
420 .It \&%j Ta KEY_SRSUME Ta Shift Resume
421 .It \&\*[Am]0 Ta KEY_SCANCEL Ta Shift Cancel
422 .It \&\*[Am]1 Ta KEY_REFERENCE Ta Reference
423 .It \&\*[Am]2 Ta KEY_REFRESH Ta Refresh
424 .It \&\*[Am]3 Ta KEY_REPLACE Ta Replace
425 .It \&\*[Am]4 Ta KEY_RESTART Ta Restart
426 .It \&\*[Am]5 Ta KEY_RESUME Ta Resume
427 .It \&\*[Am]6 Ta KEY_SAVE Ta Save
428 .It \&\*[Am]7 Ta KEY_SUSPEND Ta Suspend
429 .It \&\*[Am]8 Ta KEY_UNDO Ta Undo
430 .It \&\*[Am]9 Ta KEY_SBEG Ta Shift Begin
431 .It \&*0 Ta KEY_SFIND Ta Shift Find
432 .It \&*1 Ta KEY_SCOMMAND Ta Shift Command
433 .It \&*2 Ta KEY_SCOPY Ta Shift Copy
434 .It \&*3 Ta KEY_SCREATE Ta Shift Create
435 .It \&*4 Ta KEY_SDC Ta Shift Delete Character
436 .It \&*5 Ta KEY_SDL Ta Shift Delete Line
437 .It \&*6 Ta KEY_SELECT Ta Select
438 .It \&*7 Ta KEY_SEND Ta Shift End
439 .It \&*8 Ta KEY_SEOL Ta Shift Clear to EOL
440 .It \&*9 Ta KEY_SEXIT Ta Shift Exit
441 .It \&@0 Ta KEY_FIND Ta Find
442 .It \&@1 Ta KEY_BEG Ta Begin
443 .It \&@2 Ta KEY_CANCEL Ta Cancel
444 .It \&@3 Ta KEY_CLOSE Ta Close
445 .It \&@4 Ta KEY_COMMAND Ta Command
446 .It \&@5 Ta KEY_COPY Ta Copy
447 .It \&@6 Ta KEY_CREATE Ta Create
448 .It \&@7 Ta KEY_END Ta End
449 .It \&@8 Ta KEY_ENTER Ta Enter
450 .It \&@9 Ta KEY_EXIT Ta Exit
451 .It \&F1 Ta KEY_F(11) Ta Function Key 11
452 .It \&F2 Ta KEY_F(12) Ta Function Key 12
453 .It \&F3 Ta KEY_F(13) Ta Function Key 13
454 .It \&F4 Ta KEY_F(14) Ta Function Key 14
455 .It \&F5 Ta KEY_F(15) Ta Function Key 15
456 .It \&F6 Ta KEY_F(16) Ta Function Key 16
457 .It \&F7 Ta KEY_F(17) Ta Function Key 17
458 .It \&F8 Ta KEY_F(18) Ta Function Key 18
459 .It \&F9 Ta KEY_F(19) Ta Function Key 19
460 .It \&FA Ta KEY_F(20) Ta Function Key 20
461 .It \&FB Ta KEY_F(21) Ta Function Key 21
462 .It \&FC Ta KEY_F(22) Ta Function Key 22
463 .It \&FD Ta KEY_F(23) Ta Function Key 23
464 .It \&FE Ta KEY_F(24) Ta Function Key 24
465 .It \&FF Ta KEY_F(25) Ta Function Key 25
466 .It \&FG Ta KEY_F(26) Ta Function Key 26
467 .It \&FH Ta KEY_F(27) Ta Function Key 27
468 .It \&FI Ta KEY_F(28) Ta Function Key 28
469 .It \&FJ Ta KEY_F(29) Ta Function Key 29
470 .It \&FK Ta KEY_F(30) Ta Function Key 30
471 .It \&FL Ta KEY_F(31) Ta Function Key 31
472 .It \&FM Ta KEY_F(32) Ta Function Key 32
473 .It \&FN Ta KEY_F(33) Ta Function Key 33
474 .It \&FO Ta KEY_F(34) Ta Function Key 34
475 .It \&FP Ta KEY_F(35) Ta Function Key 35
476 .It \&FQ Ta KEY_F(36) Ta Function Key 36
477 .It \&FR Ta KEY_F(37) Ta Function Key 37
478 .It \&FS Ta KEY_F(38) Ta Function Key 38
479 .It \&FT Ta KEY_F(39) Ta Function Key 39
480 .It \&FU Ta KEY_F(40) Ta Function Key 40
481 .It \&FV Ta KEY_F(41) Ta Function Key 41
482 .It \&FW Ta KEY_F(42) Ta Function Key 42
483 .It \&FX Ta KEY_F(43) Ta Function Key 43
484 .It \&FY Ta KEY_F(44) Ta Function Key 44
485 .It \&FZ Ta KEY_F(45) Ta Function Key 45
486 .It \&Fa Ta KEY_F(46) Ta Function Key 46
487 .It \&Fb Ta KEY_F(47) Ta Function Key 47
488 .It \&Fc Ta KEY_F(48) Ta Function Key 48
489 .It \&Fd Ta KEY_F(49) Ta Function Key 49
490 .It \&Fe Ta KEY_F(50) Ta Function Key 50
491 .It \&Ff Ta KEY_F(51) Ta Function Key 51
492 .It \&Fg Ta KEY_F(52) Ta Function Key 52
493 .It \&Fh Ta KEY_F(53) Ta Function Key 53
494 .It \&Fi Ta KEY_F(54) Ta Function Key 54
495 .It \&Fj Ta KEY_F(55) Ta Function Key 55
496 .It \&Fk Ta KEY_F(56) Ta Function Key 56
497 .It \&Fl Ta KEY_F(57) Ta Function Key 57
498 .It \&Fm Ta KEY_F(58) Ta Function Key 58
499 .It \&Fn Ta KEY_F(59) Ta Function Key 59
500 .It \&Fo Ta KEY_F(60) Ta Function Key 60
501 .It \&Fp Ta KEY_F(61) Ta Function Key 61
502 .It \&Fq Ta KEY_F(62) Ta Function Key 62
503 .It \&Fr Ta KEY_F(63) Ta Function Key 63
504 .It \&K1 Ta KEY_A1 Ta Upper left key in keypad
505 .It \&K2 Ta KEY_B2 Ta Centre key in keypad
506 .It \&K3 Ta KEY_A3 Ta Upper right key in keypad
507 .It \&K4 Ta KEY_C1 Ta Lower left key in keypad
508 .It \&K5 Ta KEY_C3 Ta Lower right key in keypad
509 .It \&Km Ta KEY_MOUSE Ta Mouse Event
510 .It \&k0 Ta KEY_F0 Ta Function Key 0
511 .It \&k1 Ta KEY_F(1) Ta Function Key 1
512 .It \&k2 Ta KEY_F(2) Ta Function Key 2
513 .It \&k3 Ta KEY_F(3) Ta Function Key 3
514 .It \&k4 Ta KEY_F(4) Ta Function Key 4
515 .It \&k5 Ta KEY_F(5) Ta Function Key 5
516 .It \&k6 Ta KEY_F(6) Ta Function Key 6
517 .It \&k7 Ta KEY_F(7) Ta Function Key 7
518 .It \&k8 Ta KEY_F(8) Ta Function Key 8
519 .It \&k9 Ta KEY_F(9) Ta Function Key 9
520 .It \&k; Ta KEY_F(10) Ta Function Key 10
521 .It \&kA Ta KEY_IL Ta Insert Line
522 .It \&ka Ta KEY_CATAB Ta Clear All Tabs
523 .It \&kB Ta KEY_BTAB Ta Back Tab
524 .It \&kb Ta KEY_BACKSPACE Ta Backspace
525 .It \&kC Ta KEY_CLEAR Ta Clear
526 .It \&kD Ta KEY_DC Ta Delete Character
527 .It \&kd Ta KEY_DOWN Ta Down Arrow
528 .It \&kE Ta KEY_EOL Ta Clear to End Of Line
529 .It \&kF Ta KEY_SF Ta Scroll Forward one line
530 .It \&kH Ta KEY_LL Ta Home Down
531 .It \&kh Ta KEY_HOME Ta Home
532 .It \&kI Ta KEY_IC Ta Insert Character
533 .It \&kL Ta KEY_DL Ta Delete Line
534 .It \&kl Ta KEY_LEFT Ta Left Arrow
535 .It \&kM Ta KEY_EIC Ta Exit Insert Character Mode
536 .It \&kN Ta KEY_NPAGE Ta Next Page
537 .It \&kP Ta KEY_PPAGE Ta Previous Page
538 .It \&kR Ta KEY_SR Ta Scroll One Line Back
539 .It \&kr Ta KEY_RIGHT Ta Right Arrow
540 .It \&kS Ta KEY_EOS Ta Clear to End Of Screen
541 .It \&kT Ta KEY_STAB Ta Set Tab
542 .It \&kt Ta KEY_CTAB Ta Clear Tab
543 .It \&ku Ta KEY_UP Ta Up Arrow
546 Note that not all terminals are capable of generating all the keycodes
547 listed above nor are terminfo entries normally configured with all the
548 above capabilities defined.
550 Other functions that return an int will return one of the following
553 .Bl -tag -width ERR -compact
555 The function completed successfully.
557 An error occurred in the function.
560 Functions returning pointers will return
562 if an error is detected.
564 .Xr curses_cursor 3 ,
565 .Xr curses_keyname 3 ,
566 .Xr curses_refresh 3 ,
572 Curses library complies with the X/Open Curses specification, part of the
573 Single Unix Specification.
579 functions are implementations of extensions made by the NCurses library
580 to the Curses standard.
581 Portable implementations should avoid the use of these functions.
583 The Curses package appeared in