Revamp extended keys support to more closely match xterm and support

mode 2 as well as mode 1. From Stanislav Kljuhhin (GitHub issue 4038).

This changes tmux to always request mode 2 from parent terminal, change
to an unambiguous internal representation of keys, and adds an option
(extended-keys-format) to control the format similar to the xterm(1)
formatOtherKeys resource.
This commit is contained in:
nicm
2024-08-21 04:17:09 +00:00
parent de6bce057a
commit c7e61a01e5
12 changed files with 238 additions and 136 deletions

66
tmux.1
View File

@ -3733,6 +3733,10 @@ Note that aliases are expanded when a command is parsed rather than when it is
executed, so binding an alias with
.Ic bind-key
will bind the expanded form.
.It Ic copy-command Ar shell-command
Give the command to pipe to if the
.Ic copy-pipe
copy mode command is used without arguments.
.It Ic default-terminal Ar terminal
Set the default terminal for new windows created in this session - the
default value of the
@ -3746,10 +3750,6 @@ be set to
.Ql screen ,
.Ql tmux
or a derivative of them.
.It Ic copy-command Ar shell-command
Give the command to pipe to if the
.Ic copy-pipe
copy mode command is used without arguments.
.It Ic escape-time Ar time
Set the time in milliseconds for which
.Nm
@ -3771,22 +3771,53 @@ If enabled, the server will exit when there are no attached clients.
.It Xo Ic extended-keys
.Op Ic on | off | always
.Xc
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
Controls how modified keys (keys pressed together with Control, Meta, or Shift)
are reported.
This is the equivalent of the
.Ic modifyOtherKeys
.Xr xterm 1
resource.
.Pp
When set to
.Ic on ,
.Nm
will only forward extended keys to applications when they request them; if
the program inside the pane can request one of two modes: mode 1 which changes
the sequence for only keys which lack an existing well-known representation; or
mode 2 which changes the sequence for all keys.
When set to
.Ic always ,
mode 1 output is forced and the program cannot change it.
When set to
.Ic off ,
this feature is disabled and only standard keys are reported.
.Pp
.Nm
will always forward the keys.
will always request extended keys itself if the terminal supports them.
See also the
.Ic extkeys
feature for the
.Ic terminal-features
option, the
.Ic extended-keys-format
option and the
.Ic pane_key_mode
variable.
.It Xo Ic extended-keys-format
.Op Ic csi-u | xterm
.Xc
Selects one of the two possible formats for reporting modified keys to
applications.
This is the equivalent of the
.Ic formatOtherKeys
.Xr xterm 1
resource.
For example, C-S-a will be reported as
.Ql ^[[27;6;65~
when set to
.Ic xterm ,
and as
.Ql ^[[65;6u
when set to
.Ic csi-u .
.It Xo Ic focus-events
.Op Ic on | off
.Xc
@ -5512,6 +5543,7 @@ The following variables are available, where appropriate:
.It Li "pane_in_mode" Ta "" Ta "1 if pane is in a mode"
.It Li "pane_index" Ta "#P" Ta "Index of pane"
.It Li "pane_input_off" Ta "" Ta "1 if input to pane is disabled"
.It Li "pane_key_mode" Ta "" Ta "Extended key reporting mode in this pane"
.It Li "pane_last" Ta "" Ta "1 if last pane"
.It Li "pane_left" Ta "" Ta "Left of pane"
.It Li "pane_marked" Ta "" Ta "1 if this is the marked pane"