1curs_inopts(3X)                                                curs_inopts(3X)
2
3
4

NAME

6       cbreak, nocbreak, echo, noecho, halfdelay, intrflush, keypad, meta, nl,
7       nonl, nodelay, notimeout, raw, noraw, qiflush, noqiflush, timeout,
8       wtimeout, typeahead - curses input options
9

SYNOPSIS

11       #include <curses.h>
12
13       int cbreak(void);
14       int nocbreak(void);
15
16       int echo(void);
17       int noecho(void);
18
19       int intrflush(WINDOW *win, bool bf);
20       int keypad(WINDOW *win, bool bf);
21       int meta(WINDOW *win, bool bf);
22       int nodelay(WINDOW *win, bool bf);
23       int notimeout(WINDOW *win, bool bf);
24
25       int nl(void);
26       int nonl(void);
27
28       int raw(void);
29       int noraw(void);
30
31       void qiflush(void);
32       void noqiflush(void);
33
34       int halfdelay(int tenths);
35       void timeout(int delay);
36       void wtimeout(WINDOW *win, int delay);
37
38       int typeahead(int fd);
39

DESCRIPTION

41       The ncurses library provides several functions which let an application
42       change the way input from the terminal is handled.   Some  are  global,
43       applying to all windows.  Others apply only to a specific window.  Win‐
44       dow-specific settings are not automatically applied to new  or  derived
45       windows.   An  application must apply these to each window, if the same
46       behavior is needed.
47
48   cbreak/nocbreak
49       Normally, the tty driver buffers typed characters until  a  newline  or
50       carriage  return  is typed.  The cbreak routine disables line buffering
51       and erase/kill character-processing (interrupt and flow control charac‐
52       ters  are  unaffected), making characters typed by the user immediately
53       available to the program.  The nocbreak routine returns the terminal to
54       normal (cooked) mode.
55
56       Initially the terminal may or may not be in cbreak mode, as the mode is
57       inherited; therefore, a program should call cbreak or nocbreak  explic‐
58       itly.   Most  interactive  programs  using  curses set the cbreak mode.
59       Note that cbreak overrides raw.  [See curs_getch(3X) for  a  discussion
60       of how these routines interact with echo and noecho.]
61
62   echo/noecho
63       The  echo  and  noecho routines control whether characters typed by the
64       user are echoed by getch(3X) as they are typed.   Echoing  by  the  tty
65       driver  is  always  disabled,  but  initially getch is in echo mode, so
66       characters typed are echoed.  Authors of most interactive programs pre‐
67       fer  to do their own echoing in a controlled area of the screen, or not
68       to echo at all, so  they  disable  echoing  by  calling  noecho.   [See
69       curs_getch(3X)  for  a  discussion  of how these routines interact with
70       cbreak and nocbreak.]
71
72   halfdelay
73       The halfdelay routine is used for half-delay mode, which is similar  to
74       cbreak mode in that characters typed by the user are immediately avail‐
75       able to the program.  However, after blocking for tenths tenths of sec‐
76       onds,  ERR  is returned if nothing has been typed.  The value of tenths
77       must be a number between 1 and 255.  Use nocbreak to  leave  half-delay
78       mode.
79
80   intrflush
81       If  the  intrflush option is enabled (bf is TRUE), and an interrupt key
82       is pressed on the keyboard (interrupt, break, quit), all output in  the
83       tty  driver queue will be flushed, giving the effect of faster response
84       to the interrupt, but causing curses to have the wrong idea of what  is
85       on  the screen.  Disabling the option (bf is FALSE) prevents the flush.
86       The default for the option is inherited from the tty  driver  settings.
87       The window argument is ignored.
88
89   keypad
90       The  keypad  option  enables the keypad of the user's terminal.  If en‐
91       abled (bf is TRUE), the user can press a function key (such as an arrow
92       key)  and  wgetch(3X)  returns a single value representing the function
93       key, as in KEY_LEFT.  If disabled (bf is FALSE), curses does not  treat
94       function keys specially and the program has to interpret the escape se‐
95       quences itself.  If the keypad in the terminal can be turned  on  (made
96       to  transmit)  and  off  (made to work locally), turning on this option
97       causes the terminal keypad to be turned on when wgetch(3X)  is  called.
98       The default value for keypad is FALSE.
99
100   meta
101       Initially,  whether the terminal returns 7 or 8 significant bits on in‐
102       put depends on the control mode of the tty driver [see termios(3)].  To
103       force  8  bits  to be returned, invoke meta(win, TRUE); this is equiva‐
104       lent, under POSIX, to setting the CS8 flag on the terminal.  To force 7
105       bits to be returned, invoke meta(win, FALSE); this is equivalent, under
106       POSIX, to setting the CS7 flag on the terminal.  The  window  argument,
107       win, is always ignored.  If the terminfo capabilities smm (meta_on) and
108       rmm (meta_off) are defined for the terminal, smm is sent to the  termi‐
109       nal  when  meta(win,  TRUE)  is  called  and rmm is sent when meta(win,
110       FALSE) is called.
111
112   nl/nonl
113       The nl and nonl routines control whether the underlying display  device
114       translates the return key into newline on input.
115
116   nodelay
117       The nodelay option causes getch to be a non-blocking call.  If no input
118       is ready, getch returns ERR.  If disabled (bf is  FALSE),  getch  waits
119       until a key is pressed.
120
121   notimeout
122       When  interpreting  an  escape  sequence, wgetch(3X) sets a timer while
123       waiting for the next character.  If  notimeout(win,  TRUE)  is  called,
124       then  wgetch  does  not  set a timer.  The purpose of the timeout is to
125       differentiate between sequences received from a function key and  those
126       typed by a user.
127
128   raw/noraw
129       The  raw and noraw routines place the terminal into or out of raw mode.
130       Raw mode is similar to cbreak mode, in that characters typed are  imme‐
131       diately  passed  through to the user program.  The differences are that
132       in raw mode, the interrupt, quit, suspend, and flow control  characters
133       are  all  passed through uninterpreted, instead of generating a signal.
134       The behavior of the BREAK key depends on other bits in the  tty  driver
135       that are not set by curses.
136
137   qiflush/noqiflush
138       When  the  noqiflush  routine is used, normal flush of input and output
139       queues associated with the INTR, QUIT and SUSP characters will  not  be
140       done  [see  termios(3)].   When  qiflush  is called, the queues will be
141       flushed when these control characters are read.  You may want  to  call
142       noqiflush  in a signal handler if you want output to continue as though
143       the interrupt had not occurred, after the handler exits.
144
145   timeout/wtimeout
146       The timeout and wtimeout routines set blocking or non-blocking read for
147       a  given  window.   If  delay is negative, blocking read is used (i.e.,
148       waits indefinitely for input).  If delay  is  zero,  then  non-blocking
149       read is used (i.e., read returns ERR if no input is waiting).  If delay
150       is positive, then read blocks for delay milliseconds, and  returns  ERR
151       if  there  is  still  no input.  Hence, these routines provide the same
152       functionality as nodelay, plus the additional capability of being  able
153       to block for only delay milliseconds (where delay is positive).
154
155   typeahead
156       The curses library does “line-breakout optimization” by looking for ty‐
157       peahead periodically while updating the screen.  If input is found, and
158       it  is  coming  from  a  tty, the current update is postponed until re‐
159       fresh(3X) or doupdate is called again.  This allows faster response  to
160       commands  typed in advance.  Normally, the input FILE pointer passed to
161       newterm, or stdin in the case that initscr was used, will be used to do
162       this typeahead checking.  The typeahead routine specifies that the file
163       descriptor fd is to be used to check for typeahead instead.  If  fd  is
164       -1, then no typeahead checking is done.
165

