From 7fa5050b40c7dcb6ec3ddd9395cbc694303807fe Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Sun, 9 Sep 2018 20:53:50 -0700 Subject: Reduce ambiguous char wait time to 25ms --- src/config.def.h | 3 +++ src/tty.c | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/config.def.h b/src/config.def.h index 98cc915..1bc1ad4 100644 --- a/src/config.def.h +++ b/src/config.def.h @@ -8,3 +8,6 @@ #define SCORE_MATCH_WORD 0.8 #define SCORE_MATCH_CAPITAL 0.7 #define SCORE_MATCH_DOT 0.6 + +/* Time (in ms) to wait for additional bytes of an escape sequence */ +#define KEYTIMEOUT 25 diff --git a/src/tty.c b/src/tty.c index b5b942c..c30100b 100644 --- a/src/tty.c +++ b/src/tty.c @@ -9,6 +9,8 @@ #include "tty.h" +#include "../config.h" + void tty_reset(tty_t *tty) { tcsetattr(tty->fdin, TCSANOW, &tty->original_termios); } @@ -89,7 +91,7 @@ char tty_getchar(tty_t *tty) { int tty_input_ready(tty_t *tty, int pending) { fd_set readfs; - struct timeval tv = {0, pending ? 500000 : 0}; + struct timeval tv = {0, pending ? (KEYTIMEOUT * 1000) : 0}; FD_ZERO(&readfs); FD_SET(tty->fdin, &readfs); select(tty->fdin + 1, &readfs, NULL, NULL, &tv); -- cgit v1.2.3