History log of /openbsd-current/usr.bin/tmux/key-string.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.71 16-Jan-2023 nicm

Mark keys sent by command and skip paste handling for them.


# 1.70 01-Nov-2022 nicm

Add modified Tab key sequences, from Aaron Jensen, GitHub issue 3368.


Revision tags: OPENBSD_7_1_BASE OPENBSD_7_2_BASE
# 1.69 16-Feb-2022 nicm

Support more mouse buttons when the terminal sends them, GitHub issue
3055.


Revision tags: OPENBSD_7_0_BASE
# 1.68 16-Jun-2021 nicm

Pass Ctrl keys through as is when given as hex, GitHub issue 2724.


# 1.67 10-Jun-2021 nicm

Move "special" keys into the Unicode PUA rather than making them top bit
set, some compilers do not allow enums that are larger than int. GitHub
issue 2673.


# 1.66 10-Jun-2021 nicm

Add another couple of keys needed for extended keys, GitHub issue 2658.

Handle modifier 9 as Meta, GitHub issue 2647.


Revision tags: OPENBSD_6_9_BASE
# 1.65 07-Apr-2021 nicm

Restore previous behaviour so that C-X remains the same as C-x. Instead,
translate incoming extended keys so that they are consistent.


# 1.64 07-Apr-2021 nicm

Fixes for extended keys: 1) allow C-x and C-X to be bound separately
since some terminals report them differently 2) use the "backspace"
option to translate backspace 3) map ctrl which are have the ctrl
implied (such as C-x) properly when the terminal reports both the key
and the modifier.

Note that any key bindings for C-X where C-x is meant must now be
changed.


Revision tags: OPENBSD_6_8_BASE
# 1.63 06-Jul-2020 nicm

Always send xterm-style keys for M-Left and M-Right. GitHub issue 2296.


# 1.62 27-Jun-2020 nicm

Fix 0x Unicode character parsing, GitHub issue 2286.


# 1.61 25-May-2020 nicm

Use the internal representation for UTF-8 keys instead of wchar_t and
drop some code only needed for that.


# 1.60 20-May-2020 nicm

Fix a couple more places where the key flags need to be masked off.


# 1.59 20-May-2020 nicm

Key strings need to include the cursor and keypad flags now since the
output key lookup expects them already set.


# 1.58 16-May-2020 nicm

Separate key flags and modifiers, log key flags, make the "xterm" flag
more explicit and fix M- keys with a leading escape.


# 1.57 16-May-2020 nicm

Rename KEYC_ESCAPE to KEYC_META.


Revision tags: OPENBSD_6_7_BASE
# 1.56 09-Apr-2020 nicm

Some unnecessary assignments and unused variables.


# 1.55 31-Mar-2020 nicm

Add a "second click" key type which is fired for the second click of a
double click, even if the timer hasn't expired to confirm it isn't
actually a triple click. Provides a way for people who don't care about
triple clicks or can make their commands have no side effects to avoid
the double click timer delay.


# 1.54 15-Mar-2020 nicm

Fix C-Space key string.


# 1.53 19-Feb-2020 nicm

A few fixes to make modifier keys and dragging work - need to remove the
modifiers before checking for the dragging marker key, and apply them
before looking up the end key. Also fix key-to-string with modifiers for
special keys.


# 1.52 14-Nov-2019 nicm

Add an option to set the key sent by backspace for those whose system
uses ^H rather than ^?. GitHub issue 1969.


Revision tags: OPENBSD_6_6_BASE
# 1.51 09-Jul-2019 nicm

Add a -H flag to send-keys to send literal keys given as hex numbers
(needed for control clients to send mouse sequences). Also add some
format flags for UTF-8 and SGR mouse mode. Requested by Bradley Smith in
GitHub issues 1832 and 1833.


Revision tags: OPENBSD_6_5_BASE
# 1.50 18-Oct-2018 nicm

Support for windows larger than visible on the attached client. This has
been a limitation for a long time.

There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.

The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.

If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.

Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).

The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.

For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..

If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.

The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.

The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.


Revision tags: OPENBSD_6_4_BASE
# 1.49 22-Aug-2018 nicm

Add StatusLeft and StatusRight mouse key modifiers for the left and
right parts of the status line.


# 1.48 16-Jul-2018 nicm

Add an "Any" key to run a command if a key is pressed that is not bound
in the current key table. GitHub issue 1404.


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.47 23-Jun-2017 nicm

Add user-keys option to allow user-defined keys to be set, from Dan
Aloni.


# 1.46 12-Jun-2017 nicm

Add explicit keys for the bracketed paste sequences, both to avoid mix
ups with other keys and to make logs clearer.


Revision tags: OPENBSD_6_1_BASE
# 1.45 22-Feb-2017 nicm

Minor bits: fix an array size, add comment, make grid_cell_entry static.


# 1.44 01-Feb-2017 nicm

Implement "all event" (1003) mouse mode but in a way that works. The
main issue is that if we have two panes, A with 1002 and B with 1003, we
need to set 1003 outside tmux in order to get all the mouse events, but
then we need to suppress the ones that pane A doesn't want. This is easy
in SGR mouse mode, because buttons == 3 is only used for movement events
(for other events the trailing m/M marks a release instead), but in
normal mouse mode we can't tell so easily. So for that, look at the
previous event instead - if it is drag+release as well, then the current
event is a movement event.


# 1.43 11-Jan-2017 nicm

Add some missing special keys to key_string_lookup_key, fix a mouse
check in server_client_handle_key, and tweak a comment.


# 1.42 05-Jan-2017 nicm

Highlight all occurrences of search string after searching in copy mode.


# 1.41 23-Nov-2016 nicm

Error on invalid modifier keys.


# 1.40 11-Oct-2016 nicm

Support double and triple clicks (they are cumulative, so double is
fired then triple), and use for select-word and select-line in copy
mode. Inspired by a different solution from Omar Sandoval.


# 1.39 10-Oct-2016 nicm

Loads more static, except for cmd-*.c and window-*.c.


Revision tags: OPENBSD_6_0_BASE
# 1.38 26-May-2016 nicm

Extend 0x1234 keys form to more bits so that Unicode keys work.


# 1.37 25-Apr-2016 nicm

Don't overwrite modifiers in the buffer when making UTF-8 strings,
append instead.


# 1.36 18-Mar-2016 nicm

Instead of reusing MouseUp at the finish of a drag, add a new key
MouseDragEnd. It can be useful to bind them separately in copy mode.


# 1.35 02-Mar-2016 nicm

Handle wcwidth() and mbtowc() failures in better style and drop
characters where we can't find the width (wcwidth() fails) on input, the
same as we drop invalid UTF-8. Suggested by schwarze@.


Revision tags: OPENBSD_5_9_BASE
# 1.34 19-Jan-2016 nicm

I no longer use my SourceForge address so replace it.


# 1.33 12-Dec-2015 nicm

Allow prefix and prefix2 to be set to None to disable (useful if you
would rather bind the prefix in the root table).


# 1.32 14-Nov-2015 nicm

All these return values from utf8_* are confusing, use an enum.


# 1.31 14-Nov-2015 nicm

Couple of assignments to remove compiler warnings.


# 1.30 14-Nov-2015 nicm

Be more strict about invalid UTF-8.


# 1.29 12-Nov-2015 nicm

Rename overly-long utf8data to ud throughout.


# 1.28 12-Nov-2015 nicm

Support UTF-8 key bindings by expanding the key type from int to
uint64_t and converting UTF-8 to Unicode on input and the reverse on
output. (This allows key bindings, there are still omissions - the
largest being that the various prompts do not accept UTF-8.)


# 1.27 26-Oct-2015 nicm

Handle unknown keys more gracefully, return a string instead of NULL.


Revision tags: OPENBSD_5_8_BASE
# 1.26 19-Apr-2015 nicm

Rewrite of tmux mouse support which was a mess. Instead of having
options for "mouse-this" and "mouse-that", mouse events may be bound as
keys and there is one option "mouse" that turns on mouse support
entirely (set -g mouse on).

See the new MOUSE SUPPORT section of the man page for description of the
key names and new flags (-t= to specify the pane or window under mouse
as a target, and send-keys -M to pass through a mouse event).

The default builtin bindings for the mouse are:

bind -n MouseDown1Pane select-pane -t=; send-keys -M
bind -n MouseDown1Status select-window -t=
bind -n MouseDrag1Pane copy-mode -M
bind -n MouseDrag1Border resize-pane -M

To get the effect of turning mode-mouse off, do:

unbind -n MouseDrag1Pane
unbind -temacs-copy MouseDrag1Pane

The old mouse options are now gone, set-option -q may be used to
suppress warnings if mixing configuration files.


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.25 21-Jul-2014 nicm

Drop explicit support for F13-F20 and change to match the xterm terminfo
entry:

F13-F24 are S-F1 to S-F12
F25-F36 are C-F1 to C-F12
F37-F48 are C-S-F1 to C-S-F12
F49-F60 are M-F1 to M-F12
and F61-F63 are M-S-F1 to M-S-F3

This should be no difference for applications inside tmux, but means
that any key binding for F13 will need to be replaced by S-F1 and so on.


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.24 22-Mar-2013 nicm

In terminals with XT, turn on modifyOtherKeys=1 with the escape sequence
and handle the most common set. Pass them through if xterm-keys is on.


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.23 04-Mar-2012 nicm

Accept hex values as keys, needed for send-keys, based on a diff from
George Nachman.


Revision tags: OPENBSD_5_1_BASE
# 1.22 21-Jan-2012 nicm

Drop the ability to have a list of keys in the prefix in favour of two
separate options, prefix and prefix2. This simplifies the code and gets
rid the data options type which was only used for this one option.

Also add a -2 flag to send-prefix to send the secondary prefix key,
fixing a cause of minor irritation.

People who want three prefix keys are out of luck :-).


# 1.21 23-Oct-2011 nicm

Alias NPage/PPage as PageDown/PgDn/PageUp/PgUp to reduce occasional
confusion.


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.20 23-Jan-2011 nicm

Allow top-bit-set characters to be used for key bindings, from Tiago
Cunha.


# 1.19 01-Jan-2011 nicm

Last few tables that should be const.


Revision tags: OPENBSD_4_8_BASE
# 1.18 06-Jun-2010 nicm

Use a macro-based mask for obtaining a key or modifier-set from the
combination. Display C-@, etc, as C-Space, in list-keys. By Micah Cowan.


# 1.17 05-Jun-2010 nicm

Fix binding of C-Space/C-@, from Micah Cowan.


# 1.16 03-May-2010 mcbride

Make C-] and other punctuation-based control key combinations work again.

ok nicm


# 1.15 23-Apr-2010 nicm

When converting A-Z into a control character, want to subtract 64 not
65... whoops.


# 1.14 21-Apr-2010 nicm

Rewrite key string conversions to be readable and to work properly for
multiple modifiers.


Revision tags: OPENBSD_4_7_BASE
# 1.13 14-Jan-2010 nicm

Permit S- prefix on keys for shift. Relatively few terminals support this
(basically xterm only) and even fewer have them in terminfo (kLFT2 and kRIT2).


# 1.12 03-Dec-2009 nicm

Massive spaces->tabs and trailing whitespace cleanup, hopefully for the last
time now I've configured emacs to make them displayed in really annoying
colours...


# 1.11 26-Nov-2009 nicm

Make types clearer and lint happier.


# 1.10 10-Nov-2009 nicm

Lookup key as a named key (eg 'Space') before checking for single character
keys, makes C-Space/M-Space etc resolve to the correct key code.


# 1.9 26-Oct-2009 nicm

Rename keypad keys to something more useful.


# 1.8 06-Oct-2009 nicm

Accept ^? for backspace as well as BSpace.


# 1.7 04-Oct-2009 nicm

Add a key string for space ("Space") and document the names, suggested by
guenther@. Also document how to bind " and ', suggested by miod@.


# 1.6 28-Jul-2009 nicm

Accept and print "Enter" and "Escape" for keys rather than C-m and C-[.


# 1.5 26-Jul-2009 nicm

Detect backspace by looking at termios VERASE and translate it into \177 (which
matches screen's behaviour if not its termcap/terminfo entry). The terminfo kbs
cap is often wrong or missing so it can't be used, and just assuming \177 may
be wrong.


# 1.4 24-Jul-2009 nicm

Accept lowercase c- and m- prefix as well as C- and M-.


# 1.3 21-Jul-2009 nicm

Tidy up keys: use an enum for the key codes, and remove the macros which just
wrap flag sets/clears/tests.


# 1.2 14-Jul-2009 nicm

Add backspace key to named keys.


Revision tags: OPENBSD_4_6_BASE
# 1.1 01-Jun-2009 nicm

Import tmux, a terminal multiplexor allowing (among other things) a single
terminal to be switched between several different windows and programs
displayed on one terminal be detached from one terminal and moved to another.

ok deraadt pirofti


# 1.70 01-Nov-2022 nicm

Add modified Tab key sequences, from Aaron Jensen, GitHub issue 3368.


Revision tags: OPENBSD_7_1_BASE OPENBSD_7_2_BASE
# 1.69 16-Feb-2022 nicm

Support more mouse buttons when the terminal sends them, GitHub issue
3055.


Revision tags: OPENBSD_7_0_BASE
# 1.68 16-Jun-2021 nicm

Pass Ctrl keys through as is when given as hex, GitHub issue 2724.


# 1.67 10-Jun-2021 nicm

Move "special" keys into the Unicode PUA rather than making them top bit
set, some compilers do not allow enums that are larger than int. GitHub
issue 2673.


# 1.66 10-Jun-2021 nicm

Add another couple of keys needed for extended keys, GitHub issue 2658.

Handle modifier 9 as Meta, GitHub issue 2647.


Revision tags: OPENBSD_6_9_BASE
# 1.65 07-Apr-2021 nicm

Restore previous behaviour so that C-X remains the same as C-x. Instead,
translate incoming extended keys so that they are consistent.


# 1.64 07-Apr-2021 nicm

Fixes for extended keys: 1) allow C-x and C-X to be bound separately
since some terminals report them differently 2) use the "backspace"
option to translate backspace 3) map ctrl which are have the ctrl
implied (such as C-x) properly when the terminal reports both the key
and the modifier.

Note that any key bindings for C-X where C-x is meant must now be
changed.


Revision tags: OPENBSD_6_8_BASE
# 1.63 06-Jul-2020 nicm

Always send xterm-style keys for M-Left and M-Right. GitHub issue 2296.


# 1.62 27-Jun-2020 nicm

Fix 0x Unicode character parsing, GitHub issue 2286.


# 1.61 25-May-2020 nicm

Use the internal representation for UTF-8 keys instead of wchar_t and
drop some code only needed for that.


# 1.60 20-May-2020 nicm

Fix a couple more places where the key flags need to be masked off.


# 1.59 20-May-2020 nicm

Key strings need to include the cursor and keypad flags now since the
output key lookup expects them already set.


# 1.58 16-May-2020 nicm

Separate key flags and modifiers, log key flags, make the "xterm" flag
more explicit and fix M- keys with a leading escape.


# 1.57 16-May-2020 nicm

Rename KEYC_ESCAPE to KEYC_META.


Revision tags: OPENBSD_6_7_BASE
# 1.56 09-Apr-2020 nicm

Some unnecessary assignments and unused variables.


# 1.55 31-Mar-2020 nicm

Add a "second click" key type which is fired for the second click of a
double click, even if the timer hasn't expired to confirm it isn't
actually a triple click. Provides a way for people who don't care about
triple clicks or can make their commands have no side effects to avoid
the double click timer delay.


# 1.54 15-Mar-2020 nicm

Fix C-Space key string.


# 1.53 19-Feb-2020 nicm

A few fixes to make modifier keys and dragging work - need to remove the
modifiers before checking for the dragging marker key, and apply them
before looking up the end key. Also fix key-to-string with modifiers for
special keys.


# 1.52 14-Nov-2019 nicm

Add an option to set the key sent by backspace for those whose system
uses ^H rather than ^?. GitHub issue 1969.


Revision tags: OPENBSD_6_6_BASE
# 1.51 09-Jul-2019 nicm

Add a -H flag to send-keys to send literal keys given as hex numbers
(needed for control clients to send mouse sequences). Also add some
format flags for UTF-8 and SGR mouse mode. Requested by Bradley Smith in
GitHub issues 1832 and 1833.


Revision tags: OPENBSD_6_5_BASE
# 1.50 18-Oct-2018 nicm

Support for windows larger than visible on the attached client. This has
been a limitation for a long time.

There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.

The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.

If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.

Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).

The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.

For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..

If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.

The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.

The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.


Revision tags: OPENBSD_6_4_BASE
# 1.49 22-Aug-2018 nicm

Add StatusLeft and StatusRight mouse key modifiers for the left and
right parts of the status line.


# 1.48 16-Jul-2018 nicm

Add an "Any" key to run a command if a key is pressed that is not bound
in the current key table. GitHub issue 1404.


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.47 23-Jun-2017 nicm

Add user-keys option to allow user-defined keys to be set, from Dan
Aloni.


# 1.46 12-Jun-2017 nicm

Add explicit keys for the bracketed paste sequences, both to avoid mix
ups with other keys and to make logs clearer.


Revision tags: OPENBSD_6_1_BASE
# 1.45 22-Feb-2017 nicm

Minor bits: fix an array size, add comment, make grid_cell_entry static.


# 1.44 01-Feb-2017 nicm

Implement "all event" (1003) mouse mode but in a way that works. The
main issue is that if we have two panes, A with 1002 and B with 1003, we
need to set 1003 outside tmux in order to get all the mouse events, but
then we need to suppress the ones that pane A doesn't want. This is easy
in SGR mouse mode, because buttons == 3 is only used for movement events
(for other events the trailing m/M marks a release instead), but in
normal mouse mode we can't tell so easily. So for that, look at the
previous event instead - if it is drag+release as well, then the current
event is a movement event.


# 1.43 11-Jan-2017 nicm

Add some missing special keys to key_string_lookup_key, fix a mouse
check in server_client_handle_key, and tweak a comment.


# 1.42 05-Jan-2017 nicm

Highlight all occurrences of search string after searching in copy mode.


# 1.41 23-Nov-2016 nicm

Error on invalid modifier keys.


# 1.40 11-Oct-2016 nicm

Support double and triple clicks (they are cumulative, so double is
fired then triple), and use for select-word and select-line in copy
mode. Inspired by a different solution from Omar Sandoval.


# 1.39 10-Oct-2016 nicm

Loads more static, except for cmd-*.c and window-*.c.


Revision tags: OPENBSD_6_0_BASE
# 1.38 26-May-2016 nicm

Extend 0x1234 keys form to more bits so that Unicode keys work.


# 1.37 25-Apr-2016 nicm

Don't overwrite modifiers in the buffer when making UTF-8 strings,
append instead.


# 1.36 18-Mar-2016 nicm

Instead of reusing MouseUp at the finish of a drag, add a new key
MouseDragEnd. It can be useful to bind them separately in copy mode.


# 1.35 02-Mar-2016 nicm

Handle wcwidth() and mbtowc() failures in better style and drop
characters where we can't find the width (wcwidth() fails) on input, the
same as we drop invalid UTF-8. Suggested by schwarze@.


Revision tags: OPENBSD_5_9_BASE
# 1.34 19-Jan-2016 nicm

I no longer use my SourceForge address so replace it.


# 1.33 12-Dec-2015 nicm

Allow prefix and prefix2 to be set to None to disable (useful if you
would rather bind the prefix in the root table).


# 1.32 14-Nov-2015 nicm

All these return values from utf8_* are confusing, use an enum.


# 1.31 14-Nov-2015 nicm

Couple of assignments to remove compiler warnings.


# 1.30 14-Nov-2015 nicm

Be more strict about invalid UTF-8.


# 1.29 12-Nov-2015 nicm

Rename overly-long utf8data to ud throughout.


# 1.28 12-Nov-2015 nicm

Support UTF-8 key bindings by expanding the key type from int to
uint64_t and converting UTF-8 to Unicode on input and the reverse on
output. (This allows key bindings, there are still omissions - the
largest being that the various prompts do not accept UTF-8.)


# 1.27 26-Oct-2015 nicm

Handle unknown keys more gracefully, return a string instead of NULL.


Revision tags: OPENBSD_5_8_BASE
# 1.26 19-Apr-2015 nicm

Rewrite of tmux mouse support which was a mess. Instead of having
options for "mouse-this" and "mouse-that", mouse events may be bound as
keys and there is one option "mouse" that turns on mouse support
entirely (set -g mouse on).

See the new MOUSE SUPPORT section of the man page for description of the
key names and new flags (-t= to specify the pane or window under mouse
as a target, and send-keys -M to pass through a mouse event).

The default builtin bindings for the mouse are:

bind -n MouseDown1Pane select-pane -t=; send-keys -M
bind -n MouseDown1Status select-window -t=
bind -n MouseDrag1Pane copy-mode -M
bind -n MouseDrag1Border resize-pane -M

To get the effect of turning mode-mouse off, do:

unbind -n MouseDrag1Pane
unbind -temacs-copy MouseDrag1Pane

The old mouse options are now gone, set-option -q may be used to
suppress warnings if mixing configuration files.


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.25 21-Jul-2014 nicm

Drop explicit support for F13-F20 and change to match the xterm terminfo
entry:

F13-F24 are S-F1 to S-F12
F25-F36 are C-F1 to C-F12
F37-F48 are C-S-F1 to C-S-F12
F49-F60 are M-F1 to M-F12
and F61-F63 are M-S-F1 to M-S-F3

This should be no difference for applications inside tmux, but means
that any key binding for F13 will need to be replaced by S-F1 and so on.


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.24 22-Mar-2013 nicm

In terminals with XT, turn on modifyOtherKeys=1 with the escape sequence
and handle the most common set. Pass them through if xterm-keys is on.


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.23 04-Mar-2012 nicm

Accept hex values as keys, needed for send-keys, based on a diff from
George Nachman.


Revision tags: OPENBSD_5_1_BASE
# 1.22 21-Jan-2012 nicm

Drop the ability to have a list of keys in the prefix in favour of two
separate options, prefix and prefix2. This simplifies the code and gets
rid the data options type which was only used for this one option.

Also add a -2 flag to send-prefix to send the secondary prefix key,
fixing a cause of minor irritation.

People who want three prefix keys are out of luck :-).


# 1.21 23-Oct-2011 nicm

Alias NPage/PPage as PageDown/PgDn/PageUp/PgUp to reduce occasional
confusion.


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.20 23-Jan-2011 nicm

Allow top-bit-set characters to be used for key bindings, from Tiago
Cunha.


# 1.19 01-Jan-2011 nicm

Last few tables that should be const.


Revision tags: OPENBSD_4_8_BASE
# 1.18 06-Jun-2010 nicm

Use a macro-based mask for obtaining a key or modifier-set from the
combination. Display C-@, etc, as C-Space, in list-keys. By Micah Cowan.


# 1.17 05-Jun-2010 nicm

Fix binding of C-Space/C-@, from Micah Cowan.


# 1.16 03-May-2010 mcbride

Make C-] and other punctuation-based control key combinations work again.

ok nicm


# 1.15 23-Apr-2010 nicm

When converting A-Z into a control character, want to subtract 64 not
65... whoops.


# 1.14 21-Apr-2010 nicm

Rewrite key string conversions to be readable and to work properly for
multiple modifiers.


Revision tags: OPENBSD_4_7_BASE
# 1.13 14-Jan-2010 nicm

Permit S- prefix on keys for shift. Relatively few terminals support this
(basically xterm only) and even fewer have them in terminfo (kLFT2 and kRIT2).


# 1.12 03-Dec-2009 nicm

Massive spaces->tabs and trailing whitespace cleanup, hopefully for the last
time now I've configured emacs to make them displayed in really annoying
colours...


# 1.11 26-Nov-2009 nicm

Make types clearer and lint happier.


# 1.10 10-Nov-2009 nicm

Lookup key as a named key (eg 'Space') before checking for single character
keys, makes C-Space/M-Space etc resolve to the correct key code.


# 1.9 26-Oct-2009 nicm

Rename keypad keys to something more useful.


# 1.8 06-Oct-2009 nicm

Accept ^? for backspace as well as BSpace.


# 1.7 04-Oct-2009 nicm

Add a key string for space ("Space") and document the names, suggested by
guenther@. Also document how to bind " and ', suggested by miod@.


# 1.6 28-Jul-2009 nicm

Accept and print "Enter" and "Escape" for keys rather than C-m and C-[.


# 1.5 26-Jul-2009 nicm

Detect backspace by looking at termios VERASE and translate it into \177 (which
matches screen's behaviour if not its termcap/terminfo entry). The terminfo kbs
cap is often wrong or missing so it can't be used, and just assuming \177 may
be wrong.


# 1.4 24-Jul-2009 nicm

Accept lowercase c- and m- prefix as well as C- and M-.


# 1.3 21-Jul-2009 nicm

Tidy up keys: use an enum for the key codes, and remove the macros which just
wrap flag sets/clears/tests.


# 1.2 14-Jul-2009 nicm

Add backspace key to named keys.


Revision tags: OPENBSD_4_6_BASE
# 1.1 01-Jun-2009 nicm

Import tmux, a terminal multiplexor allowing (among other things) a single
terminal to be switched between several different windows and programs
displayed on one terminal be detached from one terminal and moved to another.

ok deraadt pirofti


# 1.69 16-Feb-2022 nicm

Support more mouse buttons when the terminal sends them, GitHub issue
3055.


Revision tags: OPENBSD_7_0_BASE
# 1.68 16-Jun-2021 nicm

Pass Ctrl keys through as is when given as hex, GitHub issue 2724.


# 1.67 10-Jun-2021 nicm

Move "special" keys into the Unicode PUA rather than making them top bit
set, some compilers do not allow enums that are larger than int. GitHub
issue 2673.


# 1.66 10-Jun-2021 nicm

Add another couple of keys needed for extended keys, GitHub issue 2658.

Handle modifier 9 as Meta, GitHub issue 2647.


Revision tags: OPENBSD_6_9_BASE
# 1.65 07-Apr-2021 nicm

Restore previous behaviour so that C-X remains the same as C-x. Instead,
translate incoming extended keys so that they are consistent.


# 1.64 07-Apr-2021 nicm

Fixes for extended keys: 1) allow C-x and C-X to be bound separately
since some terminals report them differently 2) use the "backspace"
option to translate backspace 3) map ctrl which are have the ctrl
implied (such as C-x) properly when the terminal reports both the key
and the modifier.

Note that any key bindings for C-X where C-x is meant must now be
changed.


Revision tags: OPENBSD_6_8_BASE
# 1.63 06-Jul-2020 nicm

Always send xterm-style keys for M-Left and M-Right. GitHub issue 2296.


# 1.62 27-Jun-2020 nicm

Fix 0x Unicode character parsing, GitHub issue 2286.


# 1.61 25-May-2020 nicm

Use the internal representation for UTF-8 keys instead of wchar_t and
drop some code only needed for that.


# 1.60 20-May-2020 nicm

Fix a couple more places where the key flags need to be masked off.


# 1.59 20-May-2020 nicm

Key strings need to include the cursor and keypad flags now since the
output key lookup expects them already set.


# 1.58 16-May-2020 nicm

Separate key flags and modifiers, log key flags, make the "xterm" flag
more explicit and fix M- keys with a leading escape.


# 1.57 16-May-2020 nicm

Rename KEYC_ESCAPE to KEYC_META.


Revision tags: OPENBSD_6_7_BASE
# 1.56 09-Apr-2020 nicm

Some unnecessary assignments and unused variables.


# 1.55 31-Mar-2020 nicm

Add a "second click" key type which is fired for the second click of a
double click, even if the timer hasn't expired to confirm it isn't
actually a triple click. Provides a way for people who don't care about
triple clicks or can make their commands have no side effects to avoid
the double click timer delay.


# 1.54 15-Mar-2020 nicm

Fix C-Space key string.


# 1.53 19-Feb-2020 nicm

A few fixes to make modifier keys and dragging work - need to remove the
modifiers before checking for the dragging marker key, and apply them
before looking up the end key. Also fix key-to-string with modifiers for
special keys.


# 1.52 14-Nov-2019 nicm

Add an option to set the key sent by backspace for those whose system
uses ^H rather than ^?. GitHub issue 1969.


Revision tags: OPENBSD_6_6_BASE
# 1.51 09-Jul-2019 nicm

Add a -H flag to send-keys to send literal keys given as hex numbers
(needed for control clients to send mouse sequences). Also add some
format flags for UTF-8 and SGR mouse mode. Requested by Bradley Smith in
GitHub issues 1832 and 1833.


Revision tags: OPENBSD_6_5_BASE
# 1.50 18-Oct-2018 nicm

Support for windows larger than visible on the attached client. This has
been a limitation for a long time.

There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.

The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.

If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.

Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).

The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.

For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..

If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.

The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.

The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.


Revision tags: OPENBSD_6_4_BASE
# 1.49 22-Aug-2018 nicm

Add StatusLeft and StatusRight mouse key modifiers for the left and
right parts of the status line.


# 1.48 16-Jul-2018 nicm

Add an "Any" key to run a command if a key is pressed that is not bound
in the current key table. GitHub issue 1404.


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.47 23-Jun-2017 nicm

Add user-keys option to allow user-defined keys to be set, from Dan
Aloni.


# 1.46 12-Jun-2017 nicm

Add explicit keys for the bracketed paste sequences, both to avoid mix
ups with other keys and to make logs clearer.


Revision tags: OPENBSD_6_1_BASE
# 1.45 22-Feb-2017 nicm

Minor bits: fix an array size, add comment, make grid_cell_entry static.


# 1.44 01-Feb-2017 nicm

Implement "all event" (1003) mouse mode but in a way that works. The
main issue is that if we have two panes, A with 1002 and B with 1003, we
need to set 1003 outside tmux in order to get all the mouse events, but
then we need to suppress the ones that pane A doesn't want. This is easy
in SGR mouse mode, because buttons == 3 is only used for movement events
(for other events the trailing m/M marks a release instead), but in
normal mouse mode we can't tell so easily. So for that, look at the
previous event instead - if it is drag+release as well, then the current
event is a movement event.


# 1.43 11-Jan-2017 nicm

Add some missing special keys to key_string_lookup_key, fix a mouse
check in server_client_handle_key, and tweak a comment.


# 1.42 05-Jan-2017 nicm

Highlight all occurrences of search string after searching in copy mode.


# 1.41 23-Nov-2016 nicm

Error on invalid modifier keys.


# 1.40 11-Oct-2016 nicm

Support double and triple clicks (they are cumulative, so double is
fired then triple), and use for select-word and select-line in copy
mode. Inspired by a different solution from Omar Sandoval.


# 1.39 10-Oct-2016 nicm

Loads more static, except for cmd-*.c and window-*.c.


Revision tags: OPENBSD_6_0_BASE
# 1.38 26-May-2016 nicm

Extend 0x1234 keys form to more bits so that Unicode keys work.


# 1.37 25-Apr-2016 nicm

Don't overwrite modifiers in the buffer when making UTF-8 strings,
append instead.


# 1.36 18-Mar-2016 nicm

Instead of reusing MouseUp at the finish of a drag, add a new key
MouseDragEnd. It can be useful to bind them separately in copy mode.


# 1.35 02-Mar-2016 nicm

Handle wcwidth() and mbtowc() failures in better style and drop
characters where we can't find the width (wcwidth() fails) on input, the
same as we drop invalid UTF-8. Suggested by schwarze@.


Revision tags: OPENBSD_5_9_BASE
# 1.34 19-Jan-2016 nicm

I no longer use my SourceForge address so replace it.


# 1.33 12-Dec-2015 nicm

Allow prefix and prefix2 to be set to None to disable (useful if you
would rather bind the prefix in the root table).


# 1.32 14-Nov-2015 nicm

All these return values from utf8_* are confusing, use an enum.


# 1.31 14-Nov-2015 nicm

Couple of assignments to remove compiler warnings.


# 1.30 14-Nov-2015 nicm

Be more strict about invalid UTF-8.


# 1.29 12-Nov-2015 nicm

Rename overly-long utf8data to ud throughout.


# 1.28 12-Nov-2015 nicm

Support UTF-8 key bindings by expanding the key type from int to
uint64_t and converting UTF-8 to Unicode on input and the reverse on
output. (This allows key bindings, there are still omissions - the
largest being that the various prompts do not accept UTF-8.)


# 1.27 26-Oct-2015 nicm

Handle unknown keys more gracefully, return a string instead of NULL.


Revision tags: OPENBSD_5_8_BASE
# 1.26 19-Apr-2015 nicm

Rewrite of tmux mouse support which was a mess. Instead of having
options for "mouse-this" and "mouse-that", mouse events may be bound as
keys and there is one option "mouse" that turns on mouse support
entirely (set -g mouse on).

See the new MOUSE SUPPORT section of the man page for description of the
key names and new flags (-t= to specify the pane or window under mouse
as a target, and send-keys -M to pass through a mouse event).

The default builtin bindings for the mouse are:

bind -n MouseDown1Pane select-pane -t=; send-keys -M
bind -n MouseDown1Status select-window -t=
bind -n MouseDrag1Pane copy-mode -M
bind -n MouseDrag1Border resize-pane -M

To get the effect of turning mode-mouse off, do:

unbind -n MouseDrag1Pane
unbind -temacs-copy MouseDrag1Pane

The old mouse options are now gone, set-option -q may be used to
suppress warnings if mixing configuration files.


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.25 21-Jul-2014 nicm

Drop explicit support for F13-F20 and change to match the xterm terminfo
entry:

F13-F24 are S-F1 to S-F12
F25-F36 are C-F1 to C-F12
F37-F48 are C-S-F1 to C-S-F12
F49-F60 are M-F1 to M-F12
and F61-F63 are M-S-F1 to M-S-F3

This should be no difference for applications inside tmux, but means
that any key binding for F13 will need to be replaced by S-F1 and so on.


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.24 22-Mar-2013 nicm

In terminals with XT, turn on modifyOtherKeys=1 with the escape sequence
and handle the most common set. Pass them through if xterm-keys is on.


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.23 04-Mar-2012 nicm

Accept hex values as keys, needed for send-keys, based on a diff from
George Nachman.


Revision tags: OPENBSD_5_1_BASE
# 1.22 21-Jan-2012 nicm

Drop the ability to have a list of keys in the prefix in favour of two
separate options, prefix and prefix2. This simplifies the code and gets
rid the data options type which was only used for this one option.

Also add a -2 flag to send-prefix to send the secondary prefix key,
fixing a cause of minor irritation.

People who want three prefix keys are out of luck :-).


# 1.21 23-Oct-2011 nicm

Alias NPage/PPage as PageDown/PgDn/PageUp/PgUp to reduce occasional
confusion.


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.20 23-Jan-2011 nicm

Allow top-bit-set characters to be used for key bindings, from Tiago
Cunha.


# 1.19 01-Jan-2011 nicm

Last few tables that should be const.


Revision tags: OPENBSD_4_8_BASE
# 1.18 06-Jun-2010 nicm

Use a macro-based mask for obtaining a key or modifier-set from the
combination. Display C-@, etc, as C-Space, in list-keys. By Micah Cowan.


# 1.17 05-Jun-2010 nicm

Fix binding of C-Space/C-@, from Micah Cowan.


# 1.16 03-May-2010 mcbride

Make C-] and other punctuation-based control key combinations work again.

ok nicm


# 1.15 23-Apr-2010 nicm

When converting A-Z into a control character, want to subtract 64 not
65... whoops.


# 1.14 21-Apr-2010 nicm

Rewrite key string conversions to be readable and to work properly for
multiple modifiers.


Revision tags: OPENBSD_4_7_BASE
# 1.13 14-Jan-2010 nicm

Permit S- prefix on keys for shift. Relatively few terminals support this
(basically xterm only) and even fewer have them in terminfo (kLFT2 and kRIT2).


# 1.12 03-Dec-2009 nicm

Massive spaces->tabs and trailing whitespace cleanup, hopefully for the last
time now I've configured emacs to make them displayed in really annoying
colours...


# 1.11 26-Nov-2009 nicm

Make types clearer and lint happier.


# 1.10 10-Nov-2009 nicm

Lookup key as a named key (eg 'Space') before checking for single character
keys, makes C-Space/M-Space etc resolve to the correct key code.


# 1.9 26-Oct-2009 nicm

Rename keypad keys to something more useful.


# 1.8 06-Oct-2009 nicm

Accept ^? for backspace as well as BSpace.


# 1.7 04-Oct-2009 nicm

Add a key string for space ("Space") and document the names, suggested by
guenther@. Also document how to bind " and ', suggested by miod@.


# 1.6 28-Jul-2009 nicm

Accept and print "Enter" and "Escape" for keys rather than C-m and C-[.


# 1.5 26-Jul-2009 nicm

Detect backspace by looking at termios VERASE and translate it into \177 (which
matches screen's behaviour if not its termcap/terminfo entry). The terminfo kbs
cap is often wrong or missing so it can't be used, and just assuming \177 may
be wrong.


# 1.4 24-Jul-2009 nicm

Accept lowercase c- and m- prefix as well as C- and M-.


# 1.3 21-Jul-2009 nicm

Tidy up keys: use an enum for the key codes, and remove the macros which just
wrap flag sets/clears/tests.


# 1.2 14-Jul-2009 nicm

Add backspace key to named keys.


Revision tags: OPENBSD_4_6_BASE
# 1.1 01-Jun-2009 nicm

Import tmux, a terminal multiplexor allowing (among other things) a single
terminal to be switched between several different windows and programs
displayed on one terminal be detached from one terminal and moved to another.

ok deraadt pirofti


# 1.68 16-Jun-2021 nicm

Pass Ctrl keys through as is when given as hex, GitHub issue 2724.


# 1.67 10-Jun-2021 nicm

Move "special" keys into the Unicode PUA rather than making them top bit
set, some compilers do not allow enums that are larger than int. GitHub
issue 2673.


# 1.66 10-Jun-2021 nicm

Add another couple of keys needed for extended keys, GitHub issue 2658.

Handle modifier 9 as Meta, GitHub issue 2647.


Revision tags: OPENBSD_6_9_BASE
# 1.65 07-Apr-2021 nicm

Restore previous behaviour so that C-X remains the same as C-x. Instead,
translate incoming extended keys so that they are consistent.


# 1.64 07-Apr-2021 nicm

Fixes for extended keys: 1) allow C-x and C-X to be bound separately
since some terminals report them differently 2) use the "backspace"
option to translate backspace 3) map ctrl which are have the ctrl
implied (such as C-x) properly when the terminal reports both the key
and the modifier.

Note that any key bindings for C-X where C-x is meant must now be
changed.


Revision tags: OPENBSD_6_8_BASE
# 1.63 06-Jul-2020 nicm

Always send xterm-style keys for M-Left and M-Right. GitHub issue 2296.


# 1.62 27-Jun-2020 nicm

Fix 0x Unicode character parsing, GitHub issue 2286.


# 1.61 25-May-2020 nicm

Use the internal representation for UTF-8 keys instead of wchar_t and
drop some code only needed for that.


# 1.60 20-May-2020 nicm

Fix a couple more places where the key flags need to be masked off.


# 1.59 20-May-2020 nicm

Key strings need to include the cursor and keypad flags now since the
output key lookup expects them already set.


# 1.58 16-May-2020 nicm

Separate key flags and modifiers, log key flags, make the "xterm" flag
more explicit and fix M- keys with a leading escape.


# 1.57 16-May-2020 nicm

Rename KEYC_ESCAPE to KEYC_META.


Revision tags: OPENBSD_6_7_BASE
# 1.56 09-Apr-2020 nicm

Some unnecessary assignments and unused variables.


# 1.55 31-Mar-2020 nicm

Add a "second click" key type which is fired for the second click of a
double click, even if the timer hasn't expired to confirm it isn't
actually a triple click. Provides a way for people who don't care about
triple clicks or can make their commands have no side effects to avoid
the double click timer delay.


# 1.54 15-Mar-2020 nicm

Fix C-Space key string.


# 1.53 19-Feb-2020 nicm

A few fixes to make modifier keys and dragging work - need to remove the
modifiers before checking for the dragging marker key, and apply them
before looking up the end key. Also fix key-to-string with modifiers for
special keys.


# 1.52 14-Nov-2019 nicm

Add an option to set the key sent by backspace for those whose system
uses ^H rather than ^?. GitHub issue 1969.


Revision tags: OPENBSD_6_6_BASE
# 1.51 09-Jul-2019 nicm

Add a -H flag to send-keys to send literal keys given as hex numbers
(needed for control clients to send mouse sequences). Also add some
format flags for UTF-8 and SGR mouse mode. Requested by Bradley Smith in
GitHub issues 1832 and 1833.


Revision tags: OPENBSD_6_5_BASE
# 1.50 18-Oct-2018 nicm

Support for windows larger than visible on the attached client. This has
been a limitation for a long time.

There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.

The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.

If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.

Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).

The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.

For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..

If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.

The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.

The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.


Revision tags: OPENBSD_6_4_BASE
# 1.49 22-Aug-2018 nicm

Add StatusLeft and StatusRight mouse key modifiers for the left and
right parts of the status line.


# 1.48 16-Jul-2018 nicm

Add an "Any" key to run a command if a key is pressed that is not bound
in the current key table. GitHub issue 1404.


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.47 23-Jun-2017 nicm

Add user-keys option to allow user-defined keys to be set, from Dan
Aloni.


# 1.46 12-Jun-2017 nicm

Add explicit keys for the bracketed paste sequences, both to avoid mix
ups with other keys and to make logs clearer.


Revision tags: OPENBSD_6_1_BASE
# 1.45 22-Feb-2017 nicm

Minor bits: fix an array size, add comment, make grid_cell_entry static.


# 1.44 01-Feb-2017 nicm

Implement "all event" (1003) mouse mode but in a way that works. The
main issue is that if we have two panes, A with 1002 and B with 1003, we
need to set 1003 outside tmux in order to get all the mouse events, but
then we need to suppress the ones that pane A doesn't want. This is easy
in SGR mouse mode, because buttons == 3 is only used for movement events
(for other events the trailing m/M marks a release instead), but in
normal mouse mode we can't tell so easily. So for that, look at the
previous event instead - if it is drag+release as well, then the current
event is a movement event.


# 1.43 11-Jan-2017 nicm

Add some missing special keys to key_string_lookup_key, fix a mouse
check in server_client_handle_key, and tweak a comment.


# 1.42 05-Jan-2017 nicm

Highlight all occurrences of search string after searching in copy mode.


# 1.41 23-Nov-2016 nicm

Error on invalid modifier keys.


# 1.40 11-Oct-2016 nicm

Support double and triple clicks (they are cumulative, so double is
fired then triple), and use for select-word and select-line in copy
mode. Inspired by a different solution from Omar Sandoval.


# 1.39 10-Oct-2016 nicm

Loads more static, except for cmd-*.c and window-*.c.


Revision tags: OPENBSD_6_0_BASE
# 1.38 26-May-2016 nicm

Extend 0x1234 keys form to more bits so that Unicode keys work.


# 1.37 25-Apr-2016 nicm

Don't overwrite modifiers in the buffer when making UTF-8 strings,
append instead.


# 1.36 18-Mar-2016 nicm

Instead of reusing MouseUp at the finish of a drag, add a new key
MouseDragEnd. It can be useful to bind them separately in copy mode.


# 1.35 02-Mar-2016 nicm

Handle wcwidth() and mbtowc() failures in better style and drop
characters where we can't find the width (wcwidth() fails) on input, the
same as we drop invalid UTF-8. Suggested by schwarze@.


Revision tags: OPENBSD_5_9_BASE
# 1.34 19-Jan-2016 nicm

I no longer use my SourceForge address so replace it.


# 1.33 12-Dec-2015 nicm

Allow prefix and prefix2 to be set to None to disable (useful if you
would rather bind the prefix in the root table).


# 1.32 14-Nov-2015 nicm

All these return values from utf8_* are confusing, use an enum.


# 1.31 14-Nov-2015 nicm

Couple of assignments to remove compiler warnings.


# 1.30 14-Nov-2015 nicm

Be more strict about invalid UTF-8.


# 1.29 12-Nov-2015 nicm

Rename overly-long utf8data to ud throughout.


# 1.28 12-Nov-2015 nicm

Support UTF-8 key bindings by expanding the key type from int to
uint64_t and converting UTF-8 to Unicode on input and the reverse on
output. (This allows key bindings, there are still omissions - the
largest being that the various prompts do not accept UTF-8.)


# 1.27 26-Oct-2015 nicm

Handle unknown keys more gracefully, return a string instead of NULL.


Revision tags: OPENBSD_5_8_BASE
# 1.26 19-Apr-2015 nicm

Rewrite of tmux mouse support which was a mess. Instead of having
options for "mouse-this" and "mouse-that", mouse events may be bound as
keys and there is one option "mouse" that turns on mouse support
entirely (set -g mouse on).

See the new MOUSE SUPPORT section of the man page for description of the
key names and new flags (-t= to specify the pane or window under mouse
as a target, and send-keys -M to pass through a mouse event).

The default builtin bindings for the mouse are:

bind -n MouseDown1Pane select-pane -t=; send-keys -M
bind -n MouseDown1Status select-window -t=
bind -n MouseDrag1Pane copy-mode -M
bind -n MouseDrag1Border resize-pane -M

To get the effect of turning mode-mouse off, do:

unbind -n MouseDrag1Pane
unbind -temacs-copy MouseDrag1Pane

The old mouse options are now gone, set-option -q may be used to
suppress warnings if mixing configuration files.


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.25 21-Jul-2014 nicm

Drop explicit support for F13-F20 and change to match the xterm terminfo
entry:

F13-F24 are S-F1 to S-F12
F25-F36 are C-F1 to C-F12
F37-F48 are C-S-F1 to C-S-F12
F49-F60 are M-F1 to M-F12
and F61-F63 are M-S-F1 to M-S-F3

This should be no difference for applications inside tmux, but means
that any key binding for F13 will need to be replaced by S-F1 and so on.


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.24 22-Mar-2013 nicm

In terminals with XT, turn on modifyOtherKeys=1 with the escape sequence
and handle the most common set. Pass them through if xterm-keys is on.


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.23 04-Mar-2012 nicm

Accept hex values as keys, needed for send-keys, based on a diff from
George Nachman.


Revision tags: OPENBSD_5_1_BASE
# 1.22 21-Jan-2012 nicm

Drop the ability to have a list of keys in the prefix in favour of two
separate options, prefix and prefix2. This simplifies the code and gets
rid the data options type which was only used for this one option.

Also add a -2 flag to send-prefix to send the secondary prefix key,
fixing a cause of minor irritation.

People who want three prefix keys are out of luck :-).


# 1.21 23-Oct-2011 nicm

Alias NPage/PPage as PageDown/PgDn/PageUp/PgUp to reduce occasional
confusion.


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.20 23-Jan-2011 nicm

Allow top-bit-set characters to be used for key bindings, from Tiago
Cunha.


# 1.19 01-Jan-2011 nicm

Last few tables that should be const.


Revision tags: OPENBSD_4_8_BASE
# 1.18 06-Jun-2010 nicm

Use a macro-based mask for obtaining a key or modifier-set from the
combination. Display C-@, etc, as C-Space, in list-keys. By Micah Cowan.


# 1.17 05-Jun-2010 nicm

Fix binding of C-Space/C-@, from Micah Cowan.


# 1.16 03-May-2010 mcbride

Make C-] and other punctuation-based control key combinations work again.

ok nicm


# 1.15 23-Apr-2010 nicm

When converting A-Z into a control character, want to subtract 64 not
65... whoops.


# 1.14 21-Apr-2010 nicm

Rewrite key string conversions to be readable and to work properly for
multiple modifiers.


Revision tags: OPENBSD_4_7_BASE
# 1.13 14-Jan-2010 nicm

Permit S- prefix on keys for shift. Relatively few terminals support this
(basically xterm only) and even fewer have them in terminfo (kLFT2 and kRIT2).


# 1.12 03-Dec-2009 nicm

Massive spaces->tabs and trailing whitespace cleanup, hopefully for the last
time now I've configured emacs to make them displayed in really annoying
colours...


# 1.11 26-Nov-2009 nicm

Make types clearer and lint happier.


# 1.10 10-Nov-2009 nicm

Lookup key as a named key (eg 'Space') before checking for single character
keys, makes C-Space/M-Space etc resolve to the correct key code.


# 1.9 26-Oct-2009 nicm

Rename keypad keys to something more useful.


# 1.8 06-Oct-2009 nicm

Accept ^? for backspace as well as BSpace.


# 1.7 04-Oct-2009 nicm

Add a key string for space ("Space") and document the names, suggested by
guenther@. Also document how to bind " and ', suggested by miod@.


# 1.6 28-Jul-2009 nicm

Accept and print "Enter" and "Escape" for keys rather than C-m and C-[.


# 1.5 26-Jul-2009 nicm

Detect backspace by looking at termios VERASE and translate it into \177 (which
matches screen's behaviour if not its termcap/terminfo entry). The terminfo kbs
cap is often wrong or missing so it can't be used, and just assuming \177 may
be wrong.


# 1.4 24-Jul-2009 nicm

Accept lowercase c- and m- prefix as well as C- and M-.


# 1.3 21-Jul-2009 nicm

Tidy up keys: use an enum for the key codes, and remove the macros which just
wrap flag sets/clears/tests.


# 1.2 14-Jul-2009 nicm

Add backspace key to named keys.


Revision tags: OPENBSD_4_6_BASE
# 1.1 01-Jun-2009 nicm

Import tmux, a terminal multiplexor allowing (among other things) a single
terminal to be switched between several different windows and programs
displayed on one terminal be detached from one terminal and moved to another.

ok deraadt pirofti


# 1.67 10-Jun-2021 nicm

Move "special" keys into the Unicode PUA rather than making them top bit
set, some compilers do not allow enums that are larger than int. GitHub
issue 2673.


# 1.66 10-Jun-2021 nicm

Add another couple of keys needed for extended keys, GitHub issue 2658.

Handle modifier 9 as Meta, GitHub issue 2647.


Revision tags: OPENBSD_6_9_BASE
# 1.65 07-Apr-2021 nicm

Restore previous behaviour so that C-X remains the same as C-x. Instead,
translate incoming extended keys so that they are consistent.


# 1.64 07-Apr-2021 nicm

Fixes for extended keys: 1) allow C-x and C-X to be bound separately
since some terminals report them differently 2) use the "backspace"
option to translate backspace 3) map ctrl which are have the ctrl
implied (such as C-x) properly when the terminal reports both the key
and the modifier.

Note that any key bindings for C-X where C-x is meant must now be
changed.


Revision tags: OPENBSD_6_8_BASE
# 1.63 06-Jul-2020 nicm

Always send xterm-style keys for M-Left and M-Right. GitHub issue 2296.


# 1.62 27-Jun-2020 nicm

Fix 0x Unicode character parsing, GitHub issue 2286.


# 1.61 25-May-2020 nicm

Use the internal representation for UTF-8 keys instead of wchar_t and
drop some code only needed for that.


# 1.60 20-May-2020 nicm

Fix a couple more places where the key flags need to be masked off.


# 1.59 20-May-2020 nicm

Key strings need to include the cursor and keypad flags now since the
output key lookup expects them already set.


# 1.58 16-May-2020 nicm

Separate key flags and modifiers, log key flags, make the "xterm" flag
more explicit and fix M- keys with a leading escape.


# 1.57 16-May-2020 nicm

Rename KEYC_ESCAPE to KEYC_META.


Revision tags: OPENBSD_6_7_BASE
# 1.56 09-Apr-2020 nicm

Some unnecessary assignments and unused variables.


# 1.55 31-Mar-2020 nicm

Add a "second click" key type which is fired for the second click of a
double click, even if the timer hasn't expired to confirm it isn't
actually a triple click. Provides a way for people who don't care about
triple clicks or can make their commands have no side effects to avoid
the double click timer delay.


# 1.54 15-Mar-2020 nicm

Fix C-Space key string.


# 1.53 19-Feb-2020 nicm

A few fixes to make modifier keys and dragging work - need to remove the
modifiers before checking for the dragging marker key, and apply them
before looking up the end key. Also fix key-to-string with modifiers for
special keys.


# 1.52 14-Nov-2019 nicm

Add an option to set the key sent by backspace for those whose system
uses ^H rather than ^?. GitHub issue 1969.


Revision tags: OPENBSD_6_6_BASE
# 1.51 09-Jul-2019 nicm

Add a -H flag to send-keys to send literal keys given as hex numbers
(needed for control clients to send mouse sequences). Also add some
format flags for UTF-8 and SGR mouse mode. Requested by Bradley Smith in
GitHub issues 1832 and 1833.


Revision tags: OPENBSD_6_5_BASE
# 1.50 18-Oct-2018 nicm

Support for windows larger than visible on the attached client. This has
been a limitation for a long time.

There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.

The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.

If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.

Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).

The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.

For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..

If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.

The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.

The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.


Revision tags: OPENBSD_6_4_BASE
# 1.49 22-Aug-2018 nicm

Add StatusLeft and StatusRight mouse key modifiers for the left and
right parts of the status line.


# 1.48 16-Jul-2018 nicm

Add an "Any" key to run a command if a key is pressed that is not bound
in the current key table. GitHub issue 1404.


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.47 23-Jun-2017 nicm

Add user-keys option to allow user-defined keys to be set, from Dan
Aloni.


# 1.46 12-Jun-2017 nicm

Add explicit keys for the bracketed paste sequences, both to avoid mix
ups with other keys and to make logs clearer.


Revision tags: OPENBSD_6_1_BASE
# 1.45 22-Feb-2017 nicm

Minor bits: fix an array size, add comment, make grid_cell_entry static.


# 1.44 01-Feb-2017 nicm

Implement "all event" (1003) mouse mode but in a way that works. The
main issue is that if we have two panes, A with 1002 and B with 1003, we
need to set 1003 outside tmux in order to get all the mouse events, but
then we need to suppress the ones that pane A doesn't want. This is easy
in SGR mouse mode, because buttons == 3 is only used for movement events
(for other events the trailing m/M marks a release instead), but in
normal mouse mode we can't tell so easily. So for that, look at the
previous event instead - if it is drag+release as well, then the current
event is a movement event.


# 1.43 11-Jan-2017 nicm

Add some missing special keys to key_string_lookup_key, fix a mouse
check in server_client_handle_key, and tweak a comment.


# 1.42 05-Jan-2017 nicm

Highlight all occurrences of search string after searching in copy mode.


# 1.41 23-Nov-2016 nicm

Error on invalid modifier keys.


# 1.40 11-Oct-2016 nicm

Support double and triple clicks (they are cumulative, so double is
fired then triple), and use for select-word and select-line in copy
mode. Inspired by a different solution from Omar Sandoval.


# 1.39 10-Oct-2016 nicm

Loads more static, except for cmd-*.c and window-*.c.


Revision tags: OPENBSD_6_0_BASE
# 1.38 26-May-2016 nicm

Extend 0x1234 keys form to more bits so that Unicode keys work.


# 1.37 25-Apr-2016 nicm

Don't overwrite modifiers in the buffer when making UTF-8 strings,
append instead.


# 1.36 18-Mar-2016 nicm

Instead of reusing MouseUp at the finish of a drag, add a new key
MouseDragEnd. It can be useful to bind them separately in copy mode.


# 1.35 02-Mar-2016 nicm

Handle wcwidth() and mbtowc() failures in better style and drop
characters where we can't find the width (wcwidth() fails) on input, the
same as we drop invalid UTF-8. Suggested by schwarze@.


Revision tags: OPENBSD_5_9_BASE
# 1.34 19-Jan-2016 nicm

I no longer use my SourceForge address so replace it.


# 1.33 12-Dec-2015 nicm

Allow prefix and prefix2 to be set to None to disable (useful if you
would rather bind the prefix in the root table).


# 1.32 14-Nov-2015 nicm

All these return values from utf8_* are confusing, use an enum.


# 1.31 14-Nov-2015 nicm

Couple of assignments to remove compiler warnings.


# 1.30 14-Nov-2015 nicm

Be more strict about invalid UTF-8.


# 1.29 12-Nov-2015 nicm

Rename overly-long utf8data to ud throughout.


# 1.28 12-Nov-2015 nicm

Support UTF-8 key bindings by expanding the key type from int to
uint64_t and converting UTF-8 to Unicode on input and the reverse on
output. (This allows key bindings, there are still omissions - the
largest being that the various prompts do not accept UTF-8.)


# 1.27 26-Oct-2015 nicm

Handle unknown keys more gracefully, return a string instead of NULL.


Revision tags: OPENBSD_5_8_BASE
# 1.26 19-Apr-2015 nicm

Rewrite of tmux mouse support which was a mess. Instead of having
options for "mouse-this" and "mouse-that", mouse events may be bound as
keys and there is one option "mouse" that turns on mouse support
entirely (set -g mouse on).

See the new MOUSE SUPPORT section of the man page for description of the
key names and new flags (-t= to specify the pane or window under mouse
as a target, and send-keys -M to pass through a mouse event).

The default builtin bindings for the mouse are:

bind -n MouseDown1Pane select-pane -t=; send-keys -M
bind -n MouseDown1Status select-window -t=
bind -n MouseDrag1Pane copy-mode -M
bind -n MouseDrag1Border resize-pane -M

To get the effect of turning mode-mouse off, do:

unbind -n MouseDrag1Pane
unbind -temacs-copy MouseDrag1Pane

The old mouse options are now gone, set-option -q may be used to
suppress warnings if mixing configuration files.


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.25 21-Jul-2014 nicm

Drop explicit support for F13-F20 and change to match the xterm terminfo
entry:

F13-F24 are S-F1 to S-F12
F25-F36 are C-F1 to C-F12
F37-F48 are C-S-F1 to C-S-F12
F49-F60 are M-F1 to M-F12
and F61-F63 are M-S-F1 to M-S-F3

This should be no difference for applications inside tmux, but means
that any key binding for F13 will need to be replaced by S-F1 and so on.


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.24 22-Mar-2013 nicm

In terminals with XT, turn on modifyOtherKeys=1 with the escape sequence
and handle the most common set. Pass them through if xterm-keys is on.


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.23 04-Mar-2012 nicm

Accept hex values as keys, needed for send-keys, based on a diff from
George Nachman.


Revision tags: OPENBSD_5_1_BASE
# 1.22 21-Jan-2012 nicm

Drop the ability to have a list of keys in the prefix in favour of two
separate options, prefix and prefix2. This simplifies the code and gets
rid the data options type which was only used for this one option.

Also add a -2 flag to send-prefix to send the secondary prefix key,
fixing a cause of minor irritation.

People who want three prefix keys are out of luck :-).


# 1.21 23-Oct-2011 nicm

Alias NPage/PPage as PageDown/PgDn/PageUp/PgUp to reduce occasional
confusion.


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.20 23-Jan-2011 nicm

Allow top-bit-set characters to be used for key bindings, from Tiago
Cunha.


# 1.19 01-Jan-2011 nicm

Last few tables that should be const.


Revision tags: OPENBSD_4_8_BASE
# 1.18 06-Jun-2010 nicm

Use a macro-based mask for obtaining a key or modifier-set from the
combination. Display C-@, etc, as C-Space, in list-keys. By Micah Cowan.


# 1.17 05-Jun-2010 nicm

Fix binding of C-Space/C-@, from Micah Cowan.


# 1.16 03-May-2010 mcbride

Make C-] and other punctuation-based control key combinations work again.

ok nicm


# 1.15 23-Apr-2010 nicm

When converting A-Z into a control character, want to subtract 64 not
65... whoops.


# 1.14 21-Apr-2010 nicm

Rewrite key string conversions to be readable and to work properly for
multiple modifiers.


Revision tags: OPENBSD_4_7_BASE
# 1.13 14-Jan-2010 nicm

Permit S- prefix on keys for shift. Relatively few terminals support this
(basically xterm only) and even fewer have them in terminfo (kLFT2 and kRIT2).


# 1.12 03-Dec-2009 nicm

Massive spaces->tabs and trailing whitespace cleanup, hopefully for the last
time now I've configured emacs to make them displayed in really annoying
colours...


# 1.11 26-Nov-2009 nicm

Make types clearer and lint happier.


# 1.10 10-Nov-2009 nicm

Lookup key as a named key (eg 'Space') before checking for single character
keys, makes C-Space/M-Space etc resolve to the correct key code.


# 1.9 26-Oct-2009 nicm

Rename keypad keys to something more useful.


# 1.8 06-Oct-2009 nicm

Accept ^? for backspace as well as BSpace.


# 1.7 04-Oct-2009 nicm

Add a key string for space ("Space") and document the names, suggested by
guenther@. Also document how to bind " and ', suggested by miod@.


# 1.6 28-Jul-2009 nicm

Accept and print "Enter" and "Escape" for keys rather than C-m and C-[.


# 1.5 26-Jul-2009 nicm

Detect backspace by looking at termios VERASE and translate it into \177 (which
matches screen's behaviour if not its termcap/terminfo entry). The terminfo kbs
cap is often wrong or missing so it can't be used, and just assuming \177 may
be wrong.


# 1.4 24-Jul-2009 nicm

Accept lowercase c- and m- prefix as well as C- and M-.


# 1.3 21-Jul-2009 nicm

Tidy up keys: use an enum for the key codes, and remove the macros which just
wrap flag sets/clears/tests.


# 1.2 14-Jul-2009 nicm

Add backspace key to named keys.


Revision tags: OPENBSD_4_6_BASE
# 1.1 01-Jun-2009 nicm

Import tmux, a terminal multiplexor allowing (among other things) a single
terminal to be switched between several different windows and programs
displayed on one terminal be detached from one terminal and moved to another.

ok deraadt pirofti


# 1.65 07-Apr-2021 nicm

Restore previous behaviour so that C-X remains the same as C-x. Instead,
translate incoming extended keys so that they are consistent.


# 1.64 07-Apr-2021 nicm

Fixes for extended keys: 1) allow C-x and C-X to be bound separately
since some terminals report them differently 2) use the "backspace"
option to translate backspace 3) map ctrl which are have the ctrl
implied (such as C-x) properly when the terminal reports both the key
and the modifier.

Note that any key bindings for C-X where C-x is meant must now be
changed.


Revision tags: OPENBSD_6_8_BASE
# 1.63 06-Jul-2020 nicm

Always send xterm-style keys for M-Left and M-Right. GitHub issue 2296.


# 1.62 27-Jun-2020 nicm

Fix 0x Unicode character parsing, GitHub issue 2286.


# 1.61 25-May-2020 nicm

Use the internal representation for UTF-8 keys instead of wchar_t and
drop some code only needed for that.


# 1.60 20-May-2020 nicm

Fix a couple more places where the key flags need to be masked off.


# 1.59 20-May-2020 nicm

Key strings need to include the cursor and keypad flags now since the
output key lookup expects them already set.


# 1.58 16-May-2020 nicm

Separate key flags and modifiers, log key flags, make the "xterm" flag
more explicit and fix M- keys with a leading escape.


# 1.57 16-May-2020 nicm

Rename KEYC_ESCAPE to KEYC_META.


Revision tags: OPENBSD_6_7_BASE
# 1.56 09-Apr-2020 nicm

Some unnecessary assignments and unused variables.


# 1.55 31-Mar-2020 nicm

Add a "second click" key type which is fired for the second click of a
double click, even if the timer hasn't expired to confirm it isn't
actually a triple click. Provides a way for people who don't care about
triple clicks or can make their commands have no side effects to avoid
the double click timer delay.


# 1.54 15-Mar-2020 nicm

Fix C-Space key string.


# 1.53 19-Feb-2020 nicm

A few fixes to make modifier keys and dragging work - need to remove the
modifiers before checking for the dragging marker key, and apply them
before looking up the end key. Also fix key-to-string with modifiers for
special keys.


# 1.52 14-Nov-2019 nicm

Add an option to set the key sent by backspace for those whose system
uses ^H rather than ^?. GitHub issue 1969.


Revision tags: OPENBSD_6_6_BASE
# 1.51 09-Jul-2019 nicm

Add a -H flag to send-keys to send literal keys given as hex numbers
(needed for control clients to send mouse sequences). Also add some
format flags for UTF-8 and SGR mouse mode. Requested by Bradley Smith in
GitHub issues 1832 and 1833.


Revision tags: OPENBSD_6_5_BASE
# 1.50 18-Oct-2018 nicm

Support for windows larger than visible on the attached client. This has
been a limitation for a long time.

There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.

The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.

If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.

Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).

The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.

For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..

If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.

The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.

The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.


Revision tags: OPENBSD_6_4_BASE
# 1.49 22-Aug-2018 nicm

Add StatusLeft and StatusRight mouse key modifiers for the left and
right parts of the status line.


# 1.48 16-Jul-2018 nicm

Add an "Any" key to run a command if a key is pressed that is not bound
in the current key table. GitHub issue 1404.


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.47 23-Jun-2017 nicm

Add user-keys option to allow user-defined keys to be set, from Dan
Aloni.


# 1.46 12-Jun-2017 nicm

Add explicit keys for the bracketed paste sequences, both to avoid mix
ups with other keys and to make logs clearer.


Revision tags: OPENBSD_6_1_BASE
# 1.45 22-Feb-2017 nicm

Minor bits: fix an array size, add comment, make grid_cell_entry static.


# 1.44 01-Feb-2017 nicm

Implement "all event" (1003) mouse mode but in a way that works. The
main issue is that if we have two panes, A with 1002 and B with 1003, we
need to set 1003 outside tmux in order to get all the mouse events, but
then we need to suppress the ones that pane A doesn't want. This is easy
in SGR mouse mode, because buttons == 3 is only used for movement events
(for other events the trailing m/M marks a release instead), but in
normal mouse mode we can't tell so easily. So for that, look at the
previous event instead - if it is drag+release as well, then the current
event is a movement event.


# 1.43 11-Jan-2017 nicm

Add some missing special keys to key_string_lookup_key, fix a mouse
check in server_client_handle_key, and tweak a comment.


# 1.42 05-Jan-2017 nicm

Highlight all occurrences of search string after searching in copy mode.


# 1.41 23-Nov-2016 nicm

Error on invalid modifier keys.


# 1.40 11-Oct-2016 nicm

Support double and triple clicks (they are cumulative, so double is
fired then triple), and use for select-word and select-line in copy
mode. Inspired by a different solution from Omar Sandoval.


# 1.39 10-Oct-2016 nicm

Loads more static, except for cmd-*.c and window-*.c.


Revision tags: OPENBSD_6_0_BASE
# 1.38 26-May-2016 nicm

Extend 0x1234 keys form to more bits so that Unicode keys work.


# 1.37 25-Apr-2016 nicm

Don't overwrite modifiers in the buffer when making UTF-8 strings,
append instead.


# 1.36 18-Mar-2016 nicm

Instead of reusing MouseUp at the finish of a drag, add a new key
MouseDragEnd. It can be useful to bind them separately in copy mode.


# 1.35 02-Mar-2016 nicm

Handle wcwidth() and mbtowc() failures in better style and drop
characters where we can't find the width (wcwidth() fails) on input, the
same as we drop invalid UTF-8. Suggested by schwarze@.


Revision tags: OPENBSD_5_9_BASE
# 1.34 19-Jan-2016 nicm

I no longer use my SourceForge address so replace it.


# 1.33 12-Dec-2015 nicm

Allow prefix and prefix2 to be set to None to disable (useful if you
would rather bind the prefix in the root table).


# 1.32 14-Nov-2015 nicm

All these return values from utf8_* are confusing, use an enum.


# 1.31 14-Nov-2015 nicm

Couple of assignments to remove compiler warnings.


# 1.30 14-Nov-2015 nicm

Be more strict about invalid UTF-8.


# 1.29 12-Nov-2015 nicm

Rename overly-long utf8data to ud throughout.


# 1.28 12-Nov-2015 nicm

Support UTF-8 key bindings by expanding the key type from int to
uint64_t and converting UTF-8 to Unicode on input and the reverse on
output. (This allows key bindings, there are still omissions - the
largest being that the various prompts do not accept UTF-8.)


# 1.27 26-Oct-2015 nicm

Handle unknown keys more gracefully, return a string instead of NULL.


Revision tags: OPENBSD_5_8_BASE
# 1.26 19-Apr-2015 nicm

Rewrite of tmux mouse support which was a mess. Instead of having
options for "mouse-this" and "mouse-that", mouse events may be bound as
keys and there is one option "mouse" that turns on mouse support
entirely (set -g mouse on).

See the new MOUSE SUPPORT section of the man page for description of the
key names and new flags (-t= to specify the pane or window under mouse
as a target, and send-keys -M to pass through a mouse event).

The default builtin bindings for the mouse are:

bind -n MouseDown1Pane select-pane -t=; send-keys -M
bind -n MouseDown1Status select-window -t=
bind -n MouseDrag1Pane copy-mode -M
bind -n MouseDrag1Border resize-pane -M

To get the effect of turning mode-mouse off, do:

unbind -n MouseDrag1Pane
unbind -temacs-copy MouseDrag1Pane

The old mouse options are now gone, set-option -q may be used to
suppress warnings if mixing configuration files.


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.25 21-Jul-2014 nicm

Drop explicit support for F13-F20 and change to match the xterm terminfo
entry:

F13-F24 are S-F1 to S-F12
F25-F36 are C-F1 to C-F12
F37-F48 are C-S-F1 to C-S-F12
F49-F60 are M-F1 to M-F12
and F61-F63 are M-S-F1 to M-S-F3

This should be no difference for applications inside tmux, but means
that any key binding for F13 will need to be replaced by S-F1 and so on.


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.24 22-Mar-2013 nicm

In terminals with XT, turn on modifyOtherKeys=1 with the escape sequence
and handle the most common set. Pass them through if xterm-keys is on.


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.23 04-Mar-2012 nicm

Accept hex values as keys, needed for send-keys, based on a diff from
George Nachman.


Revision tags: OPENBSD_5_1_BASE
# 1.22 21-Jan-2012 nicm

Drop the ability to have a list of keys in the prefix in favour of two
separate options, prefix and prefix2. This simplifies the code and gets
rid the data options type which was only used for this one option.

Also add a -2 flag to send-prefix to send the secondary prefix key,
fixing a cause of minor irritation.

People who want three prefix keys are out of luck :-).


# 1.21 23-Oct-2011 nicm

Alias NPage/PPage as PageDown/PgDn/PageUp/PgUp to reduce occasional
confusion.


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.20 23-Jan-2011 nicm

Allow top-bit-set characters to be used for key bindings, from Tiago
Cunha.


# 1.19 01-Jan-2011 nicm

Last few tables that should be const.


Revision tags: OPENBSD_4_8_BASE
# 1.18 06-Jun-2010 nicm

Use a macro-based mask for obtaining a key or modifier-set from the
combination. Display C-@, etc, as C-Space, in list-keys. By Micah Cowan.


# 1.17 05-Jun-2010 nicm

Fix binding of C-Space/C-@, from Micah Cowan.


# 1.16 03-May-2010 mcbride

Make C-] and other punctuation-based control key combinations work again.

ok nicm


# 1.15 23-Apr-2010 nicm

When converting A-Z into a control character, want to subtract 64 not
65... whoops.


# 1.14 21-Apr-2010 nicm

Rewrite key string conversions to be readable and to work properly for
multiple modifiers.


Revision tags: OPENBSD_4_7_BASE
# 1.13 14-Jan-2010 nicm

Permit S- prefix on keys for shift. Relatively few terminals support this
(basically xterm only) and even fewer have them in terminfo (kLFT2 and kRIT2).


# 1.12 03-Dec-2009 nicm

Massive spaces->tabs and trailing whitespace cleanup, hopefully for the last
time now I've configured emacs to make them displayed in really annoying
colours...


# 1.11 26-Nov-2009 nicm

Make types clearer and lint happier.


# 1.10 10-Nov-2009 nicm

Lookup key as a named key (eg 'Space') before checking for single character
keys, makes C-Space/M-Space etc resolve to the correct key code.


# 1.9 26-Oct-2009 nicm

Rename keypad keys to something more useful.


# 1.8 06-Oct-2009 nicm

Accept ^? for backspace as well as BSpace.


# 1.7 04-Oct-2009 nicm

Add a key string for space ("Space") and document the names, suggested by
guenther@. Also document how to bind " and ', suggested by miod@.


# 1.6 28-Jul-2009 nicm

Accept and print "Enter" and "Escape" for keys rather than C-m and C-[.


# 1.5 26-Jul-2009 nicm

Detect backspace by looking at termios VERASE and translate it into \177 (which
matches screen's behaviour if not its termcap/terminfo entry). The terminfo kbs
cap is often wrong or missing so it can't be used, and just assuming \177 may
be wrong.


# 1.4 24-Jul-2009 nicm

Accept lowercase c- and m- prefix as well as C- and M-.


# 1.3 21-Jul-2009 nicm

Tidy up keys: use an enum for the key codes, and remove the macros which just
wrap flag sets/clears/tests.


# 1.2 14-Jul-2009 nicm

Add backspace key to named keys.


Revision tags: OPENBSD_4_6_BASE
# 1.1 01-Jun-2009 nicm

Import tmux, a terminal multiplexor allowing (among other things) a single
terminal to be switched between several different windows and programs
displayed on one terminal be detached from one terminal and moved to another.

ok deraadt pirofti


# 1.64 07-Apr-2021 nicm

Fixes for extended keys: 1) allow C-x and C-X to be bound separately
since some terminals report them differently 2) use the "backspace"
option to translate backspace 3) map ctrl which are have the ctrl
implied (such as C-x) properly when the terminal reports both the key
and the modifier.

Note that any key bindings for C-X where C-x is meant must now be
changed.


Revision tags: OPENBSD_6_8_BASE
# 1.63 06-Jul-2020 nicm

Always send xterm-style keys for M-Left and M-Right. GitHub issue 2296.


# 1.62 27-Jun-2020 nicm

Fix 0x Unicode character parsing, GitHub issue 2286.


# 1.61 25-May-2020 nicm

Use the internal representation for UTF-8 keys instead of wchar_t and
drop some code only needed for that.


# 1.60 20-May-2020 nicm

Fix a couple more places where the key flags need to be masked off.


# 1.59 20-May-2020 nicm

Key strings need to include the cursor and keypad flags now since the
output key lookup expects them already set.


# 1.58 16-May-2020 nicm

Separate key flags and modifiers, log key flags, make the "xterm" flag
more explicit and fix M- keys with a leading escape.


# 1.57 16-May-2020 nicm

Rename KEYC_ESCAPE to KEYC_META.


Revision tags: OPENBSD_6_7_BASE
# 1.56 09-Apr-2020 nicm

Some unnecessary assignments and unused variables.


# 1.55 31-Mar-2020 nicm

Add a "second click" key type which is fired for the second click of a
double click, even if the timer hasn't expired to confirm it isn't
actually a triple click. Provides a way for people who don't care about
triple clicks or can make their commands have no side effects to avoid
the double click timer delay.


# 1.54 15-Mar-2020 nicm

Fix C-Space key string.


# 1.53 19-Feb-2020 nicm

A few fixes to make modifier keys and dragging work - need to remove the
modifiers before checking for the dragging marker key, and apply them
before looking up the end key. Also fix key-to-string with modifiers for
special keys.


# 1.52 14-Nov-2019 nicm

Add an option to set the key sent by backspace for those whose system
uses ^H rather than ^?. GitHub issue 1969.


Revision tags: OPENBSD_6_6_BASE
# 1.51 09-Jul-2019 nicm

Add a -H flag to send-keys to send literal keys given as hex numbers
(needed for control clients to send mouse sequences). Also add some
format flags for UTF-8 and SGR mouse mode. Requested by Bradley Smith in
GitHub issues 1832 and 1833.


Revision tags: OPENBSD_6_5_BASE
# 1.50 18-Oct-2018 nicm

Support for windows larger than visible on the attached client. This has
been a limitation for a long time.

There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.

The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.

If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.

Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).

The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.

For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..

If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.

The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.

The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.


Revision tags: OPENBSD_6_4_BASE
# 1.49 22-Aug-2018 nicm

Add StatusLeft and StatusRight mouse key modifiers for the left and
right parts of the status line.


# 1.48 16-Jul-2018 nicm

Add an "Any" key to run a command if a key is pressed that is not bound
in the current key table. GitHub issue 1404.


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.47 23-Jun-2017 nicm

Add user-keys option to allow user-defined keys to be set, from Dan
Aloni.


# 1.46 12-Jun-2017 nicm

Add explicit keys for the bracketed paste sequences, both to avoid mix
ups with other keys and to make logs clearer.


Revision tags: OPENBSD_6_1_BASE
# 1.45 22-Feb-2017 nicm

Minor bits: fix an array size, add comment, make grid_cell_entry static.


# 1.44 01-Feb-2017 nicm

Implement "all event" (1003) mouse mode but in a way that works. The
main issue is that if we have two panes, A with 1002 and B with 1003, we
need to set 1003 outside tmux in order to get all the mouse events, but
then we need to suppress the ones that pane A doesn't want. This is easy
in SGR mouse mode, because buttons == 3 is only used for movement events
(for other events the trailing m/M marks a release instead), but in
normal mouse mode we can't tell so easily. So for that, look at the
previous event instead - if it is drag+release as well, then the current
event is a movement event.


# 1.43 11-Jan-2017 nicm

Add some missing special keys to key_string_lookup_key, fix a mouse
check in server_client_handle_key, and tweak a comment.


# 1.42 05-Jan-2017 nicm

Highlight all occurrences of search string after searching in copy mode.


# 1.41 23-Nov-2016 nicm

Error on invalid modifier keys.


# 1.40 11-Oct-2016 nicm

Support double and triple clicks (they are cumulative, so double is
fired then triple), and use for select-word and select-line in copy
mode. Inspired by a different solution from Omar Sandoval.


# 1.39 10-Oct-2016 nicm

Loads more static, except for cmd-*.c and window-*.c.


Revision tags: OPENBSD_6_0_BASE
# 1.38 26-May-2016 nicm

Extend 0x1234 keys form to more bits so that Unicode keys work.


# 1.37 25-Apr-2016 nicm

Don't overwrite modifiers in the buffer when making UTF-8 strings,
append instead.


# 1.36 18-Mar-2016 nicm

Instead of reusing MouseUp at the finish of a drag, add a new key
MouseDragEnd. It can be useful to bind them separately in copy mode.


# 1.35 02-Mar-2016 nicm

Handle wcwidth() and mbtowc() failures in better style and drop
characters where we can't find the width (wcwidth() fails) on input, the
same as we drop invalid UTF-8. Suggested by schwarze@.


Revision tags: OPENBSD_5_9_BASE
# 1.34 19-Jan-2016 nicm

I no longer use my SourceForge address so replace it.


# 1.33 12-Dec-2015 nicm

Allow prefix and prefix2 to be set to None to disable (useful if you
would rather bind the prefix in the root table).


# 1.32 14-Nov-2015 nicm

All these return values from utf8_* are confusing, use an enum.


# 1.31 14-Nov-2015 nicm

Couple of assignments to remove compiler warnings.


# 1.30 14-Nov-2015 nicm

Be more strict about invalid UTF-8.


# 1.29 12-Nov-2015 nicm

Rename overly-long utf8data to ud throughout.


# 1.28 12-Nov-2015 nicm

Support UTF-8 key bindings by expanding the key type from int to
uint64_t and converting UTF-8 to Unicode on input and the reverse on
output. (This allows key bindings, there are still omissions - the
largest being that the various prompts do not accept UTF-8.)


# 1.27 26-Oct-2015 nicm

Handle unknown keys more gracefully, return a string instead of NULL.


Revision tags: OPENBSD_5_8_BASE
# 1.26 19-Apr-2015 nicm

Rewrite of tmux mouse support which was a mess. Instead of having
options for "mouse-this" and "mouse-that", mouse events may be bound as
keys and there is one option "mouse" that turns on mouse support
entirely (set -g mouse on).

See the new MOUSE SUPPORT section of the man page for description of the
key names and new flags (-t= to specify the pane or window under mouse
as a target, and send-keys -M to pass through a mouse event).

The default builtin bindings for the mouse are:

bind -n MouseDown1Pane select-pane -t=; send-keys -M
bind -n MouseDown1Status select-window -t=
bind -n MouseDrag1Pane copy-mode -M
bind -n MouseDrag1Border resize-pane -M

To get the effect of turning mode-mouse off, do:

unbind -n MouseDrag1Pane
unbind -temacs-copy MouseDrag1Pane

The old mouse options are now gone, set-option -q may be used to
suppress warnings if mixing configuration files.


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.25 21-Jul-2014 nicm

Drop explicit support for F13-F20 and change to match the xterm terminfo
entry:

F13-F24 are S-F1 to S-F12
F25-F36 are C-F1 to C-F12
F37-F48 are C-S-F1 to C-S-F12
F49-F60 are M-F1 to M-F12
and F61-F63 are M-S-F1 to M-S-F3

This should be no difference for applications inside tmux, but means
that any key binding for F13 will need to be replaced by S-F1 and so on.


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.24 22-Mar-2013 nicm

In terminals with XT, turn on modifyOtherKeys=1 with the escape sequence
and handle the most common set. Pass them through if xterm-keys is on.


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.23 04-Mar-2012 nicm

Accept hex values as keys, needed for send-keys, based on a diff from
George Nachman.


Revision tags: OPENBSD_5_1_BASE
# 1.22 21-Jan-2012 nicm

Drop the ability to have a list of keys in the prefix in favour of two
separate options, prefix and prefix2. This simplifies the code and gets
rid the data options type which was only used for this one option.

Also add a -2 flag to send-prefix to send the secondary prefix key,
fixing a cause of minor irritation.

People who want three prefix keys are out of luck :-).


# 1.21 23-Oct-2011 nicm

Alias NPage/PPage as PageDown/PgDn/PageUp/PgUp to reduce occasional
confusion.


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.20 23-Jan-2011 nicm

Allow top-bit-set characters to be used for key bindings, from Tiago
Cunha.


# 1.19 01-Jan-2011 nicm

Last few tables that should be const.


Revision tags: OPENBSD_4_8_BASE
# 1.18 06-Jun-2010 nicm

Use a macro-based mask for obtaining a key or modifier-set from the
combination. Display C-@, etc, as C-Space, in list-keys. By Micah Cowan.


# 1.17 05-Jun-2010 nicm

Fix binding of C-Space/C-@, from Micah Cowan.


# 1.16 03-May-2010 mcbride

Make C-] and other punctuation-based control key combinations work again.

ok nicm


# 1.15 23-Apr-2010 nicm

When converting A-Z into a control character, want to subtract 64 not
65... whoops.


# 1.14 21-Apr-2010 nicm

Rewrite key string conversions to be readable and to work properly for
multiple modifiers.


Revision tags: OPENBSD_4_7_BASE
# 1.13 14-Jan-2010 nicm

Permit S- prefix on keys for shift. Relatively few terminals support this
(basically xterm only) and even fewer have them in terminfo (kLFT2 and kRIT2).


# 1.12 03-Dec-2009 nicm

Massive spaces->tabs and trailing whitespace cleanup, hopefully for the last
time now I've configured emacs to make them displayed in really annoying
colours...


# 1.11 26-Nov-2009 nicm

Make types clearer and lint happier.


# 1.10 10-Nov-2009 nicm

Lookup key as a named key (eg 'Space') before checking for single character
keys, makes C-Space/M-Space etc resolve to the correct key code.


# 1.9 26-Oct-2009 nicm

Rename keypad keys to something more useful.


# 1.8 06-Oct-2009 nicm

Accept ^? for backspace as well as BSpace.


# 1.7 04-Oct-2009 nicm

Add a key string for space ("Space") and document the names, suggested by
guenther@. Also document how to bind " and ', suggested by miod@.


# 1.6 28-Jul-2009 nicm

Accept and print "Enter" and "Escape" for keys rather than C-m and C-[.


# 1.5 26-Jul-2009 nicm

Detect backspace by looking at termios VERASE and translate it into \177 (which
matches screen's behaviour if not its termcap/terminfo entry). The terminfo kbs
cap is often wrong or missing so it can't be used, and just assuming \177 may
be wrong.


# 1.4 24-Jul-2009 nicm

Accept lowercase c- and m- prefix as well as C- and M-.


# 1.3 21-Jul-2009 nicm

Tidy up keys: use an enum for the key codes, and remove the macros which just
wrap flag sets/clears/tests.


# 1.2 14-Jul-2009 nicm

Add backspace key to named keys.


Revision tags: OPENBSD_4_6_BASE
# 1.1 01-Jun-2009 nicm

Import tmux, a terminal multiplexor allowing (among other things) a single
terminal to be switched between several different windows and programs
displayed on one terminal be detached from one terminal and moved to another.

ok deraadt pirofti


# 1.63 06-Jul-2020 nicm

Always send xterm-style keys for M-Left and M-Right. GitHub issue 2296.


# 1.62 27-Jun-2020 nicm

Fix 0x Unicode character parsing, GitHub issue 2286.


# 1.61 25-May-2020 nicm

Use the internal representation for UTF-8 keys instead of wchar_t and
drop some code only needed for that.


# 1.60 20-May-2020 nicm

Fix a couple more places where the key flags need to be masked off.


# 1.59 20-May-2020 nicm

Key strings need to include the cursor and keypad flags now since the
output key lookup expects them already set.


# 1.58 16-May-2020 nicm

Separate key flags and modifiers, log key flags, make the "xterm" flag
more explicit and fix M- keys with a leading escape.


# 1.57 16-May-2020 nicm

Rename KEYC_ESCAPE to KEYC_META.


Revision tags: OPENBSD_6_7_BASE
# 1.56 09-Apr-2020 nicm

Some unnecessary assignments and unused variables.


# 1.55 31-Mar-2020 nicm

Add a "second click" key type which is fired for the second click of a
double click, even if the timer hasn't expired to confirm it isn't
actually a triple click. Provides a way for people who don't care about
triple clicks or can make their commands have no side effects to avoid
the double click timer delay.


# 1.54 15-Mar-2020 nicm

Fix C-Space key string.


# 1.53 19-Feb-2020 nicm

A few fixes to make modifier keys and dragging work - need to remove the
modifiers before checking for the dragging marker key, and apply them
before looking up the end key. Also fix key-to-string with modifiers for
special keys.


# 1.52 14-Nov-2019 nicm

Add an option to set the key sent by backspace for those whose system
uses ^H rather than ^?. GitHub issue 1969.


Revision tags: OPENBSD_6_6_BASE
# 1.51 09-Jul-2019 nicm

Add a -H flag to send-keys to send literal keys given as hex numbers
(needed for control clients to send mouse sequences). Also add some
format flags for UTF-8 and SGR mouse mode. Requested by Bradley Smith in
GitHub issues 1832 and 1833.


Revision tags: OPENBSD_6_5_BASE
# 1.50 18-Oct-2018 nicm

Support for windows larger than visible on the attached client. This has
been a limitation for a long time.

There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.

The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.

If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.

Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).

The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.

For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..

If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.

The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.

The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.


Revision tags: OPENBSD_6_4_BASE
# 1.49 22-Aug-2018 nicm

Add StatusLeft and StatusRight mouse key modifiers for the left and
right parts of the status line.


# 1.48 16-Jul-2018 nicm

Add an "Any" key to run a command if a key is pressed that is not bound
in the current key table. GitHub issue 1404.


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.47 23-Jun-2017 nicm

Add user-keys option to allow user-defined keys to be set, from Dan
Aloni.


# 1.46 12-Jun-2017 nicm

Add explicit keys for the bracketed paste sequences, both to avoid mix
ups with other keys and to make logs clearer.


Revision tags: OPENBSD_6_1_BASE
# 1.45 22-Feb-2017 nicm

Minor bits: fix an array size, add comment, make grid_cell_entry static.


# 1.44 01-Feb-2017 nicm

Implement "all event" (1003) mouse mode but in a way that works. The
main issue is that if we have two panes, A with 1002 and B with 1003, we
need to set 1003 outside tmux in order to get all the mouse events, but
then we need to suppress the ones that pane A doesn't want. This is easy
in SGR mouse mode, because buttons == 3 is only used for movement events
(for other events the trailing m/M marks a release instead), but in
normal mouse mode we can't tell so easily. So for that, look at the
previous event instead - if it is drag+release as well, then the current
event is a movement event.


# 1.43 11-Jan-2017 nicm

Add some missing special keys to key_string_lookup_key, fix a mouse
check in server_client_handle_key, and tweak a comment.


# 1.42 05-Jan-2017 nicm

Highlight all occurrences of search string after searching in copy mode.


# 1.41 23-Nov-2016 nicm

Error on invalid modifier keys.


# 1.40 11-Oct-2016 nicm

Support double and triple clicks (they are cumulative, so double is
fired then triple), and use for select-word and select-line in copy
mode. Inspired by a different solution from Omar Sandoval.


# 1.39 10-Oct-2016 nicm

Loads more static, except for cmd-*.c and window-*.c.


Revision tags: OPENBSD_6_0_BASE
# 1.38 26-May-2016 nicm

Extend 0x1234 keys form to more bits so that Unicode keys work.


# 1.37 25-Apr-2016 nicm

Don't overwrite modifiers in the buffer when making UTF-8 strings,
append instead.


# 1.36 18-Mar-2016 nicm

Instead of reusing MouseUp at the finish of a drag, add a new key
MouseDragEnd. It can be useful to bind them separately in copy mode.


# 1.35 02-Mar-2016 nicm

Handle wcwidth() and mbtowc() failures in better style and drop
characters where we can't find the width (wcwidth() fails) on input, the
same as we drop invalid UTF-8. Suggested by schwarze@.


Revision tags: OPENBSD_5_9_BASE
# 1.34 19-Jan-2016 nicm

I no longer use my SourceForge address so replace it.


# 1.33 12-Dec-2015 nicm

Allow prefix and prefix2 to be set to None to disable (useful if you
would rather bind the prefix in the root table).


# 1.32 14-Nov-2015 nicm

All these return values from utf8_* are confusing, use an enum.


# 1.31 14-Nov-2015 nicm

Couple of assignments to remove compiler warnings.


# 1.30 14-Nov-2015 nicm

Be more strict about invalid UTF-8.


# 1.29 12-Nov-2015 nicm

Rename overly-long utf8data to ud throughout.


# 1.28 12-Nov-2015 nicm

Support UTF-8 key bindings by expanding the key type from int to
uint64_t and converting UTF-8 to Unicode on input and the reverse on
output. (This allows key bindings, there are still omissions - the
largest being that the various prompts do not accept UTF-8.)


# 1.27 26-Oct-2015 nicm

Handle unknown keys more gracefully, return a string instead of NULL.


Revision tags: OPENBSD_5_8_BASE
# 1.26 19-Apr-2015 nicm

Rewrite of tmux mouse support which was a mess. Instead of having
options for "mouse-this" and "mouse-that", mouse events may be bound as
keys and there is one option "mouse" that turns on mouse support
entirely (set -g mouse on).

See the new MOUSE SUPPORT section of the man page for description of the
key names and new flags (-t= to specify the pane or window under mouse
as a target, and send-keys -M to pass through a mouse event).

The default builtin bindings for the mouse are:

bind -n MouseDown1Pane select-pane -t=; send-keys -M
bind -n MouseDown1Status select-window -t=
bind -n MouseDrag1Pane copy-mode -M
bind -n MouseDrag1Border resize-pane -M

To get the effect of turning mode-mouse off, do:

unbind -n MouseDrag1Pane
unbind -temacs-copy MouseDrag1Pane

The old mouse options are now gone, set-option -q may be used to
suppress warnings if mixing configuration files.


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.25 21-Jul-2014 nicm

Drop explicit support for F13-F20 and change to match the xterm terminfo
entry:

F13-F24 are S-F1 to S-F12
F25-F36 are C-F1 to C-F12
F37-F48 are C-S-F1 to C-S-F12
F49-F60 are M-F1 to M-F12
and F61-F63 are M-S-F1 to M-S-F3

This should be no difference for applications inside tmux, but means
that any key binding for F13 will need to be replaced by S-F1 and so on.


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.24 22-Mar-2013 nicm

In terminals with XT, turn on modifyOtherKeys=1 with the escape sequence
and handle the most common set. Pass them through if xterm-keys is on.


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.23 04-Mar-2012 nicm

Accept hex values as keys, needed for send-keys, based on a diff from
George Nachman.


Revision tags: OPENBSD_5_1_BASE
# 1.22 21-Jan-2012 nicm

Drop the ability to have a list of keys in the prefix in favour of two
separate options, prefix and prefix2. This simplifies the code and gets
rid the data options type which was only used for this one option.

Also add a -2 flag to send-prefix to send the secondary prefix key,
fixing a cause of minor irritation.

People who want three prefix keys are out of luck :-).


# 1.21 23-Oct-2011 nicm

Alias NPage/PPage as PageDown/PgDn/PageUp/PgUp to reduce occasional
confusion.


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.20 23-Jan-2011 nicm

Allow top-bit-set characters to be used for key bindings, from Tiago
Cunha.


# 1.19 01-Jan-2011 nicm

Last few tables that should be const.


Revision tags: OPENBSD_4_8_BASE
# 1.18 06-Jun-2010 nicm

Use a macro-based mask for obtaining a key or modifier-set from the
combination. Display C-@, etc, as C-Space, in list-keys. By Micah Cowan.


# 1.17 05-Jun-2010 nicm

Fix binding of C-Space/C-@, from Micah Cowan.


# 1.16 03-May-2010 mcbride

Make C-] and other punctuation-based control key combinations work again.

ok nicm


# 1.15 23-Apr-2010 nicm

When converting A-Z into a control character, want to subtract 64 not
65... whoops.


# 1.14 21-Apr-2010 nicm

Rewrite key string conversions to be readable and to work properly for
multiple modifiers.


Revision tags: OPENBSD_4_7_BASE
# 1.13 14-Jan-2010 nicm

Permit S- prefix on keys for shift. Relatively few terminals support this
(basically xterm only) and even fewer have them in terminfo (kLFT2 and kRIT2).


# 1.12 03-Dec-2009 nicm

Massive spaces->tabs and trailing whitespace cleanup, hopefully for the last
time now I've configured emacs to make them displayed in really annoying
colours...


# 1.11 26-Nov-2009 nicm

Make types clearer and lint happier.


# 1.10 10-Nov-2009 nicm

Lookup key as a named key (eg 'Space') before checking for single character
keys, makes C-Space/M-Space etc resolve to the correct key code.


# 1.9 26-Oct-2009 nicm

Rename keypad keys to something more useful.


# 1.8 06-Oct-2009 nicm

Accept ^? for backspace as well as BSpace.


# 1.7 04-Oct-2009 nicm

Add a key string for space ("Space") and document the names, suggested by
guenther@. Also document how to bind " and ', suggested by miod@.


# 1.6 28-Jul-2009 nicm

Accept and print "Enter" and "Escape" for keys rather than C-m and C-[.


# 1.5 26-Jul-2009 nicm

Detect backspace by looking at termios VERASE and translate it into \177 (which
matches screen's behaviour if not its termcap/terminfo entry). The terminfo kbs
cap is often wrong or missing so it can't be used, and just assuming \177 may
be wrong.


# 1.4 24-Jul-2009 nicm

Accept lowercase c- and m- prefix as well as C- and M-.


# 1.3 21-Jul-2009 nicm

Tidy up keys: use an enum for the key codes, and remove the macros which just
wrap flag sets/clears/tests.


# 1.2 14-Jul-2009 nicm

Add backspace key to named keys.


Revision tags: OPENBSD_4_6_BASE
# 1.1 01-Jun-2009 nicm

Import tmux, a terminal multiplexor allowing (among other things) a single
terminal to be switched between several different windows and programs
displayed on one terminal be detached from one terminal and moved to another.

ok deraadt pirofti


# 1.62 27-Jun-2020 nicm

Fix 0x Unicode character parsing, GitHub issue 2286.


# 1.61 25-May-2020 nicm

Use the internal representation for UTF-8 keys instead of wchar_t and
drop some code only needed for that.


# 1.60 20-May-2020 nicm

Fix a couple more places where the key flags need to be masked off.


# 1.59 20-May-2020 nicm

Key strings need to include the cursor and keypad flags now since the
output key lookup expects them already set.


# 1.58 16-May-2020 nicm

Separate key flags and modifiers, log key flags, make the "xterm" flag
more explicit and fix M- keys with a leading escape.


# 1.57 16-May-2020 nicm

Rename KEYC_ESCAPE to KEYC_META.


Revision tags: OPENBSD_6_7_BASE
# 1.56 09-Apr-2020 nicm

Some unnecessary assignments and unused variables.


# 1.55 31-Mar-2020 nicm

Add a "second click" key type which is fired for the second click of a
double click, even if the timer hasn't expired to confirm it isn't
actually a triple click. Provides a way for people who don't care about
triple clicks or can make their commands have no side effects to avoid
the double click timer delay.


# 1.54 15-Mar-2020 nicm

Fix C-Space key string.


# 1.53 19-Feb-2020 nicm

A few fixes to make modifier keys and dragging work - need to remove the
modifiers before checking for the dragging marker key, and apply them
before looking up the end key. Also fix key-to-string with modifiers for
special keys.


# 1.52 14-Nov-2019 nicm

Add an option to set the key sent by backspace for those whose system
uses ^H rather than ^?. GitHub issue 1969.


Revision tags: OPENBSD_6_6_BASE
# 1.51 09-Jul-2019 nicm

Add a -H flag to send-keys to send literal keys given as hex numbers
(needed for control clients to send mouse sequences). Also add some
format flags for UTF-8 and SGR mouse mode. Requested by Bradley Smith in
GitHub issues 1832 and 1833.


Revision tags: OPENBSD_6_5_BASE
# 1.50 18-Oct-2018 nicm

Support for windows larger than visible on the attached client. This has
been a limitation for a long time.

There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.

The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.

If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.

Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).

The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.

For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..

If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.

The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.

The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.


Revision tags: OPENBSD_6_4_BASE
# 1.49 22-Aug-2018 nicm

Add StatusLeft and StatusRight mouse key modifiers for the left and
right parts of the status line.


# 1.48 16-Jul-2018 nicm

Add an "Any" key to run a command if a key is pressed that is not bound
in the current key table. GitHub issue 1404.


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.47 23-Jun-2017 nicm

Add user-keys option to allow user-defined keys to be set, from Dan
Aloni.


# 1.46 12-Jun-2017 nicm

Add explicit keys for the bracketed paste sequences, both to avoid mix
ups with other keys and to make logs clearer.


Revision tags: OPENBSD_6_1_BASE
# 1.45 22-Feb-2017 nicm

Minor bits: fix an array size, add comment, make grid_cell_entry static.


# 1.44 01-Feb-2017 nicm

Implement "all event" (1003) mouse mode but in a way that works. The
main issue is that if we have two panes, A with 1002 and B with 1003, we
need to set 1003 outside tmux in order to get all the mouse events, but
then we need to suppress the ones that pane A doesn't want. This is easy
in SGR mouse mode, because buttons == 3 is only used for movement events
(for other events the trailing m/M marks a release instead), but in
normal mouse mode we can't tell so easily. So for that, look at the
previous event instead - if it is drag+release as well, then the current
event is a movement event.


# 1.43 11-Jan-2017 nicm

Add some missing special keys to key_string_lookup_key, fix a mouse
check in server_client_handle_key, and tweak a comment.


# 1.42 05-Jan-2017 nicm

Highlight all occurrences of search string after searching in copy mode.


# 1.41 23-Nov-2016 nicm

Error on invalid modifier keys.


# 1.40 11-Oct-2016 nicm

Support double and triple clicks (they are cumulative, so double is
fired then triple), and use for select-word and select-line in copy
mode. Inspired by a different solution from Omar Sandoval.


# 1.39 10-Oct-2016 nicm

Loads more static, except for cmd-*.c and window-*.c.


Revision tags: OPENBSD_6_0_BASE
# 1.38 26-May-2016 nicm

Extend 0x1234 keys form to more bits so that Unicode keys work.


# 1.37 25-Apr-2016 nicm

Don't overwrite modifiers in the buffer when making UTF-8 strings,
append instead.


# 1.36 18-Mar-2016 nicm

Instead of reusing MouseUp at the finish of a drag, add a new key
MouseDragEnd. It can be useful to bind them separately in copy mode.


# 1.35 02-Mar-2016 nicm

Handle wcwidth() and mbtowc() failures in better style and drop
characters where we can't find the width (wcwidth() fails) on input, the
same as we drop invalid UTF-8. Suggested by schwarze@.


Revision tags: OPENBSD_5_9_BASE
# 1.34 19-Jan-2016 nicm

I no longer use my SourceForge address so replace it.


# 1.33 12-Dec-2015 nicm

Allow prefix and prefix2 to be set to None to disable (useful if you
would rather bind the prefix in the root table).


# 1.32 14-Nov-2015 nicm

All these return values from utf8_* are confusing, use an enum.


# 1.31 14-Nov-2015 nicm

Couple of assignments to remove compiler warnings.


# 1.30 14-Nov-2015 nicm

Be more strict about invalid UTF-8.


# 1.29 12-Nov-2015 nicm

Rename overly-long utf8data to ud throughout.


# 1.28 12-Nov-2015 nicm

Support UTF-8 key bindings by expanding the key type from int to
uint64_t and converting UTF-8 to Unicode on input and the reverse on
output. (This allows key bindings, there are still omissions - the
largest being that the various prompts do not accept UTF-8.)


# 1.27 26-Oct-2015 nicm

Handle unknown keys more gracefully, return a string instead of NULL.


Revision tags: OPENBSD_5_8_BASE
# 1.26 19-Apr-2015 nicm

Rewrite of tmux mouse support which was a mess. Instead of having
options for "mouse-this" and "mouse-that", mouse events may be bound as
keys and there is one option "mouse" that turns on mouse support
entirely (set -g mouse on).

See the new MOUSE SUPPORT section of the man page for description of the
key names and new flags (-t= to specify the pane or window under mouse
as a target, and send-keys -M to pass through a mouse event).

The default builtin bindings for the mouse are:

bind -n MouseDown1Pane select-pane -t=; send-keys -M
bind -n MouseDown1Status select-window -t=
bind -n MouseDrag1Pane copy-mode -M
bind -n MouseDrag1Border resize-pane -M

To get the effect of turning mode-mouse off, do:

unbind -n MouseDrag1Pane
unbind -temacs-copy MouseDrag1Pane

The old mouse options are now gone, set-option -q may be used to
suppress warnings if mixing configuration files.


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.25 21-Jul-2014 nicm

Drop explicit support for F13-F20 and change to match the xterm terminfo
entry:

F13-F24 are S-F1 to S-F12
F25-F36 are C-F1 to C-F12
F37-F48 are C-S-F1 to C-S-F12
F49-F60 are M-F1 to M-F12
and F61-F63 are M-S-F1 to M-S-F3

This should be no difference for applications inside tmux, but means
that any key binding for F13 will need to be replaced by S-F1 and so on.


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.24 22-Mar-2013 nicm

In terminals with XT, turn on modifyOtherKeys=1 with the escape sequence
and handle the most common set. Pass them through if xterm-keys is on.


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.23 04-Mar-2012 nicm

Accept hex values as keys, needed for send-keys, based on a diff from
George Nachman.


Revision tags: OPENBSD_5_1_BASE
# 1.22 21-Jan-2012 nicm

Drop the ability to have a list of keys in the prefix in favour of two
separate options, prefix and prefix2. This simplifies the code and gets
rid the data options type which was only used for this one option.

Also add a -2 flag to send-prefix to send the secondary prefix key,
fixing a cause of minor irritation.

People who want three prefix keys are out of luck :-).


# 1.21 23-Oct-2011 nicm

Alias NPage/PPage as PageDown/PgDn/PageUp/PgUp to reduce occasional
confusion.


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.20 23-Jan-2011 nicm

Allow top-bit-set characters to be used for key bindings, from Tiago
Cunha.


# 1.19 01-Jan-2011 nicm

Last few tables that should be const.


Revision tags: OPENBSD_4_8_BASE
# 1.18 06-Jun-2010 nicm

Use a macro-based mask for obtaining a key or modifier-set from the
combination. Display C-@, etc, as C-Space, in list-keys. By Micah Cowan.


# 1.17 05-Jun-2010 nicm

Fix binding of C-Space/C-@, from Micah Cowan.


# 1.16 03-May-2010 mcbride

Make C-] and other punctuation-based control key combinations work again.

ok nicm


# 1.15 23-Apr-2010 nicm

When converting A-Z into a control character, want to subtract 64 not
65... whoops.


# 1.14 21-Apr-2010 nicm

Rewrite key string conversions to be readable and to work properly for
multiple modifiers.


Revision tags: OPENBSD_4_7_BASE
# 1.13 14-Jan-2010 nicm

Permit S- prefix on keys for shift. Relatively few terminals support this
(basically xterm only) and even fewer have them in terminfo (kLFT2 and kRIT2).


# 1.12 03-Dec-2009 nicm

Massive spaces->tabs and trailing whitespace cleanup, hopefully for the last
time now I've configured emacs to make them displayed in really annoying
colours...


# 1.11 26-Nov-2009 nicm

Make types clearer and lint happier.


# 1.10 10-Nov-2009 nicm

Lookup key as a named key (eg 'Space') before checking for single character
keys, makes C-Space/M-Space etc resolve to the correct key code.


# 1.9 26-Oct-2009 nicm

Rename keypad keys to something more useful.


# 1.8 06-Oct-2009 nicm

Accept ^? for backspace as well as BSpace.


# 1.7 04-Oct-2009 nicm

Add a key string for space ("Space") and document the names, suggested by
guenther@. Also document how to bind " and ', suggested by miod@.


# 1.6 28-Jul-2009 nicm

Accept and print "Enter" and "Escape" for keys rather than C-m and C-[.


# 1.5 26-Jul-2009 nicm

Detect backspace by looking at termios VERASE and translate it into \177 (which
matches screen's behaviour if not its termcap/terminfo entry). The terminfo kbs
cap is often wrong or missing so it can't be used, and just assuming \177 may
be wrong.


# 1.4 24-Jul-2009 nicm

Accept lowercase c- and m- prefix as well as C- and M-.


# 1.3 21-Jul-2009 nicm

Tidy up keys: use an enum for the key codes, and remove the macros which just
wrap flag sets/clears/tests.


# 1.2 14-Jul-2009 nicm

Add backspace key to named keys.


Revision tags: OPENBSD_4_6_BASE
# 1.1 01-Jun-2009 nicm

Import tmux, a terminal multiplexor allowing (among other things) a single
terminal to be switched between several different windows and programs
displayed on one terminal be detached from one terminal and moved to another.

ok deraadt pirofti


# 1.61 25-May-2020 nicm

Use the internal representation for UTF-8 keys instead of wchar_t and
drop some code only needed for that.


# 1.60 20-May-2020 nicm

Fix a couple more places where the key flags need to be masked off.


# 1.59 20-May-2020 nicm

Key strings need to include the cursor and keypad flags now since the
output key lookup expects them already set.


# 1.58 16-May-2020 nicm

Separate key flags and modifiers, log key flags, make the "xterm" flag
more explicit and fix M- keys with a leading escape.


# 1.57 16-May-2020 nicm

Rename KEYC_ESCAPE to KEYC_META.


Revision tags: OPENBSD_6_7_BASE
# 1.56 09-Apr-2020 nicm

Some unnecessary assignments and unused variables.


# 1.55 31-Mar-2020 nicm

Add a "second click" key type which is fired for the second click of a
double click, even if the timer hasn't expired to confirm it isn't
actually a triple click. Provides a way for people who don't care about
triple clicks or can make their commands have no side effects to avoid
the double click timer delay.


# 1.54 15-Mar-2020 nicm

Fix C-Space key string.


# 1.53 19-Feb-2020 nicm

A few fixes to make modifier keys and dragging work - need to remove the
modifiers before checking for the dragging marker key, and apply them
before looking up the end key. Also fix key-to-string with modifiers for
special keys.


# 1.52 14-Nov-2019 nicm

Add an option to set the key sent by backspace for those whose system
uses ^H rather than ^?. GitHub issue 1969.


Revision tags: OPENBSD_6_6_BASE
# 1.51 09-Jul-2019 nicm

Add a -H flag to send-keys to send literal keys given as hex numbers
(needed for control clients to send mouse sequences). Also add some
format flags for UTF-8 and SGR mouse mode. Requested by Bradley Smith in
GitHub issues 1832 and 1833.


Revision tags: OPENBSD_6_5_BASE
# 1.50 18-Oct-2018 nicm

Support for windows larger than visible on the attached client. This has
been a limitation for a long time.

There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.

The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.

If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.

Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).

The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.

For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..

If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.

The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.

The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.


Revision tags: OPENBSD_6_4_BASE
# 1.49 22-Aug-2018 nicm

Add StatusLeft and StatusRight mouse key modifiers for the left and
right parts of the status line.


# 1.48 16-Jul-2018 nicm

Add an "Any" key to run a command if a key is pressed that is not bound
in the current key table. GitHub issue 1404.


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.47 23-Jun-2017 nicm

Add user-keys option to allow user-defined keys to be set, from Dan
Aloni.


# 1.46 12-Jun-2017 nicm

Add explicit keys for the bracketed paste sequences, both to avoid mix
ups with other keys and to make logs clearer.


Revision tags: OPENBSD_6_1_BASE
# 1.45 22-Feb-2017 nicm

Minor bits: fix an array size, add comment, make grid_cell_entry static.


# 1.44 01-Feb-2017 nicm

Implement "all event" (1003) mouse mode but in a way that works. The
main issue is that if we have two panes, A with 1002 and B with 1003, we
need to set 1003 outside tmux in order to get all the mouse events, but
then we need to suppress the ones that pane A doesn't want. This is easy
in SGR mouse mode, because buttons == 3 is only used for movement events
(for other events the trailing m/M marks a release instead), but in
normal mouse mode we can't tell so easily. So for that, look at the
previous event instead - if it is drag+release as well, then the current
event is a movement event.


# 1.43 11-Jan-2017 nicm

Add some missing special keys to key_string_lookup_key, fix a mouse
check in server_client_handle_key, and tweak a comment.


# 1.42 05-Jan-2017 nicm

Highlight all occurrences of search string after searching in copy mode.


# 1.41 23-Nov-2016 nicm

Error on invalid modifier keys.


# 1.40 11-Oct-2016 nicm

Support double and triple clicks (they are cumulative, so double is
fired then triple), and use for select-word and select-line in copy
mode. Inspired by a different solution from Omar Sandoval.


# 1.39 10-Oct-2016 nicm

Loads more static, except for cmd-*.c and window-*.c.


Revision tags: OPENBSD_6_0_BASE
# 1.38 26-May-2016 nicm

Extend 0x1234 keys form to more bits so that Unicode keys work.


# 1.37 25-Apr-2016 nicm

Don't overwrite modifiers in the buffer when making UTF-8 strings,
append instead.


# 1.36 18-Mar-2016 nicm

Instead of reusing MouseUp at the finish of a drag, add a new key
MouseDragEnd. It can be useful to bind them separately in copy mode.


# 1.35 02-Mar-2016 nicm

Handle wcwidth() and mbtowc() failures in better style and drop
characters where we can't find the width (wcwidth() fails) on input, the
same as we drop invalid UTF-8. Suggested by schwarze@.


Revision tags: OPENBSD_5_9_BASE
# 1.34 19-Jan-2016 nicm

I no longer use my SourceForge address so replace it.


# 1.33 12-Dec-2015 nicm

Allow prefix and prefix2 to be set to None to disable (useful if you
would rather bind the prefix in the root table).


# 1.32 14-Nov-2015 nicm

All these return values from utf8_* are confusing, use an enum.


# 1.31 14-Nov-2015 nicm

Couple of assignments to remove compiler warnings.


# 1.30 14-Nov-2015 nicm

Be more strict about invalid UTF-8.


# 1.29 12-Nov-2015 nicm

Rename overly-long utf8data to ud throughout.


# 1.28 12-Nov-2015 nicm

Support UTF-8 key bindings by expanding the key type from int to
uint64_t and converting UTF-8 to Unicode on input and the reverse on
output. (This allows key bindings, there are still omissions - the
largest being that the various prompts do not accept UTF-8.)


# 1.27 26-Oct-2015 nicm

Handle unknown keys more gracefully, return a string instead of NULL.


Revision tags: OPENBSD_5_8_BASE
# 1.26 19-Apr-2015 nicm

Rewrite of tmux mouse support which was a mess. Instead of having
options for "mouse-this" and "mouse-that", mouse events may be bound as
keys and there is one option "mouse" that turns on mouse support
entirely (set -g mouse on).

See the new MOUSE SUPPORT section of the man page for description of the
key names and new flags (-t= to specify the pane or window under mouse
as a target, and send-keys -M to pass through a mouse event).

The default builtin bindings for the mouse are:

bind -n MouseDown1Pane select-pane -t=; send-keys -M
bind -n MouseDown1Status select-window -t=
bind -n MouseDrag1Pane copy-mode -M
bind -n MouseDrag1Border resize-pane -M

To get the effect of turning mode-mouse off, do:

unbind -n MouseDrag1Pane
unbind -temacs-copy MouseDrag1Pane

The old mouse options are now gone, set-option -q may be used to
suppress warnings if mixing configuration files.


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.25 21-Jul-2014 nicm

Drop explicit support for F13-F20 and change to match the xterm terminfo
entry:

F13-F24 are S-F1 to S-F12
F25-F36 are C-F1 to C-F12
F37-F48 are C-S-F1 to C-S-F12
F49-F60 are M-F1 to M-F12
and F61-F63 are M-S-F1 to M-S-F3

This should be no difference for applications inside tmux, but means
that any key binding for F13 will need to be replaced by S-F1 and so on.


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.24 22-Mar-2013 nicm

In terminals with XT, turn on modifyOtherKeys=1 with the escape sequence
and handle the most common set. Pass them through if xterm-keys is on.


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.23 04-Mar-2012 nicm

Accept hex values as keys, needed for send-keys, based on a diff from
George Nachman.


Revision tags: OPENBSD_5_1_BASE
# 1.22 21-Jan-2012 nicm

Drop the ability to have a list of keys in the prefix in favour of two
separate options, prefix and prefix2. This simplifies the code and gets
rid the data options type which was only used for this one option.

Also add a -2 flag to send-prefix to send the secondary prefix key,
fixing a cause of minor irritation.

People who want three prefix keys are out of luck :-).


