diff options
author | Artur Grabowski <art@cvs.openbsd.org> | 2001-05-03 20:40:23 +0000 |
---|---|---|
committer | Artur Grabowski <art@cvs.openbsd.org> | 2001-05-03 20:40:23 +0000 |
commit | ee4fabc5c39065b30e24a2d63196cb833b73278c (patch) | |
tree | 3bca64bf11633e55cf3aa679748275adf89cf955 | |
parent | 1149cf529a2c0f87f7c7eaa485d4dc579eefc0a9 (diff) |
Add a delay (in miliseconds) argument to ttwait.
-rw-r--r-- | usr.bin/mg/def.h | 4 | ||||
-rw-r--r-- | usr.bin/mg/kbd.c | 4 | ||||
-rw-r--r-- | usr.bin/mg/ttyio.c | 14 |
3 files changed, 10 insertions, 12 deletions
diff --git a/usr.bin/mg/def.h b/usr.bin/mg/def.h index 8d3a36e85ac..3849cebab75 100644 --- a/usr.bin/mg/def.h +++ b/usr.bin/mg/def.h @@ -1,4 +1,4 @@ -/* $OpenBSD: def.h,v 1.8 2001/05/03 12:57:22 art Exp $ */ +/* $OpenBSD: def.h,v 1.9 2001/05/03 20:40:22 art Exp $ */ /* * This file is the general header file for all parts @@ -300,7 +300,7 @@ int ttcooked __P((void)); int ttputc __P((int)); VOID ttflush __P((void)); int ttgetc __P((void)); -int ttwait __P((void)); +int ttwait __P((int)); VOID setttysize __P((void)); int typeahead __P((void)); diff --git a/usr.bin/mg/kbd.c b/usr.bin/mg/kbd.c index 70b8d6e4ab3..702b52c1662 100644 --- a/usr.bin/mg/kbd.c +++ b/usr.bin/mg/kbd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kbd.c,v 1.4 2001/01/29 01:58:07 niklas Exp $ */ +/* $OpenBSD: kbd.c,v 1.5 2001/05/03 20:40:22 art Exp $ */ /* * Terminal independent keyboard handling. @@ -85,7 +85,7 @@ getkey(flag) #ifndef NO_DPROMPT if (flag && !pushed) { - if (prompt[0] != '\0' && ttwait()) { + if (prompt[0] != '\0' && ttwait(2000)) { /* avoid problems with % */ ewprintf("%s", prompt); /* put the cursor back */ diff --git a/usr.bin/mg/ttyio.c b/usr.bin/mg/ttyio.c index ef1977c10b4..58ad2cd05a6 100644 --- a/usr.bin/mg/ttyio.c +++ b/usr.bin/mg/ttyio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ttyio.c,v 1.13 2001/01/29 01:58:10 niklas Exp $ */ +/* $OpenBSD: ttyio.c,v 1.14 2001/05/03 20:40:22 art Exp $ */ /* * POSIX terminal I/O. @@ -213,13 +213,12 @@ panic(s) exit(1); } -#ifndef NO_DPROMPT /* - * A program to return TRUE if we wait for 2 seconds without anything - * happening, else return FALSE. Cribbed from mod.sources xmodem. + * This function returns FALSE if any characters have showed up on the + * tty before 'msec' miliseconds. */ int -ttwait() +ttwait(int msec) { fd_set readfds; struct timeval tmout; @@ -227,11 +226,10 @@ ttwait() FD_ZERO(&readfds); FD_SET(0, &readfds); - tmout.tv_sec = 2; - tmout.tv_usec = 0; + tmout.tv_sec = msec/1000; + tmout.tv_usec = msec - tmout.tv_sec * 1000; if ((select(1, &readfds, NULL, NULL, &tmout)) == 0) return (TRUE); return (FALSE); } -#endif /* NO_DPROMPT */ |