diff --git a/options-table.c b/options-table.c index 7e379382..1341ed2e 100644 --- a/options-table.c +++ b/options-table.c @@ -251,6 +251,14 @@ const struct options_table_entry options_table[] = { "clients." }, + { .name = "extended-keys", + .type = OPTIONS_TABLE_FLAG, + .scope = OPTIONS_TABLE_SERVER, + .default_num = 0, + .text = "Whether to request extended key sequences from terminals " + "that support it." + }, + { .name = "focus-events", .type = OPTIONS_TABLE_FLAG, .scope = OPTIONS_TABLE_SERVER, diff --git a/tmux.1 b/tmux.1 index 17793911..e0c5667d 100644 --- a/tmux.1 +++ b/tmux.1 @@ -3225,6 +3225,12 @@ sessions. .Op Ic on | off .Xc If enabled, the server will exit when there are no attached clients. +.It Xo Ic extended-keys +.Op Ic on | off +.Xc +When enabled, extended keys are requested from the terminal and if supported +are recognised by +.Nm . .It Xo Ic focus-events .Op Ic on | off .Xc @@ -5744,6 +5750,8 @@ Disable and enable bracketed paste. These are set automatically if the .Em XT capability is present. +.It Em \&Dseks , \&Eneks +Disable and enable extended keys. .It Em \&Dsfcs , \&Enfcs Disable and enable focus reporting. These are set automatically if the diff --git a/tmux.h b/tmux.h index 07d10bcc..d814aa6c 100644 --- a/tmux.h +++ b/tmux.h @@ -292,6 +292,7 @@ enum tty_code_code { TTYC_DL, TTYC_DL1, TTYC_DSBP, + TTYC_DSEKS, TTYC_DSFCS, TTYC_DSMG, TTYC_E3, @@ -301,6 +302,7 @@ enum tty_code_code { TTYC_EL1, TTYC_ENACS, TTYC_ENBP, + TTYC_ENEKS, TTYC_ENFCS, TTYC_ENMG, TTYC_FSL, @@ -1286,7 +1288,7 @@ struct tty { /* 0x8 unused */ #define TTY_STARTED 0x10 #define TTY_OPENED 0x20 -#define TTY_FOCUS 0x40 +/* 0x40 unused */ #define TTY_BLOCK 0x80 #define TTY_HAVEDA 0x100 #define TTY_HAVEXDA 0x200 diff --git a/tty-features.c b/tty-features.c index 30d3d1a0..26344b90 100644 --- a/tty-features.c +++ b/tty-features.c @@ -190,6 +190,18 @@ static const struct tty_feature tty_feature_sync = { 0 }; +/* Terminal supports extended keys. */ +static const char *tty_feature_extkeys_capabilities[] = { + "Eneks=\\E[>4;1m", + "Dseks=\\E[>4m", + NULL +}; +static const struct tty_feature tty_feature_extkeys = { + "extkeys", + tty_feature_extkeys_capabilities, + 0 +}; + /* Terminal supports DECSLRM margins. */ static const char *tty_feature_margins_capabilities[] = { "Enmg=\\E[?69h", @@ -218,6 +230,7 @@ static const struct tty_feature *tty_features[] = { &tty_feature_ccolour, &tty_feature_clipboard, &tty_feature_cstyle, + &tty_feature_extkeys, &tty_feature_focus, &tty_feature_margins, &tty_feature_overline, @@ -321,7 +334,7 @@ tty_default_features(int *feat, const char *name, u_int version) } table[] = { #define TTY_FEATURES_BASE_MODERN_XTERM "256,RGB,bpaste,clipboard,strikethrough,title" { .name = "mintty", - .features = TTY_FEATURES_BASE_MODERN_XTERM ",ccolour,cstyle,margins,overline" + .features = TTY_FEATURES_BASE_MODERN_XTERM ",ccolour,cstyle,extkeys,margins,overline" }, { .name = "tmux", .features = TTY_FEATURES_BASE_MODERN_XTERM ",ccolour,cstyle,focus,overline,usstyle" @@ -333,7 +346,7 @@ tty_default_features(int *feat, const char *name, u_int version) .features = TTY_FEATURES_BASE_MODERN_XTERM ",cstyle,margins,sync" }, { .name = "XTerm", - .features = TTY_FEATURES_BASE_MODERN_XTERM ",ccolour,cstyle,focus,margins,rectfill" + .features = TTY_FEATURES_BASE_MODERN_XTERM ",ccolour,cstyle,extkeys,focus,margins,rectfill" } }; u_int i; diff --git a/tty-term.c b/tty-term.c index e8ac6634..36d8a2e6 100644 --- a/tty-term.c +++ b/tty-term.c @@ -86,6 +86,7 @@ static const struct tty_term_code_entry tty_term_codes[] = { [TTYC_DIM] = { TTYCODE_STRING, "dim" }, [TTYC_DL1] = { TTYCODE_STRING, "dl1" }, [TTYC_DL] = { TTYCODE_STRING, "dl" }, + [TTYC_DSEKS] = { TTYCODE_STRING, "Dseks" }, [TTYC_DSFCS] = { TTYCODE_STRING, "Dsfcs" }, [TTYC_DSBP] = { TTYCODE_STRING, "Dsbp" }, [TTYC_DSMG] = { TTYCODE_STRING, "Dsmg" }, @@ -96,6 +97,7 @@ static const struct tty_term_code_entry tty_term_codes[] = { [TTYC_EL] = { TTYCODE_STRING, "el" }, [TTYC_ENACS] = { TTYCODE_STRING, "enacs" }, [TTYC_ENBP] = { TTYCODE_STRING, "Enbp" }, + [TTYC_ENEKS] = { TTYCODE_STRING, "Eneks" }, [TTYC_ENFCS] = { TTYCODE_STRING, "Enfcs" }, [TTYC_ENMG] = { TTYCODE_STRING, "Enmg" }, [TTYC_FSL] = { TTYCODE_STRING, "fsl" }, diff --git a/tty.c b/tty.c index 99996dfa..1c025b6f 100644 --- a/tty.c +++ b/tty.c @@ -329,10 +329,10 @@ tty_start_tty(struct tty *tty) tty_puts(tty, "\033[?1006l\033[?1005l"); } - if (options_get_number(global_options, "focus-events")) { - tty->flags |= TTY_FOCUS; + if (options_get_number(global_options, "focus-events")) tty_raw(tty, tty_term_string(tty->term, TTYC_ENFCS)); - } + if (options_get_number(global_options, "extended-keys")) + tty_raw(tty, tty_term_string(tty->term, TTYC_ENEKS)); if (tty->term->flags & TERM_VT100LIKE) tty_puts(tty, "\033[?7727h"); @@ -415,12 +415,10 @@ tty_stop_tty(struct tty *tty) tty_raw(tty, "\033[?1006l\033[?1005l"); } - if (tty->flags & TTY_FOCUS) { - tty->flags &= ~TTY_FOCUS; - tty_raw(tty, tty_term_string(tty->term, TTYC_DSFCS)); - } if (tty->term->flags & TERM_VT100LIKE) tty_raw(tty, "\033[?7727l"); + tty_raw(tty, tty_term_string(tty->term, TTYC_DSFCS)); + tty_raw(tty, tty_term_string(tty->term, TTYC_DSEKS)); if (tty_use_margin(tty)) tty_raw(tty, tty_term_string(tty->term, TTYC_DSMG));