📄 curs_inopts.3x
字号:
.\"***************************************************************************.\" Copyright (c) 1998-2003,2005 Free Software Foundation, Inc. *.\" *.\" Permission is hereby granted, free of charge, to any person obtaining a *.\" copy of this software and associated documentation files (the *.\" "Software"), to deal in the Software without restriction, including *.\" without limitation the rights to use, copy, modify, merge, publish, *.\" distribute, distribute with modifications, sublicense, and/or sell *.\" copies of the Software, and to permit persons to whom the Software is *.\" furnished to do so, subject to the following conditions: *.\" *.\" The above copyright notice and this permission notice shall be included *.\" in all copies or substantial portions of the Software. *.\" *.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *.\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *.\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *.\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *.\" THE USE OR OTHER DEALINGS IN THE SOFTWARE. *.\" *.\" Except as contained in this notice, the name(s) of the above copyright *.\" holders shall not be used in advertising or otherwise to promote the *.\" sale, use or other dealings in this Software without prior written *.\" authorization. *.\"***************************************************************************.\".\" $Id: curs_inopts.3x,v 1.13 2005/05/15 16:18:07 tom Exp $.TH curs_inopts 3X "".na.hy 0.SH NAME\fBcbreak\fR,\fBnocbreak\fR,\fBecho\fR,\fBnoecho\fR,\fBhalfdelay\fR,\fBintrflush\fR,\fBkeypad\fR,\fBmeta\fR,\fBnodelay\fR,\fBnotimeout\fR,\fBraw\fR,\fBnoraw\fR,\fBnoqiflush\fR,\fBqiflush\fR,\fBtimeout\fR,\fBwtimeout\fR,\fBtypeahead\fR - \fBcurses\fR input options.ad.hy.SH SYNOPSIS\fB#include <curses.h>\fR.PP\fBint cbreak(void);\fR.br\fBint nocbreak(void);\fR.br\fBint echo(void);\fR.br\fBint noecho(void);\fR.br\fBint halfdelay(int tenths);\fR.br\fBint intrflush(WINDOW *win, bool bf);\fR.br\fBint keypad(WINDOW *win, bool bf);\fR.br\fBint meta(WINDOW *win, bool bf);\fR.br\fBint nodelay(WINDOW *win, bool bf);\fR.br\fBint raw(void);\fR.br\fBint noraw(void);\fR.br\fBvoid noqiflush(void);\fR.br\fBvoid qiflush(void);\fR.br\fBint notimeout(WINDOW *win, bool bf);\fR.br\fBvoid timeout(int delay);\fR.br\fBvoid wtimeout(WINDOW *win, int delay);\fR.br\fBint typeahead(int fd);\fR.br.SH DESCRIPTIONNormally, the tty driver buffers typed characters until a newline or carriagereturn is typed. The \fBcbreak\fR routine disables line buffering anderase/kill character-processing (interrupt and flow control characters areunaffected), making characters typed by the user immediately available to theprogram. The \fBnocbreak\fR routine returns the terminal to normal (cooked)mode..PPInitially the terminal may or may not be in \fBcbreak\fR mode, as the mode isinherited; therefore, a program should call \fBcbreak\fR or \fBnocbreak\fRexplicitly. Most interactive programs using \fBcurses\fR set the \fBcbreak\fRmode. Note that \fBcbreak\fR overrides \fBraw\fR.[See \fBcurs_getch\fR(3X) for adiscussion of how these routines interact with \fBecho\fR and \fBnoecho\fR.].PPThe \fBecho\fR and \fBnoecho\fR routines control whether characters typed bythe user are echoed by \fBgetch\fR as they are typed. Echoing by the ttydriver is always disabled, but initially \fBgetch\fR is in echo mode, socharacters typed are echoed. Authors of most interactive programs prefer to dotheir own echoing in a controlled area of the screen, or not to echo at all, sothey disable echoing by calling \fBnoecho\fR.[See \fBcurs_getch\fR(3X) for adiscussion of how these routines interact with \fBcbreak\fR and\fBnocbreak\fR.].PPThe \fBhalfdelay\fR routine is used for half-delay mode, which is similar to\fBcbreak\fR mode in that characters typed by the user are immediatelyavailable to the program. However, after blocking for \fItenths\fR tenths ofseconds, ERR is returned if nothing has been typed. The value of \fBtenths\fRmust be a number between 1 and 255. Use \fBnocbreak\fR to leave half-delaymode..PPIf the \fBintrflush\fR option is enabled, (\fIbf\fR is \fBTRUE\fR), when aninterrupt key is pressed on the keyboard (interrupt, break, quit) all output inthe tty driver queue will be flushed, giving the effect of faster response tothe interrupt, but causing \fBcurses\fR to have the wrong idea of what is onthe screen. Disabling (\fIbf\fR is \fBFALSE\fR), the option prevents theflush. The default for the option is inherited from the tty driver settings.The window argument is ignored..PPThe \fBkeypad\fR option enables the keypad of the user's terminal. Ifenabled (\fIbf\fR is \fBTRUE\fR), the user can press a function key(such as an arrow key) and \fBwgetch\fR returns a single valuerepresenting the function key, as in \fBKEY_LEFT\fR. If disabled(\fIbf\fR is \fBFALSE\fR), \fBcurses\fR does not treat function keysspecially and the program has to interpret the escape sequencesitself. If the keypad in the terminal can be turned on (made totransmit) and off (made to work locally), turning on this optioncauses the terminal keypad to be turned on when \fBwgetch\fR iscalled. The default value for keypad is false..PPInitially, whether the terminal returns 7 or 8 significant bits oninput depends on the control mode of the tty driver [see termio(7)].To force 8 bits to be returned, invoke \fBmeta\fR(\fIwin\fR,\fBTRUE\fR); this is equivalent, under POSIX, to setting the CS8 flagon the terminal. To force 7 bits to be returned, invoke\fBmeta\fR(\fIwin\fR, \fBFALSE\fR); this is equivalent, under POSIX,to setting the CS7 flag on the terminal. The window argument,\fIwin\fR, is always ignored. If the terminfo capabilities \fBsmm\fR(meta_on) and \fBrmm\fR (meta_off) are defined for the terminal,\fBsmm\fR is sent to the terminal when \fBmeta\fR(\fIwin\fR,\fBTRUE\fR) is called and \fBrmm\fR is sent when \fBmeta\fR(\fIwin\fR,\fBFALSE\fR) is called..PPThe \fBnodelay\fR option causes \fBgetch\fR to be a non-blocking call.If no input is ready, \fBgetch\fR returns \fBERR\fR. If disabled(\fIbf\fR is \fBFALSE\fR), \fBgetch\fR waits until a key is pressed..PPWhile interpreting an input escape sequence, \fBwgetch\fR sets a timerwhile waiting for the next character. If \fBnotimeout(\fR\fIwin\fR,\fBTRUE\fR) is called, then \fBwgetch\fR does not set a timer. Thepurpose of the timeout is to differentiate between sequences receivedfrom a function key and those typed by a user..PPThe \fBraw\fR and \fBnoraw\fR routines place the terminal into or out of rawmode. Raw mode is similar to \fBcbreak\fR mode, in that characters typed areimmediately passed through to the user program. The differences are that inraw mode, the interrupt, quit, suspend, and flow control characters are allpassed through uninterpreted, instead of generating a signal. The behavior ofthe BREAK key depends on other bits in the tty driver that are not set by\fBcurses\fR..PPWhen the \fBnoqiflush\fR routine is used, normal flush of input andoutput queues associated with the \fBINTR\fR, \fBQUIT\fR and\fBSUSP\fR characters will not be done [see termio(7)]. When\fBqiflush\fR is called, the queues will be flushed when these controlcharacters are read. You may want to call \fBnoqiflush()\fR in a signalhandler if you want output to continue as though the interrupthad not occurred, after the handler exits..PPThe \fBtimeout\fR and \fBwtimeout\fR routines set blocking ornon-blocking read for a given window. If \fIdelay\fR is negative,blocking read is used (i.e., waits indefinitely forinput). If \fIdelay\fR is zero, then non-blocking read is used(i.e., read returns \fBERR\fR if no input is waiting). If\fIdelay\fR is positive, then read blocks for \fIdelay\fRmilliseconds, and returns \fBERR\fR if there is still no input.Hence, these routines provide the same functionality as \fBnodelay\fR,plus the additional capability of being able to block for only\fIdelay\fR milliseconds (where \fIdelay\fR is positive)..PPThe \fBcurses\fR library does ``line-breakout optimization'' by looking fortypeahead periodically while updating the screen. If input is found,and it is coming from a tty, the current update is postponed until\fBrefresh\fR or \fBdoupdate\fR is called again. This allows fasterresponse to commands typed in advance. Normally, the input FILEpointer passed to \fBnewterm\fR, or \fBstdin\fR in the case that\fBinitscr\fR was used, will be used to do this typeahead checking.The \fBtypeahead\fR routine specifies that the file descriptor\fIfd\fR is to be used to check for typeahead instead. If \fIfd\fR is-1, then no typeahead checking is done..SH RETURN VALUEAll routines that return an integer return \fBERR\fR upon failure and OK (SVr4specifies only "an integer value other than \fBERR\fR") upon successfulcompletion, unless otherwise noted in the preceding routine descriptions..PPX/Open does not define any error conditions.In this implementation,functions with a window parameter will return an error if it is null.Any function will also return an error if the terminal was not initialized.Also,.RS.TP 5\fBhalfdelay\fPreturns an errorif its parameter is outside the range 1..255..RE.SH PORTABILITYThese functions are described in the XSI Curses standard, Issue 4..PPThe ncurses library obeys the XPG4 standard and the historical practice of theAT&T curses implementations, in that the echo bit is cleared when cursesinitializes the terminal state. BSD curses differed from this slightly; itleft the echo bit on at initialization, but the BSD \fBraw\fR call turned itoff as a side-effect. For best portability, set echo or noecho explicitlyjust after initialization, even if your program remains in cooked mode..SH NOTESNote that \fBecho\fR, \fBnoecho\fR, \fBhalfdelay\fR, \fBintrflush\fR,\fBmeta\fR, \fBnodelay\fR, \fBnotimeout\fR, \fBnoqiflush\fR,\fBqiflush\fR, \fBtimeout\fR, and \fBwtimeout\fR may be macros..PPThe \fBnoraw\fR and \fBnocbreak\fR calls follow historical practice in thatthey attempt to restore to normal (`cooked') mode from raw and cbreak modesrespectively. Mixing raw/noraw and cbreak/nocbreak calls leads to tty drivercontrol states that are hard to predict or understand; it is not recommended..SH SEE ALSO\fBcurses\fR(3X), \fBcurs_getch\fR(3X), \fBcurs_initscr\fR(3X), \fBtermio\fR(7).\"#.\"# The following sets edit modes for GNU EMACS.\"# Local Variables:.\"# mode:nroff.\"# fill-column:79.\"# End:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -