version 1.36, 2009/06/29 20:21:28
|
version 1.39, 2009/12/31 15:32:36
|
Line 1
|
Line 1
|
/* direct key io driver |
/* direct key io driver |
|
|
Copyright (C) 1995,1996,1997,1998,1999,2002,2003,2006,2007,2008 Free Software Foundation, Inc. |
Copyright (C) 1995,1996,1997,1998,1999,2002,2003,2006,2007,2008,2009 Free Software Foundation, Inc. |
|
|
This file is part of Gforth. |
This file is part of Gforth. |
|
|
Line 672 long key_avail (FILE *stream)
|
Line 672 long key_avail (FILE *stream)
|
static struct timeval now = { 0 , 0 }; |
static struct timeval now = { 0 , 0 }; |
int chars_avail; |
int chars_avail; |
|
|
|
if (gf_ungottenc(stream)) |
|
return 1; |
setvbuf(stream, NULL, _IONBF, 0); |
setvbuf(stream, NULL, _IONBF, 0); |
if(!terminal_prepped && stream == stdin) |
if(!terminal_prepped && stream == stdin) |
prep_terminal(); |
prep_terminal(); |
if (gf_ungottenc(stream)) |
|
return 1; |
|
|
|
FD_ZERO(&selin); |
FD_ZERO(&selin); |
FD_SET(tty, &selin); |
FD_SET(tty, &selin); |
Line 703 Cell getkey(FILE * stream)
|
Line 703 Cell getkey(FILE * stream)
|
Cell result; |
Cell result; |
unsigned char c; |
unsigned char c; |
|
|
setvbuf(stream, NULL, _IONBF, 0); |
if (!gf_ungottenc(stream)) |
|
setvbuf(stream, NULL, _IONBF, 0); |
if(!terminal_prepped && stream == stdin) |
if(!terminal_prepped && stream == stdin) |
prep_terminal(); |
prep_terminal(); |
|
|
result = fread(&c, sizeof(c), 1, stream); |
result = fread(&c, sizeof(c), 1, stream); |
|
if (result>0) |
|
gf_regetc(stream); |
return result==0 ? (errno == EINTR ? 12 : 4) : c; |
return result==0 ? (errno == EINTR ? 12 : 4) : c; |
} |
} |
|
|