version 1.32, 2007/12/31 18:40:25
|
version 1.35, 2009/06/13 10:22:24
|
Line 1
|
Line 1
|
/* direct key io driver |
/* direct key io driver |
|
|
Copyright (C) 1995,1996,1997,1998,1999,2002,2003,2006,2007 Free Software Foundation, Inc. |
Copyright (C) 1995,1996,1997,1998,1999,2002,2003,2006,2007,2008 Free Software Foundation, Inc. |
|
|
This file is part of Gforth. |
This file is part of Gforth. |
|
|
Line 621 long key_avail (FILE * stream)
|
Line 621 long key_avail (FILE * stream)
|
{ |
{ |
int tty = fileno (stream); |
int tty = fileno (stream); |
fd_set selin; |
fd_set selin; |
static struct timespec now = { 0 , 0 }; |
static struct timeval now = { 0 , 0 }; |
int res; |
int chars_avail; |
|
|
setvbuf(stream, NULL, _IONBF, 0); |
setvbuf(stream, NULL, _IONBF, 0); |
if(!terminal_prepped && stream == stdin) |
if(!terminal_prepped && stream == stdin) |
Line 630 long key_avail (FILE * stream)
|
Line 630 long key_avail (FILE * stream)
|
|
|
FD_ZERO(&selin); |
FD_ZERO(&selin); |
FD_SET(tty, &selin); |
FD_SET(tty, &selin); |
return select(1, &selin, NULL, NULL, &now); |
chars_avail = select(1, &selin, NULL, NULL, &now); |
|
return (chars_avail == -1) ? 0 : chars_avail; |
} |
} |
|
|
/* Get a key from the buffer of characters to be read. |
/* Get a key from the buffer of characters to be read. |