new six version M.Z.
This commit is contained in:
@@ -5,38 +5,41 @@
|
||||
|
||||
static int lastFd=-1;
|
||||
static struct termios atts;
|
||||
static echo=1;
|
||||
|
||||
void sys_keys_on(void) {
|
||||
int iret;
|
||||
|
||||
struct termios attr;
|
||||
iret=tcgetattr(STDIN_FILENO,&attr);
|
||||
atts=attr; /* save term. attr. */
|
||||
if (iret!=0) { perror("***\n");}
|
||||
attr.c_lflag &= ~(ICANON) & ~(ECHO); /* canonical mode off, echo off */
|
||||
attr.c_cc[VMIN]=0;
|
||||
attr.c_cc[VTIME]=1; /* 0.1 sec */
|
||||
iret= tcsetattr(STDIN_FILENO,TCSANOW,&attr);
|
||||
if (iret!=0) {perror("***\n");}
|
||||
if (echo) {
|
||||
iret=tcgetattr(STDIN_FILENO,&attr);
|
||||
atts=attr; /* save term. attr. */
|
||||
if (iret!=0) { perror("***\n");}
|
||||
attr.c_lflag &= ~(ICANON) & ~(ECHO); /* canonical mode off, echo off */
|
||||
attr.c_cc[VMIN]=0;
|
||||
attr.c_cc[VTIME]=1; /* 0.1 sec */
|
||||
iret= tcsetattr(STDIN_FILENO,TCSANOW,&attr);
|
||||
if (iret!=0) {perror("***\n");}
|
||||
echo=0;
|
||||
}
|
||||
}
|
||||
|
||||
void sys_keys_off(void) {
|
||||
int iret;
|
||||
|
||||
iret=tcsetattr(STDIN_FILENO,TCSANOW,&atts); /* restore term. attributes */
|
||||
if (iret!=0) {perror("***\n");};
|
||||
|
||||
if (!echo) {
|
||||
iret=tcsetattr(STDIN_FILENO,TCSANOW,&atts); /* restore term. attributes */
|
||||
if (iret!=0) {perror("***\n");};
|
||||
echo=1;
|
||||
}
|
||||
}
|
||||
|
||||
int sys_select_or_key(fd_set *mask, int msecTmo, char *key) {
|
||||
int chan, fd, iret, fd1, m, chr;
|
||||
struct timeval tmo, tmo0={0,0};
|
||||
fd_set rmask;
|
||||
static int init=1;
|
||||
|
||||
if (init) {
|
||||
sys_keys_on();
|
||||
init=0;
|
||||
}
|
||||
sys_keys_on();
|
||||
rmask=*mask;
|
||||
iret=select(FD_SETSIZE, &rmask, NULL, NULL, &tmo0);
|
||||
if (iret<0) {
|
||||
@@ -84,8 +87,5 @@ int sys_select_or_key(fd_set *mask, int msecTmo, char *key) {
|
||||
}
|
||||
*mask=rmask;
|
||||
*key=chr;
|
||||
/*
|
||||
sys_keys_off();
|
||||
*/
|
||||
return(fd1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user