# 1.21 23-Oct-2011 nicm

Alias NPage/PPage as PageDown/PgDn/PageUp/PgUp to reduce occasional
confusion.


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.20 23-Jan-2011 nicm

Allow top-bit-set characters to be used for key bindings, from Tiago
Cunha.


# 1.19 01-Jan-2011 nicm

Last few tables that should be const.


Revision tags: OPENBSD_4_8_BASE
# 1.18 06-Jun-2010 nicm

Use a macro-based mask for obtaining a key or modifier-set from the
combination. Display C-@, etc, as C-Space, in list-keys. By Micah Cowan.


# 1.17 05-Jun-2010 nicm

Fix binding of C-Space/C-@, from Micah Cowan.


# 1.16 03-May-2010 mcbride

Make C-] and other punctuation-based control key combinations work again.

ok nicm


# 1.15 23-Apr-2010 nicm

When converting A-Z into a control character, want to subtract 64 not
65... whoops.


# 1.14 21-Apr-2010 nicm

Rewrite key string conversions to be readable and to work properly for
multiple modifiers.


Revision tags: OPENBSD_4_7_BASE
# 1.13 14-Jan-2010 nicm

Permit S- prefix on keys for shift. Relatively few terminals support this
(basically xterm only) and even fewer have them in terminfo (kLFT2 and kRIT2).


# 1.12 03-Dec-2009 nicm

Massive spaces->tabs and trailing whitespace cleanup, hopefully for the last
time now I've configured emacs to make them displayed in really annoying
colours...


# 1.11 26-Nov-2009 nicm

Make types clearer and lint happier.


# 1.10 10-Nov-2009 nicm

Lookup key as a named key (eg 'Space') before checking for single character
keys, makes C-Space/M-Space etc resolve to the correct key code.


# 1.9 26-Oct-2009 nicm

Rename keypad keys to something more useful.


# 1.8 06-Oct-2009 nicm

Accept ^? for backspace as well as BSpace.


# 1.7 04-Oct-2009 nicm

Add a key string for space ("Space") and document the names, suggested by
guenther@. Also document how to bind " and ', suggested by miod@.


# 1.6 28-Jul-2009 nicm

Accept and print "Enter" and "Escape" for keys rather than C-m and C-[.


# 1.5 26-Jul-2009 nicm

Detect backspace by looking at termios VERASE and translate it into \177 (which
matches screen's behaviour if not its termcap/terminfo entry). The terminfo kbs
cap is often wrong or missing so it can't be used, and just assuming \177 may
be wrong.


# 1.4 24-Jul-2009 nicm

Accept lowercase c- and m- prefix as well as C- and M-.


# 1.3 21-Jul-2009 nicm

Tidy up keys: use an enum for the key codes, and remove the macros which just
wrap flag sets/clears/tests.


# 1.2 14-Jul-2009 nicm

Add backspace key to named keys.


Revision tags: OPENBSD_4_6_BASE
# 1.1 01-Jun-2009 nicm

Import tmux, a terminal multiplexor allowing (among other things) a single
terminal to be switched between several different windows and programs
displayed on one terminal be detached from one terminal and moved to another.

ok deraadt pirofti


# 1.60 20-May-2020 nicm

Fix a couple more places where the key flags need to be masked off.


# 1.59 20-May-2020 nicm

Key strings need to include the cursor and keypad flags now since the
output key lookup expects them already set.


# 1.58 16-May-2020 nicm

Separate key flags and modifiers, log key flags, make the "xterm" flag
more explicit and fix M- keys with a leading escape.


# 1.57 16-May-2020 nicm

Rename KEYC_ESCAPE to KEYC_META.


Revision tags: OPENBSD_6_7_BASE
# 1.56 09-Apr-2020 nicm

Some unnecessary assignments and unused variables.


# 1.55 31-Mar-2020 nicm

Add a "second click" key type which is fired for the second click of a
double click, even if the timer hasn't expired to confirm it isn't
actually a triple click. Provides a way for people who don't care about
triple clicks or can make their commands have no side effects to avoid
the double click timer delay.


# 1.54 15-Mar-2020 nicm

Fix C-Space key string.


# 1.53 19-Feb-2020 nicm

A few fixes to make modifier keys and dragging work - need to remove the
modifiers before checking for the dragging marker key, and apply them
before looking up the end key. Also fix key-to-string with modifiers for
special keys.


# 1.52 14-Nov-2019 nicm

Add an option to set the key sent by backspace for those whose system
uses ^H rather than ^?. GitHub issue 1969.


Revision tags: OPENBSD_6_6_BASE
# 1.51 09-Jul-2019 nicm

Add a -H flag to send-keys to send literal keys given as hex numbers
(needed for control clients to send mouse sequences). Also add some
format flags for UTF-8 and SGR mouse mode. Requested by Bradley Smith in
GitHub issues 1832 and 1833.


Revision tags: OPENBSD_6_5_BASE
# 1.50 18-Oct-2018 nicm

Support for windows larger than visible on the attached client. This has
been a limitation for a long time.

There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.

The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.

If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.

Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).

The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.

For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..

If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.

The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.

The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.


Revision tags: OPENBSD_6_4_BASE
# 1.49 22-Aug-2018 nicm

Add StatusLeft and StatusRight mouse key modifiers for the left and
right parts of the status line.


# 1.48 16-Jul-2018 nicm

Add an "Any" key to run a command if a key is pressed that is not bound
in the current key table. GitHub issue 1404.


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.47 23-Jun-2017 nicm

Add user-keys option to allow user-defined keys to be set, from Dan
Aloni.


# 1.46 12-Jun-2017 nicm

Add explicit keys for the bracketed paste sequences, both to avoid mix
ups with other keys and to make logs clearer.


Revision tags: OPENBSD_6_1_BASE
# 1.45 22-Feb-2017 nicm

Minor bits: fix an array size, add comment, make grid_cell_entry static.


# 1.44 01-Feb-2017 nicm

Implement "all event" (1003) mouse mode but in a way that works. The
main issue is that if we have two panes, A with 1002 and B with 1003, we
need to set 1003 outside tmux in order to get all the mouse events, but
then we need to suppress the ones that pane A doesn't want. This is easy
in SGR mouse mode, because buttons == 3 is only used for movement events
(for other events the trailing m/M marks a release instead), but in
normal mouse mode we can't tell so easily. So for that, look at the
previous event instead - if it is drag+release as well, then the current
event is a movement event.


# 1.43 11-Jan-2017 nicm

Add some missing special keys to key_string_lookup_key, fix a mouse
check in server_client_handle_key, and tweak a comment.


# 1.42 05-Jan-2017 nicm

Highlight all occurrences of search string after searching in copy mode.


# 1.41 23-Nov-2016 nicm

Error on invalid modifier keys.


# 1.40 11-Oct-2016 nicm

Support double and triple clicks (they are cumulative, so double is
fired then triple), and use for select-word and select-line in copy
mode. Inspired by a different solution from Omar Sandoval.


# 1.39 10-Oct-2016 nicm

Loads more static, except for cmd-*.c and window-*.c.


Revision tags: OPENBSD_6_0_BASE
# 1.38 26-May-2016 nicm

Extend 0x1234 keys form to more bits so that Unicode keys work.


# 1.37 25-Apr-2016 nicm

Don't overwrite modifiers in the buffer when making UTF-8 strings,
append instead.


# 1.36 18-Mar-2016 nicm

Instead of reusing MouseUp at the finish of a drag, add a new key
MouseDragEnd. It can be useful to bind them separately in copy mode.


# 1.35 02-Mar-2016 nicm

Handle wcwidth() and mbtowc() failures in better style and drop
characters where we can't find the width (wcwidth() fails) on input, the
same as we drop invalid UTF-8. Suggested by schwarze@.


Revision tags: OPENBSD_5_9_BASE
# 1.34 19-Jan-2016 nicm

I no longer use my SourceForge address so replace it.


# 1.33 12-Dec-2015 nicm

Allow prefix and prefix2 to be set to None to disable (useful if you
would rather bind the prefix in the root table).


# 1.32 14-Nov-2015 nicm

All these return values from utf8_* are confusing, use an enum.


# 1.31 14-Nov-2015 nicm

Couple of assignments to remove compiler warnings.


# 1.30 14-Nov-2015 nicm

Be more strict about invalid UTF-8.


# 1.29 12-Nov-2015 nicm

Rename overly-long utf8data to ud throughout.


# 1.28 12-Nov-2015 nicm

Support UTF-8 key bindings by expanding the key type from int to
uint64_t and converting UTF-8 to Unicode on input and the reverse on
output. (This allows key bindings, there are still omissions - the
largest being that the various prompts do not accept UTF-8.)


# 1.27 26-Oct-2015 nicm

Handle unknown keys more gracefully, return a string instead of NULL.


Revision tags: OPENBSD_5_8_BASE
# 1.26 19-Apr-2015 nicm

Rewrite of tmux mouse support which was a mess. Instead of having
options for "mouse-this" and "mouse-that", mouse events may be bound as
keys and there is one option "mouse" that turns on mouse support
entirely (set -g mouse on).

See the new MOUSE SUPPORT section of the man page for description of the
key names and new flags (-t= to specify the pane or window under mouse
as a target, and send-keys -M to pass through a mouse event).

The default builtin bindings for the mouse are:

bind -n MouseDown1Pane select-pane -t=; send-keys -M
bind -n MouseDown1Status select-window -t=
bind -n MouseDrag1Pane copy-mode -M
bind -n MouseDrag1Border resize-pane -M

To get the effect of turning mode-mouse off, do:

unbind -n MouseDrag1Pane
unbind -temacs-copy MouseDrag1Pane

The old mouse options are now gone, set-option -q may be used to
suppress warnings if mixing configuration files.


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.25 21-Jul-2014 nicm

Drop explicit support for F13-F20 and change to match the xterm terminfo
entry:

F13-F24 are S-F1 to S-F12
F25-F36 are C-F1 to C-F12
F37-F48 are C-S-F1 to C-S-F12
F49-F60 are M-F1 to M-F12
and F61-F63 are M-S-F1 to M-S-F3

This should be no difference for applications inside tmux, but means
that any key binding for F13 will need to be replaced by S-F1 and so on.


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.24 22-Mar-2013 nicm

In terminals with XT, turn on modifyOtherKeys=1 with the escape sequence
and handle the most common set. Pass them through if xterm-keys is on.


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.23 04-Mar-2012 nicm

Accept hex values as keys, needed for send-keys, based on a diff from
George Nachman.


Revision tags: OPENBSD_5_1_BASE
# 1.22 21-Jan-2012 nicm

Drop the ability to have a list of keys in the prefix in favour of two
separate options, prefix and prefix2. This simplifies the code and gets
rid the data options type which was only used for this one option.

Also add a -2 flag to send-prefix to send the secondary prefix key,
fixing a cause of minor irritation.

People who want three prefix keys are out of luck :-).


# 1.21 23-Oct-2011 nicm

Alias NPage/PPage as PageDown/PgDn/PageUp/PgUp to reduce occasional
confusion.


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.20 23-Jan-2011 nicm

Allow top-bit-set characters to be used for key bindings, from Tiago
Cunha.


# 1.19 01-Jan-2011 nicm

Last few tables that should be const.


Revision tags: OPENBSD_4_8_BASE
# 1.18 06-Jun-2010 nicm

Use a macro-based mask for obtaining a key or modifier-set from the
combination. Display C-@, etc, as C-Space, in list-keys. By Micah Cowan.


# 1.17 05-Jun-2010 nicm

Fix binding of C-Space/C-@, from Micah Cowan.


# 1.16 03-May-2010 mcbride

Make C-] and other punctuation-based control key combinations work again.

ok nicm


# 1.15 23-Apr-2010 nicm

When converting A-Z into a control character, want to subtract 64 not
65... whoops.


# 1.14 21-Apr-2010 nicm

Rewrite key string conversions to be readable and to work properly for
multiple modifiers.


Revision tags: OPENBSD_4_7_BASE
# 1.13 14-Jan-2010 nicm

Permit S- prefix on keys for shift. Relatively few terminals support this
(basically xterm only) and even fewer have them in terminfo (kLFT2 and kRIT2).


# 1.12 03-Dec-2009 nicm

Massive spaces->tabs and trailing whitespace cleanup, hopefully for the last
time now I've configured emacs to make them displayed in really annoying
colours...


# 1.11 26-Nov-2009 nicm

Make types clearer and lint happier.


# 1.10 10-Nov-2009 nicm

Lookup key as a named key (eg 'Space') before checking for single character
keys, makes C-Space/M-Space etc resolve to the correct key code.


# 1.9 26-Oct-2009 nicm

Rename keypad keys to something more useful.


# 1.8 06-Oct-2009 nicm

Accept ^? for backspace as well as BSpace.


# 1.7 04-Oct-2009 nicm

Add a key string for space ("Space") and document the names, suggested by
guenther@. Also document how to bind " and ', suggested by miod@.


# 1.6 28-Jul-2009 nicm

Accept and print "Enter" and "Escape" for keys rather than C-m and C-[.


# 1.5 26-Jul-2009 nicm

Detect backspace by looking at termios VERASE and translate it into \177 (which
matches screen's behaviour if not its termcap/terminfo entry). The terminfo kbs
cap is often wrong or missing so it can't be used, and just assuming \177 may
be wrong.


# 1.4 24-Jul-2009 nicm

Accept lowercase c- and m- prefix as well as C- and M-.


# 1.3 21-Jul-2009 nicm

Tidy up keys: use an enum for the key codes, and remove the macros which just
wrap flag sets/clears/tests.


# 1.2 14-Jul-2009 nicm

Add backspace key to named keys.


Revision tags: OPENBSD_4_6_BASE
# 1.1 01-Jun-2009 nicm

Import tmux, a terminal multiplexor allowing (among other things) a single
terminal to be switched between several different windows and programs
displayed on one terminal be detached from one terminal and moved to another.

ok deraadt pirofti


# 1.58 16-May-2020 nicm

Separate key flags and modifiers, log key flags, make the "xterm" flag
more explicit and fix M- keys with a leading escape.


# 1.57 16-May-2020 nicm

Rename KEYC_ESCAPE to KEYC_META.


Revision tags: OPENBSD_6_7_BASE
# 1.56 09-Apr-2020 nicm

Some unnecessary assignments and unused variables.


# 1.55 31-Mar-2020 nicm

Add a "second click" key type which is fired for the second click of a
double click, even if the timer hasn't expired to confirm it isn't
actually a triple click. Provides a way for people who don't care about
triple clicks or can make their commands have no side effects to avoid
the double click timer delay.


# 1.54 15-Mar-2020 nicm

Fix C-Space key string.


# 1.53 19-Feb-2020 nicm

A few fixes to make modifier keys and dragging work - need to remove the
modifiers before checking for the dragging marker key, and apply them
before looking up the end key. Also fix key-to-string with modifiers for
special keys.


# 1.52 14-Nov-2019 nicm

Add an option to set the key sent by backspace for those whose system
uses ^H rather than ^?. GitHub issue 1969.


Revision tags: OPENBSD_6_6_BASE
# 1.51 09-Jul-2019 nicm

Add a -H flag to send-keys to send literal keys given as hex numbers
(needed for control clients to send mouse sequences). Also add some
format flags for UTF-8 and SGR mouse mode. Requested by Bradley Smith in
GitHub issues 1832 and 1833.


Revision tags: OPENBSD_6_5_BASE
# 1.50 18-Oct-2018 nicm

Support for windows larger than visible on the attached client. This has
been a limitation for a long time.

There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.

The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.

If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.

Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).

The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.

For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..

If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.

The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.

The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.


Revision tags: OPENBSD_6_4_BASE
# 1.49 22-Aug-2018 nicm

Add StatusLeft and StatusRight mouse key modifiers for the left and
right parts of the status line.


# 1.48 16-Jul-2018 nicm

Add an "Any" key to run a command if a key is pressed that is not bound
in the current key table. GitHub issue 1404.


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.47 23-Jun-2017 nicm

Add user-keys option to allow user-defined keys to be set, from Dan
Aloni.


# 1.46 12-Jun-2017 nicm

Add explicit keys for the bracketed paste sequences, both to avoid mix
ups with other keys and to make logs clearer.


Revision tags: OPENBSD_6_1_BASE
# 1.45 22-Feb-2017 nicm

Minor bits: fix an array size, add comment, make grid_cell_entry static.


# 1.44 01-Feb-2017 nicm

Implement "all event" (1003) mouse mode but in a way that works. The
main issue is that if we have two panes, A with 1002 and B with 1003, we
need to set 1003 outside tmux in order to get all the mouse events, but
then we need to suppress the ones that pane A doesn't want. This is easy
in SGR mouse mode, because buttons == 3 is only used for movement events
(for other events the trailing m/M marks a release instead), but in
normal mouse mode we can't tell so easily. So for that, look at the
previous event instead - if it is drag+release as well, then the current
event is a movement event.


# 1.43 11-Jan-2017 nicm

Add some missing special keys to key_string_lookup_key, fix a mouse
check in server_client_handle_key, and tweak a comment.


# 1.42 05-Jan-2017 nicm

Highlight all occurrences of search string after searching in copy mode.


# 1.41 23-Nov-2016 nicm

Error on invalid modifier keys.


# 1.40 11-Oct-2016 nicm

Support double and triple clicks (they are cumulative, so double is
fired then triple), and use for select-word and select-line in copy
mode. Inspired by a different solution from Omar Sandoval.


# 1.39 10-Oct-2016 nicm

Loads more static, except for cmd-*.c and window-*.c.


Revision tags: OPENBSD_6_0_BASE
# 1.38 26-May-2016 nicm

Extend 0x1234 keys form to more bits so that Unicode keys work.


# 1.37 25-Apr-2016 nicm

Don't overwrite modifiers in the buffer when making UTF-8 strings,
append instead.


# 1.36 18-Mar-2016 nicm

Instead of reusing MouseUp at the finish of a drag, add a new key
MouseDragEnd. It can be useful to bind them separately in copy mode.


# 1.35 02-Mar-2016 nicm

Handle wcwidth() and mbtowc() failures in better style and drop
characters where we can't find the width (wcwidth() fails) on input, the
same as we drop invalid UTF-8. Suggested by schwarze@.


Revision tags: OPENBSD_5_9_BASE
# 1.34 19-Jan-2016 nicm

I no longer use my SourceForge address so replace it.


# 1.33 12-Dec-2015 nicm

Allow prefix and prefix2 to be set to None to disable (useful if you
would rather bind the prefix in the root table).


# 1.32 14-Nov-2015 nicm

All these return values from utf8_* are confusing, use an enum.


# 1.31 14-Nov-2015 nicm

Couple of assignments to remove compiler warnings.


# 1.30 14-Nov-2015 nicm

Be more strict about invalid UTF-8.


# 1.29 12-Nov-2015 nicm

Rename overly-long utf8data to ud throughout.


# 1.28 12-Nov-2015 nicm

Support UTF-8 key bindings by expanding the key type from int to
uint64_t and converting UTF-8 to Unicode on input and the reverse on
output. (This allows key bindings, there are still omissions - the
largest being that the various prompts do not accept UTF-8.)


# 1.27 26-Oct-2015 nicm

Handle unknown keys more gracefully, return a string instead of NULL.


Revision tags: OPENBSD_5_8_BASE
# 1.26 19-Apr-2015 nicm

Rewrite of tmux mouse support which was a mess. Instead of having
options for "mouse-this" and "mouse-that", mouse events may be bound as
keys and there is one option "mouse" that turns on mouse support
entirely (set -g mouse on).

See the new MOUSE SUPPORT section of the man page for description of the
key names and new flags (-t= to specify the pane or window under mouse
as a target, and send-keys -M to pass through a mouse event).

The default builtin bindings for the mouse are:

bind -n MouseDown1Pane select-pane -t=; send-keys -M
bind -n MouseDown1Status select-window -t=
bind -n MouseDrag1Pane copy-mode -M
bind -n MouseDrag1Border resize-pane -M

To get the effect of turning mode-mouse off, do:

unbind -n MouseDrag1Pane
unbind -temacs-copy MouseDrag1Pane

The old mouse options are now gone, set-option -q may be used to
suppress warnings if mixing configuration files.


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.25 21-Jul-2014 nicm

Drop explicit support for F13-F20 and change to match the xterm terminfo
entry:

F13-F24 are S-F1 to S-F12
F25-F36 are C-F1 to C-F12
F37-F48 are C-S-F1 to C-S-F12
F49-F60 are M-F1 to M-F12
and F61-F63 are M-S-F1 to M-S-F3

This should be no difference for applications inside tmux, but means
that any key binding for F13 will need to be replaced by S-F1 and so on.


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.24 22-Mar-2013 nicm

In terminals with XT, turn on modifyOtherKeys=1 with the escape sequence
and handle the most common set. Pass them through if xterm-keys is on.


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.23 04-Mar-2012 nicm

Accept hex values as keys, needed for send-keys, based on a diff from
George Nachman.


Revision tags: OPENBSD_5_1_BASE
# 1.22 21-Jan-2012 nicm

Drop the ability to have a list of keys in the prefix in favour of two
separate options, prefix and prefix2. This simplifies the code and gets
rid the data options type which was only used for this one option.

Also add a -2 flag to send-prefix to send the secondary prefix key,
fixing a cause of minor irritation.

People who want three prefix keys are out of luck :-).


# 1.21 23-Oct-2011 nicm

Alias NPage/PPage as PageDown/PgDn/PageUp/PgUp to reduce occasional
confusion.


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.20 23-Jan-2011 nicm

Allow top-bit-set characters to be used for key bindings, from Tiago
Cunha.


# 1.19 01-Jan-2011 nicm

Last few tables that should be const.


Revision tags: OPENBSD_4_8_BASE
# 1.18 06-Jun-2010 nicm

Use a macro-based mask for obtaining a key or modifier-set from the
combination. Display C-@, etc, as C-Space, in list-keys. By Micah Cowan.


# 1.17 05-Jun-2010 nicm

Fix binding of C-Space/C-@, from Micah Cowan.


# 1.16 03-May-2010 mcbride

Make C-] and other punctuation-based control key combinations work again.

ok nicm


# 1.15 23-Apr-2010 nicm

When converting A-Z into a control character, want to subtract 64 not
65... whoops.


# 1.14 21-Apr-2010 nicm

Rewrite key string conversions to be readable and to work properly for
multiple modifiers.


Revision tags: OPENBSD_4_7_BASE
# 1.13 14-Jan-2010 nicm

Permit S- prefix on keys for shift. Relatively few terminals support this
(basically xterm only) and even fewer have them in terminfo (kLFT2 and kRIT2).


# 1.12 03-Dec-2009 nicm

Massive spaces->tabs and trailing whitespace cleanup, hopefully for the last
time now I've configured emacs to make them displayed in really annoying
colours...


# 1.11 26-Nov-2009 nicm

Make types clearer and lint happier.


# 1.10 10-Nov-2009 nicm

Lookup key as a named key (eg 'Space') before checking for single character
keys, makes C-Space/M-Space etc resolve to the correct key code.


# 1.9 26-Oct-2009 nicm

Rename keypad keys to something more useful.


# 1.8 06-Oct-2009 nicm

Accept ^? for backspace as well as BSpace.


# 1.7 04-Oct-2009 nicm

Add a key string for space ("Space") and document the names, suggested by
guenther@. Also document how to bind " and ', suggested by miod@.


# 1.6 28-Jul-2009 nicm

