curs_inopts.3x.html 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
  2. <!--
  3. ****************************************************************************
  4. * Copyright (c) 1998-2003,2005 Free Software Foundation, Inc. *
  5. * *
  6. * Permission is hereby granted, free of charge, to any person obtaining a *
  7. * copy of this software and associated documentation files (the *
  8. * "Software"), to deal in the Software without restriction, including *
  9. * without limitation the rights to use, copy, modify, merge, publish, *
  10. * distribute, distribute with modifications, sublicense, and/or sell *
  11. * copies of the Software, and to permit persons to whom the Software is *
  12. * furnished to do so, subject to the following conditions: *
  13. * *
  14. * The above copyright notice and this permission notice shall be included *
  15. * in all copies or substantial portions of the Software. *
  16. * *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
  18. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
  19. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
  20. * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
  21. * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
  22. * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
  23. * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
  24. * *
  25. * Except as contained in this notice, the name(s) of the above copyright *
  26. * holders shall not be used in advertising or otherwise to promote the *
  27. * sale, use or other dealings in this Software without prior written *
  28. * authorization. *
  29. ****************************************************************************
  30. * @Id: curs_inopts.3x,v 1.13 2005/05/15 16:18:07 tom Exp @
  31. -->
  32. <HTML>
  33. <HEAD>
  34. <TITLE>curs_inopts 3x</TITLE>
  35. <link rev=made href="mailto:bug-ncurses@gnu.org">
  36. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  37. </HEAD>
  38. <BODY>
  39. <H1>curs_inopts 3x</H1>
  40. <HR>
  41. <PRE>
  42. <!-- Manpage converted by man2html 3.0.1 -->
  43. <STRONG><A HREF="curs_inopts.3x.html">curs_inopts(3x)</A></STRONG> <STRONG><A HREF="curs_inopts.3x.html">curs_inopts(3x)</A></STRONG>
  44. </PRE>
  45. <H2>NAME</H2><PRE>
  46. <STRONG>cbreak</STRONG>, <STRONG>nocbreak</STRONG>, <STRONG>echo</STRONG>, <STRONG>noecho</STRONG>, <STRONG>halfdelay</STRONG>, <STRONG>intrflush</STRONG>,
  47. <STRONG>keypad</STRONG>, <STRONG>meta</STRONG>, <STRONG>nodelay</STRONG>, <STRONG>notimeout</STRONG>, <STRONG>raw</STRONG>, <STRONG>noraw</STRONG>, <STRONG>noqiflush</STRONG>,
  48. <STRONG>qiflush</STRONG>, <STRONG>timeout</STRONG>, <STRONG>wtimeout</STRONG>, <STRONG>typeahead</STRONG> - <STRONG>curses</STRONG> input
  49. options
  50. </PRE>
  51. <H2>SYNOPSIS</H2><PRE>
  52. <STRONG>#include</STRONG> <STRONG>&lt;curses.h&gt;</STRONG>
  53. <STRONG>int</STRONG> <STRONG>cbreak(void);</STRONG>
  54. <STRONG>int</STRONG> <STRONG>nocbreak(void);</STRONG>
  55. <STRONG>int</STRONG> <STRONG>echo(void);</STRONG>
  56. <STRONG>int</STRONG> <STRONG>noecho(void);</STRONG>
  57. <STRONG>int</STRONG> <STRONG>halfdelay(int</STRONG> <STRONG>tenths);</STRONG>
  58. <STRONG>int</STRONG> <STRONG>intrflush(WINDOW</STRONG> <STRONG>*win,</STRONG> <STRONG>bool</STRONG> <STRONG>bf);</STRONG>
  59. <STRONG>int</STRONG> <STRONG>keypad(WINDOW</STRONG> <STRONG>*win,</STRONG> <STRONG>bool</STRONG> <STRONG>bf);</STRONG>
  60. <STRONG>int</STRONG> <STRONG>meta(WINDOW</STRONG> <STRONG>*win,</STRONG> <STRONG>bool</STRONG> <STRONG>bf);</STRONG>
  61. <STRONG>int</STRONG> <STRONG>nodelay(WINDOW</STRONG> <STRONG>*win,</STRONG> <STRONG>bool</STRONG> <STRONG>bf);</STRONG>
  62. <STRONG>int</STRONG> <STRONG>raw(void);</STRONG>
  63. <STRONG>int</STRONG> <STRONG>noraw(void);</STRONG>
  64. <STRONG>void</STRONG> <STRONG>noqiflush(void);</STRONG>
  65. <STRONG>void</STRONG> <STRONG>qiflush(void);</STRONG>
  66. <STRONG>int</STRONG> <STRONG>notimeout(WINDOW</STRONG> <STRONG>*win,</STRONG> <STRONG>bool</STRONG> <STRONG>bf);</STRONG>
  67. <STRONG>void</STRONG> <STRONG>timeout(int</STRONG> <STRONG>delay);</STRONG>
  68. <STRONG>void</STRONG> <STRONG>wtimeout(WINDOW</STRONG> <STRONG>*win,</STRONG> <STRONG>int</STRONG> <STRONG>delay);</STRONG>
  69. <STRONG>int</STRONG> <STRONG>typeahead(int</STRONG> <STRONG>fd);</STRONG>
  70. </PRE>
  71. <H2>DESCRIPTION</H2><PRE>
  72. Normally, the tty driver buffers typed characters until a
  73. newline or carriage return is typed. The <STRONG>cbreak</STRONG> routine
  74. disables line buffering and erase/kill character-process-
  75. ing (interrupt and flow control characters are unaffect-
  76. ed), making characters typed by the user immediately
  77. available to the program. The <STRONG>nocbreak</STRONG> routine returns
  78. the terminal to normal (cooked) mode.
  79. Initially the terminal may or may not be in <STRONG>cbreak</STRONG> mode,
  80. as the mode is inherited; therefore, a program should call
  81. <STRONG>cbreak</STRONG> or <STRONG>nocbreak</STRONG> explicitly. Most interactive programs
  82. using <STRONG>curses</STRONG> set the <STRONG>cbreak</STRONG> mode. Note that <STRONG>cbreak</STRONG> over-
  83. rides <STRONG>raw</STRONG>. [See <STRONG><A HREF="curs_getch.3x.html">curs_getch(3x)</A></STRONG> for a discussion of how
  84. these routines interact with <STRONG>echo</STRONG> and <STRONG>noecho</STRONG>.]
  85. The <STRONG>echo</STRONG> and <STRONG>noecho</STRONG> routines control whether characters
  86. typed by the user are echoed by <STRONG>getch</STRONG> as they are typed.
  87. Echoing by the tty driver is always disabled, but initial-
  88. ly <STRONG>getch</STRONG> is in echo mode, so characters typed are echoed.
  89. Authors of most interactive programs prefer to do their
  90. own echoing in a controlled area of the screen, or not to
  91. echo at all, so they disable echoing by calling <STRONG>noecho</STRONG>.
  92. [See <STRONG><A HREF="curs_getch.3x.html">curs_getch(3x)</A></STRONG> for a discussion of how these routines
  93. interact with <STRONG>cbreak</STRONG> and <STRONG>nocbreak</STRONG>.]
  94. The <STRONG>halfdelay</STRONG> routine is used for half-delay mode, which
  95. is similar to <STRONG>cbreak</STRONG> mode in that characters typed by the
  96. user are immediately available to the program. However,
  97. after blocking for <EM>tenths</EM> tenths of seconds, ERR is re-
  98. turned if nothing has been typed. The value of <STRONG>tenths</STRONG>
  99. must be a number between 1 and 255. Use <STRONG>nocbreak</STRONG> to leave
  100. half-delay mode.
  101. If the <STRONG>intrflush</STRONG> option is enabled, (<EM>bf</EM> is <STRONG>TRUE</STRONG>), when an
  102. interrupt key is pressed on the keyboard (interrupt,
  103. break, quit) all output in the tty driver queue will be
  104. flushed, giving the effect of faster response to the in-
  105. terrupt, but causing <STRONG>curses</STRONG> to have the wrong idea of what
  106. is on the screen. Disabling (<EM>bf</EM> is <STRONG>FALSE</STRONG>), the option
  107. prevents the flush. The default for the option is inher-
  108. ited from the tty driver settings. The window argument is
  109. ignored.
  110. The <STRONG>keypad</STRONG> option enables the keypad of the user's termi-
  111. nal. If enabled (<EM>bf</EM> is <STRONG>TRUE</STRONG>), the user can press a func-
  112. tion key (such as an arrow key) and <STRONG>wgetch</STRONG> returns a sin-
  113. gle value representing the function key, as in <STRONG>KEY_LEFT</STRONG>.
  114. If disabled (<EM>bf</EM> is <STRONG>FALSE</STRONG>), <STRONG>curses</STRONG> does not treat function
  115. keys specially and the program has to interpret the escape
  116. sequences itself. If the keypad in the terminal can be
  117. turned on (made to transmit) and off (made to work local-
  118. ly), turning on this option causes the terminal keypad to
  119. be turned on when <STRONG>wgetch</STRONG> is called. The default value for
  120. keypad is false.
  121. Initially, whether the terminal returns 7 or 8 significant
  122. bits on input depends on the control mode of the tty driv-
  123. er [see <STRONG><A HREF="termio.7.html">termio(7)</A></STRONG>]. To force 8 bits to be returned, in-
  124. voke <STRONG>meta</STRONG>(<EM>win</EM>, <STRONG>TRUE</STRONG>); this is equivalent, under POSIX, to
  125. setting the CS8 flag on the terminal. To force 7 bits to
  126. be returned, invoke <STRONG>meta</STRONG>(<EM>win</EM>, <STRONG>FALSE</STRONG>); this is equivalent,
  127. under POSIX, to setting the CS7 flag on the terminal. The
  128. window argument, <EM>win</EM>, is always ignored. If the terminfo
  129. capabilities <STRONG>smm</STRONG> (meta_on) and <STRONG>rmm</STRONG> (meta_off) are defined
  130. for the terminal, <STRONG>smm</STRONG> is sent to the terminal when
  131. <STRONG>meta</STRONG>(<EM>win</EM>, <STRONG>TRUE</STRONG>) is called and <STRONG>rmm</STRONG> is sent when <STRONG>meta</STRONG>(<EM>win</EM>,
  132. <STRONG>FALSE</STRONG>) is called.
  133. The <STRONG>nodelay</STRONG> option causes <STRONG>getch</STRONG> to be a non-blocking call.
  134. If no input is ready, <STRONG>getch</STRONG> returns <STRONG>ERR</STRONG>. If disabled (<EM>bf</EM>
  135. is <STRONG>FALSE</STRONG>), <STRONG>getch</STRONG> waits until a key is pressed.
  136. While interpreting an input escape sequence, <STRONG>wgetch</STRONG> sets a
  137. timer while waiting for the next character. If <STRONG>notime-</STRONG>
  138. <STRONG>out(</STRONG><EM>win</EM>, <STRONG>TRUE</STRONG>) is called, then <STRONG>wgetch</STRONG> does not set a
  139. timer. The purpose of the timeout is to differentiate be-
  140. tween sequences received from a function key and those
  141. typed by a user.
  142. The <STRONG>raw</STRONG> and <STRONG>noraw</STRONG> routines place the terminal into or out
  143. of raw mode. Raw mode is similar to <STRONG>cbreak</STRONG> mode, in that
  144. characters typed are immediately passed through to the us-
  145. er program. The differences are that in raw mode, the in-
  146. terrupt, quit, suspend, and flow control characters are
  147. all passed through uninterpreted, instead of generating a
  148. signal. The behavior of the BREAK key depends on other
  149. bits in the tty driver that are not set by <STRONG>curses</STRONG>.
  150. When the <STRONG>noqiflush</STRONG> routine is used, normal flush of input
  151. and output queues associated with the <STRONG>INTR</STRONG>, <STRONG>QUIT</STRONG> and <STRONG>SUSP</STRONG>
  152. characters will not be done [see <STRONG><A HREF="termio.7.html">termio(7)</A></STRONG>]. When <STRONG>qiflush</STRONG>
  153. is called, the queues will be flushed when these control
  154. characters are read. You may want to call <STRONG>noqiflush()</STRONG> in
  155. a signal handler if you want output to continue as though
  156. the interrupt had not occurred, after the handler exits.
  157. The <STRONG>timeout</STRONG> and <STRONG>wtimeout</STRONG> routines set blocking or non-
  158. blocking read for a given window. If <EM>delay</EM> is negative,
  159. blocking read is used (i.e., waits indefinitely for in-
  160. put). If <EM>delay</EM> is zero, then non-blocking read is used
  161. (i.e., read returns <STRONG>ERR</STRONG> if no input is waiting). If <EM>delay</EM>
  162. is positive, then read blocks for <EM>delay</EM> milliseconds, and
  163. returns <STRONG>ERR</STRONG> if there is still no input. Hence, these rou-
  164. tines provide the same functionality as <STRONG>nodelay</STRONG>, plus the
  165. additional capability of being able to block for only <EM>de-</EM>
  166. <EM>lay</EM> milliseconds (where <EM>delay</EM> is positive).
  167. The <STRONG>curses</STRONG> library does ``line-breakout optimization'' by
  168. looking for typeahead periodically while updating the
  169. screen. If input is found, and it is coming from a tty,
  170. the current update is postponed until <STRONG>refresh</STRONG> or <STRONG>doupdate</STRONG>
  171. is called again. This allows faster response to commands
  172. typed in advance. Normally, the input FILE pointer passed
  173. to <STRONG>newterm</STRONG>, or <STRONG>stdin</STRONG> in the case that <STRONG>initscr</STRONG> was used,
  174. will be used to do this typeahead checking. The <STRONG>typeahead</STRONG>
  175. routine specifies that the file descriptor <EM>fd</EM> is to be
  176. used to check for typeahead instead. If <EM>fd</EM> is -1, then no
  177. typeahead checking is done.
  178. </PRE>
  179. <H2>RETURN VALUE</H2><PRE>
  180. All routines that return an integer return <STRONG>ERR</STRONG> upon fail-
  181. ure and OK (SVr4 specifies only "an integer value other
  182. than <STRONG>ERR</STRONG>") upon successful completion, unless otherwise
  183. noted in the preceding routine descriptions.
  184. X/Open does not define any error conditions. In this im-
  185. plementation, functions with a window parameter will re-
  186. turn an error if it is null. Any function will also re-
  187. turn an error if the terminal was not initialized. Also,
  188. <STRONG>halfdelay</STRONG>
  189. returns an error if its parameter is outside
  190. the range 1..255.
  191. </PRE>
  192. <H2>PORTABILITY</H2><PRE>
  193. These functions are described in the XSI Curses standard,
  194. Issue 4.
  195. The ncurses library obeys the XPG4 standard and the his-
  196. torical practice of the AT&amp;T curses implementations, in
  197. that the echo bit is cleared when curses initializes the
  198. terminal state. BSD curses differed from this slightly;
  199. it left the echo bit on at initialization, but the BSD <STRONG>raw</STRONG>
  200. call turned it off as a side-effect. For best portabili-
  201. ty, set echo or noecho explicitly just after initializa-
  202. tion, even if your program remains in cooked mode.
  203. </PRE>
  204. <H2>NOTES</H2><PRE>
  205. Note that <STRONG>echo</STRONG>, <STRONG>noecho</STRONG>, <STRONG>halfdelay</STRONG>, <STRONG>intrflush</STRONG>, <STRONG>meta</STRONG>, <STRONG>node-</STRONG>
  206. <STRONG>lay</STRONG>, <STRONG>notimeout</STRONG>, <STRONG>noqiflush</STRONG>, <STRONG>qiflush</STRONG>, <STRONG>timeout</STRONG>, and <STRONG>wtimeout</STRONG>
  207. may be macros.
  208. The <STRONG>noraw</STRONG> and <STRONG>nocbreak</STRONG> calls follow historical practice in
  209. that they attempt to restore to normal (`cooked') mode
  210. from raw and cbreak modes respectively. Mixing raw/noraw
  211. and cbreak/nocbreak calls leads to tty driver control
  212. states that are hard to predict or understand; it is not
  213. recommended.
  214. </PRE>
  215. <H2>SEE ALSO</H2><PRE>
  216. <STRONG><A HREF="ncurses.3x.html">curses(3x)</A></STRONG>, <STRONG><A HREF="curs_getch.3x.html">curs_getch(3x)</A></STRONG>, <STRONG><A HREF="curs_initscr.3x.html">curs_initscr(3x)</A></STRONG>, <STRONG><A HREF="termio.7.html">termio(7)</A></STRONG>
  217. <STRONG><A HREF="curs_inopts.3x.html">curs_inopts(3x)</A></STRONG>
  218. </PRE>
  219. <HR>
  220. <ADDRESS>
  221. Man(1) output converted with
  222. <a href="http://www.oac.uci.edu/indiv/ehood/man2html.html">man2html</a>
  223. </ADDRESS>
  224. </BODY>
  225. </HTML>