4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 1997 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1988 AT&T */
28 /* All Rights Reserved */
31 * University Copyright- Copyright (c) 1982, 1986, 1988
32 * The Regents of the University of California
35 * University Acknowledgment- Portions of this document are derived from
36 * software developed by the University of California, Berkeley, and its
40 #pragma ident "%Z%%M% %I% %E% SMI"
44 #include <sys/types.h>
45 #include "curses_inc.h"
51 * This routine reads in a character from the window.
53 * wgetch MUST return an int, not a char, because it can return
54 * things like ERR, meta characters, and function keys > 256.
65 fprintf(outf
, "WGETCH: SP->fl_echoit = %c\n",
66 SP
->fl_echoit
? 'T' : 'F');
67 fprintf(outf
, "_use_keypad %d, kp_state %d\n",
68 win
->_use_keypad
, SP
->kp_state
);
69 fprintf(outf
, "file %x fd %d\n", SP
->input_file
,
70 fileno(SP
->input_file
));
74 if (SP
->fl_echoit
&& cur_term
->_fl_rawmode
== 0) {
79 /* Make sure we are in proper nodelay state and not */
80 /* in halfdelay state */
81 if (cur_term
->_delay
<= 0 && cur_term
->_delay
!= win
->_delay
)
82 (void) ttimeout(win
->_delay
);
84 if ((win
->_flags
& (_WINCHANGED
| _WINMOVED
)) && !(win
->_flags
&
88 if ((cur_term
->_ungotten
== 0) && (req_for_input
)) {
89 (void) tputs(req_for_input
, 1, _outch
);
90 (void) fflush(SP
->term_file
);
92 inp
= (int)tgetch((int)(win
->_use_keypad
? 1 + win
->_notimeout
: 0));
94 /* echo the key out to the screen */
95 if (SP
->fl_echoit
&& (inp
< 0200) && (inp
>= 0) && !(win
->_flags
&
97 (void) wechochar(win
, (chtype
) inp
);
100 * Do nl() mapping. nl() affects both input and output. Since
101 * we turn off input mapping of CR->NL to not affect input
102 * virtualization, we do the mapping here in software.
104 if (inp
== '\r' && !SP
->fl_nonl
)