xref: /original-bsd/lib/libcurses/getch.c (revision 6c57d260)
1 # include	"curses.ext"
2 
3 /*
4  *	This routine reads in a character from the window.
5  *
6  * 05/11/81 (Berkeley) @(#)getch.c	1.2
7  */
8 wgetch(win)
9 reg WINDOW	*win; {
10 
11 	reg bool	weset = FALSE;
12 	reg char	inp;
13 
14 	if (!win->_scroll && (win->_flags&_FULLWIN)
15 	    && win->_curx == win->_maxx - 1 && win->_cury == win->_maxy - 1)
16 		return ERR;
17 # ifdef DEBUG
18 	fprintf(outf, "WGETCH: _echoit = %c, _rawmode = %c\n", _echoit ? 'T' : 'F', _rawmode ? 'T' : 'F');
19 # endif
20 	if (_echoit && !_rawmode) {
21 		raw();
22 		weset++;
23 	}
24 	inp = getchar();
25 # ifdef DEBUG
26 	fprintf(outf,"WGETCH got '%s'\n",unctrl(inp));
27 # endif
28 	if (_echoit) {
29 		mvwaddch(curscr, win->_cury, win->_curx, inp);
30 		waddch(win, inp);
31 	}
32 	if (weset)
33 		noraw();
34 	return inp;
35 }
36