New server option, escape-time, to set the timeout used to detect if escapes

are alone or part of a function key or meta sequence.
pull/1/head
Nicholas Marriott 2009-12-14 10:43:41 +00:00
parent 3f58cbaae9
commit 30962cb200
5 changed files with 15 additions and 9 deletions

View File

@ -74,6 +74,7 @@ const char *set_option_bell_action_list[] = {
}; };
const struct set_option_entry set_option_table[] = { const struct set_option_entry set_option_table[] = {
{ "escape-time", SET_OPTION_NUMBER, 0, INT_MAX, NULL },
{ "quiet", SET_OPTION_FLAG, 0, 0, NULL }, { "quiet", SET_OPTION_FLAG, 0, 0, NULL },
{ NULL, 0, 0, 0, NULL } { NULL, 0, 0, 0, NULL }
}; };

8
tmux.1
View File

@ -1288,8 +1288,14 @@ Available window options are listed under
.Pp .Pp
Available server options are: Available server options are:
.Bl -tag -width Ds .Bl -tag -width Ds
.It Ic escape-time
Set the time in milliseconds for which
.Nm
waits after an escape is input to determine if it is part of a function or meta
key sequences.
The default is 500 milliseconds.
.It Ic quiet .It Ic quiet
Enable of disable the display of various informational messages (see also the Enable or disable the display of various informational messages (see also the
.Fl q .Fl q
command line flag). command line flag).
.El .El

1
tmux.c
View File

@ -317,6 +317,7 @@ main(int argc, char **argv)
options_init(&global_options, NULL); options_init(&global_options, NULL);
oo = &global_options; oo = &global_options;
options_set_number(oo, "quiet", quiet); options_set_number(oo, "quiet", quiet);
options_set_number(oo, "escape-time", 500);
options_init(&global_s_options, NULL); options_init(&global_s_options, NULL);
so = &global_s_options; so = &global_s_options;

3
tmux.h
View File

@ -59,9 +59,6 @@ extern char **environ;
/* Automatic name refresh interval, in milliseconds. */ /* Automatic name refresh interval, in milliseconds. */
#define NAME_INTERVAL 500 #define NAME_INTERVAL 500
/* Escape timer period, in milliseconds. */
#define ESCAPE_PERIOD 500
/* Maximum data to buffer for output before suspending reading from panes. */ /* Maximum data to buffer for output before suspending reading from panes. */
#define BACKOFF_THRESHOLD 1024 #define BACKOFF_THRESHOLD 1024

View File

@ -429,7 +429,7 @@ tty_keys_next(struct tty *tty)
const char *buf; const char *buf;
size_t len, size; size_t len, size;
cc_t bspace; cc_t bspace;
int key; int key, delay;
buf = EVBUFFER_DATA(tty->event->input); buf = EVBUFFER_DATA(tty->event->input);
len = EVBUFFER_LENGTH(tty->event->input); len = EVBUFFER_LENGTH(tty->event->input);
@ -521,8 +521,9 @@ partial_key:
start_timer: start_timer:
/* Start the timer and wait for expiry or more data. */ /* Start the timer and wait for expiry or more data. */
tv.tv_sec = 0; delay = options_get_number(&global_options, "escape-time");
tv.tv_usec = ESCAPE_PERIOD * 1000L; tv.tv_sec = delay / 1000;
tv.tv_usec = (delay % 1000) * 1000L;
evtimer_del(&tty->key_timer); evtimer_del(&tty->key_timer);
evtimer_set(&tty->key_timer, tty_keys_callback, tty); evtimer_set(&tty->key_timer, tty_keys_callback, tty);