Use iskey() and getchar() to interact with console, rather than object

abstraction.
pull/1/head
Michael Brown 2006-12-18 16:46:25 +00:00
parent a497e16767
commit 2ed2b2efe8
3 changed files with 5 additions and 19 deletions

View File

@ -1,6 +1,7 @@
#include <curses.h> #include <curses.h>
#include <stddef.h> #include <stddef.h>
#include <timer.h> #include <timer.h>
#include <console.h>
#include "core.h" #include "core.h"
/** @file /** @file
@ -37,7 +38,7 @@ int _wgetc ( WINDOW *win ) {
return ERR; return ERR;
timer = INPUT_DELAY_TIMEOUT; timer = INPUT_DELAY_TIMEOUT;
while ( ! win->scr->peek( win->scr ) ) { while ( ! iskey() ) {
if ( m_delay == 0 ) // non-blocking read if ( m_delay == 0 ) // non-blocking read
return ERR; return ERR;
if ( timer > 0 ) { // time-limited blocking read if ( timer > 0 ) { // time-limited blocking read
@ -47,7 +48,7 @@ int _wgetc ( WINDOW *win ) {
} else { return ERR; } // non-blocking read } else { return ERR; } // non-blocking read
} }
c = win->scr->getc( win->scr ); c = getchar();
if ( m_echo && ( c >= 32 && c <= 126 ) ) // printable ASCII characters if ( m_echo && ( c >= 32 && c <= 126 ) ) // printable ASCII characters
_wputch( win, (chtype) ( c | win->attrs ), WRAP ); _wputch( win, (chtype) ( c | win->attrs ), WRAP );

View File

@ -46,21 +46,6 @@ typedef struct _curses_screen {
* @v c character to be written * @v c character to be written
*/ */
void ( * putc ) ( struct _curses_screen *scr, chtype c ); void ( * putc ) ( struct _curses_screen *scr, chtype c );
/**
* Pop a character from the keyboard input stream
*
* @v scr screen on which to operate
* @ret c popped character
*/
int ( * getc ) ( struct _curses_screen *scr );
/**
* Checks to see whether a character is waiting in the input stream
*
* @v scr screen on which to operate
* @ret TRUE character waiting in stream
* @ret FALSE no character waiting in stream
*/
bool ( *peek ) ( struct _curses_screen *scr );
} SCREEN; } SCREEN;
/** Curses Window struct */ /** Curses Window struct */

View File

@ -83,6 +83,6 @@ SCREEN _curscr = {
.exit = _exit_screen, .exit = _exit_screen,
.movetoyx = _movetoyx, .movetoyx = _movetoyx,
.putc = _putc, .putc = _putc,
.getc = _getc, // .getc = _getc,
.peek = _peek, // .peek = _peek,
}; };