From 5107e848977640398843e720e26d45a66954e7f9 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Wed, 21 Apr 2021 09:32:48 +0100 Subject: [PATCH] Add an "always" value to the extended-keys option to always forward these keys to applications inside tmux. --- input.c | 2 ++ options-table.c | 6 +++++- screen.c | 4 +++- tmux.1 | 21 +++++++++++++++++---- 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/input.c b/input.c index f6aeb027..b599f27d 100644 --- a/input.c +++ b/input.c @@ -1390,6 +1390,8 @@ input_csi_dispatch(struct input_ctx *ictx) case INPUT_CSI_MODSET: n = input_get(ictx, 0, 0, 0); m = input_get(ictx, 1, 0, 0); + if (options_get_number(global_options, "extended-keys") == 2) + break; if (n == 0 || (n == 4 && m == 0)) screen_write_mode_clear(sctx, MODE_KEXTENDED); else if (n == 4 && (m == 1 || m == 2)) diff --git a/options-table.c b/options-table.c index b185969c..8264d1b7 100644 --- a/options-table.c +++ b/options-table.c @@ -74,6 +74,9 @@ static const char *options_table_remain_on_exit_list[] = { static const char *options_table_detach_on_destroy_list[] = { "off", "on", "no-detached", NULL }; +static const char *options_table_extended_keys_list[] = { + "off", "on", "always", NULL +}; /* Status line format. */ #define OPTIONS_TABLE_STATUS_FORMAT1 \ @@ -266,8 +269,9 @@ const struct options_table_entry options_table[] = { }, { .name = "extended-keys", - .type = OPTIONS_TABLE_FLAG, + .type = OPTIONS_TABLE_CHOICE, .scope = OPTIONS_TABLE_SERVER, + .choices = options_table_extended_keys_list, .default_num = 0, .text = "Whether to request extended key sequences from terminals " "that support it." diff --git a/screen.c b/screen.c index 2b9d70de..2b83c285 100644 --- a/screen.c +++ b/screen.c @@ -100,7 +100,9 @@ screen_reinit(struct screen *s) s->rupper = 0; s->rlower = screen_size_y(s) - 1; - s->mode = MODE_CURSOR | MODE_WRAP; + s->mode = MODE_CURSOR|MODE_WRAP; + if (options_get_number(global_options, "extended-keys") == 2) + s->mode |= MODE_KEXTENDED; if (s->saved_grid != NULL) screen_alternate_off(s, NULL, 0); diff --git a/tmux.1 b/tmux.1 index c4fc06ba..6967c769 100644 --- a/tmux.1 +++ b/tmux.1 @@ -3418,11 +3418,24 @@ sessions. .Xc If enabled, the server will exit when there are no attached clients. .It Xo Ic extended-keys -.Op Ic on | off +.Op Ic on | off | always .Xc -When enabled, extended keys are requested from the terminal and if supported -are recognised by -.Nm . +When +.Ic on +or +.Ic always , +the escape sequence to enable extended keys is sent to the terminal, if +.Nm +knows that it is supported. +.Nm +always recognises extended keys itself. +If this option is +.Ic on , +.Nm +will only forward extended keys to applications when they request them; if +.Ic always , +.Nm +will always forward the keys. .It Xo Ic focus-events .Op Ic on | off .Xc