version 1.1, 2000/02/25 19:08:52 |
version 1.2, 2000/02/25 19:09:48 |
|
|
|
|
#include <sys/types.h> |
#include <sys/types.h> |
#include <fcntl.h> |
#include <fcntl.h> |
#include <termio.h> |
#include <termios.h> |
|
|
#define NOBUF 512 /* Output buffer size. */ |
#define NOBUF 512 /* Output buffer size. */ |
|
|
char obuf[NOBUF]; /* Output buffer. */ |
char obuf[NOBUF]; /* Output buffer. */ |
int nobuf; /* buffer count */ |
int nobuf; /* buffer count */ |
|
|
static struct termio ot; /* entry state of the terminal */ |
static struct termios ot; /* entry state of the terminal */ |
static struct termio nt; /* editor's terminal state */ |
static struct termios nt; /* editor's terminal state */ |
|
|
static int ttyactivep = FALSE; /* terminal in editor mode? */ |
static int ttyactivep = FALSE; /* terminal in editor mode? */ |
static int ttysavedp = FALSE; /* terminal state saved? */ |
static int ttysavedp = FALSE; /* terminal state saved? */ |
|
|
|
|
if( !ttysavedp ) |
if( !ttysavedp ) |
{ |
{ |
if (ioctl(0, TCGETA, &ot) < 0) |
if (tcgetattr(0, &ot) < 0) |
abort(); |
abort(); |
nt = ot; /* save entry state */ |
nt = ot; /* save entry state */ |
nt.c_cc[VMIN] = 1; /* one character read is OK */ |
nt.c_cc[VMIN] = 1; /* one character read is OK */ |
|
|
ttysavedp = TRUE; |
ttysavedp = TRUE; |
} |
} |
|
|
if (ioctl(0, TCSETAF, &nt) < 0) |
if (tcsetattr(0, TCSAFLUSH, &nt) < 0) |
abort(); |
abort(); |
|
|
/* This really belongs in tty/termcap... */ |
/* This really belongs in tty/termcap... */ |
|
|
if(!ttysavedp || !ttyactivep) |
if(!ttysavedp || !ttyactivep) |
return; |
return; |
ttflush(); |
ttflush(); |
if (ioctl(0, TCSETAF, &ot) < 0 || fcntl( 0, F_SETFL, kbdflgs ) < 0) |
if (tcsetattr(0, TCSAFLUSH, &ot) < 0 || |
|
fcntl( 0, F_SETFL, kbdflgs ) < 0) |
abort(); |
abort(); |
ttyactivep = FALSE; |
ttyactivep = FALSE; |
} |
} |
|
|
|
|
ttwait() |
ttwait() |
{ |
{ |
int alrm(); |
|
|
|
if (kbdqp) |
if (kbdqp) |
return FALSE; /* already pending input */ |
return FALSE; /* already pending input */ |
if (setjmp(tohere)) |
if (setjmp(tohere)) |