Accept and print "Enter" and "Escape" for keys rather than C-m and C-[.


# 1.5 26-Jul-2009 nicm

Detect backspace by looking at termios VERASE and translate it into \177 (which
matches screen's behaviour if not its termcap/terminfo entry). The terminfo kbs
cap is often wrong or missing so it can't be used, and just assuming \177 may
be wrong.


# 1.4 24-Jul-2009 nicm

Accept lowercase c- and m- prefix as well as C- and M-.


# 1.3 21-Jul-2009 nicm

Tidy up keys: use an enum for the key codes, and remove the macros which just
wrap flag sets/clears/tests.


# 1.2 14-Jul-2009 nicm

Add backspace key to named keys.


Revision tags: OPENBSD_4_6_BASE
# 1.1 01-Jun-2009 nicm

Import tmux, a terminal multiplexor allowing (among other things) a single
terminal to be switched between several different windows and programs
displayed on one terminal be detached from one terminal and moved to another.

ok deraadt pirofti


# 1.56 09-Apr-2020 nicm

Some unnecessary assignments and unused variables.


# 1.55 31-Mar-2020 nicm

Add a "second click" key type which is fired for the second click of a
double click, even if the timer hasn't expired to confirm it isn't
actually a triple click. Provides a way for people who don't care about
triple clicks or can make their commands have no side effects to avoid
the double click timer delay.


# 1.54 15-Mar-2020 nicm

Fix C-Space key string.


# 1.53 19-Feb-2020 nicm

A few fixes to make modifier keys and dragging work - need to remove the
modifiers before checking for the dragging marker key, and apply them
before looking up the end key. Also fix key-to-string with modifiers for
special keys.


# 1.52 14-Nov-2019 nicm

Add an option to set the key sent by backspace for those whose system
uses ^H rather than ^?. GitHub issue 1969.


Revision tags: OPENBSD_6_6_BASE
# 1.51 09-Jul-2019 nicm

Add a -H flag to send-keys to send literal keys given as hex numbers
(needed for control clients to send mouse sequences). Also add some
format flags for UTF-8 and SGR mouse mode. Requested by Bradley Smith in
GitHub issues 1832 and 1833.


Revision tags: OPENBSD_6_5_BASE
# 1.50 18-Oct-2018 nicm

Support for windows larger than visible on the attached client. This has
been a limitation for a long time.

There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.

The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.

If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.

Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).

The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.

For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..

If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.

The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.

The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.


Revision tags: OPENBSD_6_4_BASE
# 1.49 22-Aug-2018 nicm

Add StatusLeft and StatusRight mouse key modifiers for the left and
right parts of the status line.


# 1.48 16-Jul-2018 nicm

Add an "Any" key to run a command if a key is pressed that is not bound
in the current key table. GitHub issue 1404.


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.47 23-Jun-2017 nicm

Add user-keys option to allow user-defined keys to be set, from Dan
Aloni.


# 1.46 12-Jun-2017 nicm

Add explicit keys for the bracketed paste sequences, both to avoid mix
ups with other keys and to make logs clearer.


Revision tags: OPENBSD_6_1_BASE
# 1.45 22-Feb-2017 nicm

Minor bits: fix an array size, add comment, make grid_cell_entry static.


# 1.44 01-Feb-2017 nicm

Implement "all event" (1003) mouse mode but in a way that works. The
main issue is that if we have two panes, A with 1002 and B with 1003, we
need to set 1003 outside tmux in order to get all the mouse events, but
then we need to suppress the ones that pane A doesn't want. This is easy
in SGR mouse mode, because buttons == 3 is only used for movement events
(for other events the trailing m/M marks a release instead), but in
normal mouse mode we can't tell so easily. So for that, look at the
previous event instead - if it is drag+release as well, then the current
event is a movement event.


# 1.43 11-Jan-2017 nicm

Add some missing special keys to key_string_lookup_key, fix a mouse
check in server_client_handle_key, and tweak a comment.


# 1.42 05-Jan-2017 nicm

Highlight all occurrences of search string after searching in copy mode.


# 1.41 23-Nov-2016 nicm

Error on invalid modifier keys.


# 1.40 11-Oct-2016 nicm

Support double and triple clicks (they are cumulative, so double is
fired then triple), and use for select-word and select-line in copy
mode. Inspired by a different solution from Omar Sandoval.


# 1.39 10-Oct-2016 nicm

Loads more static, except for cmd-*.c and window-*.c.


Revision tags: OPENBSD_6_0_BASE
# 1.38 26-May-2016 nicm

Extend 0x1234 keys form to more bits so that Unicode keys work.


# 1.37 25-Apr-2016 nicm

Don't overwrite modifiers in the buffer when making UTF-8 strings,
append instead.


# 1.36 18-Mar-2016 nicm

Instead of reusing MouseUp at the finish of a drag, add a new key
MouseDragEnd. It can be useful to bind them separately in copy mode.


# 1.35 02-Mar-2016 nicm

Handle wcwidth() and mbtowc() failures in better style and drop
characters where we can't find the width (wcwidth() fails) on input, the
same as we drop invalid UTF-8. Suggested by schwarze@.


Revision tags: OPENBSD_5_9_BASE
# 1.34 19-Jan-2016 nicm

I no longer use my SourceForge address so replace it.


# 1.33 12-Dec-2015 nicm

Allow prefix and prefix2 to be set to None to disable (useful if you
would rather bind the prefix in the root table).


# 1.32 14-Nov-2015 nicm

All these return values from utf8_* are confusing, use an enum.


# 1.31 14-Nov-2015 nicm

Couple of assignments to remove compiler warnings.


# 1.30 14-Nov-2015 nicm

Be more strict about invalid UTF-8.


# 1.29 12-Nov-2015 nicm

Rename overly-long utf8data to ud throughout.


# 1.28 12-Nov-2015 nicm

Support UTF-8 key bindings by expanding the key type from int to
uint64_t and converting UTF-8 to Unicode on input and the reverse on
output. (This allows key bindings, there are still omissions - the
largest being that the various prompts do not accept UTF-8.)


# 1.27 26-Oct-2015 nicm

Handle unknown keys more gracefully, return a string instead of NULL.


Revision tags: OPENBSD_5_8_BASE
# 1.26 19-Apr-2015 nicm

Rewrite of tmux mouse support which was a mess. Instead of having
options for "mouse-this" and "mouse-that", mouse events may be bound as
keys and there is one option "mouse" that turns on mouse support
entirely (set -g mouse on).

See the new MOUSE SUPPORT section of the man page for description of the
key names and new flags (-t= to specify the pane or window under mouse
as a target, and send-keys -M to pass through a mouse event).

The default builtin bindings for the mouse are:

bind -n MouseDown1Pane select-pane -t=; send-keys -M
bind -n MouseDown1Status select-window -t=
bind -n MouseDrag1Pane copy-mode -M
bind -n MouseDrag1Border resize-pane -M

To get the effect of turning mode-mouse off, do:

unbind -n MouseDrag1Pane
unbind -temacs-copy MouseDrag1Pane

The old mouse options are now gone, set-option -q may be used to
suppress warnings if mixing configuration files.


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.25 21-Jul-2014 nicm

Drop explicit support for F13-F20 and change to match the xterm terminfo
entry:

F13-F24 are S-F1 to S-F12
F25-F36 are C-F1 to C-F12
F37-F48 are C-S-F1 to C-S-F12
F49-F60 are M-F1 to M-F12
and F61-F63 are M-S-F1 to M-S-F3

This should be no difference for applications inside tmux, but means
that any key binding for F13 will need to be replaced by S-F1 and so on.


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.24 22-Mar-2013 nicm

In terminals with XT, turn on modifyOtherKeys=1 with the escape sequence
and handle the most common set. Pass them through if xterm-keys is on.


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.23 04-Mar-2012 nicm

Accept hex values as keys, needed for send-keys, based on a diff from
George Nachman.


Revision tags: OPENBSD_5_1_BASE
# 1.22 21-Jan-2012 nicm

Drop the ability to have a list of keys in the prefix in favour of two
separate options, prefix and prefix2. This simplifies the code and gets
rid the data options type which was only used for this one option.

Also add a -2 flag to send-prefix to send the secondary prefix key,
fixing a cause of minor irritation.

People who want three prefix keys are out of luck :-).


# 1.21 23-Oct-2011 nicm

Alias NPage/PPage as PageDown/PgDn/PageUp/PgUp to reduce occasional
confusion.


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.20 23-Jan-2011 nicm

Allow top-bit-set characters to be used for key bindings, from Tiago
Cunha.


# 1.19 01-Jan-2011 nicm

Last few tables that should be const.


Revision tags: OPENBSD_4_8_BASE
# 1.18 06-Jun-2010 nicm

Use a macro-based mask for obtaining a key or modifier-set from the
combination. Display C-@, etc, as C-Space, in list-keys. By Micah Cowan.


# 1.17 05-Jun-2010 nicm

Fix binding of C-Space/C-@, from Micah Cowan.


# 1.16 03-May-2010 mcbride

Make C-] and other punctuation-based control key combinations work again.

ok nicm


# 1.15 23-Apr-2010 nicm

When converting A-Z into a control character, want to subtract 64 not
65... whoops.


# 1.14 21-Apr-2010 nicm

Rewrite key string conversions to be readable and to work properly for
multiple modifiers.


Revision tags: OPENBSD_4_7_BASE
# 1.13 14-Jan-2010 nicm

Permit S- prefix on keys for shift. Relatively few terminals support this
(basically xterm only) and even fewer have them in terminfo (kLFT2 and kRIT2).


# 1.12 03-Dec-2009 nicm

Massive spaces->tabs and trailing whitespace cleanup, hopefully for the last
time now I've configured emacs to make them displayed in really annoying
colours...


# 1.11 26-Nov-2009 nicm

Make types clearer and lint happier.


# 1.10 10-Nov-2009 nicm

Lookup key as a named key (eg 'Space') before checking for single character
keys, makes C-Space/M-Space etc resolve to the correct key code.


# 1.9 26-Oct-2009 nicm

Rename keypad keys to something more useful.


# 1.8 06-Oct-2009 nicm

Accept ^? for backspace as well as BSpace.


# 1.7 04-Oct-2009 nicm

Add a key string for space ("Space") and document the names, suggested by
guenther@. Also document how to bind " and ', suggested by miod@.


# 1.6 28-Jul-2009 nicm

Accept and print "Enter" and "Escape" for keys rather than C-m and C-[.


# 1.5 26-Jul-2009 nicm

Detect backspace by looking at termios VERASE and translate it into \177 (which
matches screen's behaviour if not its termcap/terminfo entry). The terminfo kbs
cap is often wrong or missing so it can't be used, and just assuming \177 may
be wrong.


# 1.4 24-Jul-2009 nicm

Accept lowercase c- and m- prefix as well as C- and M-.


# 1.3 21-Jul-2009 nicm

Tidy up keys: use an enum for the key codes, and remove the macros which just
wrap flag sets/clears/tests.


# 1.2 14-Jul-2009 nicm

Add backspace key to named keys.


Revision tags: OPENBSD_4_6_BASE
# 1.1 01-Jun-2009 nicm

Import tmux, a terminal multiplexor allowing (among other things) a single
terminal to be switched between several different windows and programs
displayed on one terminal be detached from one terminal and moved to another.

ok deraadt pirofti


# 1.55 31-Mar-2020 nicm

Add a "second click" key type which is fired for the second click of a
double click, even if the timer hasn't expired to confirm it isn't
actually a triple click. Provides a way for people who don't care about
triple clicks or can make their commands have no side effects to avoid
the double click timer delay.


# 1.54 15-Mar-2020 nicm

Fix C-Space key string.


# 1.53 19-Feb-2020 nicm

A few fixes to make modifier keys and dragging work - need to remove the
modifiers before checking for the dragging marker key, and apply them
before looking up the end key. Also fix key-to-string with modifiers for
special keys.


# 1.52 14-Nov-2019 nicm

Add an option to set the key sent by backspace for those whose system
uses ^H rather than ^?. GitHub issue 1969.


Revision tags: OPENBSD_6_6_BASE
# 1.51 09-Jul-2019 nicm

Add a -H flag to send-keys to send literal keys given as hex numbers
(needed for control clients to send mouse sequences). Also add some
format flags for UTF-8 and SGR mouse mode. Requested by Bradley Smith in
GitHub issues 1832 and 1833.


Revision tags: OPENBSD_6_5_BASE
# 1.50 18-Oct-2018 nicm

Support for windows larger than visible on the attached client. This has
been a limitation for a long time.

There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.

The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.

If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.

Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).

The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.

For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..

If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.

The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.

The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.


Revision tags: OPENBSD_6_4_BASE
# 1.49 22-Aug-2018 nicm

Add StatusLeft and StatusRight mouse key modifiers for the left and
right parts of the status line.


# 1.48 16-Jul-2018 nicm

Add an "Any" key to run a command if a key is pressed that is not bound
in the current key table. GitHub issue 1404.


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.47 23-Jun-2017 nicm

Add user-keys option to allow user-defined keys to be set, from Dan
Aloni.


# 1.46 12-Jun-2017 nicm

Add explicit keys for the bracketed paste sequences, both to avoid mix
ups with other keys and to make logs clearer.


Revision tags: OPENBSD_6_1_BASE
# 1.45 22-Feb-2017 nicm

Minor bits: fix an array size, add comment, make grid_cell_entry static.


# 1.44 01-Feb-2017 nicm

Implement "all event" (1003) mouse mode but in a way that works. The
main issue is that if we have two panes, A with 1002 and B with 1003, we
need to set 1003 outside tmux in order to get all the mouse events, but
then we need to suppress the ones that pane A doesn't want. This is easy
in SGR mouse mode, because buttons == 3 is only used for movement events
(for other events the trailing m/M marks a release instead), but in
normal mouse mode we can't tell so easily. So for that, look at the
previous event instead - if it is drag+release as well, then the current
event is a movement event.


# 1.43 11-Jan-2017 nicm

Add some missing special keys to key_string_lookup_key, fix a mouse
check in server_client_handle_key, and tweak a comment.


# 1.42 05-Jan-2017 nicm

Highlight all occurrences of search string after searching in copy mode.


# 1.41 23-Nov-2016 nicm

Error on invalid modifier keys.


# 1.40 11-Oct-2016 nicm

Support double and triple clicks (they are cumulative, so double is
fired then triple), and use for select-word and select-line in copy
mode. Inspired by a different solution from Omar Sandoval.


# 1.39 10-Oct-2016 nicm

Loads more static, except for cmd-*.c and window-*.c.


Revision tags: OPENBSD_6_0_BASE
# 1.38 26-May-2016 nicm

Extend 0x1234 keys form to more bits so that Unicode keys work.


# 1.37 25-Apr-2016 nicm

Don't overwrite modifiers in the buffer when making UTF-8 strings,
append instead.


# 1.36 18-Mar-2016 nicm

Instead of reusing MouseUp at the finish of a drag, add a new key
MouseDragEnd. It can be useful to bind them separately in copy mode.


# 1.35 02-Mar-2016 nicm

Handle wcwidth() and mbtowc() failures in better style and drop
characters where we can't find the width (wcwidth() fails) on input, the
same as we drop invalid UTF-8. Suggested by schwarze@.


Revision tags: OPENBSD_5_9_BASE
# 1.34 19-Jan-2016 nicm

I no longer use my SourceForge address so replace it.


# 1.33 12-Dec-2015 nicm

Allow prefix and prefix2 to be set to None to disable (useful if you
would rather bind the prefix in the root table).


# 1.32 14-Nov-2015 nicm

All these return values from utf8_* are confusing, use an enum.


# 1.31 14-Nov-2015 nicm

Couple of assignments to remove compiler warnings.


# 1.30 14-Nov-2015 nicm

Be more strict about invalid UTF-8.


# 1.29 12-Nov-2015 nicm

Rename overly-long utf8data to ud throughout.


# 1.28 12-Nov-2015 nicm

Support UTF-8 key bindings by expanding the key type from int to
uint64_t and converting UTF-8 to Unicode on input and the reverse on
output. (This allows key bindings, there are still omissions - the
largest being that the various prompts do not accept UTF-8.)


# 1.27 26-Oct-2015 nicm

Handle unknown keys more gracefully, return a string instead of NULL.


Revision tags: OPENBSD_5_8_BASE
# 1.26 19-Apr-2015 nicm

Rewrite of tmux mouse support which was a mess. Instead of having
options for "mouse-this" and "mouse-that", mouse events may be bound as
keys and there is one option "mouse" that turns on mouse support
entirely (set -g mouse on).

See the new MOUSE SUPPORT section of the man page for description of the
key names and new flags (-t= to specify the pane or window under mouse
as a target, and send-keys -M to pass through a mouse event).

The default builtin bindings for the mouse are:

bind -n MouseDown1Pane select-pane -t=; send-keys -M
bind -n MouseDown1Status select-window -t=
bind -n MouseDrag1Pane copy-mode -M
bind -n MouseDrag1Border resize-pane -M

To get the effect of turning mode-mouse off, do:

unbind -n MouseDrag1Pane
unbind -temacs-copy MouseDrag1Pane

The old mouse options are now gone, set-option -q may be used to
suppress warnings if mixing configuration files.


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.25 21-Jul-2014 nicm

Drop explicit support for F13-F20 and change to match the xterm terminfo
entry:

F13-F24 are S-F1 to S-F12
F25-F36 are C-F1 to C-F12
F37-F48 are C-S-F1 to C-S-F12
F49-F60 are M-F1 to M-F12
and F61-F63 are M-S-F1 to M-S-F3

This should be no difference for applications inside tmux, but means
that any key binding for F13 will need to be replaced by S-F1 and so on.


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.24 22-Mar-2013 nicm

In terminals with XT, turn on modifyOtherKeys=1 with the escape sequence
and handle the most common set. Pass them through if xterm-keys is on.


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.23 04-Mar-2012 nicm

Accept hex values as keys, needed for send-keys, based on a diff from
George Nachman.


Revision tags: OPENBSD_5_1_BASE
# 1.22 21-Jan-2012 nicm

Drop the ability to have a list of keys in the prefix in favour of two
separate options, prefix and prefix2. This simplifies the code and gets
rid the data options type which was only used for this one option.

Also add a -2 flag to send-prefix to send the secondary prefix key,
fixing a cause of minor irritation.

People who want three prefix keys are out of luck :-).


# 1.21 23-Oct-2011 nicm

Alias NPage/PPage as PageDown/PgDn/PageUp/PgUp to reduce occasional
confusion.


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.20 23-Jan-2011 nicm

Allow top-bit-set characters to be used for key bindings, from Tiago
Cunha.


# 1.19 01-Jan-2011 nicm

Last few tables that should be const.


Revision tags: OPENBSD_4_8_BASE
# 1.18 06-Jun-2010 nicm

Use a macro-based mask for obtaining a key or modifier-set from the
combination. Display C-@, etc, as C-Space, in list-keys. By Micah Cowan.


# 1.17 05-Jun-2010 nicm

Fix binding of C-Space/C-@, from Micah Cowan.


# 1.16 03-May-2010 mcbride

Make C-] and other punctuation-based control key combinations work again.

ok nicm


# 1.15 23-Apr-2010 nicm

When converting A-Z into a control character, want to subtract 64 not
65... whoops.


# 1.14 21-Apr-2010 nicm

Rewrite key string conversions to be readable and to work properly for
multiple modifiers.


Revision tags: OPENBSD_4_7_BASE
# 1.13 14-Jan-2010 nicm

Permit S- prefix on keys for shift. Relatively few terminals support this
(basically xterm only) and even fewer have them in terminfo (kLFT2 and kRIT2).


# 1.12 03-Dec-2009 nicm

Massive spaces->tabs and trailing whitespace cleanup, hopefully for the last
time now I've configured emacs to make them displayed in really annoying
colours...


# 1.11 26-Nov-2009 nicm

Make types clearer and lint happier.


# 1.10 10-Nov-2009 nicm

Lookup key as a named key (eg 'Space') before checking for single character
keys, makes C-Space/M-Space etc resolve to the correct key code.


# 1.9 26-Oct-2009 nicm

Rename keypad keys to something more useful.


# 1.8 06-Oct-2009 nicm

Accept ^? for backspace as well as BSpace.


# 1.7 04-Oct-2009 nicm

Add a key string for space ("Space") and document the names, suggested by
guenther@. Also document how to bind " and ', suggested by miod@.


# 1.6 28-Jul-2009 nicm

Accept and print "Enter" and "Escape" for keys rather than C-m and C-[.


# 1.5 26-Jul-2009 nicm

Detect backspace by looking at termios VERASE and translate it into \177 (which
matches screen's behaviour if not its termcap/terminfo entry). The terminfo kbs
cap is often wrong or missing so it can't be used, and just assuming \177 may
be wrong.


# 1.4 24-Jul-2009 nicm

Accept lowercase c- and m- prefix as well as C- and M-.


# 1.3 21-Jul-2009 nicm

Tidy up keys: use an enum for the key codes, and remove the macros which just
wrap flag sets/clears/tests.


# 1.2 14-Jul-2009 nicm

Add backspace key to named keys.


Revision tags: OPENBSD_4_6_BASE
# 1.1 01-Jun-2009 nicm

Import tmux, a terminal multiplexor allowing (among other things) a single
terminal to be switched between several different windows and programs
displayed on one terminal be detached from one terminal and moved to another.

ok deraadt pirofti


# 1.54 15-Mar-2020 nicm

Fix C-Space key string.


# 1.53 19-Feb-2020 nicm

A few fixes to make modifier keys and dragging work - need to remove the
modifiers before checking for the dragging marker key, and apply them
before looking up the end key. Also fix key-to-string with modifiers for
special keys.


# 1.52 14-Nov-2019 nicm

Add an option to set the key sent by backspace for those whose system
uses ^H rather than ^?. GitHub issue 1969.


Revision tags: OPENBSD_6_6_BASE
# 1.51 09-Jul-2019 nicm

Add a -H flag to send-keys to send literal keys given as hex numbers
(needed for control clients to send mouse sequences). Also add some
format flags for UTF-8 and SGR mouse mode. Requested by Bradley Smith in
GitHub issues 1832 and 1833.


Revision tags: OPENBSD_6_5_BASE
# 1.50 18-Oct-2018 nicm

Support for windows larger than visible on the attached client. This has
been a limitation for a long time.

There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.

The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.

If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.

Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).

The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.

For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..

If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.

The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.

The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.


Revision tags: OPENBSD_6_4_BASE
# 1.49 22-Aug-2018 nicm

Add StatusLeft and StatusRight mouse key modifiers for the left and
right parts of the status line.


# 1.48 16-Jul-2018 nicm

Add an "Any" key to run a command if a key is pressed that is not bound
in the current key table. GitHub issue 1404.


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.47 23-Jun-2017 nicm

Add user-keys option to allow user-defined keys to be set, from Dan
Aloni.


# 1.46 12-Jun-2017 nicm

Add explicit keys for the bracketed paste sequences, both to avoid mix
ups with other keys and to make logs clearer.


Revision tags: OPENBSD_6_1_BASE
# 1.45 22-Feb-2017 nicm

Minor bits: fix an array size, add comment, make grid_cell_entry static.


# 1.44 01-Feb-2017 nicm

Implement "all event" (1003) mouse mode but in a way that works. The
main issue is that if we have two panes, A with 1002 and B with 1003, we
need to set 1003 outside tmux in order to get all the mouse events, but
then we need to suppress the ones that pane A doesn't want. This is easy
in SGR mouse mode, because buttons == 3 is only used for movement events
(for other events the trailing m/M marks a release instead), but in
normal mouse mode we can't tell so easily. So for that, look at the
previous event instead - if it is drag+release as well, then the current
event is a movement event.


# 1.43 11-Jan-2017 nicm

Add some missing special keys to key_string_lookup_key, fix a mouse
check in server_client_handle_key, and tweak a comment.


# 1.42 05-Jan-2017 nicm

Highlight all occurrences of search string after searching in copy mode.


# 1.41 23-Nov-2016 nicm

Error on invalid modifier keys.


# 1.40 11-Oct-2016 nicm

Support double and triple clicks (they are cumulative, so double is
fired then triple), and use for select-word and select-line in copy
mode. Inspired by a different solution from Omar Sandoval.


# 1.39 10-Oct-2016 nicm

Loads more static, except for cmd-*.c and window-*.c.


Revision tags: OPENBSD_6_0_BASE
# 1.38 26-May-2016 nicm

Extend 0x1234 keys form to more bits so that Unicode keys work.


# 1.37 25-Apr-2016 nicm

Don't overwrite modifiers in the buffer when making UTF-8 strings,
append instead.


# 1.36 18-Mar-2016 nicm

Instead of reusing MouseUp at the finish of a drag, add a new key
MouseDragEnd. It can be useful to bind them separately in copy mode.


# 1.35 02-Mar-2016 nicm

Handle wcwidth() and mbtowc() failures in better style and drop
characters where we can't find the width (wcwidth() fails) on input, the
same as we drop invalid UTF-8. Suggested by schwarze@.


Revision tags: OPENBSD_5_9_BASE
# 1.34 19-Jan-2016 nicm

I no longer use my SourceForge address so replace it.


# 1.33 12-Dec-2015 nicm

Allow prefix and prefix2 to be set to None to disable (useful if you
would rather bind the prefix in the root table).


# 1.32 14-Nov-2015 nicm

All these return values from utf8_* are confusing, use an enum.


# 1.31 14-Nov-2015 nicm

Couple of assignments to remove compiler warnings.


# 1.30 14-Nov-2015 nicm

Be more strict about invalid UTF-8.


# 1.29 12-Nov-2015 nicm

Rename overly-long utf8data to ud throughout.


# 1.28 12-Nov-2015 nicm

Support UTF-8 key bindings by expanding the key type from int to
uint64_t and converting UTF-8 to Unicode on input and the reverse on
output. (This allows key bindings, there are still omissions - the
largest being that the various prompts do not accept UTF-8.)


# 1.27 26-Oct-2015 nicm

Handle unknown keys more gracefully, return a string instead of NULL.


Revision tags: OPENBSD_5_8_BASE
# 1.26 19-Apr-2015 nicm

Rewrite of tmux mouse support which was a mess. Instead of having
options for "mouse-this" and "mouse-that", mouse events may be bound as
keys and there is one option "mouse" that turns on mouse support
entirely (set -g mouse on).

See the new MOUSE SUPPORT section of the man page for description of the
key names and new flags (-t= to specify the pane or window under mouse
as a target, and send-keys -M to pass through a mouse event).

The default builtin bindings for the mouse are:

bind -n MouseDown1Pane select-pane -t=; send-keys -M
bind -n MouseDown1Status select-window -t=
bind -n MouseDrag1Pane copy-mode -M
bind -n MouseDrag1Border resize-pane -M

To get the effect of turning mode-mouse off, do:

unbind -n MouseDrag1Pane
unbind -temacs-copy MouseDrag1Pane

The old mouse options are now gone, set-option -q may be used to
suppress warnings if mixing configuration files.


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.25 21-Jul-2014 nicm

Drop explicit support for F13-F20 and change to match the xterm terminfo
entry:

F13-F24 are S-F1 to S-F12
F25-F36 are C-F1 to C-F12
F37-F48 are C-S-F1 to C-S-F12
F49-F60 are M-F1 to M-F12
and F61-F63 are M-S-F1 to M-S-F3

This should be no difference for applications inside tmux, but means
that any key binding for F13 will need to be replaced by S-F1 and so on.


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.24 22-Mar-2013 nicm

In terminals with XT, turn on modifyOtherKeys=1 with the escape sequence
and handle the most common set. Pass them through if xterm-keys is on.


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.23 04-Mar-2012 nicm

Accept hex values as keys, needed for send-keys, based on a diff from
George Nachman.


Revision tags: OPENBSD_5_1_BASE
# 1.22 21-Jan-2012 nicm

Drop the ability to have a list of keys in the prefix in favour of two
separate options, prefix and prefix2. This simplifies the code and gets
rid the data options type which was only used for this one option.

Also add a -2 flag to send-prefix to send the secondary prefix key,
fixing a cause of minor irritation.

People who want three prefix keys are out of luck :-).


# 1.21 23-Oct-2011 nicm

Alias NPage/PPage as PageDown/PgDn/PageUp/PgUp to reduce occasional
confusion.


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.20 23-Jan-2011 nicm

Allow top-bit-set characters to be used for key bindings, from Tiago
Cunha.


# 1.19 01-Jan-2011 nicm

Last few tables that should be const.


Revision tags: OPENBSD_4_8_BASE
# 1.18 06-Jun-2010 nicm

Use a macro-based mask for obtaining a key or modifier-set from the
combination. Display C-@, etc, as C-Space, in list-keys. By Micah Cowan.


# 1.17 05-Jun-2010 nicm

Fix binding of C-Space/C-@, from Micah Cowan.


# 1.16 03-May-2010 mcbride

Make C-] and other punctuation-based control key combinations work again.

ok nicm


# 1.15 23-Apr-2010 nicm

When converting A-Z into a control character, want to subtract 64 not
65... whoops.


# 1.14 21-Apr-2010 nicm

Rewrite key string conversions to be readable and to work properly for
multiple modifiers.


Revision tags: OPENBSD_4_7_BASE
# 1.13 14-Jan-2010 nicm

Permit S- prefix on keys for shift. Relatively few terminals support this
(basically xterm only) and even fewer have them in terminfo (kLFT2 and kRIT2).


# 1.12 03-Dec-2009 nicm

Massive spaces->tabs and trailing whitespace cleanup, hopefully for the last
time now I've configured emacs to make them displayed in really annoying
colours...


# 1.11 26-Nov-2009 nicm

Make types clearer and lint happier.


# 1.10 10-Nov-2009 nicm

Lookup key as a named key (eg 'Space') before checking for single character
keys, makes C-Space/M-Space etc resolve to the correct key code.


# 1.9 26-Oct-2009 nicm

Rename keypad keys to something more useful.


# 1.8 06-Oct-2009 nicm

Accept ^? for backspace as well as BSpace.


# 1.7 04-Oct-2009 nicm

Add a key string for space ("Space") and document the names, suggested by
guenther@. Also document how to bind " and ', suggested by miod@.


# 1.6 28-Jul-2009 nicm

