From b055b8440c87c69e7f92a81f114ee77f48940f66 Mon Sep 17 00:00:00 2001 From: Kurtis Rader Date: Fri, 6 May 2016 21:22:28 -0700 Subject: 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 --- src/input_common.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/input_common.cpp') 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 #include #include +#include #include #include #include @@ -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() { -- cgit v1.2.3