1 /*
2 * Copyright (c) 1981, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * %sccs.include.redist.c%
6 */
7
8 #ifndef lint
9 static char sccsid[] = "@(#)getch.c 8.2 (Berkeley) 05/04/94";
10 #endif /* not lint */
11
12 #include "curses.h"
13
14 /*
15 * wgetch --
16 * Read in a character from the window.
17 */
18 int
wgetch(win)19 wgetch(win)
20 register WINDOW *win;
21 {
22 register int inp, weset;
23
24 if (!(win->flags & __SCROLLOK) && (win->flags & __FULLWIN)
25 && win->curx == win->maxx - 1 && win->cury == win->maxy - 1)
26 return (ERR);
27 #ifdef DEBUG
28 __CTRACE("wgetch: __echoit = %d, __rawmode = %d\n",
29 __echoit, __rawmode);
30 #endif
31 if (__echoit && !__rawmode) {
32 cbreak();
33 weset = 1;
34 } else
35 weset = 0;
36
37 inp = getchar();
38 #ifdef DEBUG
39 __CTRACE("wgetch got '%s'\n", unctrl(inp));
40 #endif
41 if (__echoit) {
42 mvwaddch(curscr,
43 win->cury + win->begy, win->curx + win->begx, inp);
44 waddch(win, inp);
45 }
46 if (weset)
47 nocbreak();
48 return (inp);
49 }
50