Accept and print "Enter" and "Escape" for keys rather than C-m and C-[.


# 1.5 26-Jul-2009 nicm

Detect backspace by looking at termios VERASE and translate it into \177 (which
matches screen's behaviour if not its termcap/terminfo entry). The terminfo kbs
cap is often wrong or missing so it can't be used, and just assuming \177 may
be wrong.


# 1.4 24-Jul-2009 nicm

Accept lowercase c- and m- prefix as well as C- and M-.


# 1.3 21-Jul-2009 nicm

Tidy up keys: use an enum for the key codes, and remove the macros which just
wrap flag sets/clears/tests.


# 1.2 14-Jul-2009 nicm

Add backspace key to named keys.


Revision tags: OPENBSD_4_6_BASE
# 1.1 01-Jun-2009 nicm

Import tmux, a terminal multiplexor allowing (among other things) a single
terminal to be switched between several different windows and programs
displayed on one terminal be detached from one terminal and moved to another.

ok deraadt pirofti


# 1.53 19-Feb-2020 nicm

A few fixes to make modifier keys and dragging work - need to remove the
modifiers before checking for the dragging marker key, and apply them
before looking up the end key. Also fix key-to-string with modifiers for
special keys.


# 1.52 14-Nov-2019 nicm

Add an option to set the key sent by backspace for those whose system
uses ^H rather than ^?. GitHub issue 1969.


Revision tags: OPENBSD_6_6_BASE
# 1.51 09-Jul-2019 nicm

Add a -H flag to send-keys to send literal keys given as hex numbers
(needed for control clients to send mouse sequences). Also add some
format flags for UTF-8 and SGR mouse mode. Requested by Bradley Smith in
GitHub issues 1832 and 1833.


Revision tags: OPENBSD_6_5_BASE
# 1.50 18-Oct-2018 nicm

Support for windows larger than visible on the attached client. This has
been a limitation for a long time.

There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.

The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.

If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.

Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).

The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.

For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..

If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.

The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.

The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.


Revision tags: OPENBSD_6_4_BASE
# 1.49 22-Aug-2018 nicm

Add StatusLeft and StatusRight mouse key modifiers for the left and
right parts of the status line.


# 1.48 16-Jul-2018 nicm

Add an "Any" key to run a command if a key is pressed that is not bound
in the current key table. GitHub issue 1404.


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.47 23-Jun-2017 nicm

Add user-keys option to allow user-defined keys to be set, from Dan
Aloni.


# 1.46 12-Jun-2017 nicm

Add explicit keys for the bracketed paste sequences, both to avoid mix
ups with other keys and to make logs clearer.


Revision tags: OPENBSD_6_1_BASE
# 1.45 22-Feb-2017 nicm

Minor bits: fix an array size, add comment, make grid_cell_entry static.


# 1.44 01-Feb-2017 nicm

Implement "all event" (1003) mouse mode but in a way that works. The
main issue is that if we have two panes, A with 1002 and B with 1003, we
need to set 1003 outside tmux in order to get all the mouse events, but
then we need to suppress the ones that pane A doesn't want. This is easy
in SGR mouse mode, because buttons == 3 is only used for movement events
(for other events the trailing m/M marks a release instead), but in
normal mouse mode we can't tell so easily. So for that, look at the
previous event instead - if it is drag+release as well, then the current
event is a movement event.


# 1.43 11-Jan-2017 nicm

Add some missing special keys to key_string_lookup_key, fix a mouse
check in server_client_handle_key, and tweak a comment.


# 1.42 05-Jan-2017 nicm

Highlight all occurrences of search string after searching in copy mode.


# 1.41 23-Nov-2016 nicm

Error on invalid modifier keys.


# 1.40 11-Oct-2016 nicm

Support double and triple clicks (they are cumulative, so double is
fired then triple), and use for select-word and select-line in copy
mode. Inspired by a different solution from Omar Sandoval.


# 1.39 10-Oct-2016 nicm

Loads more static, except for cmd-*.c and window-*.c.


Revision tags: OPENBSD_6_0_BASE
# 1.38 26-May-2016 nicm

Extend 0x1234 keys form to more bits so that Unicode keys work.


# 1.37 25-Apr-2016 nicm

Don't overwrite modifiers in the buffer when making UTF-8 strings,
append instead.


# 1.36 18-Mar-2016 nicm

Instead of reusing MouseUp at the finish of a drag, add a new key
MouseDragEnd. It can be useful to bind them separately in copy mode.


# 1.35 02-Mar-2016 nicm

Handle wcwidth() and mbtowc() failures in better style and drop
characters where we can't find the width (wcwidth() fails) on input, the
same as we drop invalid UTF-8. Suggested by schwarze@.


Revision tags: OPENBSD_5_9_BASE
# 1.34 19-Jan-2016 nicm

I no longer use my SourceForge address so replace it.


# 1.33 12-Dec-2015 nicm

Allow prefix and prefix2 to be set to None to disable (useful if you
would rather bind the prefix in the root table).


# 1.32 14-Nov-2015 nicm

All these return values from utf8_* are confusing, use an enum.


# 1.31 14-Nov-2015 nicm

Couple of assignments to remove compiler warnings.


# 1.30 14-Nov-2015 nicm

Be more strict about invalid UTF-8.


# 1.29 12-Nov-2015 nicm

Rename overly-long utf8data to ud throughout.


# 1.28 12-Nov-2015 nicm

Support UTF-8 key bindings by expanding the key type from int to
uint64_t and converting UTF-8 to Unicode on input and the reverse on
output. (This allows key bindings, there are still omissions - the
largest being that the various prompts do not accept UTF-8.)


# 1.27 26-Oct-2015 nicm

Handle unknown keys more gracefully, return a string instead of NULL.


Revision tags: OPENBSD_5_8_BASE
# 1.26 19-Apr-2015 nicm

Rewrite of tmux mouse support which was a mess. Instead of having
options for "mouse-this" and "mouse-that", mouse events may be bound as
keys and there is one option "mouse" that turns on mouse support
entirely (set -g mouse on).

See the new MOUSE SUPPORT section of the man page for description of the
key names and new flags (-t= to specify the pane or window under mouse
as a target, and send-keys -M to pass through a mouse event).

The default builtin bindings for the mouse are:

bind -n MouseDown1Pane select-pane -t=; send-keys -M
bind -n MouseDown1Status select-window -t=
bind -n MouseDrag1Pane copy-mode -M
bind -n MouseDrag1Border resize-pane -M

To get the effect of turning mode-mouse off, do:

unbind -n MouseDrag1Pane
unbind -temacs-copy MouseDrag1Pane

The old mouse options are now gone, set-option -q may be used to
suppress warnings if mixing configuration files.


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.25 21-Jul-2014 nicm

Drop explicit support for F13-F20 and change to match the xterm terminfo
entry:

F13-F24 are S-F1 to S-F12
F25-F36 are C-F1 to C-F12
F37-F48 are C-S-F1 to C-S-F12
F49-F60 are M-F1 to M-F12
and F61-F63 are M-S-F1 to M-S-F3

This should be no difference for applications inside tmux, but means
that any key binding for F13 will need to be replaced by S-F1 and so on.


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.24 22-Mar-2013 nicm

In terminals with XT, turn on modifyOtherKeys=1 with the escape sequence
and handle the most common set. Pass them through if xterm-keys is on.


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.23 04-Mar-2012 nicm

Accept hex values as keys, needed for send-keys, based on a diff from
George Nachman.


Revision tags: OPENBSD_5_1_BASE
# 1.22 21-Jan-2012 nicm

Drop the ability to have a list of keys in the prefix in favour of two
separate options, prefix and prefix2. This simplifies the code and gets
rid the data options type which was only used for this one option.

Also add a -2 flag to send-prefix to send the secondary prefix key,
fixing a cause of minor irritation.

People who want three prefix keys are out of luck :-).


# 1.21 23-Oct-2011 nicm

Alias NPage/PPage as PageDown/PgDn/PageUp/PgUp to reduce occasional
confusion.


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.20 23-Jan-2011 nicm

Allow top-bit-set characters to be used for key bindings, from Tiago
Cunha.


# 1.19 01-Jan-2011 nicm

Last few tables that should be const.


Revision tags: OPENBSD_4_8_BASE
# 1.18 06-Jun-2010 nicm

Use a macro-based mask for obtaining a key or modifier-set from the
combination. Display C-@, etc, as C-Space, in list-keys. By Micah Cowan.


# 1.17 05-Jun-2010 nicm

Fix binding of C-Space/C-@, from Micah Cowan.


# 1.16 03-May-2010 mcbride

Make C-] and other punctuation-based control key combinations work again.

ok nicm


# 1.15 23-Apr-2010 nicm

When converting A-Z into a control character, want to subtract 64 not
65... whoops.


# 1.14 21-Apr-2010 nicm

Rewrite key string conversions to be readable and to work properly for
multiple modifiers.


Revision tags: OPENBSD_4_7_BASE
# 1.13 14-Jan-2010 nicm

Permit S- prefix on keys for shift. Relatively few terminals support this
(basically xterm only) and even fewer have them in terminfo (kLFT2 and kRIT2).


# 1.12 03-Dec-2009 nicm

Massive spaces->tabs and trailing whitespace cleanup, hopefully for the last
time now I've configured emacs to make them displayed in really annoying
colours...


# 1.11 26-Nov-2009 nicm

Make types clearer and lint happier.


# 1.10 10-Nov-2009 nicm

Lookup key as a named key (eg 'Space') before checking for single character
keys, makes C-Space/M-Space etc resolve to the correct key code.


# 1.9 26-Oct-2009 nicm

Rename keypad keys to something more useful.


# 1.8 06-Oct-2009 nicm

Accept ^? for backspace as well as BSpace.


# 1.7 04-Oct-2009 nicm

Add a key string for space ("Space") and document the names, suggested by
guenther@. Also document how to bind " and ', suggested by miod@.


# 1.6 28-Jul-2009 nicm

Accept and print "Enter" and "Escape" for keys rather than C-m and C-[.


# 1.5 26-Jul-2009 nicm

Detect backspace by looking at termios VERASE and translate it into \177 (which
matches screen's behaviour if not its termcap/terminfo entry). The terminfo kbs
cap is often wrong or missing so it can't be used, and just assuming \177 may
be wrong.


# 1.4 24-Jul-2009 nicm

Accept lowercase c- and m- prefix as well as C- and M-.


# 1.3 21-Jul-2009 nicm

Tidy up keys: use an enum for the key codes, and remove the macros which just
wrap flag sets/clears/tests.


# 1.2 14-Jul-2009 nicm

Add backspace key to named keys.


Revision tags: OPENBSD_4_6_BASE
# 1.1 01-Jun-2009 nicm

Import tmux, a terminal multiplexor allowing (among other things) a single
terminal to be switched between several different windows and programs
displayed on one terminal be detached from one terminal and moved to another.

ok deraadt pirofti


# 1.52 14-Nov-2019 nicm

Add an option to set the key sent by backspace for those whose system
uses ^H rather than ^?. GitHub issue 1969.


Revision tags: OPENBSD_6_6_BASE
# 1.51 09-Jul-2019 nicm

Add a -H flag to send-keys to send literal keys given as hex numbers
(needed for control clients to send mouse sequences). Also add some
format flags for UTF-8 and SGR mouse mode. Requested by Bradley Smith in
GitHub issues 1832 and 1833.


Revision tags: OPENBSD_6_5_BASE
# 1.50 18-Oct-2018 nicm

Support for windows larger than visible on the attached client. This has
been a limitation for a long time.

There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.

The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.

If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.

Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).

The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.

For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..

If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.

The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.

The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.


Revision tags: OPENBSD_6_4_BASE
# 1.49 22-Aug-2018 nicm

Add StatusLeft and StatusRight mouse key modifiers for the left and
right parts of the status line.


# 1.48 16-Jul-2018 nicm

Add an "Any" key to run a command if a key is pressed that is not bound
in the current key table. GitHub issue 1404.


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.47 23-Jun-2017 nicm

Add user-keys option to allow user-defined keys to be set, from Dan
Aloni.


# 1.46 12-Jun-2017 nicm

Add explicit keys for the bracketed paste sequences, both to avoid mix
ups with other keys and to make logs clearer.


Revision tags: OPENBSD_6_1_BASE
# 1.45 22-Feb-2017 nicm

Minor bits: fix an array size, add comment, make grid_cell_entry static.


# 1.44 01-Feb-2017 nicm

Implement "all event" (1003) mouse mode but in a way that works. The
main issue is that if we have two panes, A with 1002 and B with 1003, we
need to set 1003 outside tmux in order to get all the mouse events, but
then we need to suppress the ones that pane A doesn't want. This is easy
in SGR mouse mode, because buttons == 3 is only used for movement events
(for other events the trailing m/M marks a release instead), but in
normal mouse mode we can't tell so easily. So for that, look at the
previous event instead - if it is drag+release as well, then the current
event is a movement event.


# 1.43 11-Jan-2017 nicm

Add some missing special keys to key_string_lookup_key, fix a mouse
check in server_client_handle_key, and tweak a comment.


# 1.42 05-Jan-2017 nicm

Highlight all occurrences of search string after searching in copy mode.


# 1.41 23-Nov-2016 nicm

Error on invalid modifier keys.


# 1.40 11-Oct-2016 nicm

Support double and triple clicks (they are cumulative, so double is
fired then triple), and use for select-word and select-line in copy
mode. Inspired by a different solution from Omar Sandoval.


# 1.39 10-Oct-2016 nicm

Loads more static, except for cmd-*.c and window-*.c.


Revision tags: OPENBSD_6_0_BASE
# 1.38 26-May-2016 nicm

Extend 0x1234 keys form to more bits so that Unicode keys work.


# 1.37 25-Apr-2016 nicm

Don't overwrite modifiers in the buffer when making UTF-8 strings,
append instead.


# 1.36 18-Mar-2016 nicm

Instead of reusing MouseUp at the finish of a drag, add a new key
MouseDragEnd. It can be useful to bind them separately in copy mode.


# 1.35 02-Mar-2016 nicm

Handle wcwidth() and mbtowc() failures in better style and drop
characters where we can't find the width (wcwidth() fails) on input, the
same as we drop invalid UTF-8. Suggested by schwarze@.


Revision tags: OPENBSD_5_9_BASE
# 1.34 19-Jan-2016 nicm

I no longer use my SourceForge address so replace it.


# 1.33 12-Dec-2015 nicm

Allow prefix and prefix2 to be set to None to disable (useful if you
would rather bind the prefix in the root table).


# 1.32 14-Nov-2015 nicm

All these return values from utf8_* are confusing, use an enum.


# 1.31 14-Nov-2015 nicm

Couple of assignments to remove compiler warnings.


# 1.30 14-Nov-2015 nicm

Be more strict about invalid UTF-8.


# 1.29 12-Nov-2015 nicm

Rename overly-long utf8data to ud throughout.


# 1.28 12-Nov-2015 nicm

Support UTF-8 key bindings by expanding the key type from int to
uint64_t and converting UTF-8 to Unicode on input and the reverse on
output. (This allows key bindings, there are still omissions - the
largest being that the various prompts do not accept UTF-8.)


# 1.27 26-Oct-2015 nicm

Handle unknown keys more gracefully, return a string instead of NULL.


Revision tags: OPENBSD_5_8_BASE
# 1.26 19-Apr-2015 nicm

Rewrite of tmux mouse support which was a mess. Instead of having
options for "mouse-this" and "mouse-that", mouse events may be bound as
keys and there is one option "mouse" that turns on mouse support
entirely (set -g mouse on).

See the new MOUSE SUPPORT section of the man page for description of the
key names and new flags (-t= to specify the pane or window under mouse
as a target, and send-keys -M to pass through a mouse event).

The default builtin bindings for the mouse are:

bind -n MouseDown1Pane select-pane -t=; send-keys -M
bind -n MouseDown1Status select-window -t=
bind -n MouseDrag1Pane copy-mode -M
bind -n MouseDrag1Border resize-pane -M

To get the effect of turning mode-mouse off, do:

unbind -n MouseDrag1Pane
unbind -temacs-copy MouseDrag1Pane

The old mouse options are now gone, set-option -q may be used to
suppress warnings if mixing configuration files.


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.25 21-Jul-2014 nicm

Drop explicit support for F13-F20 and change to match the xterm terminfo
entry:

F13-F24 are S-F1 to S-F12
F25-F36 are C-F1 to C-F12
F37-F48 are C-S-F1 to C-S-F12
F49-F60 are M-F1 to M-F12
and F61-F63 are M-S-F1 to M-S-F3

This should be no difference for applications inside tmux, but means
that any key binding for F13 will need to be replaced by S-F1 and so on.


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.24 22-Mar-2013 nicm

In terminals with XT, turn on modifyOtherKeys=1 with the escape sequence
and handle the most common set. Pass them through if xterm-keys is on.


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.23 04-Mar-2012 nicm

Accept hex values as keys, needed for send-keys, based on a diff from
George Nachman.


Revision tags: OPENBSD_5_1_BASE
# 1.22 21-Jan-2012 nicm

Drop the ability to have a list of keys in the prefix in favour of two
separate options, prefix and prefix2. This simplifies the code and gets
rid the data options type which was only used for this one option.

Also add a -2 flag to send-prefix to send the secondary prefix key,
fixing a cause of minor irritation.

People who want three prefix keys are out of luck :-).


# 1.21 23-Oct-2011 nicm

Alias NPage/PPage as PageDown/PgDn/PageUp/PgUp to reduce occasional
confusion.


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.20 23-Jan-2011 nicm

Allow top-bit-set characters to be used for key bindings, from Tiago
Cunha.


# 1.19 01-Jan-2011 nicm

Last few tables that should be const.


Revision tags: OPENBSD_4_8_BASE
# 1.18 06-Jun-2010 nicm

Use a macro-based mask for obtaining a key or modifier-set from the
combination. Display C-@, etc, as C-Space, in list-keys. By Micah Cowan.


# 1.17 05-Jun-2010 nicm

Fix binding of C-Space/C-@, from Micah Cowan.


# 1.16 03-May-2010 mcbride

Make C-] and other punctuation-based control key combinations work again.

ok nicm


# 1.15 23-Apr-2010 nicm

When converting A-Z into a control character, want to subtract 64 not
65... whoops.


# 1.14 21-Apr-2010 nicm

Rewrite key string conversions to be readable and to work properly for
multiple modifiers.


Revision tags: OPENBSD_4_7_BASE
# 1.13 14-Jan-2010 nicm

Permit S- prefix on keys for shift. Relatively few terminals support this
(basically xterm only) and even fewer have them in terminfo (kLFT2 and kRIT2).


# 1.12 03-Dec-2009 nicm

Massive spaces->tabs and trailing whitespace cleanup, hopefully for the last
time now I've configured emacs to make them displayed in really annoying
colours...


# 1.11 26-Nov-2009 nicm

Make types clearer and lint happier.


# 1.10 10-Nov-2009 nicm

Lookup key as a named key (eg 'Space') before checking for single character
keys, makes C-Space/M-Space etc resolve to the correct key code.


# 1.9 26-Oct-2009 nicm

Rename keypad keys to something more useful.


# 1.8 06-Oct-2009 nicm

Accept ^? for backspace as well as BSpace.


# 1.7 04-Oct-2009 nicm

Add a key string for space ("Space") and document the names, suggested by
guenther@. Also document how to bind " and ', suggested by miod@.


# 1.6 28-Jul-2009 nicm

Accept and print "Enter" and "Escape" for keys rather than C-m and C-[.


# 1.5 26-Jul-2009 nicm

Detect backspace by looking at termios VERASE and translate it into \177 (which
matches screen's behaviour if not its termcap/terminfo entry). The terminfo kbs
cap is often wrong or missing so it can't be used, and just assuming \177 may
be wrong.


# 1.4 24-Jul-2009 nicm

Accept lowercase c- and m- prefix as well as C- and M-.


# 1.3 21-Jul-2009 nicm

Tidy up keys: use an enum for the key codes, and remove the macros which just
wrap flag sets/clears/tests.


# 1.2 14-Jul-2009 nicm

Add backspace key to named keys.


Revision tags: OPENBSD_4_6_BASE
# 1.1 01-Jun-2009 nicm

Import tmux, a terminal multiplexor allowing (among other things) a single
terminal to be switched between several different windows and programs
displayed on one terminal be detached from one terminal and moved to another.

ok deraadt pirofti


# 1.51 09-Jul-2019 nicm

Add a -H flag to send-keys to send literal keys given as hex numbers
(needed for control clients to send mouse sequences). Also add some
format flags for UTF-8 and SGR mouse mode. Requested by Bradley Smith in
GitHub issues 1832 and 1833.


Revision tags: OPENBSD_6_5_BASE
# 1.50 18-Oct-2018 nicm

Support for windows larger than visible on the attached client. This has
been a limitation for a long time.

There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.

The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.

If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.

Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).

The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.

For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..

If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.

The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.

The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.


Revision tags: OPENBSD_6_4_BASE
# 1.49 22-Aug-2018 nicm

Add StatusLeft and StatusRight mouse key modifiers for the left and
right parts of the status line.


# 1.48 16-Jul-2018 nicm

Add an "Any" key to run a command if a key is pressed that is not bound
in the current key table. GitHub issue 1404.


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.47 23-Jun-2017 nicm

Add user-keys option to allow user-defined keys to be set, from Dan
Aloni.


# 1.46 12-Jun-2017 nicm

Add explicit keys for the bracketed paste sequences, both to avoid mix
ups with other keys and to make logs clearer.


Revision tags: OPENBSD_6_1_BASE
# 1.45 22-Feb-2017 nicm

Minor bits: fix an array size, add comment, make grid_cell_entry static.


# 1.44 01-Feb-2017 nicm

Implement "all event" (1003) mouse mode but in a way that works. The
main issue is that if we have two panes, A with 1002 and B with 1003, we
need to set 1003 outside tmux in order to get all the mouse events, but
then we need to suppress the ones that pane A doesn't want. This is easy
in SGR mouse mode, because buttons == 3 is only used for movement events
(for other events the trailing m/M marks a release instead), but in
normal mouse mode we can't tell so easily. So for that, look at the
previous event instead - if it is drag+release as well, then the current
event is a movement event.


# 1.43 11-Jan-2017 nicm

Add some missing special keys to key_string_lookup_key, fix a mouse
check in server_client_handle_key, and tweak a comment.


# 1.42 05-Jan-2017 nicm

Highlight all occurrences of search string after searching in copy mode.


# 1.41 23-Nov-2016 nicm

Error on invalid modifier keys.


# 1.40 11-Oct-2016 nicm

Support double and triple clicks (they are cumulative, so double is
fired then triple), and use for select-word and select-line in copy
mode. Inspired by a different solution from Omar Sandoval.


# 1.39 10-Oct-2016 nicm

Loads more static, except for cmd-*.c and window-*.c.


Revision tags: OPENBSD_6_0_BASE
# 1.38 26-May-2016 nicm

Extend 0x1234 keys form to more bits so that Unicode keys work.


# 1.37 25-Apr-2016 nicm

Don't overwrite modifiers in the buffer when making UTF-8 strings,
append instead.


# 1.36 18-Mar-2016 nicm

Instead of reusing MouseUp at the finish of a drag, add a new key
MouseDragEnd. It can be useful to bind them separately in copy mode.


# 1.35 02-Mar-2016 nicm

Handle wcwidth() and mbtowc() failures in better style and drop
characters where we can't find the width (wcwidth() fails) on input, the
same as we drop invalid UTF-8. Suggested by schwarze@.


Revision tags: OPENBSD_5_9_BASE
# 1.34 19-Jan-2016 nicm

I no longer use my SourceForge address so replace it.


# 1.33 12-Dec-2015 nicm

Allow prefix and prefix2 to be set to None to disable (useful if you
would rather bind the prefix in the root table).


# 1.32 14-Nov-2015 nicm

All these return values from utf8_* are confusing, use an enum.


# 1.31 14-Nov-2015 nicm

Couple of assignments to remove compiler warnings.


# 1.30 14-Nov-2015 nicm

Be more strict about invalid UTF-8.


# 1.29 12-Nov-2015 nicm

Rename overly-long utf8data to ud throughout.


# 1.28 12-Nov-2015 nicm

Support UTF-8 key bindings by expanding the key type from int to
uint64_t and converting UTF-8 to Unicode on input and the reverse on
output. (This allows key bindings, there are still omissions - the
largest being that the various prompts do not accept UTF-8.)


# 1.27 26-Oct-2015 nicm

Handle unknown keys more gracefully, return a string instead of NULL.


Revision tags: OPENBSD_5_8_BASE
# 1.26 19-Apr-2015 nicm

Rewrite of tmux mouse support which was a mess. Instead of having
options for "mouse-this" and "mouse-that", mouse events may be bound as
keys and there is one option "mouse" that turns on mouse support
entirely (set -g mouse on).

See the new MOUSE SUPPORT section of the man page for description of the
key names and new flags (-t= to specify the pane or window under mouse
as a target, and send-keys -M to pass through a mouse event).

The default builtin bindings for the mouse are:

bind -n MouseDown1Pane select-pane -t=; send-keys -M
bind -n MouseDown1Status select-window -t=
bind -n MouseDrag1Pane copy-mode -M
bind -n MouseDrag1Border resize-pane -M

To get the effect of turning mode-mouse off, do:

unbind -n MouseDrag1Pane
unbind -temacs-copy MouseDrag1Pane

The old mouse options are now gone, set-option -q may be used to
suppress warnings if mixing configuration files.


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.25 21-Jul-2014 nicm

Drop explicit support for F13-F20 and change to match the xterm terminfo
entry:

F13-F24 are S-F1 to S-F12
F25-F36 are C-F1 to C-F12
F37-F48 are C-S-F1 to C-S-F12
F49-F60 are M-F1 to M-F12
and F61-F63 are M-S-F1 to M-S-F3

This should be no difference for applications inside tmux, but means
that any key binding for F13 will need to be replaced by S-F1 and so on.


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.24 22-Mar-2013 nicm

In terminals with XT, turn on modifyOtherKeys=1 with the escape sequence
and handle the most common set. Pass them through if xterm-keys is on.


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.23 04-Mar-2012 nicm

Accept hex values as keys, needed for send-keys, based on a diff from
George Nachman.


Revision tags: OPENBSD_5_1_BASE
# 1.22 21-Jan-2012 nicm

Drop the ability to have a list of keys in the prefix in favour of two
separate options, prefix and prefix2. This simplifies the code and gets
rid the data options type which was only used for this one option.

Also add a -2 flag to send-prefix to send the secondary prefix key,
fixing a cause of minor irritation.

People who want three prefix keys are out of luck :-).


# 1.21 23-Oct-2011 nicm

Alias NPage/PPage as PageDown/PgDn/PageUp/PgUp to reduce occasional
confusion.


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.20 23-Jan-2011 nicm

Allow top-bit-set characters to be used for key bindings, from Tiago
Cunha.


# 1.19 01-Jan-2011 nicm

Last few tables that should be const.


Revision tags: OPENBSD_4_8_BASE
# 1.18 06-Jun-2010 nicm

Use a macro-based mask for obtaining a key or modifier-set from the
combination. Display C-@, etc, as C-Space, in list-keys. By Micah Cowan.


# 1.17 05-Jun-2010 nicm

Fix binding of C-Space/C-@, from Micah Cowan.


# 1.16 03-May-2010 mcbride

Make C-] and other punctuation-based control key combinations work again.

ok nicm


# 1.15 23-Apr-2010 nicm

When converting A-Z into a control character, want to subtract 64 not
65... whoops.


# 1.14 21-Apr-2010 nicm

Rewrite key string conversions to be readable and to work properly for
multiple modifiers.


Revision tags: OPENBSD_4_7_BASE
# 1.13 14-Jan-2010 nicm

Permit S- prefix on keys for shift. Relatively few terminals support this
(basically xterm only) and even fewer have them in terminfo (kLFT2 and kRIT2).


# 1.12 03-Dec-2009 nicm

Massive spaces->tabs and trailing whitespace cleanup, hopefully for the last
time now I've configured emacs to make them displayed in really annoying
colours...


# 1.11 26-Nov-2009 nicm

Make types clearer and lint happier.


# 1.10 10-Nov-2009 nicm

Lookup key as a named key (eg 'Space') before checking for single character
keys, makes C-Space/M-Space etc resolve to the correct key code.


# 1.9 26-Oct-2009 nicm

Rename keypad keys to something more useful.


# 1.8 06-Oct-2009 nicm

Accept ^? for backspace as well as BSpace.


# 1.7 04-Oct-2009 nicm

Add a key string for space ("Space") and document the names, suggested by
guenther@. Also document how to bind " and ', suggested by miod@.


# 1.6 28-Jul-2009 nicm

