8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / ucblib / libcurses / getch.c
blob30c179462df27b78260bc28eedc1f0e3bb26b756
1 /*
2 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
4 */
6 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
7 /* All Rights Reserved */
9 /*
10 * Copyright (c) 1980 Regents of the University of California.
11 * All rights reserved. The Berkeley software License Agreement
12 * specifies the terms and conditions for redistribution.
15 #pragma ident "%Z%%M% %I% %E% SMI"
17 /*LINTLIBRARY*/
19 #ifndef lint
20 static char
21 sccsid[] = "@(#)getch.c 1.9 88/02/08 SMI"; /* from UCB 5.3 86/04/16 */
22 #endif /* not lint */
24 #include "curses.ext"
27 * This routine reads in a character from the window.
30 int
31 wgetch(WINDOW *win)
33 bool weset = FALSE;
34 char inp;
36 if (!win->_scroll && (win->_flags&_FULLWIN) &&
37 win->_curx == win->_maxx - 1 && win->_cury == win->_maxy - 1)
38 return (ERR);
39 #ifdef DEBUG
40 fprintf(outf, "WGETCH: _echoit = %c, _rawmode = %c\n",
41 _echoit ? 'T' : 'F', _rawmode ? 'T' : 'F');
42 #endif
43 if (_echoit && !_rawmode) {
44 cbreak();
45 weset++;
47 inp = getchar();
48 #ifdef DEBUG
49 fprintf(outf, "WGETCH got '%s'\n", unctrl(inp));
50 #endif
51 if (_echoit) {
52 (void) mvwaddch(curscr, win->_cury + win->_begy,
53 win->_curx + win->_begx, inp);
54 (void) waddch(win, inp);
56 if (weset)
57 nocbreak();
58 return ((int)inp);