mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-17 11:01:14 -03:00
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
This commit is contained in:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user