Accept and print "Enter" and "Escape" for keys rather than C-m and C-[.


# 1.5 26-Jul-2009 nicm

Detect backspace by looking at termios VERASE and translate it into \177 (which
matches screen's behaviour if not its termcap/terminfo entry). The terminfo kbs
cap is often wrong or missing so it can't be used, and just assuming \177 may
be wrong.


# 1.4 24-Jul-2009 nicm

Accept lowercase c- and m- prefix as well as C- and M-.


# 1.3 21-Jul-2009 nicm

Tidy up keys: use an enum for the key codes, and remove the macros which just
wrap flag sets/clears/tests.


# 1.2 14-Jul-2009 nicm

Add backspace key to named keys.


Revision tags: OPENBSD_4_6_BASE
# 1.1 01-Jun-2009 nicm

Import tmux, a terminal multiplexor allowing (among other things) a single
terminal to be switched between several different windows and programs
displayed on one terminal be detached from one terminal and moved to another.

ok deraadt pirofti


# 1.50 18-Oct-2018 nicm

Support for windows larger than visible on the attached client. This has
been a limitation for a long time.

There are two new options, window-size and default-size, and a new
command, resize-window. The force-width and force-height options and the
session_width and session_height formats have been removed.

The new window-size option tells tmux how to work out the size of
windows: largest means it picks the size of the largest session,
smallest the smallest session (similar to the old behaviour) and manual
means that it does not automatically resize windows. The default is
currently largest but this may change. aggressive-resize modifies the
choice of session for largest and smallest as it did before.

If a window is in a session attached to a client that is too small, only
part of the window is shown. tmux attempts to keep the cursor visible,
so the part of the window displayed is changed as the cursor moves (with
a small delay, to try and avoid excess redrawing when applications
redraw status lines or similar that are not currently visible). The
offset of the visible portion of the window is shown in status-right.

Drawing windows which are larger than the client is not as efficient as
those which fit, particularly when the cursor moves, so it is
recommended to avoid using this on slow machines or networks (set
window-size to smallest or manual).

The resize-window command can be used to resize a window manually. If it
is used, the window-size option is automatically set to manual for the
window (undo this with "setw -u window-size"). resize-window works in a
similar way to resize-pane (-U -D -L -R -x -y flags) but also has -a and
-A flags. -a sets the window to the size of the smallest client (what it
would be if window-size was smallest) and -A the largest.

For the same behaviour as force-width or force-height, use resize-window
-x or -y, and "setw -u window-size" to revert to automatic sizing..

If the global window-size option is set to manual, the default-size
option is used for new windows. If -x or -y is used with new-session,
that sets the default-size option for the new session.

The maximum size of a window is 10000x10000. But expect applications to
complain and much higher memory use if making a window excessively
big. The minimum size is the size required for the current layout
including borders.

The refresh-client command can be used to pan around a window, -U -D -L
-R moves up, down, left or right and -c returns to automatic cursor
tracking. The position is reset when the current window is changed.


Revision tags: OPENBSD_6_4_BASE
# 1.49 22-Aug-2018 nicm

Add StatusLeft and StatusRight mouse key modifiers for the left and
right parts of the status line.


# 1.48 16-Jul-2018 nicm

Add an "Any" key to run a command if a key is pressed that is not bound
in the current key table. GitHub issue 1404.


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.47 23-Jun-2017 nicm

Add user-keys option to allow user-defined keys to be set, from Dan
Aloni.


# 1.46 12-Jun-2017 nicm

Add explicit keys for the bracketed paste sequences, both to avoid mix
ups with other keys and to make logs clearer.


Revision tags: OPENBSD_6_1_BASE
# 1.45 22-Feb-2017 nicm

Minor bits: fix an array size, add comment, make grid_cell_entry static.


# 1.44 01-Feb-2017 nicm

Implement "all event" (1003) mouse mode but in a way that works. The
main issue is that if we have two panes, A with 1002 and B with 1003, we
need to set 1003 outside tmux in order to get all the mouse events, but
then we need to suppress the ones that pane A doesn't want. This is easy
in SGR mouse mode, because buttons == 3 is only used for movement events
(for other events the trailing m/M marks a release instead), but in
normal mouse mode we can't tell so easily. So for that, look at the
previous event instead - if it is drag+release as well, then the current
event is a movement event.


# 1.43 11-Jan-2017 nicm

Add some missing special keys to key_string_lookup_key, fix a mouse
check in server_client_handle_key, and tweak a comment.


# 1.42 05-Jan-2017 nicm

Highlight all occurrences of search string after searching in copy mode.


# 1.41 23-Nov-2016 nicm

Error on invalid modifier keys.


# 1.40 11-Oct-2016 nicm

Support double and triple clicks (they are cumulative, so double is
fired then triple), and use for select-word and select-line in copy
mode. Inspired by a different solution from Omar Sandoval.


# 1.39 10-Oct-2016 nicm

Loads more static, except for cmd-*.c and window-*.c.


Revision tags: OPENBSD_6_0_BASE
# 1.38 26-May-2016 nicm

Extend 0x1234 keys form to more bits so that Unicode keys work.


# 1.37 25-Apr-2016 nicm

Don't overwrite modifiers in the buffer when making UTF-8 strings,
append instead.


# 1.36 18-Mar-2016 nicm

Instead of reusing MouseUp at the finish of a drag, add a new key
MouseDragEnd. It can be useful to bind them separately in copy mode.


# 1.35 02-Mar-2016 nicm

Handle wcwidth() and mbtowc() failures in better style and drop
characters where we can't find the width (wcwidth() fails) on input, the
same as we drop invalid UTF-8. Suggested by schwarze@.


Revision tags: OPENBSD_5_9_BASE
# 1.34 19-Jan-2016 nicm

I no longer use my SourceForge address so replace it.


# 1.33 12-Dec-2015 nicm

Allow prefix and prefix2 to be set to None to disable (useful if you
would rather bind the prefix in the root table).


# 1.32 14-Nov-2015 nicm

All these return values from utf8_* are confusing, use an enum.


# 1.31 14-Nov-2015 nicm

Couple of assignments to remove compiler warnings.


# 1.30 14-Nov-2015 nicm

Be more strict about invalid UTF-8.


# 1.29 12-Nov-2015 nicm

Rename overly-long utf8data to ud throughout.


# 1.28 12-Nov-2015 nicm

Support UTF-8 key bindings by expanding the key type from int to
uint64_t and converting UTF-8 to Unicode on input and the reverse on
output. (This allows key bindings, there are still omissions - the
largest being that the various prompts do not accept UTF-8.)


# 1.27 26-Oct-2015 nicm

Handle unknown keys more gracefully, return a string instead of NULL.


Revision tags: OPENBSD_5_8_BASE
# 1.26 19-Apr-2015 nicm

Rewrite of tmux mouse support which was a mess. Instead of having
options for "mouse-this" and "mouse-that", mouse events may be bound as
keys and there is one option "mouse" that turns on mouse support
entirely (set -g mouse on).

See the new MOUSE SUPPORT section of the man page for description of the
key names and new flags (-t= to specify the pane or window under mouse
as a target, and send-keys -M to pass through a mouse event).

The default builtin bindings for the mouse are:

bind -n MouseDown1Pane select-pane -t=; send-keys -M
bind -n MouseDown1Status select-window -t=
bind -n MouseDrag1Pane copy-mode -M
bind -n MouseDrag1Border resize-pane -M

To get the effect of turning mode-mouse off, do:

unbind -n MouseDrag1Pane
unbind -temacs-copy MouseDrag1Pane

The old mouse options are now gone, set-option -q may be used to
suppress warnings if mixing configuration files.


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.25 21-Jul-2014 nicm

Drop explicit support for F13-F20 and change to match the xterm terminfo
entry:

F13-F24 are S-F1 to S-F12
F25-F36 are C-F1 to C-F12
F37-F48 are C-S-F1 to C-S-F12
F49-F60 are M-F1 to M-F12
and F61-F63 are M-S-F1 to M-S-F3

This should be no difference for applications inside tmux, but means
that any key binding for F13 will need to be replaced by S-F1 and so on.


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.24 22-Mar-2013 nicm

In terminals with XT, turn on modifyOtherKeys=1 with the escape sequence
and handle the most common set. Pass them through if xterm-keys is on.


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.23 04-Mar-2012 nicm

Accept hex values as keys, needed for send-keys, based on a diff from
George Nachman.


Revision tags: OPENBSD_5_1_BASE
# 1.22 21-Jan-2012 nicm

Drop the ability to have a list of keys in the prefix in favour of two
separate options, prefix and prefix2. This simplifies the code and gets
rid the data options type which was only used for this one option.

Also add a -2 flag to send-prefix to send the secondary prefix key,
fixing a cause of minor irritation.

People who want three prefix keys are out of luck :-).


# 1.21 23-Oct-2011 nicm

Alias NPage/PPage as PageDown/PgDn/PageUp/PgUp to reduce occasional
confusion.


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.20 23-Jan-2011 nicm

Allow top-bit-set characters to be used for key bindings, from Tiago
Cunha.


# 1.19 01-Jan-2011 nicm

Last few tables that should be const.


Revision tags: OPENBSD_4_8_BASE
# 1.18 06-Jun-2010 nicm

Use a macro-based mask for obtaining a key or modifier-set from the
combination. Display C-@, etc, as C-Space, in list-keys. By Micah Cowan.


# 1.17 05-Jun-2010 nicm

Fix binding of C-Space/C-@, from Micah Cowan.


# 1.16 03-May-2010 mcbride

Make C-] and other punctuation-based control key combinations work again.

ok nicm


# 1.15 23-Apr-2010 nicm

When converting A-Z into a control character, want to subtract 64 not
65... whoops.


# 1.14 21-Apr-2010 nicm

Rewrite key string conversions to be readable and to work properly for
multiple modifiers.


Revision tags: OPENBSD_4_7_BASE
# 1.13 14-Jan-2010 nicm

Permit S- prefix on keys for shift. Relatively few terminals support this
(basically xterm only) and even fewer have them in terminfo (kLFT2 and kRIT2).


# 1.12 03-Dec-2009 nicm

Massive spaces->tabs and trailing whitespace cleanup, hopefully for the last
time now I've configured emacs to make them displayed in really annoying
colours...


# 1.11 26-Nov-2009 nicm

Make types clearer and lint happier.


# 1.10 10-Nov-2009 nicm

Lookup key as a named key (eg 'Space') before checking for single character
keys, makes C-Space/M-Space etc resolve to the correct key code.


# 1.9 26-Oct-2009 nicm

Rename keypad keys to something more useful.


# 1.8 06-Oct-2009 nicm

Accept ^? for backspace as well as BSpace.


# 1.7 04-Oct-2009 nicm

Add a key string for space ("Space") and document the names, suggested by
guenther@. Also document how to bind " and ', suggested by miod@.


# 1.6 28-Jul-2009 nicm

Accept and print "Enter" and "Escape" for keys rather than C-m and C-[.


# 1.5 26-Jul-2009 nicm

Detect backspace by looking at termios VERASE and translate it into \177 (which
matches screen's behaviour if not its termcap/terminfo entry). The terminfo kbs
cap is often wrong or missing so it can't be used, and just assuming \177 may
be wrong.


# 1.4 24-Jul-2009 nicm

Accept lowercase c- and m- prefix as well as C- and M-.


# 1.3 21-Jul-2009 nicm

Tidy up keys: use an enum for the key codes, and remove the macros which just
wrap flag sets/clears/tests.


# 1.2 14-Jul-2009 nicm

Add backspace key to named keys.


Revision tags: OPENBSD_4_6_BASE
# 1.1 01-Jun-2009 nicm

Import tmux, a terminal multiplexor allowing (among other things) a single
terminal to be switched between several different windows and programs
displayed on one terminal be detached from one terminal and moved to another.

ok deraadt pirofti


# 1.49 22-Aug-2018 nicm

Add StatusLeft and StatusRight mouse key modifiers for the left and
right parts of the status line.


# 1.48 16-Jul-2018 nicm

Add an "Any" key to run a command if a key is pressed that is not bound
in the current key table. GitHub issue 1404.


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.47 23-Jun-2017 nicm

Add user-keys option to allow user-defined keys to be set, from Dan
Aloni.


# 1.46 12-Jun-2017 nicm

Add explicit keys for the bracketed paste sequences, both to avoid mix
ups with other keys and to make logs clearer.


Revision tags: OPENBSD_6_1_BASE
# 1.45 22-Feb-2017 nicm

Minor bits: fix an array size, add comment, make grid_cell_entry static.


# 1.44 01-Feb-2017 nicm

Implement "all event" (1003) mouse mode but in a way that works. The
main issue is that if we have two panes, A with 1002 and B with 1003, we
need to set 1003 outside tmux in order to get all the mouse events, but
then we need to suppress the ones that pane A doesn't want. This is easy
in SGR mouse mode, because buttons == 3 is only used for movement events
(for other events the trailing m/M marks a release instead), but in
normal mouse mode we can't tell so easily. So for that, look at the
previous event instead - if it is drag+release as well, then the current
event is a movement event.


# 1.43 11-Jan-2017 nicm

Add some missing special keys to key_string_lookup_key, fix a mouse
check in server_client_handle_key, and tweak a comment.


# 1.42 05-Jan-2017 nicm

Highlight all occurrences of search string after searching in copy mode.


# 1.41 23-Nov-2016 nicm

Error on invalid modifier keys.


# 1.40 11-Oct-2016 nicm

Support double and triple clicks (they are cumulative, so double is
fired then triple), and use for select-word and select-line in copy
mode. Inspired by a different solution from Omar Sandoval.


# 1.39 10-Oct-2016 nicm

Loads more static, except for cmd-*.c and window-*.c.


Revision tags: OPENBSD_6_0_BASE
# 1.38 26-May-2016 nicm

Extend 0x1234 keys form to more bits so that Unicode keys work.


# 1.37 25-Apr-2016 nicm

Don't overwrite modifiers in the buffer when making UTF-8 strings,
append instead.


# 1.36 18-Mar-2016 nicm

Instead of reusing MouseUp at the finish of a drag, add a new key
MouseDragEnd. It can be useful to bind them separately in copy mode.


# 1.35 02-Mar-2016 nicm

Handle wcwidth() and mbtowc() failures in better style and drop
characters where we can't find the width (wcwidth() fails) on input, the
same as we drop invalid UTF-8. Suggested by schwarze@.


Revision tags: OPENBSD_5_9_BASE
# 1.34 19-Jan-2016 nicm

I no longer use my SourceForge address so replace it.


# 1.33 12-Dec-2015 nicm

Allow prefix and prefix2 to be set to None to disable (useful if you
would rather bind the prefix in the root table).


# 1.32 14-Nov-2015 nicm

All these return values from utf8_* are confusing, use an enum.


# 1.31 14-Nov-2015 nicm

Couple of assignments to remove compiler warnings.


# 1.30 14-Nov-2015 nicm

Be more strict about invalid UTF-8.


# 1.29 12-Nov-2015 nicm

Rename overly-long utf8data to ud throughout.


# 1.28 12-Nov-2015 nicm

Support UTF-8 key bindings by expanding the key type from int to
uint64_t and converting UTF-8 to Unicode on input and the reverse on
output. (This allows key bindings, there are still omissions - the
largest being that the various prompts do not accept UTF-8.)


# 1.27 26-Oct-2015 nicm

Handle unknown keys more gracefully, return a string instead of NULL.


Revision tags: OPENBSD_5_8_BASE
# 1.26 19-Apr-2015 nicm

Rewrite of tmux mouse support which was a mess. Instead of having
options for "mouse-this" and "mouse-that", mouse events may be bound as
keys and there is one option "mouse" that turns on mouse support
entirely (set -g mouse on).

See the new MOUSE SUPPORT section of the man page for description of the
key names and new flags (-t= to specify the pane or window under mouse
as a target, and send-keys -M to pass through a mouse event).

The default builtin bindings for the mouse are:

bind -n MouseDown1Pane select-pane -t=; send-keys -M
bind -n MouseDown1Status select-window -t=
bind -n MouseDrag1Pane copy-mode -M
bind -n MouseDrag1Border resize-pane -M

To get the effect of turning mode-mouse off, do:

unbind -n MouseDrag1Pane
unbind -temacs-copy MouseDrag1Pane

The old mouse options are now gone, set-option -q may be used to
suppress warnings if mixing configuration files.


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.25 21-Jul-2014 nicm

Drop explicit support for F13-F20 and change to match the xterm terminfo
entry:

F13-F24 are S-F1 to S-F12
F25-F36 are C-F1 to C-F12
F37-F48 are C-S-F1 to C-S-F12
F49-F60 are M-F1 to M-F12
and F61-F63 are M-S-F1 to M-S-F3

This should be no difference for applications inside tmux, but means
that any key binding for F13 will need to be replaced by S-F1 and so on.


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.24 22-Mar-2013 nicm

In terminals with XT, turn on modifyOtherKeys=1 with the escape sequence
and handle the most common set. Pass them through if xterm-keys is on.


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.23 04-Mar-2012 nicm

Accept hex values as keys, needed for send-keys, based on a diff from
George Nachman.


Revision tags: OPENBSD_5_1_BASE
# 1.22 21-Jan-2012 nicm

Drop the ability to have a list of keys in the prefix in favour of two
separate options, prefix and prefix2. This simplifies the code and gets
rid the data options type which was only used for this one option.

Also add a -2 flag to send-prefix to send the secondary prefix key,
fixing a cause of minor irritation.

People who want three prefix keys are out of luck :-).


# 1.21 23-Oct-2011 nicm

Alias NPage/PPage as PageDown/PgDn/PageUp/PgUp to reduce occasional
confusion.


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.20 23-Jan-2011 nicm

Allow top-bit-set characters to be used for key bindings, from Tiago
Cunha.


# 1.19 01-Jan-2011 nicm

Last few tables that should be const.


Revision tags: OPENBSD_4_8_BASE
# 1.18 06-Jun-2010 nicm

Use a macro-based mask for obtaining a key or modifier-set from the
combination. Display C-@, etc, as C-Space, in list-keys. By Micah Cowan.


# 1.17 05-Jun-2010 nicm

Fix binding of C-Space/C-@, from Micah Cowan.


# 1.16 03-May-2010 mcbride

Make C-] and other punctuation-based control key combinations work again.

ok nicm


# 1.15 23-Apr-2010 nicm

When converting A-Z into a control character, want to subtract 64 not
65... whoops.


# 1.14 21-Apr-2010 nicm

Rewrite key string conversions to be readable and to work properly for
multiple modifiers.


Revision tags: OPENBSD_4_7_BASE
# 1.13 14-Jan-2010 nicm

Permit S- prefix on keys for shift. Relatively few terminals support this
(basically xterm only) and even fewer have them in terminfo (kLFT2 and kRIT2).


# 1.12 03-Dec-2009 nicm

Massive spaces->tabs and trailing whitespace cleanup, hopefully for the last
time now I've configured emacs to make them displayed in really annoying
colours...


# 1.11 26-Nov-2009 nicm

Make types clearer and lint happier.


# 1.10 10-Nov-2009 nicm

Lookup key as a named key (eg 'Space') before checking for single character
keys, makes C-Space/M-Space etc resolve to the correct key code.


# 1.9 26-Oct-2009 nicm

Rename keypad keys to something more useful.


# 1.8 06-Oct-2009 nicm

Accept ^? for backspace as well as BSpace.


# 1.7 04-Oct-2009 nicm

Add a key string for space ("Space") and document the names, suggested by
guenther@. Also document how to bind " and ', suggested by miod@.


# 1.6 28-Jul-2009 nicm

Accept and print "Enter" and "Escape" for keys rather than C-m and C-[.


# 1.5 26-Jul-2009 nicm

Detect backspace by looking at termios VERASE and translate it into \177 (which
matches screen's behaviour if not its termcap/terminfo entry). The terminfo kbs
cap is often wrong or missing so it can't be used, and just assuming \177 may
be wrong.


# 1.4 24-Jul-2009 nicm

Accept lowercase c- and m- prefix as well as C- and M-.


# 1.3 21-Jul-2009 nicm

Tidy up keys: use an enum for the key codes, and remove the macros which just
wrap flag sets/clears/tests.


# 1.2 14-Jul-2009 nicm

Add backspace key to named keys.


Revision tags: OPENBSD_4_6_BASE
# 1.1 01-Jun-2009 nicm

Import tmux, a terminal multiplexor allowing (among other things) a single
terminal to be switched between several different windows and programs
displayed on one terminal be detached from one terminal and moved to another.

ok deraadt pirofti


Revision tags: OPENBSD_6_2_BASE
# 1.47 23-Jun-2017 nicm

Add user-keys option to allow user-defined keys to be set, from Dan
Aloni.


# 1.46 12-Jun-2017 nicm

Add explicit keys for the bracketed paste sequences, both to avoid mix
ups with other keys and to make logs clearer.


Revision tags: OPENBSD_6_1_BASE
# 1.45 22-Feb-2017 nicm

Minor bits: fix an array size, add comment, make grid_cell_entry static.


# 1.44 01-Feb-2017 nicm

Implement "all event" (1003) mouse mode but in a way that works. The
main issue is that if we have two panes, A with 1002 and B with 1003, we
need to set 1003 outside tmux in order to get all the mouse events, but
then we need to suppress the ones that pane A doesn't want. This is easy
in SGR mouse mode, because buttons == 3 is only used for movement events
(for other events the trailing m/M marks a release instead), but in
normal mouse mode we can't tell so easily. So for that, look at the
previous event instead - if it is drag+release as well, then the current
event is a movement event.


# 1.43 11-Jan-2017 nicm

Add some missing special keys to key_string_lookup_key, fix a mouse
check in server_client_handle_key, and tweak a comment.


# 1.42 05-Jan-2017 nicm

Highlight all occurrences of search string after searching in copy mode.


# 1.41 23-Nov-2016 nicm

Error on invalid modifier keys.


# 1.40 11-Oct-2016 nicm

Support double and triple clicks (they are cumulative, so double is
fired then triple), and use for select-word and select-line in copy
mode. Inspired by a different solution from Omar Sandoval.


# 1.39 10-Oct-2016 nicm

Loads more static, except for cmd-*.c and window-*.c.


Revision tags: OPENBSD_6_0_BASE
# 1.38 26-May-2016 nicm

Extend 0x1234 keys form to more bits so that Unicode keys work.


# 1.37 25-Apr-2016 nicm

Don't overwrite modifiers in the buffer when making UTF-8 strings,
append instead.


# 1.36 18-Mar-2016 nicm

Instead of reusing MouseUp at the finish of a drag, add a new key
MouseDragEnd. It can be useful to bind them separately in copy mode.


# 1.35 02-Mar-2016 nicm

Handle wcwidth() and mbtowc() failures in better style and drop
characters where we can't find the width (wcwidth() fails) on input, the
same as we drop invalid UTF-8. Suggested by schwarze@.


Revision tags: OPENBSD_5_9_BASE
# 1.34 19-Jan-2016 nicm

I no longer use my SourceForge address so replace it.


# 1.33 12-Dec-2015 nicm

Allow prefix and prefix2 to be set to None to disable (useful if you
would rather bind the prefix in the root table).


# 1.32 14-Nov-2015 nicm

All these return values from utf8_* are confusing, use an enum.


# 1.31 14-Nov-2015 nicm

Couple of assignments to remove compiler warnings.


# 1.30 14-Nov-2015 nicm

Be more strict about invalid UTF-8.


# 1.29 12-Nov-2015 nicm

Rename overly-long utf8data to ud throughout.


# 1.28 12-Nov-2015 nicm

Support UTF-8 key bindings by expanding the key type from int to
uint64_t and converting UTF-8 to Unicode on input and the reverse on
output. (This allows key bindings, there are still omissions - the
largest being that the various prompts do not accept UTF-8.)


# 1.27 26-Oct-2015 nicm

Handle unknown keys more gracefully, return a string instead of NULL.


Revision tags: OPENBSD_5_8_BASE
# 1.26 19-Apr-2015 nicm

Rewrite of tmux mouse support which was a mess. Instead of having
options for "mouse-this" and "mouse-that", mouse events may be bound as
keys and there is one option "mouse" that turns on mouse support
entirely (set -g mouse on).

See the new MOUSE SUPPORT section of the man page for description of the
key names and new flags (-t= to specify the pane or window under mouse
as a target, and send-keys -M to pass through a mouse event).

The default builtin bindings for the mouse are:

bind -n MouseDown1Pane select-pane -t=; send-keys -M
bind -n MouseDown1Status select-window -t=
bind -n MouseDrag1Pane copy-mode -M
bind -n MouseDrag1Border resize-pane -M

To get the effect of turning mode-mouse off, do:

unbind -n MouseDrag1Pane
unbind -temacs-copy MouseDrag1Pane

The old mouse options are now gone, set-option -q may be used to
suppress warnings if mixing configuration files.


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.25 21-Jul-2014 nicm

Drop explicit support for F13-F20 and change to match the xterm terminfo
entry:

F13-F24 are S-F1 to S-F12
F25-F36 are C-F1 to C-F12
F37-F48 are C-S-F1 to C-S-F12
F49-F60 are M-F1 to M-F12
and F61-F63 are M-S-F1 to M-S-F3

This should be no difference for applications inside tmux, but means
that any key binding for F13 will need to be replaced by S-F1 and so on.


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.24 22-Mar-2013 nicm

In terminals with XT, turn on modifyOtherKeys=1 with the escape sequence
and handle the most common set. Pass them through if xterm-keys is on.


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.23 04-Mar-2012 nicm

Accept hex values as keys, needed for send-keys, based on a diff from
George Nachman.


Revision tags: OPENBSD_5_1_BASE
# 1.22 21-Jan-2012 nicm

Drop the ability to have a list of keys in the prefix in favour of two
separate options, prefix and prefix2. This simplifies the code and gets
rid the data options type which was only used for this one option.

Also add a -2 flag to send-prefix to send the secondary prefix key,
fixing a cause of minor irritation.

People who want three prefix keys are out of luck :-).


# 1.21 23-Oct-2011 nicm

Alias NPage/PPage as PageDown/PgDn/PageUp/PgUp to reduce occasional
confusion.


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.20 23-Jan-2011 nicm

Allow top-bit-set characters to be used for key bindings, from Tiago
Cunha.


# 1.19 01-Jan-2011 nicm

Last few tables that should be const.


Revision tags: OPENBSD_4_8_BASE
# 1.18 06-Jun-2010 nicm

Use a macro-based mask for obtaining a key or modifier-set from the
combination. Display C-@, etc, as C-Space, in list-keys. By Micah Cowan.


# 1.17 05-Jun-2010 nicm

Fix binding of C-Space/C-@, from Micah Cowan.


# 1.16 03-May-2010 mcbride

Make C-] and other punctuation-based control key combinations work again.

ok nicm


# 1.15 23-Apr-2010 nicm

When converting A-Z into a control character, want to subtract 64 not
65... whoops.


# 1.14 21-Apr-2010 nicm

Rewrite key string conversions to be readable and to work properly for
multiple modifiers.


Revision tags: OPENBSD_4_7_BASE
# 1.13 14-Jan-2010 nicm

Permit S- prefix on keys for shift. Relatively few terminals support this
(basically xterm only) and even fewer have them in terminfo (kLFT2 and kRIT2).


# 1.12 03-Dec-2009 nicm

Massive spaces->tabs and trailing whitespace cleanup, hopefully for the last
time now I've configured emacs to make them displayed in really annoying
colours...


# 1.11 26-Nov-2009 nicm

Make types clearer and lint happier.


# 1.10 10-Nov-2009 nicm

Lookup key as a named key (eg 'Space') before checking for single character
keys, makes C-Space/M-Space etc resolve to the correct key code.


# 1.9 26-Oct-2009 nicm

Rename keypad keys to something more useful.


# 1.8 06-Oct-2009 nicm

Accept ^? for backspace as well as BSpace.


# 1.7 04-Oct-2009 nicm

Add a key string for space ("Space") and document the names, suggested by
guenther@. Also document how to bind " and ', suggested by miod@.


# 1.6 28-Jul-2009 nicm

Accept and print "Enter" and "Escape" for keys rather than C-m and C-[.


# 1.5 26-Jul-2009 nicm

Detect backspace by looking at termios VERASE and translate it into \177 (which
matches screen's behaviour if not its termcap/terminfo entry). The terminfo kbs
cap is often wrong or missing so it can't be used, and just assuming \177 may
be wrong.


# 1.4 24-Jul-2009 nicm

Accept lowercase c- and m- prefix as well as C- and M-.


# 1.3 21-Jul-2009 nicm

Tidy up keys: use an enum for the key codes, and remove the macros which just
wrap flag sets/clears/tests.


# 1.2 14-Jul-2009 nicm

Add backspace key to named keys.


Revision tags: OPENBSD_4_6_BASE
# 1.1 01-Jun-2009 nicm

Import tmux, a terminal multiplexor allowing (among other things) a single
terminal to be switched between several different windows and programs
displayed on one terminal be detached from one terminal and moved to another.

ok deraadt pirofti