Commit | Line | Data |
---|---|---|
6e1c93d0 | 1 | /* |
2f14f200 KB |
2 | * Copyright (c) 1981 Regents of the University of California. |
3 | * All rights reserved. | |
4 | * | |
c07973a2 | 5 | * %sccs.include.redist.c% |
6e1c93d0 DF |
6 | */ |
7 | ||
8 | #ifndef lint | |
c07973a2 | 9 | static char sccsid[] = "@(#)getch.c 5.6 (Berkeley) %G%"; |
2f14f200 | 10 | #endif /* not lint */ |
6e1c93d0 | 11 | |
486a0650 KA |
12 | # include "curses.ext" |
13 | ||
14 | /* | |
15 | * This routine reads in a character from the window. | |
16 | * | |
486a0650 KA |
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) | |
8da28f22 | 25 | && win->_curx == win->_maxx - 1 && win->_cury == win->_maxy - 1) |
486a0650 KA |
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) { | |
5b51ebe8 | 31 | cbreak(); |
486a0650 KA |
32 | weset++; |
33 | } | |
34 | inp = getchar(); | |
35 | # ifdef DEBUG | |
36 | fprintf(outf,"WGETCH got '%s'\n",unctrl(inp)); | |
37 | # endif | |
38 | if (_echoit) { | |
8f536208 JB |
39 | mvwaddch(curscr, win->_cury + win->_begy, |
40 | win->_curx + win->_begx, inp); | |
486a0650 KA |
41 | waddch(win, inp); |
42 | } | |
43 | if (weset) | |
5b51ebe8 | 44 | nocbreak(); |
486a0650 KA |
45 | return inp; |
46 | } |