RETURN VALUE

167       All  routines  that  return  an  integer return ERR upon failure and OK
168       (SVr4 specifies only “an integer value other than ERR”) upon successful
169       completion,  unless  otherwise  noted in the preceding routine descrip‐
170       tions.
171
172       X/Open does not define any error conditions.  In  this  implementation,
173       functions  with  a window parameter will return an error if it is null.
174       Any function will also return an error if the terminal was not initial‐
175       ized.  Also,
176
177              halfdelay
178                   returns  an  error  if  its  parameter is outside the range
179                   1..255.
180

PORTABILITY

182       These functions are described in the XSI Curses standard, Issue 4.
183
184       The ncurses library obeys the XPG4 standard and the historical practice
185       of  the  AT&T  curses  implementations, in that the echo bit is cleared
186       when curses initializes the terminal state.  BSD curses  differed  from
187       this  slightly;  it left the echo bit on at initialization, but the BSD
188       raw call turned it off as a side-effect.   For  best  portability,  set
189       echo  or noecho explicitly just after initialization, even if your pro‐
190       gram remains in cooked mode.
191
192       The XSI Curses standard is ambiguous on the  question  of  whether  raw
193       should  disable  the  CRLF translations controlled by nl and nonl.  BSD
194       curses did turn off these translations; AT&T curses (at least  as  late
195       as  SVr1)  did not.  We chose to do so, on the theory that a programmer
196       requesting raw input wants a clean  (ideally  8-bit  clean)  connection
197       that the operating system will not alter.
198
199       When keypad is first enabled, ncurses loads the key-definitions for the
200       current terminal description.  If the terminal description includes ex‐
201       tended string capabilities, e.g., from using the -x option of tic, then
202       ncurses also defines keys for the capabilities whose names  begin  with
203       “k”.  The corresponding keycodes are generated and (depending on previ‐
204       ous loads of terminal descriptions) may differ from one execution of  a
205       program to the next.  The generated keycodes are recognized by the key‐
206       name function (which will then return a name beginning with “k”  denot‐
207       ing  the terminfo capability name rather than “K”, used for curses key-
208       names).  On the other hand, an application can use define_key to estab‐
209       lish a specific keycode for a given string.  This makes it possible for
210       an application to check for  an  extended  capability's  presence  with
211       tigetstr, and reassign the keycode to match its own needs.
212
213       Low-level applications can use tigetstr to obtain the definition of any
214       particular string capability.  Higher-level applications which use  the
215       curses  wgetch  and  similar functions to return keycodes rely upon the
216       order in which the strings are loaded.  If more than one key definition
217       has  the  same  string  value, then wgetch can return only one keycode.
218       Most curses implementations (including ncurses) load key definitions in
219       the  order  defined  by the array of string capability names.  The last
220       key to be loaded determines the keycode which  will  be  returned.   In
221       ncurses,  you  may  also  have extended capabilities interpreted as key
222       definitions.  These are loaded after the predefined keys, and if a  ca‐
223       pability's value is the same as a previously-loaded key definition, the
224       later definition is the one used.
225

NOTES

227       Note that echo, noecho, halfdelay, intrflush, meta, nl, nonl,  nodelay,
228       notimeout, noqiflush, qiflush, timeout, and wtimeout may be macros.
229
230       The  noraw  and  nocbreak calls follow historical practice in that they
231       attempt to restore to normal (“cooked”) mode from raw and cbreak  modes
232       respectively.   Mixing raw/noraw and cbreak/nocbreak calls leads to tty
233       driver control states that are hard to predict or understand; it is not
234       recommended.
235

SEE ALSO

237       curses(3X),   curs_getch(3X),   curs_initscr(3X),   curs_util(3X),  de‐
238       fine_key(3X), termios(3)
239
240
241
242                                                               curs_inopts(3X)
Impressum