date and time created 81/01/26 17:02:54 by arnold
authorKen Arnold <arnold@ucbvax.Berkeley.EDU>
Tue, 27 Jan 1981 09:02:54 +0000 (01:02 -0800)
committerKen Arnold <arnold@ucbvax.Berkeley.EDU>
Tue, 27 Jan 1981 09:02:54 +0000 (01:02 -0800)
SCCS-vsn: lib/libcurses/getch.c 1.1

usr/src/lib/libcurses/getch.c [new file with mode: 0644]

diff --git a/usr/src/lib/libcurses/getch.c b/usr/src/lib/libcurses/getch.c
new file mode 100644 (file)
index 0000000..04060d1
--- /dev/null
@@ -0,0 +1,35 @@
+# include      "curses.ext"
+
+/*
+ *     This routine reads in a character from the window.
+ *
+ * %G% (Berkeley) @(#)getch.c  1.1
+ */
+wgetch(win)
+reg WINDOW     *win; {
+
+       reg bool        weset = FALSE;
+       reg char        inp;
+
+       if (!win->_scroll && (win->_flags&_FULLWIN)
+           && win->_curx == win->_maxx && win->_cury == win->_maxy)
+               return ERR;
+# ifdef DEBUG
+       fprintf(outf, "WGETCH: _echoit = %c, _rawmode = %c\n", _echoit ? 'T' : 'F', _rawmode ? 'T' : 'F');
+# endif
+       if (_echoit && !_rawmode) {
+               raw();
+               weset++;
+       }
+       inp = getchar();
+# ifdef DEBUG
+       fprintf(outf,"WGETCH got '%s'\n",unctrl(inp));
+# endif
+       if (_echoit) {
+               mvwaddch(curscr, win->_cury, win->_curx, inp);
+               waddch(win, inp);
+       }
+       if (weset)
+               noraw();
+       return inp;
+}