1 /* 2 * Copyright (c) 1981 Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 */ 7 8 #ifndef lint 9 static char sccsid[] = "@(#)getch.c 5.6 (Berkeley) 06/01/90"; 10 #endif /* not lint */ 11 12 # include "curses.ext" 13 14 /* 15 * This routine reads in a character from the window. 16 * 17 */ 18 wgetch(win) 19 reg WINDOW *win; { 20 21 reg bool weset = FALSE; 22 reg char inp; 23 24 if (!win->_scroll && (win->_flags&_FULLWIN) 25 && win->_curx == win->_maxx - 1 && win->_cury == win->_maxy - 1) 26 return ERR; 27 # ifdef DEBUG 28 fprintf(outf, "WGETCH: _echoit = %c, _rawmode = %c\n", _echoit ? 'T' : 'F', _rawmode ? 'T' : 'F'); 29 # endif 30 if (_echoit && !_rawmode) { 31 cbreak(); 32 weset++; 33 } 34 inp = getchar(); 35 # ifdef DEBUG 36 fprintf(outf,"WGETCH got '%s'\n",unctrl(inp)); 37 # endif 38 if (_echoit) { 39 mvwaddch(curscr, win->_cury + win->_begy, 40 win->_curx + win->_begx, inp); 41 waddch(win, inp); 42 } 43 if (weset) 44 nocbreak(); 45 return inp; 46 } 47