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

NAME

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

SYNOPSIS

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

DESCRIPTION

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

RETURN VALUE

153       All routines that return an integer return  ERR  upon  failure  and  OK
154       (SVr4 specifies only “an integer value other than ERR”) upon successful
155       completion, unless otherwise noted in the  preceding  routine  descrip‐
156       tions.
157
158       X/Open  does  not define any error conditions.  In this implementation,
159       functions with a window parameter will return an error if it  is  null.
160       Any function will also return an error if the terminal was not initial‐
161       ized.  Also,
162
163              halfdelay
164                   returns an error if its  parameter  is  outside  the  range
165                   1..255.
166

PORTABILITY

168       These functions are described in the XSI Curses standard, Issue 4.
169
170       The ncurses library obeys the XPG4 standard and the historical practice
171       of the AT&T curses implementations, in that the  echo  bit  is  cleared
172       when  curses  initializes the terminal state.  BSD curses differed from
173       this slightly; it left the echo bit on at initialization, but  the  BSD
174       raw  call  turned  it  off as a side-effect.  For best portability, set
175       echo or noecho explicitly just after initialization, even if your  pro‐
176       gram remains in cooked mode.
177
178       When keypad is first enabled, ncurses loads the key-definitions for the
179       current terminal description.  If the terminal description includes ex‐
180       tended string capabilities, e.g., from using the -x option of tic, then
181       ncurses also defines keys for the capabilities whose names  begin  with
182       “k”.  The corresponding keycodes are generated and (depending on previ‐
183       ous loads of terminal descriptions) may differ from one execution of  a
184       program to the next.  The generated keycodes are recognized by the key‐
185       name function (which will then return a name beginning with “k”  denot‐
186       ing  the terminfo capability name rather than “K”, used for curses key-
187       names).  On the other hand, an application can use define_key to estab‐
188       lish a specific keycode for a given string.  This makes it possible for
189       an application to check for  an  extended  capability's  presence  with
190       tigetstr, and reassign the keycode to match its own needs.
191
192       Low-level applications can use tigetstr to obtain the definition of any
193       particular string capability.  Higher-level applications which use  the
194       curses  wgetch  and  similar functions to return keycodes rely upon the
195       order in which the strings are loaded.  If more than one key definition
196       has  the  same  string  value, then wgetch can return only one keycode.
197       Most curses implementations (including ncurses) load key definitions in
198       the  order  defined  by the array of string capability names.  The last
199       key to be loaded determines the keycode which  will  be  returned.   In
200       ncurses,  you  may  also  have extended capabilities interpreted as key
201       definitions.  These are loaded after the predefined keys, and if a  ca‐
202       pability's value is the same as a previously-loaded key definition, the
203       later definition is the one used.
204

NOTES

206       Note that echo, noecho, halfdelay, intrflush, meta, nodelay, notimeout,
207       noqiflush, qiflush, timeout, and wtimeout may be macros.
208
209       The  noraw  and  nocbreak calls follow historical practice in that they
210       attempt to restore to normal (“cooked”) mode from raw and cbreak  modes
211       respectively.   Mixing raw/noraw and cbreak/nocbreak calls leads to tty
212       driver control states that are hard to predict or understand; it is not
213       recommended.
214

SEE ALSO

216       curses(3X),   curs_getch(3X),   curs_initscr(3X),   curs_util(3X),  de‐
217       fine_key(3X), termio(7)
218
219
220
221                                                               curs_inopts(3X)
Impressum