about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/ui/inputwin.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c
index 0ee1d721..f29b5318 100644
--- a/src/ui/inputwin.c
+++ b/src/ui/inputwin.c
@@ -39,6 +39,7 @@
 #include <string.h>
 #include <wchar.h>
 #include <sys/time.h>
+#include <errno.h>
 
 #include <readline/readline.h>
 #include <readline/history.h>
@@ -111,8 +112,13 @@ create_input_window(void)
 #else
     ESCDELAY = 25;
 #endif
-	p_rl_timeout.tv_sec = 0;
-    p_rl_timeout.tv_usec = inp_timeout * 1000;
+    if (inp_timeout == 1000) {
+        p_rl_timeout.tv_sec = 1;
+        p_rl_timeout.tv_usec = 0;
+    } else {
+        p_rl_timeout.tv_sec = 0;
+        p_rl_timeout.tv_usec = inp_timeout * 1000;
+    }
 
     rl_readline_name = "profanity";
     rl_getc_function = _inp_rl_getc;
@@ -134,9 +140,11 @@ inp_readline(void)
 {
     FD_ZERO(&fds);
     FD_SET(fileno(rl_instream), &fds);
+    errno = 0;
     r = select(FD_SETSIZE, &fds, NULL, NULL, &p_rl_timeout);
     if (r < 0) {
-        log_error("Readline failed.");
+        char *err_msg = strerror(errno);
+        log_error("Readline failed: %s", err_msg);
         return TRUE;
     }
 
@@ -155,8 +163,13 @@ inp_readline(void)
         prof_handle_idle();
     }
 
-    p_rl_timeout.tv_sec = 0;
-    p_rl_timeout.tv_usec = inp_timeout * 1000;
+    if (inp_timeout == 1000) {
+        p_rl_timeout.tv_sec = 1;
+        p_rl_timeout.tv_usec = 0;
+    } else {
+        p_rl_timeout.tv_sec = 0;
+        p_rl_timeout.tv_usec = inp_timeout * 1000;
+    }
 
     return cmd_result;
 }
ter Kartik Agaram <vc@akkartik.com> 2019-08-25 17:37:10 -0700 5584' href='/akkartik/mu/commit/ntranslate?h=main&id=300f4554910095a6c8762f625816dafae55dea98'>300f4554 ^
90538f23 ^
27a5b1a8 ^


d9d9ab81 ^


099f0d5d ^

418ea7d3 ^
e97b446a ^
90538f23 ^
6488bfcf ^
90538f23 ^
6488bfcf ^
90538f23 ^
23fd294d ^

6488bfcf ^











90538f23 ^



531f14c9 ^

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56