Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 1 | .\"*************************************************************************** |
| 2 | .\" Copyright (c) 1998-2003,2005 Free Software Foundation, Inc. * |
| 3 | .\" * |
| 4 | .\" Permission is hereby granted, free of charge, to any person obtaining a * |
| 5 | .\" copy of this software and associated documentation files (the * |
| 6 | .\" "Software"), to deal in the Software without restriction, including * |
| 7 | .\" without limitation the rights to use, copy, modify, merge, publish, * |
| 8 | .\" distribute, distribute with modifications, sublicense, and/or sell * |
| 9 | .\" copies of the Software, and to permit persons to whom the Software is * |
| 10 | .\" furnished to do so, subject to the following conditions: * |
| 11 | .\" * |
| 12 | .\" The above copyright notice and this permission notice shall be included * |
| 13 | .\" in all copies or substantial portions of the Software. * |
| 14 | .\" * |
| 15 | .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * |
| 16 | .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * |
| 17 | .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * |
| 18 | .\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * |
| 19 | .\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * |
| 20 | .\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * |
| 21 | .\" THE USE OR OTHER DEALINGS IN THE SOFTWARE. * |
| 22 | .\" * |
| 23 | .\" Except as contained in this notice, the name(s) of the above copyright * |
| 24 | .\" holders shall not be used in advertising or otherwise to promote the * |
| 25 | .\" sale, use or other dealings in this Software without prior written * |
| 26 | .\" authorization. * |
| 27 | .\"*************************************************************************** |
| 28 | .\" |
| 29 | .\" $Id: curs_inopts.3x,v 1.13 2005/05/15 16:18:07 tom Exp $ |
| 30 | .TH curs_inopts 3X "" |
| 31 | .na |
| 32 | .hy 0 |
| 33 | .SH NAME |
| 34 | \fBcbreak\fR, |
| 35 | \fBnocbreak\fR, |
| 36 | \fBecho\fR, |
| 37 | \fBnoecho\fR, |
| 38 | \fBhalfdelay\fR, |
| 39 | \fBintrflush\fR, |
| 40 | \fBkeypad\fR, |
| 41 | \fBmeta\fR, |
| 42 | \fBnodelay\fR, |
| 43 | \fBnotimeout\fR, |
| 44 | \fBraw\fR, |
| 45 | \fBnoraw\fR, |
| 46 | \fBnoqiflush\fR, |
| 47 | \fBqiflush\fR, |
| 48 | \fBtimeout\fR, |
| 49 | \fBwtimeout\fR, |
| 50 | \fBtypeahead\fR - \fBcurses\fR input options |
| 51 | .ad |
| 52 | .hy |
| 53 | .SH SYNOPSIS |
| 54 | \fB#include <curses.h>\fR |
| 55 | .PP |
| 56 | \fBint cbreak(void);\fR |
| 57 | .br |
| 58 | \fBint nocbreak(void);\fR |
| 59 | .br |
| 60 | \fBint echo(void);\fR |
| 61 | .br |
| 62 | \fBint noecho(void);\fR |
| 63 | .br |
| 64 | \fBint halfdelay(int tenths);\fR |
| 65 | .br |
| 66 | \fBint intrflush(WINDOW *win, bool bf);\fR |
| 67 | .br |
| 68 | \fBint keypad(WINDOW *win, bool bf);\fR |
| 69 | .br |
| 70 | \fBint meta(WINDOW *win, bool bf);\fR |
| 71 | .br |
| 72 | \fBint nodelay(WINDOW *win, bool bf);\fR |
| 73 | .br |
| 74 | \fBint raw(void);\fR |
| 75 | .br |
| 76 | \fBint noraw(void);\fR |
| 77 | .br |
| 78 | \fBvoid noqiflush(void);\fR |
| 79 | .br |
| 80 | \fBvoid qiflush(void);\fR |
| 81 | .br |
| 82 | \fBint notimeout(WINDOW *win, bool bf);\fR |
| 83 | .br |
| 84 | \fBvoid timeout(int delay);\fR |
| 85 | .br |
| 86 | \fBvoid wtimeout(WINDOW *win, int delay);\fR |
| 87 | .br |
| 88 | \fBint typeahead(int fd);\fR |
| 89 | .br |
| 90 | .SH DESCRIPTION |
| 91 | Normally, the tty driver buffers typed characters until a newline or carriage |
| 92 | return is typed. The \fBcbreak\fR routine disables line buffering and |
| 93 | erase/kill character-processing (interrupt and flow control characters are |
| 94 | unaffected), making characters typed by the user immediately available to the |
| 95 | program. The \fBnocbreak\fR routine returns the terminal to normal (cooked) |
| 96 | mode. |
| 97 | .PP |
| 98 | Initially the terminal may or may not be in \fBcbreak\fR mode, as the mode is |
| 99 | inherited; therefore, a program should call \fBcbreak\fR or \fBnocbreak\fR |
| 100 | explicitly. Most interactive programs using \fBcurses\fR set the \fBcbreak\fR |
| 101 | mode. Note that \fBcbreak\fR overrides \fBraw\fR. |
| 102 | [See \fBcurs_getch\fR(3X) for a |
| 103 | discussion of how these routines interact with \fBecho\fR and \fBnoecho\fR.] |
| 104 | .PP |
| 105 | The \fBecho\fR and \fBnoecho\fR routines control whether characters typed by |
| 106 | the user are echoed by \fBgetch\fR as they are typed. Echoing by the tty |
| 107 | driver is always disabled, but initially \fBgetch\fR is in echo mode, so |
| 108 | characters typed are echoed. Authors of most interactive programs prefer to do |
| 109 | their own echoing in a controlled area of the screen, or not to echo at all, so |
| 110 | they disable echoing by calling \fBnoecho\fR. |
| 111 | [See \fBcurs_getch\fR(3X) for a |
| 112 | discussion of how these routines interact with \fBcbreak\fR and |
| 113 | \fBnocbreak\fR.] |
| 114 | .PP |
| 115 | The \fBhalfdelay\fR routine is used for half-delay mode, which is similar to |
| 116 | \fBcbreak\fR mode in that characters typed by the user are immediately |
| 117 | available to the program. However, after blocking for \fItenths\fR tenths of |
| 118 | seconds, ERR is returned if nothing has been typed. The value of \fBtenths\fR |
| 119 | must be a number between 1 and 255. Use \fBnocbreak\fR to leave half-delay |
| 120 | mode. |
| 121 | .PP |
| 122 | If the \fBintrflush\fR option is enabled, (\fIbf\fR is \fBTRUE\fR), when an |
| 123 | interrupt key is pressed on the keyboard (interrupt, break, quit) all output in |
| 124 | the tty driver queue will be flushed, giving the effect of faster response to |
| 125 | the interrupt, but causing \fBcurses\fR to have the wrong idea of what is on |
| 126 | the screen. Disabling (\fIbf\fR is \fBFALSE\fR), the option prevents the |
| 127 | flush. The default for the option is inherited from the tty driver settings. |
| 128 | The window argument is ignored. |
| 129 | .PP |
| 130 | The \fBkeypad\fR option enables the keypad of the user's terminal. If |
| 131 | enabled (\fIbf\fR is \fBTRUE\fR), the user can press a function key |
| 132 | (such as an arrow key) and \fBwgetch\fR returns a single value |
| 133 | representing the function key, as in \fBKEY_LEFT\fR. If disabled |
| 134 | (\fIbf\fR is \fBFALSE\fR), \fBcurses\fR does not treat function keys |
| 135 | specially and the program has to interpret the escape sequences |
| 136 | itself. If the keypad in the terminal can be turned on (made to |
| 137 | transmit) and off (made to work locally), turning on this option |
| 138 | causes the terminal keypad to be turned on when \fBwgetch\fR is |
| 139 | called. The default value for keypad is false. |
| 140 | .PP |
| 141 | Initially, whether the terminal returns 7 or 8 significant bits on |
| 142 | input depends on the control mode of the tty driver [see termio(7)]. |
| 143 | To force 8 bits to be returned, invoke \fBmeta\fR(\fIwin\fR, |
| 144 | \fBTRUE\fR); this is equivalent, under POSIX, to setting the CS8 flag |
| 145 | on the terminal. To force 7 bits to be returned, invoke |
| 146 | \fBmeta\fR(\fIwin\fR, \fBFALSE\fR); this is equivalent, under POSIX, |
| 147 | to setting the CS7 flag on the terminal. The window argument, |
| 148 | \fIwin\fR, is always ignored. If the terminfo capabilities \fBsmm\fR |
| 149 | (meta_on) and \fBrmm\fR (meta_off) are defined for the terminal, |
| 150 | \fBsmm\fR is sent to the terminal when \fBmeta\fR(\fIwin\fR, |
| 151 | \fBTRUE\fR) is called and \fBrmm\fR is sent when \fBmeta\fR(\fIwin\fR, |
| 152 | \fBFALSE\fR) is called. |
| 153 | .PP |
| 154 | The \fBnodelay\fR option causes \fBgetch\fR to be a non-blocking call. |
| 155 | If no input is ready, \fBgetch\fR returns \fBERR\fR. If disabled |
| 156 | (\fIbf\fR is \fBFALSE\fR), \fBgetch\fR waits until a key is pressed. |
| 157 | .PP |
| 158 | While interpreting an input escape sequence, \fBwgetch\fR sets a timer |
| 159 | while waiting for the next character. If \fBnotimeout(\fR\fIwin\fR, |
| 160 | \fBTRUE\fR) is called, then \fBwgetch\fR does not set a timer. The |
| 161 | purpose of the timeout is to differentiate between sequences received |
| 162 | from a function key and those typed by a user. |
| 163 | .PP |
| 164 | The \fBraw\fR and \fBnoraw\fR routines place the terminal into or out of raw |
| 165 | mode. Raw mode is similar to \fBcbreak\fR mode, in that characters typed are |
| 166 | immediately passed through to the user program. The differences are that in |
| 167 | raw mode, the interrupt, quit, suspend, and flow control characters are all |
| 168 | passed through uninterpreted, instead of generating a signal. The behavior of |
| 169 | the BREAK key depends on other bits in the tty driver that are not set by |
| 170 | \fBcurses\fR. |
| 171 | .PP |
| 172 | When the \fBnoqiflush\fR routine is used, normal flush of input and |
| 173 | output queues associated with the \fBINTR\fR, \fBQUIT\fR and |
| 174 | \fBSUSP\fR characters will not be done [see termio(7)]. When |
| 175 | \fBqiflush\fR is called, the queues will be flushed when these control |
| 176 | characters are read. You may want to call \fBnoqiflush()\fR in a signal |
| 177 | handler if you want output to continue as though the interrupt |
| 178 | had not occurred, after the handler exits. |
| 179 | .PP |
| 180 | The \fBtimeout\fR and \fBwtimeout\fR routines set blocking or |
| 181 | non-blocking read for a given window. If \fIdelay\fR is negative, |
| 182 | blocking read is used (i.e., waits indefinitely for |
| 183 | input). If \fIdelay\fR is zero, then non-blocking read is used |
| 184 | (i.e., read returns \fBERR\fR if no input is waiting). If |
| 185 | \fIdelay\fR is positive, then read blocks for \fIdelay\fR |
| 186 | milliseconds, and returns \fBERR\fR if there is still no input. |
| 187 | Hence, these routines provide the same functionality as \fBnodelay\fR, |
| 188 | plus the additional capability of being able to block for only |
| 189 | \fIdelay\fR milliseconds (where \fIdelay\fR is positive). |
| 190 | .PP |
| 191 | The \fBcurses\fR library does ``line-breakout optimization'' by looking for |
| 192 | typeahead periodically while updating the screen. If input is found, |
| 193 | and it is coming from a tty, the current update is postponed until |
| 194 | \fBrefresh\fR or \fBdoupdate\fR is called again. This allows faster |
| 195 | response to commands typed in advance. Normally, the input FILE |
| 196 | pointer passed to \fBnewterm\fR, or \fBstdin\fR in the case that |
| 197 | \fBinitscr\fR was used, will be used to do this typeahead checking. |
| 198 | The \fBtypeahead\fR routine specifies that the file descriptor |
| 199 | \fIfd\fR is to be used to check for typeahead instead. If \fIfd\fR is |
| 200 | -1, then no typeahead checking is done. |
| 201 | .SH RETURN VALUE |
| 202 | All routines that return an integer return \fBERR\fR upon failure and OK (SVr4 |
| 203 | specifies only "an integer value other than \fBERR\fR") upon successful |
| 204 | completion, unless otherwise noted in the preceding routine descriptions. |
| 205 | .PP |
| 206 | X/Open does not define any error conditions. |
| 207 | In this implementation, |
| 208 | functions with a window parameter will return an error if it is null. |
| 209 | Any function will also return an error if the terminal was not initialized. |
| 210 | Also, |
| 211 | .RS |
| 212 | .TP 5 |
| 213 | \fBhalfdelay\fP |
| 214 | returns an error |
| 215 | if its parameter is outside the range 1..255. |
| 216 | .RE |
| 217 | .SH PORTABILITY |
| 218 | These functions are described in the XSI Curses standard, Issue 4. |
| 219 | .PP |
| 220 | The ncurses library obeys the XPG4 standard and the historical practice of the |
| 221 | AT&T curses implementations, in that the echo bit is cleared when curses |
| 222 | initializes the terminal state. BSD curses differed from this slightly; it |
| 223 | left the echo bit on at initialization, but the BSD \fBraw\fR call turned it |
| 224 | off as a side-effect. For best portability, set echo or noecho explicitly |
| 225 | just after initialization, even if your program remains in cooked mode. |
| 226 | .SH NOTES |
| 227 | Note that \fBecho\fR, \fBnoecho\fR, \fBhalfdelay\fR, \fBintrflush\fR, |
| 228 | \fBmeta\fR, \fBnodelay\fR, \fBnotimeout\fR, \fBnoqiflush\fR, |
| 229 | \fBqiflush\fR, \fBtimeout\fR, and \fBwtimeout\fR may be macros. |
| 230 | .PP |
| 231 | The \fBnoraw\fR and \fBnocbreak\fR calls follow historical practice in that |
| 232 | they attempt to restore to normal (`cooked') mode from raw and cbreak modes |
| 233 | respectively. Mixing raw/noraw and cbreak/nocbreak calls leads to tty driver |
| 234 | control states that are hard to predict or understand; it is not recommended. |
| 235 | .SH SEE ALSO |
| 236 | \fBcurses\fR(3X), \fBcurs_getch\fR(3X), \fBcurs_initscr\fR(3X), \fBtermio\fR(7) |
| 237 | .\"# |
| 238 | .\"# The following sets edit modes for GNU EMACS |
| 239 | .\"# Local Variables: |
| 240 | .\"# mode:nroff |
| 241 | .\"# fill-column:79 |
| 242 | .\"# End: |