Commit | Line | Data |
---|---|---|
6e1c93d0 DF |
1 | /* |
2 | * Copyright (c) 1980 Regents of the University of California. | |
3 | * All rights reserved. The Berkeley software License Agreement | |
4 | * specifies the terms and conditions for redistribution. | |
5 | */ | |
6 | ||
7 | #ifndef lint | |
5b51ebe8 | 8 | static char sccsid[] = "@(#)getch.c 5.3 (Berkeley) %G%"; |
6e1c93d0 DF |
9 | #endif not lint |
10 | ||
486a0650 KA |
11 | # include "curses.ext" |
12 | ||
13 | /* | |
14 | * This routine reads in a character from the window. | |
15 | * | |
486a0650 KA |
16 | */ |
17 | wgetch(win) | |
18 | reg WINDOW *win; { | |
19 | ||
20 | reg bool weset = FALSE; | |
21 | reg char inp; | |
22 | ||
23 | if (!win->_scroll && (win->_flags&_FULLWIN) | |
8da28f22 | 24 | && win->_curx == win->_maxx - 1 && win->_cury == win->_maxy - 1) |
486a0650 KA |
25 | return ERR; |
26 | # ifdef DEBUG | |
27 | fprintf(outf, "WGETCH: _echoit = %c, _rawmode = %c\n", _echoit ? 'T' : 'F', _rawmode ? 'T' : 'F'); | |
28 | # endif | |
29 | if (_echoit && !_rawmode) { | |
5b51ebe8 | 30 | cbreak(); |
486a0650 KA |
31 | weset++; |
32 | } | |
33 | inp = getchar(); | |
34 | # ifdef DEBUG | |
35 | fprintf(outf,"WGETCH got '%s'\n",unctrl(inp)); | |
36 | # endif | |
37 | if (_echoit) { | |
8f536208 JB |
38 | mvwaddch(curscr, win->_cury + win->_begy, |
39 | win->_curx + win->_begx, inp); | |
486a0650 KA |
40 | waddch(win, inp); |
41 | } | |
42 | if (weset) | |
5b51ebe8 | 43 | nocbreak(); |
486a0650 KA |
44 | return inp; |
45 | } |