Browse code

Pass a timeout to tty_input_ready

John Hawthorn authored on 15/09/2018 20:55:10
Showing 3 changed files

... ...
@@ -89,9 +89,9 @@ char tty_getchar(tty_t *tty) {
89 89
 	}
90 90
 }
91 91
 
92
-int tty_input_ready(tty_t *tty, int pending) {
92
+int tty_input_ready(tty_t *tty, unsigned long timeout) {
93 93
 	fd_set readfs;
94
-	struct timeval tv = {0, pending ? (KEYTIMEOUT * 1000) : 0};
94
+	struct timeval tv = {timeout / 1000, (timeout % 1000) * 1000};
95 95
 	FD_ZERO(&readfs);
96 96
 	FD_SET(tty->fdin, &readfs);
97 97
 	select(tty->fdin + 1, &readfs, NULL, NULL, &tv);
... ...
@@ -17,7 +17,7 @@ void tty_close(tty_t *tty);
17 17
 void tty_init(tty_t *tty, const char *tty_filename);
18 18
 void tty_getwinsz(tty_t *tty);
19 19
 char tty_getchar(tty_t *tty);
20
-int tty_input_ready(tty_t *tty, int pending);
20
+int tty_input_ready(tty_t *tty, unsigned long timeout);
21 21
 
22 22
 void tty_setfg(tty_t *tty, int fg);
23 23
 void tty_setinvert(tty_t *tty);
... ...
@@ -373,7 +373,7 @@ int tty_interface_run(tty_interface_t *state) {
373 373
 				return state->exit;
374 374
 
375 375
 			draw(state);
376
-		} while (tty_input_ready(state->tty, state->ambiguous_key_pending));
376
+		} while (tty_input_ready(state->tty, state->ambiguous_key_pending ? KEYTIMEOUT : 0));
377 377
 
378 378
 		if (state->ambiguous_key_pending) {
379 379
 			char s[1] = "";