aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/input_common.cpp
diff options
context:
space:
mode:
authorGravatar Kurtis Rader <krader@skepticism.us>2016-05-06 21:22:28 -0700
committerGravatar Kurtis Rader <krader@skepticism.us>2016-05-10 14:11:30 -0700
commitb055b8440c87c69e7f92a81f114ee77f48940f66 (patch)
tree5e686c338bb775fac7277be9f82ffa18e89b3cdb /src/input_common.cpp
parent14d7b1a0fa4e9890a1d576cc0c5e04cca37e9ec7 (diff)
enhance the key_reader program
The original `key_reader` program was useful but didn't do much that `xxd` or `od -tx1z` didn't do. Furthermore, it wasn't built and installed by default. This change adds features that make it superior to those programs for decoding interactive key presses and makes it a first-class citizen like the `fish_indent` program that is always available. Fixes #2991
Diffstat (limited to 'src/input_common.cpp')
-rw-r--r--src/input_common.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/input_common.cpp b/src/input_common.cpp
index 93e94fd3..405e0d6e 100644
--- a/src/input_common.cpp
+++ b/src/input_common.cpp
@@ -14,6 +14,7 @@
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
+#include <sys/time.h>
#include <sys/types.h>
#include <wchar.h>
#include <wctype.h>
@@ -28,9 +29,9 @@
#include "iothread.h"
#include "util.h"
-// Time in milliseconds to wait for another byte to be available for reading
-// after \x1b is read before assuming that escape key was pressed, and not an
-// escape sequence.
+/// Time in milliseconds to wait for another byte to be available for reading
+/// after \x1b is read before assuming that escape key was pressed, and not an
+/// escape sequence.
#define WAIT_ON_ESCAPE_DEFAULT 300
static int wait_on_escape_ms = WAIT_ON_ESCAPE_DEFAULT;
@@ -169,6 +170,9 @@ static wint_t readb() {
return arr[0];
}
+// Directly set the input timeout.
+void set_wait_on_escape_ms(int ms) { wait_on_escape_ms = ms; }
+
// Update the wait_on_escape_ms value in response to the fish_escape_delay_ms user variable being
// set.
void update_wait_on_escape_ms() {