Browse code

Reduce ambiguous char wait time to 25ms

John Hawthorn authored on 10/09/2018 03:53:50
Showing 2 changed files

... ...
@@ -8,3 +8,6 @@
8 8
 #define SCORE_MATCH_WORD 0.8
9 9
 #define SCORE_MATCH_CAPITAL 0.7
10 10
 #define SCORE_MATCH_DOT 0.6
11
+
12
+/* Time (in ms) to wait for additional bytes of an escape sequence */
13
+#define KEYTIMEOUT 25
... ...
@@ -9,6 +9,8 @@
9 9
 
10 10
 #include "tty.h"
11 11
 
12
+#include "../config.h"
13
+
12 14
 void tty_reset(tty_t *tty) {
13 15
 	tcsetattr(tty->fdin, TCSANOW, &tty->original_termios);
14 16
 }
... ...
@@ -89,7 +91,7 @@ char tty_getchar(tty_t *tty) {
89 91
 
90 92
 int tty_input_ready(tty_t *tty, int pending) {
91 93
 	fd_set readfs;
92
-	struct timeval tv = {0, pending ? 500000 : 0};
94
+	struct timeval tv = {0, pending ? (KEYTIMEOUT * 1000) : 0};
93 95
 	FD_ZERO(&readfs);
94 96
 	FD_SET(tty->fdin, &readfs);
95 97
 	select(tty->fdin + 1, &readfs, NULL, NULL, &tv);