Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 1 | .\"*************************************************************************** |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 2 | .\" Copyright (c) 1998-2013,2015 Free Software Foundation, Inc. * |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 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 | .\" |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 29 | .\" $Id: curs_inopts.3x,v 1.19 2015/04/11 10:21:38 tom Exp $ |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 30 | .TH curs_inopts 3X "" |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 31 | .ie \n(.g .ds `` \(lq |
| 32 | .el .ds `` `` |
| 33 | .ie \n(.g .ds '' \(rq |
| 34 | .el .ds '' '' |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 35 | .na |
| 36 | .hy 0 |
| 37 | .SH NAME |
| 38 | \fBcbreak\fR, |
| 39 | \fBnocbreak\fR, |
| 40 | \fBecho\fR, |
| 41 | \fBnoecho\fR, |
| 42 | \fBhalfdelay\fR, |
| 43 | \fBintrflush\fR, |
| 44 | \fBkeypad\fR, |
| 45 | \fBmeta\fR, |
| 46 | \fBnodelay\fR, |
| 47 | \fBnotimeout\fR, |
| 48 | \fBraw\fR, |
| 49 | \fBnoraw\fR, |
| 50 | \fBnoqiflush\fR, |
| 51 | \fBqiflush\fR, |
| 52 | \fBtimeout\fR, |
| 53 | \fBwtimeout\fR, |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 54 | \fBtypeahead\fR \- \fBcurses\fR input options |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 55 | .ad |
| 56 | .hy |
| 57 | .SH SYNOPSIS |
| 58 | \fB#include <curses.h>\fR |
| 59 | .PP |
| 60 | \fBint cbreak(void);\fR |
| 61 | .br |
| 62 | \fBint nocbreak(void);\fR |
| 63 | .br |
| 64 | \fBint echo(void);\fR |
| 65 | .br |
| 66 | \fBint noecho(void);\fR |
| 67 | .br |
| 68 | \fBint halfdelay(int tenths);\fR |
| 69 | .br |
| 70 | \fBint intrflush(WINDOW *win, bool bf);\fR |
| 71 | .br |
| 72 | \fBint keypad(WINDOW *win, bool bf);\fR |
| 73 | .br |
| 74 | \fBint meta(WINDOW *win, bool bf);\fR |
| 75 | .br |
| 76 | \fBint nodelay(WINDOW *win, bool bf);\fR |
| 77 | .br |
| 78 | \fBint raw(void);\fR |
| 79 | .br |
| 80 | \fBint noraw(void);\fR |
| 81 | .br |
| 82 | \fBvoid noqiflush(void);\fR |
| 83 | .br |
| 84 | \fBvoid qiflush(void);\fR |
| 85 | .br |
| 86 | \fBint notimeout(WINDOW *win, bool bf);\fR |
| 87 | .br |
| 88 | \fBvoid timeout(int delay);\fR |
| 89 | .br |
| 90 | \fBvoid wtimeout(WINDOW *win, int delay);\fR |
| 91 | .br |
| 92 | \fBint typeahead(int fd);\fR |
| 93 | .br |
| 94 | .SH DESCRIPTION |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 95 | The \fBncurses\fP library provides several functions which let an application |
| 96 | change way input from the terminal is handled. |
| 97 | Some are global, applying to all windows. |
| 98 | Others apply only to a specific window. |
| 99 | Window-specific settings are not automatically applied to new or derived |
| 100 | windows. |
| 101 | An application must apply these to each window, if the same behavior |
| 102 | is needed. |
| 103 | .\" |
| 104 | .SS cbreak |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 105 | Normally, the tty driver buffers typed characters until a newline or carriage |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 106 | return is typed. |
| 107 | The \fBcbreak\fR routine disables line buffering and |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 108 | erase/kill character-processing (interrupt and flow control characters are |
| 109 | unaffected), making characters typed by the user immediately available to the |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 110 | program. |
| 111 | The \fBnocbreak\fR routine returns the terminal to normal (cooked) |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 112 | mode. |
| 113 | .PP |
| 114 | Initially the terminal may or may not be in \fBcbreak\fR mode, as the mode is |
| 115 | inherited; therefore, a program should call \fBcbreak\fR or \fBnocbreak\fR |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 116 | explicitly. |
| 117 | Most interactive programs using \fBcurses\fR set the \fBcbreak\fR |
| 118 | mode. |
| 119 | Note that \fBcbreak\fR overrides \fBraw\fR. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 120 | [See \fBcurs_getch\fR(3X) for a |
| 121 | discussion of how these routines interact with \fBecho\fR and \fBnoecho\fR.] |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 122 | .\" |
| 123 | .SS echo/noecho |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 124 | .PP |
| 125 | The \fBecho\fR and \fBnoecho\fR routines control whether characters typed by |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 126 | the user are echoed by \fBgetch\fR as they are typed. |
| 127 | Echoing by the tty |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 128 | driver is always disabled, but initially \fBgetch\fR is in echo mode, so |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 129 | characters typed are echoed. |
| 130 | Authors of most interactive programs prefer to do |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 131 | their own echoing in a controlled area of the screen, or not to echo at all, so |
| 132 | they disable echoing by calling \fBnoecho\fR. |
| 133 | [See \fBcurs_getch\fR(3X) for a |
| 134 | discussion of how these routines interact with \fBcbreak\fR and |
| 135 | \fBnocbreak\fR.] |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 136 | .\" |
| 137 | .SS halfdelay |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 138 | .PP |
| 139 | The \fBhalfdelay\fR routine is used for half-delay mode, which is similar to |
| 140 | \fBcbreak\fR mode in that characters typed by the user are immediately |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 141 | available to the program. |
| 142 | However, after blocking for \fItenths\fR tenths of |
| 143 | seconds, ERR is returned if nothing has been typed. |
| 144 | The value of \fBtenths\fR |
| 145 | must be a number between 1 and 255. |
| 146 | Use \fBnocbreak\fR to leave half-delay |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 147 | mode. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 148 | .\" |
| 149 | .SS intrflush |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 150 | .PP |
| 151 | If the \fBintrflush\fR option is enabled, (\fIbf\fR is \fBTRUE\fR), when an |
| 152 | interrupt key is pressed on the keyboard (interrupt, break, quit) all output in |
| 153 | the tty driver queue will be flushed, giving the effect of faster response to |
| 154 | the interrupt, but causing \fBcurses\fR to have the wrong idea of what is on |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 155 | the screen. |
| 156 | Disabling (\fIbf\fR is \fBFALSE\fR), the option prevents the |
| 157 | flush. |
| 158 | The default for the option is inherited from the tty driver settings. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 159 | The window argument is ignored. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 160 | .\" |
| 161 | .SS keypad |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 162 | .PP |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 163 | The \fBkeypad\fR option enables the keypad of the user's terminal. |
| 164 | If |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 165 | enabled (\fIbf\fR is \fBTRUE\fR), the user can press a function key |
| 166 | (such as an arrow key) and \fBwgetch\fR returns a single value |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 167 | representing the function key, as in \fBKEY_LEFT\fR. |
| 168 | If disabled |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 169 | (\fIbf\fR is \fBFALSE\fR), \fBcurses\fR does not treat function keys |
| 170 | specially and the program has to interpret the escape sequences |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 171 | itself. |
| 172 | If the keypad in the terminal can be turned on (made to |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 173 | transmit) and off (made to work locally), turning on this option |
| 174 | causes the terminal keypad to be turned on when \fBwgetch\fR is |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 175 | called. |
| 176 | The default value for keypad is \fBFALSE\fP. |
| 177 | .\" |
| 178 | .SS meta |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 179 | .PP |
| 180 | Initially, whether the terminal returns 7 or 8 significant bits on |
| 181 | input depends on the control mode of the tty driver [see termio(7)]. |
| 182 | To force 8 bits to be returned, invoke \fBmeta\fR(\fIwin\fR, |
| 183 | \fBTRUE\fR); this is equivalent, under POSIX, to setting the CS8 flag |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 184 | on the terminal. |
| 185 | To force 7 bits to be returned, invoke |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 186 | \fBmeta\fR(\fIwin\fR, \fBFALSE\fR); this is equivalent, under POSIX, |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 187 | to setting the CS7 flag on the terminal. |
| 188 | The window argument, |
| 189 | \fIwin\fR, is always ignored. |
| 190 | If the terminfo capabilities \fBsmm\fR |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 191 | (meta_on) and \fBrmm\fR (meta_off) are defined for the terminal, |
| 192 | \fBsmm\fR is sent to the terminal when \fBmeta\fR(\fIwin\fR, |
| 193 | \fBTRUE\fR) is called and \fBrmm\fR is sent when \fBmeta\fR(\fIwin\fR, |
| 194 | \fBFALSE\fR) is called. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 195 | .\" |
| 196 | .SS nodelay |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 197 | .PP |
| 198 | The \fBnodelay\fR option causes \fBgetch\fR to be a non-blocking call. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 199 | If no input is ready, \fBgetch\fR returns \fBERR\fR. |
| 200 | If disabled |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 201 | (\fIbf\fR is \fBFALSE\fR), \fBgetch\fR waits until a key is pressed. |
| 202 | .PP |
| 203 | While interpreting an input escape sequence, \fBwgetch\fR sets a timer |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 204 | while waiting for the next character. |
| 205 | If \fBnotimeout(\fR\fIwin\fR, |
| 206 | \fBTRUE\fR) is called, then \fBwgetch\fR does not set a timer. |
| 207 | The |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 208 | purpose of the timeout is to differentiate between sequences received |
| 209 | from a function key and those typed by a user. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 210 | .\" |
| 211 | .SS raw/noraw |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 212 | .PP |
| 213 | The \fBraw\fR and \fBnoraw\fR routines place the terminal into or out of raw |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 214 | mode. |
| 215 | Raw mode is similar to \fBcbreak\fR mode, in that characters typed are |
| 216 | immediately passed through to the user program. |
| 217 | The differences are that in |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 218 | raw mode, the interrupt, quit, suspend, and flow control characters are all |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 219 | passed through uninterpreted, instead of generating a signal. |
| 220 | The behavior of |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 221 | the BREAK key depends on other bits in the tty driver that are not set by |
| 222 | \fBcurses\fR. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 223 | .\" |
| 224 | .SS noqiflush |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 225 | .PP |
| 226 | When the \fBnoqiflush\fR routine is used, normal flush of input and |
| 227 | output queues associated with the \fBINTR\fR, \fBQUIT\fR and |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 228 | \fBSUSP\fR characters will not be done [see termio(7)]. |
| 229 | When |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 230 | \fBqiflush\fR is called, the queues will be flushed when these control |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 231 | characters are read. |
| 232 | You may want to call \fBnoqiflush()\fR in a signal |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 233 | handler if you want output to continue as though the interrupt |
| 234 | had not occurred, after the handler exits. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 235 | .\" |
| 236 | .SS timeout/wtimeout |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 237 | .PP |
| 238 | The \fBtimeout\fR and \fBwtimeout\fR routines set blocking or |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 239 | non-blocking read for a given window. |
| 240 | If \fIdelay\fR is negative, |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 241 | blocking read is used (i.e., waits indefinitely for |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 242 | input). |
| 243 | If \fIdelay\fR is zero, then non-blocking read is used |
| 244 | (i.e., read returns \fBERR\fR if no input is waiting). |
| 245 | If |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 246 | \fIdelay\fR is positive, then read blocks for \fIdelay\fR |
| 247 | milliseconds, and returns \fBERR\fR if there is still no input. |
| 248 | Hence, these routines provide the same functionality as \fBnodelay\fR, |
| 249 | plus the additional capability of being able to block for only |
| 250 | \fIdelay\fR milliseconds (where \fIdelay\fR is positive). |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 251 | .\" |
| 252 | .SS typeahead |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 253 | .PP |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 254 | The \fBcurses\fR library does \*(``line-breakout optimization\*('' |
| 255 | by looking for typeahead periodically while updating the screen. |
| 256 | If input is found, and it is coming from a tty, |
| 257 | the current update is postponed until |
| 258 | \fBrefresh\fR or \fBdoupdate\fR is called again. |
| 259 | This allows faster response to commands typed in advance. |
| 260 | Normally, the input FILE |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 261 | pointer passed to \fBnewterm\fR, or \fBstdin\fR in the case that |
| 262 | \fBinitscr\fR was used, will be used to do this typeahead checking. |
| 263 | The \fBtypeahead\fR routine specifies that the file descriptor |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 264 | \fIfd\fR is to be used to check for typeahead instead. |
| 265 | If \fIfd\fR is |
| 266 | \-1, then no typeahead checking is done. |
| 267 | .\" |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 268 | .SH RETURN VALUE |
| 269 | All routines that return an integer return \fBERR\fR upon failure and OK (SVr4 |
| 270 | specifies only "an integer value other than \fBERR\fR") upon successful |
| 271 | completion, unless otherwise noted in the preceding routine descriptions. |
| 272 | .PP |
| 273 | X/Open does not define any error conditions. |
| 274 | In this implementation, |
| 275 | functions with a window parameter will return an error if it is null. |
| 276 | Any function will also return an error if the terminal was not initialized. |
| 277 | Also, |
| 278 | .RS |
| 279 | .TP 5 |
| 280 | \fBhalfdelay\fP |
| 281 | returns an error |
| 282 | if its parameter is outside the range 1..255. |
| 283 | .RE |
| 284 | .SH PORTABILITY |
| 285 | These functions are described in the XSI Curses standard, Issue 4. |
| 286 | .PP |
| 287 | The ncurses library obeys the XPG4 standard and the historical practice of the |
| 288 | AT&T curses implementations, in that the echo bit is cleared when curses |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 289 | initializes the terminal state. |
| 290 | BSD curses differed from this slightly; it |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 291 | left the echo bit on at initialization, but the BSD \fBraw\fR call turned it |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 292 | off as a side-effect. |
| 293 | For best portability, set echo or noecho explicitly |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 294 | just after initialization, even if your program remains in cooked mode. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 295 | .PP |
| 296 | When \fBkeypad\fP is first enabled, |
| 297 | ncurses loads the key-definitions for the current terminal description. |
| 298 | If the terminal description includes extended string capabilities, |
| 299 | e.g., from using the \fB\-x\fP option of @TIC@, |
| 300 | then ncurses also defines keys for the capabilities whose names |
| 301 | begin with "k". |
| 302 | The corresponding keycodes are generated and (depending on previous |
| 303 | loads of terminal descriptions) may differ from one execution of a |
| 304 | program to the next. |
| 305 | The generated keycodes are recognized by the \fBkeyname\fP function |
| 306 | (which will then return a name beginning with "k" denoting the |
| 307 | terminfo capability name rather than "K", used for curses key-names). |
| 308 | On the other hand, an application can use \fBdefine_key\fP to establish |
| 309 | a specific keycode for a given string. |
| 310 | This makes it possible for an application to check for an extended |
| 311 | capability's presence with \fItigetstr\fP, |
| 312 | and reassign the keycode to match its own needs. |
| 313 | .PP |
| 314 | Low-level applications can use \fBtigetstr\fP to obtain the definition |
| 315 | of any particular string capability. |
| 316 | Higher-level applications which use the curses \fBwgetch\fP |
| 317 | and similar functions to return keycodes rely upon the order in which |
| 318 | the strings are loaded. |
| 319 | If more than one key definition has the same string value, |
| 320 | then \fBwgetch\fP can return only one keycode. |
| 321 | Most curses implementations (including ncurses) |
| 322 | load key definitions in the order |
| 323 | defined by the array of string capability names. |
| 324 | The last key to be loaded determines the keycode which will be returned. |
| 325 | In ncurses, you may also have extended capabilities interpreted as |
| 326 | key definitions. |
| 327 | These are loaded after the predefined keys, |
| 328 | and if a capability's value is the same as a previously-loaded |
| 329 | key definition, |
| 330 | the later definition is the one used. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 331 | .SH NOTES |
| 332 | Note that \fBecho\fR, \fBnoecho\fR, \fBhalfdelay\fR, \fBintrflush\fR, |
| 333 | \fBmeta\fR, \fBnodelay\fR, \fBnotimeout\fR, \fBnoqiflush\fR, |
| 334 | \fBqiflush\fR, \fBtimeout\fR, and \fBwtimeout\fR may be macros. |
| 335 | .PP |
| 336 | The \fBnoraw\fR and \fBnocbreak\fR calls follow historical practice in that |
| 337 | they attempt to restore to normal (`cooked') mode from raw and cbreak modes |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 338 | respectively. |
| 339 | Mixing raw/noraw and cbreak/nocbreak calls leads to tty driver |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 340 | control states that are hard to predict or understand; it is not recommended. |
| 341 | .SH SEE ALSO |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 342 | \fBcurses\fR(3X), |
| 343 | \fBcurs_getch\fR(3X), |
| 344 | \fBcurs_initscr\fR(3X), |
| 345 | \fBcurs_util\fR(3X), |
| 346 | \fBdefine_key\fR(3X), |
| 347 | \fBtermio\fR(7) |