History log of /openbsd-current/usr.bin/tmux/status.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.242 15-May-2024 nicm

Fix memory leaks reported by Lu Ming Yin.


Revision tags: OPENBSD_7_5_BASE
# 1.241 14-Nov-2023 nicm

Handle NULL client (in config file) when showing a status message; also
copy the file when processing if-shell since it may be freed. GitHub
issue 3746.


Revision tags: OPENBSD_7_4_BASE
# 1.240 15-Aug-2023 nicm

Add an option menu-selected-style to configure the currently selected
menu item, from Alexis Hildebrandt.


# 1.239 08-Aug-2023 nicm

Add options and flags for menu styles similar to those existing for
popups, from Alexis Hildebrandt. GitHub issue 3650.


# 1.238 17-Apr-2023 nicm

Ignore the user keys range when checking if a key is Unicode.


Revision tags: OPENBSD_7_3_BASE
# 1.237 20-Jan-2023 nicm

Add a flag to display-menu to select the manu item chosen first, GitHub
issue 3442.


Revision tags: OPENBSD_7_2_BASE
# 1.236 10-Sep-2022 nicm

Use correct option name.


# 1.235 09-Sep-2022 nicm

Add message-line option to control where message and prompt go, from
Varun Kumar E in GitHub issue 3324.


# 1.234 30-May-2022 nicm

Remove duplicates from completion list, GitHub issue 3178.


Revision tags: OPENBSD_7_1_BASE
# 1.233 07-Mar-2022 nicm

Pass client when adding menu item, GitHub issue 3103.


# 1.232 03-Feb-2022 nicm

Use format_draw for command prompt prefix to allow styles, GitHub issue
3054.


# 1.231 15-Nov-2021 nicm

Leave the hardware cursor at the position of the selected line in choose
modes and current editing position and at the command prompt. It is
invisible but this is helpful for people using screen readers. GitHub
issue 2970.


# 1.230 01-Nov-2021 nicm

Fix a comparison, from Ben Boeckel, and a crash when opening completion
menu, from Anindya Mukherjee.


# 1.229 26-Oct-2021 nicm

Accept some emacs control keys in vi normal mode, from Alexis
Hildebrandt in GitHub issue 2922.


# 1.228 26-Oct-2021 nicm

Do not allow inline styles to replace mode-style for the selected item,
from Alexis Hildebrandt in GitHub issue 2946.


Revision tags: OPENBSD_7_0_BASE
# 1.227 20-Aug-2021 nicm

Remove stray spaces after function names.


# 1.226 12-Aug-2021 nicm

Use COLOUR_DEFAULT not hardcoded 8.


# 1.225 10-Jun-2021 nicm

More accurate vi(1) word navigation in copy mode and on the status line.
This changes the meaning of the word-separators option - setting it to
the empty string is equivalent to the previous behavior. From Will Noble
in GitHub issue 2693.


# 1.224 10-Jun-2021 nicm

Add different command historys for different types of prompts
("command", "search" etc). From Anindya Mukherjee.


# 1.223 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.222 10-Jun-2021 nicm

Include current client in size calculation for new sessions, GitHub
issue 2662.


Revision tags: OPENBSD_6_9_BASE
# 1.221 12-Apr-2021 nicm

Add a flag to disable keys to close a message, GitHub issue 2625.


# 1.220 22-Feb-2021 nicm

Move jump commands to grid reader, make them UTF-8 aware, and tidy up,
from Anindya Mukherjee.


# 1.219 08-Jan-2021 nicm

With incremental search, start empty and only repeat the previous search
if the user tries to search again with an empty prompt. This matches
emacs behaviour more closely.


Revision tags: OPENBSD_6_8_BASE
# 1.218 27-Jul-2020 nicm

Add a -d option to display-message to set delay, from theonekeyg at
gmail dot com in GitHub issue 2322.


# 1.217 11-Jun-2020 nicm

Fix a crash when completing sessions, from Anindya Mukherjee.


# 1.216 26-May-2020 nicm

Remove leftover debug logging and fix comparison.


# 1.215 26-May-2020 nicm

Set up UTF-8 data for ASCII keys correctly.


# 1.214 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.213 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.212 16-May-2020 nicm

Rename KEYC_ESCAPE to KEYC_META.


# 1.211 16-May-2020 nicm

Expand target from client and use it to expand the prompt.


# 1.210 16-May-2020 nicm

Support embedded styles in the display-message message, GitHub issue
2206.


# 1.209 16-May-2020 nicm

Change message log to be per server rather than per client and include
every command that is run.


# 1.208 16-May-2020 nicm

Do not hoke into struct window_pane from the tty code and instead set
everything up in tty_ctx. Provide a way to initialize the tty_ctx from a
callback and use it to let popups draw directly through input_parse in
the same way as panes do, rather than forcing a full redraw on every
change.


# 1.207 16-May-2020 nicm

Use formats for status-style and message-style.


# 1.206 16-May-2020 nicm

Complete partial window indexes properly.


# 1.205 16-May-2020 nicm

Add -W and -T flags to command-prompt to only complete a window and a
target, also complete aliases.


# 1.204 16-May-2020 nicm

Improve command prompt completion:

- Show a menu with completions if there are multiple.

- Don't complete argument stuff (options, layouts) at start of text.

- For -t and -s, if there is no : then complete sessions but if there is
a :, show a menu of all windows in the session rather than trying to
complete the window name which is a bit useless if there are
duplicates.


# 1.203 16-May-2020 nicm

Drop having a separate type for style options and make them all strings,
which allows formats to be expanded. Any styles without a '#{' are still
validated when they are set but any with a '#{' are not. Formats are not
expanded usefully in many cases yet, that will be changed later.

To make this work, a few other changes:

- set-option -a with a style option automatically appends a ",".

- OSC 10 and 11 don't set the window-style option anymore, instead the
fg and bg are stored in the pane struct and act as the defaults that
can be overridden by window-style.

- status-fg and -bg now override status-style instead of trying to keep
them in sync.


Revision tags: OPENBSD_6_7_BASE
# 1.202 12-Mar-2020 nicm

Add C-g to cancel command prompt with vi(1) keys as well as emacs, and q
in command mode.


# 1.201 27-Jan-2020 nicm

Add support for adding a note to a key binding (with bind-key -N) and
use this to add descriptions to the default key bindings. A new -N flag
to list-keys shows key bindings with notes rather than the default
bind-key command used to create them. Change the default ? binding to
use this to show a readable summary of keys.

Also extend command-prompt to return the name of the key pressed and add
a default binding (/) to show the note for the next key pressed

Suggested by Alex Tremblay in GitHub issue 2000.


Revision tags: OPENBSD_6_6_BASE
# 1.200 28-May-2019 nicm

Redraw status line if size changes, GitHub issue 1762. Also fix length
of target buffer when pasting into status line.


# 1.199 23-May-2019 nicm

Fix length calculation for pasting UTF-8 characters in the status line,
GitHub issue 1753.


# 1.198 11-May-2019 nicm

Do not reduce window height by status line height for control mode
clients, from George Nachman.


# 1.197 03-May-2019 nicm

Fix reverse attribute in status line, GitHub issue 1709.


# 1.196 26-Apr-2019 nicm

Merge hooks into options and make each one an array option. This allows
multiple commands to be easily bound to one hook. set-hook and
show-hooks remain but they are now variants of set-option and
show-options. show-options now has a -H flag to show hooks (by default
they are not shown).


# 1.195 25-Apr-2019 nicm

options_array_item_value cannot return NULL.


# 1.194 23-Apr-2019 nicm

Somehow missed these bits in last commit.


# 1.193 23-Apr-2019 nicm

Indicate an array option with a flag rather than a special type so that
in future will not have to be strings.


Revision tags: OPENBSD_6_5_BASE
# 1.192 18-Mar-2019 nicm

Extend the #[] style syntax and use that together with previous format
changes to allow the status line to be entirely configured with a single
option.

Now that it is possible to configure their content, enable the existing
code that lets the status line be multiple lines in height. The status
option can now take a value of 2, 3, 4 or 5 (as well as the previous on
or off) to configure more than one line. The new status-format array
option configures the format of each line, the default just references
the existing status-* options, although some of the more obscure status
options may be eliminated in time.

Additions to the #[] syntax are: "align" to specify alignment (left,
centre, right), "list" for the window list and "range" to configure
ranges of text for the mouse bindings.

The "align" keyword can also be used to specify alignment of entries in
tree mode and the pane status lines.


# 1.191 18-Mar-2019 nicm

Make array options a sparse tree instead of an array of char * and
remove the size limit.


# 1.190 18-Mar-2019 nicm

With force, kill previous job before starting new. Fixes problem
reported by Scott Mcdermott in GitHub issue 1627.


# 1.189 16-Mar-2019 nicm

Use a pointer for the active screen in the status line instead of
copying them around all the time.


# 1.188 16-Mar-2019 nicm

Give status_save_old the client so it can do the reinit too.


# 1.187 16-Mar-2019 nicm

Tidy and rename some bits of status line code.


# 1.186 15-Mar-2019 nicm

Move status line free into its own function.


# 1.185 14-Mar-2019 nicm

Store the time in the format tree rather than passing it around.


# 1.184 12-Mar-2019 nicm

DECRC and DECSC apparently need to preserve origin mode as well, based
on a fix from Marc Reisner.


# 1.183 09-Feb-2019 nicm

Completion of command-alias members.


# 1.182 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.181 29-Aug-2018 nicm

Keep any text killed in the command prompt with C-w and yank it with
C-y, only use the top buffer if no text has previously been killed. This
and previous change promped by discussion with kn@.


# 1.180 29-Aug-2018 nicm

Add C-Left and C-Right as aliases for M-b and M-f.


# 1.179 22-Aug-2018 nicm

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


# 1.178 20-Aug-2018 nicm

Move offset of window list into status struct.


# 1.177 19-Aug-2018 nicm

Add a client redraw-window flag instead of the redraw-all flag and for
all just use the three flags together (window, borders, status).


Revision tags: OPENBSD_6_3_BASE
# 1.176 22-Feb-2018 nicm

Remove an unused variable.


# 1.175 05-Feb-2018 nicm

Add struct status_line to hold status line members of struct client, not
used yet but will be soon. From Thomas Adam.


# 1.174 01-Jan-2018 nicm

Add C-g at command prompt for emacs people, GitHub issue 1213.


# 1.173 27-Dec-2017 nicm

Draw command prompt correctly with status line off.


# 1.172 18-Dec-2017 nicm

Remove unused variable from Thomas Adam.


# 1.171 02-Nov-2017 nicm

Add a "fast" version of screen_write_copy for tree mode that doesn't do
all the checks and selection and marking stuff needed for copy mode.


# 1.170 20-Oct-2017 nicm

Clear status line with spaces again so reverse works, spotted by sthen.


# 1.169 16-Oct-2017 nicm

Infrastructure for drawing status lines of more than one line in height,
still only one is allowed but this lets tmux draw bigger ones.


Revision tags: OPENBSD_6_2_BASE
# 1.168 29-May-2017 nicm

Add a flag to stop the prompt input being expanded.


# 1.167 29-May-2017 nicm

Store a copy of the old status line, will be needed soon for new choose mode.


# 1.166 17-May-2017 nicm

Tidy command prompt callbacks and pass in the client.


# 1.165 03-May-2017 nicm

Add a format for the last search string in copy mode and fix the prompt
so it can work when in -I, suggested by Suraj N Kurapati.


# 1.164 01-May-2017 nicm

In order that people can use formats like #D in #() in the status line
and not have to wait for an update when they change pane, we allow
commands to run more than once a second if the expanded form
changes. Unfortunately this can mean them being run far too often
(pretty much continually) when multiple clients exist, because some
formats (including #D) will always differ between clients.

To avoid this, give each client its own tree of jobs which means that
the same command will be different instances for each client - similar
to how we have the tag to separate commands for different panes.

GitHub issue 889; test case reported by Paul Johnson.


# 1.163 22-Apr-2017 nicm

Memory leak from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.162 09-Feb-2017 nicm

Break the message storage function into its own function, useful for
debugging.


# 1.161 03-Feb-2017 nicm

Cache status line position to reduce option lookups during output.


# 1.160 03-Feb-2017 nicm

Add a window or pane id "tag" to each format tree and use it to separate
jobs, this means that if the same job is used for different windows or
panes (for example in pane-border-format), it will be run separately for
each pane.


# 1.159 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.158 06-Jan-2017 nicm

Incremental search in copy mode (on for emacs keys by default) - much
the same as normal searching but updates the cursor position and marked
search terms as you type. C-r and C-s in the prompt repeat the search,
once finished searching (with Enter), N and n work as before.


# 1.157 05-Jan-2017 nicm

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


# 1.156 07-Dec-2016 nicm

Do not clear the prompt when a message is shown, just leave it around and
return to it when the message is finished.


# 1.155 12-Oct-2016 nicm

Drop the edit mode key tables and just use fixed key bindings for the
command prompt.


# 1.154 12-Oct-2016 nicm

The repeat prompt in both emacs and vi (and the old one in tmux) doesn't
support line editing and instead executes a command as soon as a
non-number key is pressed. Add a -N flag to command-prompt for the same
in copy mode. Reported by Theo Buehler.


# 1.153 11-Oct-2016 nicm

Fundamental change to how copy mode key bindings work:

The vi-copy and emacs-copy mode key tables are gone, and instead copy
mode commands are bound in one of two normal key tables ("copy-mode" or
"copy-mode-vi"). Keys are bound to "send-keys -X copy-mode-command". So:

bind -temacs-copy C-Up scroll-up
bind -temacs-copy -R5 WheelUpPane scroll-up

Becomes:

bind -Tcopy-mode C-Up send -X scroll-up
bind -Tcopy-mode WheelUpPane send -N5 -X scroll-up

This allows the full command parser and command set to be used - for
example, we can use the normal command prompt for searching, jumping,
and so on instead of a custom one:

bind -Tcopy-mode C-r command-prompt -p'search up' "send -X search-backward '%%'"

command-prompt also gets a -1 option to only require on key press, which
is needed for jumping.

The plan is to get rid of mode keys entirely, so more to come eventually.


# 1.152 11-Oct-2016 nicm

Support UTF-8 entry into the command prompt.


# 1.151 10-Oct-2016 nicm

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


# 1.150 12-Sep-2016 nicm

Allow repeat count to be specified in mode key tables with bind-key -R,
and set the default repeat count to 5 for WheelUp and WheelDown in
copy-mode.


Revision tags: OPENBSD_6_0_BASE
# 1.149 06-Jun-2016 nicm

Allow #[] in window-status-separator.


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

I no longer use my SourceForge address so replace it.


# 1.147 01-Jan-2016 nicm

Don't rely on a calculation wrapping when applying message-limit, and
break out of the loop early. From Nicolas Viennot.


# 1.146 11-Dec-2015 nicm

Style nits and line wrapping of function declarations.


# 1.145 11-Dec-2015 nicm

Add cmdq as an argument to format_create and add a format for the
command name (will also be used for more later).


# 1.144 08-Dec-2015 nicm

Remove format_create_flags and just pass flags to format_create.


# 1.143 22-Nov-2015 tim

If display-time is set to 0, show status messages until a key is pressed;
OK nicm@


# 1.142 20-Nov-2015 nicm

Instead of separate tables for different types of options, give each
option a scope type (server, session, window) in one table.


# 1.141 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.140 13-Nov-2015 nicm

Long overdue change to the way we store cells in the grid: now, instead
of storing a full grid_cell with UTF-8 data and everything, store a new
type grid_cell_entry. This can either be the cell itself (for ASCII
cells), or an offset into an extended array (per line) for UTF-8
data.

This avoid a large (8 byte) overhead on non-UTF-8 cells (by far the
majority for most users) without the complexity of the shadow array we
had before. Grid memory without any UTF-8 is about half.

The disadvantage that cells can no longer be modified in place and need
to be copied out of the grid and back but it turned out to be lot less
complicated than I expected.


# 1.139 12-Nov-2015 nicm

Nuke the utf8 and status-utf8 options and make tmux only a UTF-8
terminal. We still support non-UTF-8 terminals outside tmux, but inside
it is always UTF-8 (as when the utf8 and status-utf8 options were on).


# 1.138 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.137 27-Oct-2015 nicm

Move struct options into options.c.


# 1.136 20-Oct-2015 nicm

Use client pointer not file descriptor in logging.


# 1.135 14-Sep-2015 nicm

Make refresh-client force update of jobs, from Sina Siadat.


# 1.134 29-Aug-2015 nicm

Move struct paste_buffer out of tmux.h.


# 1.133 28-Aug-2015 nicm

Run status update on a per-client timer at status-interval.


Revision tags: OPENBSD_5_8_BASE
# 1.132 29-Jul-2015 nicm

status_out and associated data structures are no longer used.


# 1.131 28-Jul-2015 nicm

Tidy up the way terminals are described and move some structs out of tmux.h.


# 1.130 20-Jul-2015 nicm

Add an option (history-file) for a file to save/restore command prompt
history, from Olof-Joachim Frahm.


# 1.129 27-May-2015 nicm

Move the jobs output cache into the formats code so that #() work more
generally (for example, again working in set-titles-string).


# 1.128 06-May-2015 nicm

Remove ARRAY_* from history and expand completion to complete a) layout
names and b) targets beginning with -t or -s.


# 1.127 25-Apr-2015 nicm

Make message log a TAILQ.


# 1.126 24-Apr-2015 nicm

Set working directory for run-shell and if-shell.


# 1.125 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_7_BASE
# 1.124 06-Feb-2015 nicm

Use the same time for both calls to format_expand_time.


# 1.123 06-Feb-2015 nicm

status_replace can now become local to status.c and it no longer needs
the jobsflag argument. While here there is no need to repeat work that
format_defaults already does.


# 1.122 06-Feb-2015 nicm

Add format_expand_time and use it instead of status_replace where
command execution is not needed.


# 1.121 05-Feb-2015 nicm

Wrap all the individual format_* calls in a single format_defaults
functions.


# 1.120 01-Feb-2015 nicm

Remove two unused arguments from status_replace.


# 1.119 20-Jan-2015 sthen

typo in comment ;) ok nicm


# 1.118 05-Nov-2014 nicm

Do not put a space between status-left/status-right and the window list,
instead move the space into the defaults for the options (so status-left
now defaults to "[#S] ". From Balazs Kezes.


# 1.117 20-Oct-2014 nicm

Better format for printf format attributes.


# 1.116 08-Oct-2014 nicm

Add xreallocarray and remove nmemb argument from xrealloc.


# 1.115 02-Oct-2014 nicm

Take account of window-status-separator when checking window position,
based on diff from Balazs Kezes.


Revision tags: OPENBSD_5_6_BASE
# 1.114 24-Apr-2014 nicm

There is no longer a need for a paste_stack struct or for global_buffers
to be global. Move to paste.c.


# 1.113 17-Apr-2014 nicm

Remove the monitor-content option and associated bits and bobs. It's
never worked very well. If there is a big demand for it to return, will
consider better ways to do it.


# 1.112 02-Apr-2014 nicm

Do not replace ## with # in status_replace1 because it'll be done later
by the format code.


# 1.111 31-Mar-2014 nicm

Make message-limit a server option.


Revision tags: OPENBSD_5_5_BASE
# 1.110 14-Feb-2014 nicm

Style nit - no space between function name and bracket.


# 1.109 14-Feb-2014 nicm

Check for NULL session and whatnot in status_replace, from Thomas Adam.


# 1.108 28-Jan-2014 nicm

Allow replacing each of the many sets of separate foo-{fg,bg,attr}
options with a single foo-style option. For example:

set -g status-fg yellow
set -g status-bg red
set -g status-attr blink

Becomes:

set -g status-style fg=yellow,bg=red,blink

The -a flag to set can be used to add to rather than replace a style. So:

set -g status-bg red

Becomes:

set -ag status-style bg=red

Currently this is fully backwards compatible (all *-{fg,bg,attr} options
remain) but the plan is to deprecate them over time.

From Tiago Cunha.


Revision tags: OPENBSD_5_4_BASE
# 1.107 05-Jul-2013 nicm

Whitespace nits, from Ben Boeckel.


# 1.106 05-Jul-2013 nicm

Act like vi(1) when moving words, from Ben Boeckel.


# 1.105 05-Jul-2013 nicm

Implement s, S, C mode switch commands in vi(1) mode, from Ben Boeckel.


# 1.104 31-May-2013 nicm

Demote the old single-character replacement variables (#S and friends)
to aliases of formats. From Tiago Cunha.


# 1.103 25-Mar-2013 nicm

Extend jobs to support writing and use that for copy-pipe instead of
popen, from Chris Johnsen.


# 1.102 22-Mar-2013 nicm

evbuffer_readline returns allocated storage, don't leak it.


# 1.101 22-Mar-2013 nicm

Add copy-pipe mode command to copy selection and also pipe to a command.


# 1.100 22-Mar-2013 nicm

No more lint means no more ARGSUSED.


# 1.99 21-Mar-2013 nicm

Aargh. Spaces -> tabs.


# 1.98 21-Mar-2013 nicm

Do not leak formats in status_replace.


# 1.97 21-Mar-2013 nicm

Add a format client_prefix which is 1 if prefix key has been
pressed, used for example #{?client_prefix,X,Y}. Also a few extra
server_client_status needed.


# 1.96 21-Mar-2013 nicm

Allow formats in status options.


Revision tags: OPENBSD_5_3_BASE
# 1.95 27-Nov-2012 nicm

Add window-status-last-* options, from Boris Faure.


Revision tags: OPENBSD_5_2_BASE
# 1.94 10-Jul-2012 nicm

xfree is not particularly helpful, remove it. From Thomas Adam.


# 1.93 09-Jul-2012 nicm

Move a NULL check inside a function, from Tiago Cunha.


# 1.92 29-Apr-2012 nicm

Use int not u_char for colours from options since they may have bit 8
set to mark them as 256-colour. Reported by Chris Johnson.


# 1.91 23-Apr-2012 nicm

Add window-status-separator option, from Thomas Adam.


# 1.90 17-Mar-2012 nicm

Check event_initialized before event_del if event may not have been set
up; libevent2 complains about this. Reported by Moriyoshi Koizumi.


# 1.89 04-Mar-2012 nicm

Add A and I keys for vi status line editing.


# 1.88 03-Mar-2012 nicm

The wlmouse offset should be part of the client, not the server. From
Ailin Nemui.


Revision tags: OPENBSD_5_1_BASE
# 1.87 29-Jan-2012 nicm

Add an option to move the status line to the top of the screen,
requested by many.


# 1.86 26-Jan-2012 nicm

Terminate strftime buffer properly even if a really long format string
is given, from Tiago Cunha.


# 1.85 26-Jan-2012 nicm

Fix memory leak in error path, from Tiago Cunha.


# 1.84 20-Jan-2012 nicm

Add some trivial additional status line attributes from jwcxz at users
dot sourceforge dot net.


# 1.83 20-Jan-2012 nicm

Add space movement keys for vi mode in the status line from Ben Boeckel.


# 1.82 01-Dec-2011 nicm

Make M-f and M-b work the same at the command prompt as in copy mode,
pointed out by Romain Francoise.


# 1.81 15-Nov-2011 nicm

Add word movement and editing command for command prompt editing, from
Ben Boeckel.


# 1.80 15-Nov-2011 nicm

Make window_pane_index work the same as window_index, from Ben Boeckel.


# 1.79 05-Nov-2011 nicm

Option to change status line (message) background when using vi keys and
in command mode. From Ben Boeckel.


# 1.78 20-Aug-2011 nicm

Fix a couple of memory leaks, from marcel partap.


Revision tags: OPENBSD_5_0_BASE
# 1.77 08-Jul-2011 nicm

Make confirm-before prompt customizable with -p option like
command-prompt. Also move responsibility for calling status_replace into
status_prompt_{set,update} and add #W and #P to the default kill-window
and kill-pane prompts. By Tiago Cunha.


# 1.76 02-Jul-2011 nicm

Allow the initial context on prompts to be set with the new -I option to
command-prompt. From Tiago Cunha.


# 1.75 29-Apr-2011 nicm

Only redraw the status line on command update, not the entire client
(big DOH).


# 1.74 24-Apr-2011 nicm

Provide #h for short hostname (no domain) from Michal Mazurek.


# 1.73 18-Apr-2011 nicm

Add an option (mouse-select-window) which allows the mouse to be used by
clicking on the status line, written by hsim at gmx dot li.


# 1.72 29-Mar-2011 nicm

Change -t on display-message to be target-pane for the #[A-Z]
replacements and add -c as target-client.


Revision tags: OPENBSD_4_9_BASE
# 1.71 26-Jan-2011 nicm

Simplify the way jobs work and drop the persist type, so all jobs are
fire-and-forget.

Status jobs now managed with two trees of output (new and old), rather
than storing the output in the jobs themselves. When the status line is
processed any jobs which don't appear in the new tree are started and
the output from the old tree displayed. When a job finishes it updates
the new tree with its output and that is used for any subsequent
redraws. When the status interval expires, the new tree is moved to the
old so that all jobs are run again.

This fixes the "#(echo %H:%M:%S)" problem which would lead to thousands
of identical persistent jobs and high memory use (this can still be
achieved by adding "sleep 30" but that is much less likely to happen by
accident).


# 1.70 03-Jan-2011 nicm

Handle a # at the end of a replacement string (such as status-left)
correctly. Found by Thomas Adam.


# 1.69 01-Jan-2011 nicm

Move the user-visible parts of all options (names, types, limit, default
values) together into one set of tables in options-table.c. Also clean
up and simplify cmd-set-options.c and move a common print function into
option-table.c.


# 1.68 30-Dec-2010 nicm

Change from a per-session stack of buffers to one global stack which is
much more convenient and also simplifies lot of code. This renders
copy-buffer useless and makes buffer-limit now a server option.

By Tiago Cunha.


# 1.67 30-Dec-2010 nicm

Add a function to create window flags rather than doing the same thing
in two places. From Thomas Adam.


# 1.66 11-Dec-2010 nicm

Oops, these functions return a const char *, so make the local variable
const as well.


# 1.65 11-Dec-2010 nicm

Make the prompt history global for all clients which is much more useful than per-client history.


# 1.64 06-Dec-2010 nicm

Add an option to alert (monitor) for silence (lack of activity) in a
window. From Thomas Adam.


Revision tags: OPENBSD_4_8_BASE
# 1.63 21-Jun-2010 nicm

Having a list of winlinks->alerts for each session is stupid, just store
the alert flags directly in the winlink itself.


# 1.62 14-May-2010 nicm

Colour+attribute options for status line alerts, from Alex Alexander.


# 1.61 31-Mar-2010 nicm

Don't accept keys with modifiers as input. Fixes crash reported by Brian
R Landy.


# 1.60 27-Mar-2010 nicm

Don't leak job command in #().


# 1.59 22-Mar-2010 nicm

Dead functions, lint.


Revision tags: OPENBSD_4_7_BASE
# 1.58 27-Jan-2010 nicm

Calculate offset correctly, fixes incorrect offset and prevents crash when
status-left is empty. From Micah Cowan.


# 1.57 26-Jan-2010 nicm

Actually use the copy made when no newline is found, from martynas@.


# 1.56 14-Dec-2009 nicm

Add server options to completion as well.


# 1.55 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.54 03-Dec-2009 nicm

Eliminate duplicate code and ease the passage for server-wide options by adding
a -w flag to set-option and show-options and making setw and showw aliases to
set -w and show -w.

Note: setw and showw are still there, but now aliases for set -w and show -w.


# 1.53 26-Nov-2009 nicm

Tidy up various bits of the paste code, make the data buffer char * and add
comments.


# 1.52 26-Nov-2009 nicm

Remove a couple of unused arguments where possible, and add /* ARGSUSED */ to
the rest to reduce lint output.


# 1.51 20-Nov-2009 nicm

Display UTF-8 properly in status line messages and prompt. Cursor handling is
still way off though.


# 1.50 20-Nov-2009 nicm

Remove oldest messages from log when limit is hit, not newest.


# 1.49 19-Nov-2009 nicm

Get some brackets in the right place so ## works. Also fix a space in a
comment.


# 1.48 19-Nov-2009 nicm

Change status line drawing to create the window list in a separate screen and
then copy it into the status line screen. This allows UTF-8 in window names and
fixes some problems with #[] in window-status-format.


# 1.47 19-Nov-2009 nicm

Two new options, window-status-format and window-status-current-format, which
allow the format of each window in the status line window list to be controlled
using similar # sequences as status-left/right.

This diff also moves part of the way towards UTF-8 support in window names but
it isn't quite there yet.


# 1.46 19-Nov-2009 nicm

Tidy up by breaking the # replacement code into a separate function, also add a
few comments.


# 1.45 19-Nov-2009 nicm

Don't interpret #() for display-message, it usually doesn't make sense and may
leak commands.


# 1.44 18-Nov-2009 nicm

Add a per-client log of status line messages displayed while that client
exists. A new message-limit session option sets the maximum number of entries
and a command, show-messages, shows the log (bound to ~ by default).

This (and prompt history) might be better as a single global log but until
there are global options it is easier for them to be per client.


# 1.43 17-Nov-2009 nicm

Permit top-bit-set characters to be entered in the status line. They could
already be set from the shell and are just passed through when printing (so
invisible characters or displaying on terminals with different character sets
may cause problems).

Note that entering UTF-8 may not work and in any case currently the status line
cannot display it correctly (outside of status-left/status-right).


# 1.42 04-Nov-2009 nicm

Use timeout events for the identify and message timers.


# 1.41 04-Nov-2009 nicm

Switch jobs over to use a bufferevent.


# 1.40 04-Nov-2009 nicm

Unused (but assigned to) variable, found by lint.


# 1.39 01-Nov-2009 nicm

Add a flag for jobs that shouldn't be freed after they've died and use it for
status jobs, then only kill those jobs when status-left, status-right or
set-titles-string is changed.

Fixes problems with changing options from inside #().


# 1.38 10-Oct-2009 nicm

Rather than running status-left, status-right and window title #() with popen
immediately every redraw, queue them up and run them in the background,
starting each once every status-interval. The actual status line uses the
output from the last run.

This brings several advantages:

- tmux itself may be called from inside #() without causing the server to hang;
- likewise, sleep or similar doesn't cause the server to block;
- commands aren't run excessively often when redrawing;
- commands shared by status-left and status-right, or used multiple times, will
only be run once.

run-shell and if-shell still use system()/popen() but will be changed over to
use this too later.


# 1.37 10-Oct-2009 nicm

Add "grouped sessions" which have independent name, options, current window and
so on but where the linked windows are synchronized (ie creating, killing
windows and so on are mirrored between the sessions). A grouped session may be
created by passing -t to new-session.

Had this around for a while, tested by a couple of people.


# 1.36 23-Sep-2009 nicm

Remove PROMPT_HIDDEN code which is now unused.


# 1.35 23-Sep-2009 nicm

Remove the internal tmux locking and instead detach each client and run the
command specified by a new option "lock-command" (by default "lock -np") in
each client.

This means each terminal has to be unlocked individually but simplifies the
code and allows the system password to be used to unlock.

Note that the set-password command is gone, so it will need to be removed from
configuration files, and the -U command line flag has been removed.

This is the third protocol version change so again it is best to stop the tmux
server before upgrading.


# 1.34 20-Sep-2009 nicm

Regularise some fatal messages.


# 1.33 10-Sep-2009 nicm

Permit options such as status-bg to be configured using the entire 256 colour
palette by setting "colour0" to "colour255".


# 1.32 07-Sep-2009 nicm

Give each paste buffer a size member instead of requiring them to be
zero-terminated.


# 1.31 07-Sep-2009 nicm

Permit embedded colour and attributes in status-left and status-right using new
#[] special characters, for example #[fg=red,bg=blue,blink].


# 1.30 02-Sep-2009 nicm

Add a transpose-chars command in edit mode (C-t in emacs mode only). From Kalle
Olavi Niemitalo.


# 1.29 01-Sep-2009 nicm

Use "Password:" with no space for password prompts and don't display a *s for
the password, like pretty much everything else. From martynas@ with minor
tweaks by me.


# 1.28 31-Aug-2009 nicm

Add a new display-panes command, with two options (display-panes-colour and
display-panes-time), which displays a visual indication of the number of each
pane.


# 1.27 19-Aug-2009 nicm

Extend command-prompt with a -p option which is a comma-separated list of one
or more prompts to present in order.

The responses to the prompt are replaced in the template string: %% are
replaced in order, so the first prompt replaces the first %%, the second
replaces the second, and so on. In addition, %1 up to %9 are replaced with the
responses to the first the ninth prompts

The default template is "%1" so the response to the first prompt is processed
as a command.

Note that this changes the behaviour for %% so if there is only one prompt,
only the first %% will be replaced. Templates such as "neww -n '%%' 'ssh %%'"
should be changed to "neww -n '%1' 'ssh %1'".

From Tiago Cunha.


# 1.26 18-Aug-2009 nicm

Add a "delete line" key when editing in the status line or the search up/down
prompt. C-u with emacs keys, d with vi.


# 1.25 13-Aug-2009 nicm

Switch the prompt code to return an empty string when the user enters no
response and reserve NULL for an explicit cancel. Change all callbacks to treat
them the same so no functional change.

Also add cancel key bindings to emacs mode which were missing.


# 1.24 08-Aug-2009 nicm

Options to set the colours and attributes for status-left/-right. From Thomas
Adam, thanks.


# 1.23 05-Aug-2009 nicm

If colours are not supported by the terminal, try to emulate a coloured
background by setting or clearing the reverse attribute.

This makes a few applications which don't use the reverse attribute themselves
a little happier, and allows the status, message and mode options to have
default attributes and fg/bg options that work as expected when set as reverse.


# 1.22 30-Jul-2009 nicm

Plug some memory leaks.


# 1.21 28-Jul-2009 nicm

Next step towards customisable mode keys: build each default table of keys into
a named tree on start and use that for lookups. Also add command to string
translation tables and modify list-keys to show the the mode key bindings (new
-t argument).


# 1.20 27-Jul-2009 nicm

Change mode key bindings from big switches into a set of tables. Rather than
lumping them all together, split editing keys from those used in choice/more
mode and those for copy/scroll mode.

Tidier and clearer, and the first step towards customisable mode keys.


# 1.19 27-Jul-2009 nicm

Get rid of empty mode_key_free function.


# 1.18 27-Jul-2009 nicm

Add a key to delete to end of line at the prompt (^K in emacs mode, C/D in vi).

From Kalle Olavi Niemitalo.


# 1.17 26-Jul-2009 nicm

Calculate the space available for the prompt buffer and the cursor position
correctly, and make it work when the screen is not wide enough.

Noticed by Kalle Olavi Niemitalo.


# 1.16 21-Jul-2009 nicm

Remove a couple of unused functions and fix a type ("FALLTHOUGH"), found by
lint.


# 1.15 20-Jul-2009 nicm

Add a status-justify option to allow the window list in the status line to be
positioned at the left, centre, or right.


# 1.14 20-Jul-2009 nicm

New options, window-status-current-{fg,bg,attr}, to set the fg, bg and
attributes with which the current window is shown in the status line. From
Johan Friis, thanks.


# 1.13 17-Jul-2009 nicm

- New command display-message (alias display) to display a message in the
status line (bound to "i" and displays the current window and time by
default). The same substitutions are applied as for status-left/right.
- Add support for including the window index (#I), pane index (#P) and window
name (#W) in the message, and status-left or status-right.
- Bump protocol version.

From Tiago Cunha, thanks!


# 1.12 17-Jul-2009 nicm

Memory could be leaked if a second prompt or message appeared while another was
still present, so add a separate prompt free callback and make the _clear
function responsible for calling it if necessary (rather than the individual
prompt callbacks). Also make both messages and prompts clear any existing when
a new is set.

In addition, the screen could be modified while the prompt is there, restore
the redraw-entire-screen behaviour on prompt clear; add a comment as a
reminder.


# 1.11 16-Jul-2009 nicm

Remove some duplicate code that was causing the status line to be redrawn even
when it hadn't changed.


# 1.10 15-Jul-2009 nicm

Make status_message_set a variadic printf-like function. No functional change -
helpful for a couple of things coming soon.


# 1.9 15-Jul-2009 nicm

Having to update NSETOPTION/NSETWINDOWOPTION when adding new options is a bit
annoying and it is only use for iterating, so use a sentinel to mark the end of
each array instead. Different fix for a problem pointed out by Kalle Olavi
Niemitalo.


# 1.8 14-Jul-2009 nicm

For some reason when clearing status/message it was redrawing the entire client
not just the status line. Changing this also revealed the check for the status
line was incorrect when drawing the pane.


# 1.7 14-Jul-2009 nicm

Instead of faking up a status line in status_redraw, use the same code to
redraw it as to draw the entire screen, just skip all lines but the last.

This makes horizontal split redraw properly when the status line is off.


# 1.6 12-Jul-2009 nicm

Add a "back to indentation" key in copy mode to move the cursor to the first
non-whitespace character. ^ with vi and M-m with emacs key bindings. Another
from Kalle Olavi Niemitalo, thanks.


Revision tags: OPENBSD_4_6_BASE
# 1.5 26-Jun-2009 nicm

Status line fixes: don't truncate status-right now the length calculation is
done for UTF-8, limit to the maximum length correctly when printing, and always
print a space even if the left string is longer than the width available.


# 1.4 04-Jun-2009 nicm

If the prompt is hidden or a password is sent with -U, zero it before freeing
it.


# 1.3 03-Jun-2009 nicm

New session option, status-utf8, to control the interpretation of top-bit-set
characters in status-left and status-right (if on, they are treated as UTF-8;
otherwise passed through).


# 1.2 03-Jun-2009 nicm

Add a UTF-8 aware string length function and make UTF-8 in
status-left/status-right work properly. At the moment any top-bit-set
characters are assumed to be UTF-8: a status-utf8 option to configure this will
come shortly.


# 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.241 14-Nov-2023 nicm

Handle NULL client (in config file) when showing a status message; also
copy the file when processing if-shell since it may be freed. GitHub
issue 3746.


Revision tags: OPENBSD_7_4_BASE
# 1.240 15-Aug-2023 nicm

Add an option menu-selected-style to configure the currently selected
menu item, from Alexis Hildebrandt.


# 1.239 08-Aug-2023 nicm

Add options and flags for menu styles similar to those existing for
popups, from Alexis Hildebrandt. GitHub issue 3650.


# 1.238 17-Apr-2023 nicm

Ignore the user keys range when checking if a key is Unicode.


Revision tags: OPENBSD_7_3_BASE
# 1.237 20-Jan-2023 nicm

Add a flag to display-menu to select the manu item chosen first, GitHub
issue 3442.


Revision tags: OPENBSD_7_2_BASE
# 1.236 10-Sep-2022 nicm

Use correct option name.


# 1.235 09-Sep-2022 nicm

Add message-line option to control where message and prompt go, from
Varun Kumar E in GitHub issue 3324.


# 1.234 30-May-2022 nicm

Remove duplicates from completion list, GitHub issue 3178.


Revision tags: OPENBSD_7_1_BASE
# 1.233 07-Mar-2022 nicm

Pass client when adding menu item, GitHub issue 3103.


# 1.232 03-Feb-2022 nicm

Use format_draw for command prompt prefix to allow styles, GitHub issue
3054.


# 1.231 15-Nov-2021 nicm

Leave the hardware cursor at the position of the selected line in choose
modes and current editing position and at the command prompt. It is
invisible but this is helpful for people using screen readers. GitHub
issue 2970.


# 1.230 01-Nov-2021 nicm

Fix a comparison, from Ben Boeckel, and a crash when opening completion
menu, from Anindya Mukherjee.


# 1.229 26-Oct-2021 nicm

Accept some emacs control keys in vi normal mode, from Alexis
Hildebrandt in GitHub issue 2922.


# 1.228 26-Oct-2021 nicm

Do not allow inline styles to replace mode-style for the selected item,
from Alexis Hildebrandt in GitHub issue 2946.


Revision tags: OPENBSD_7_0_BASE
# 1.227 20-Aug-2021 nicm

Remove stray spaces after function names.


# 1.226 12-Aug-2021 nicm

Use COLOUR_DEFAULT not hardcoded 8.


# 1.225 10-Jun-2021 nicm

More accurate vi(1) word navigation in copy mode and on the status line.
This changes the meaning of the word-separators option - setting it to
the empty string is equivalent to the previous behavior. From Will Noble
in GitHub issue 2693.


# 1.224 10-Jun-2021 nicm

Add different command historys for different types of prompts
("command", "search" etc). From Anindya Mukherjee.


# 1.223 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.222 10-Jun-2021 nicm

Include current client in size calculation for new sessions, GitHub
issue 2662.


Revision tags: OPENBSD_6_9_BASE
# 1.221 12-Apr-2021 nicm

Add a flag to disable keys to close a message, GitHub issue 2625.


# 1.220 22-Feb-2021 nicm

Move jump commands to grid reader, make them UTF-8 aware, and tidy up,
from Anindya Mukherjee.


# 1.219 08-Jan-2021 nicm

With incremental search, start empty and only repeat the previous search
if the user tries to search again with an empty prompt. This matches
emacs behaviour more closely.


Revision tags: OPENBSD_6_8_BASE
# 1.218 27-Jul-2020 nicm

Add a -d option to display-message to set delay, from theonekeyg at
gmail dot com in GitHub issue 2322.


# 1.217 11-Jun-2020 nicm

Fix a crash when completing sessions, from Anindya Mukherjee.


# 1.216 26-May-2020 nicm

Remove leftover debug logging and fix comparison.


# 1.215 26-May-2020 nicm

Set up UTF-8 data for ASCII keys correctly.


# 1.214 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.213 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.212 16-May-2020 nicm

Rename KEYC_ESCAPE to KEYC_META.


# 1.211 16-May-2020 nicm

Expand target from client and use it to expand the prompt.


# 1.210 16-May-2020 nicm

Support embedded styles in the display-message message, GitHub issue
2206.


# 1.209 16-May-2020 nicm

Change message log to be per server rather than per client and include
every command that is run.


# 1.208 16-May-2020 nicm

Do not hoke into struct window_pane from the tty code and instead set
everything up in tty_ctx. Provide a way to initialize the tty_ctx from a
callback and use it to let popups draw directly through input_parse in
the same way as panes do, rather than forcing a full redraw on every
change.


# 1.207 16-May-2020 nicm

Use formats for status-style and message-style.


# 1.206 16-May-2020 nicm

Complete partial window indexes properly.


# 1.205 16-May-2020 nicm

Add -W and -T flags to command-prompt to only complete a window and a
target, also complete aliases.


# 1.204 16-May-2020 nicm

Improve command prompt completion:

- Show a menu with completions if there are multiple.

- Don't complete argument stuff (options, layouts) at start of text.

- For -t and -s, if there is no : then complete sessions but if there is
a :, show a menu of all windows in the session rather than trying to
complete the window name which is a bit useless if there are
duplicates.


# 1.203 16-May-2020 nicm

Drop having a separate type for style options and make them all strings,
which allows formats to be expanded. Any styles without a '#{' are still
validated when they are set but any with a '#{' are not. Formats are not
expanded usefully in many cases yet, that will be changed later.

To make this work, a few other changes:

- set-option -a with a style option automatically appends a ",".

- OSC 10 and 11 don't set the window-style option anymore, instead the
fg and bg are stored in the pane struct and act as the defaults that
can be overridden by window-style.

- status-fg and -bg now override status-style instead of trying to keep
them in sync.


Revision tags: OPENBSD_6_7_BASE
# 1.202 12-Mar-2020 nicm

Add C-g to cancel command prompt with vi(1) keys as well as emacs, and q
in command mode.


# 1.201 27-Jan-2020 nicm

Add support for adding a note to a key binding (with bind-key -N) and
use this to add descriptions to the default key bindings. A new -N flag
to list-keys shows key bindings with notes rather than the default
bind-key command used to create them. Change the default ? binding to
use this to show a readable summary of keys.

Also extend command-prompt to return the name of the key pressed and add
a default binding (/) to show the note for the next key pressed

Suggested by Alex Tremblay in GitHub issue 2000.


Revision tags: OPENBSD_6_6_BASE
# 1.200 28-May-2019 nicm

Redraw status line if size changes, GitHub issue 1762. Also fix length
of target buffer when pasting into status line.


# 1.199 23-May-2019 nicm

Fix length calculation for pasting UTF-8 characters in the status line,
GitHub issue 1753.


# 1.198 11-May-2019 nicm

Do not reduce window height by status line height for control mode
clients, from George Nachman.


# 1.197 03-May-2019 nicm

Fix reverse attribute in status line, GitHub issue 1709.


# 1.196 26-Apr-2019 nicm

Merge hooks into options and make each one an array option. This allows
multiple commands to be easily bound to one hook. set-hook and
show-hooks remain but they are now variants of set-option and
show-options. show-options now has a -H flag to show hooks (by default
they are not shown).


# 1.195 25-Apr-2019 nicm

options_array_item_value cannot return NULL.


# 1.194 23-Apr-2019 nicm

Somehow missed these bits in last commit.


# 1.193 23-Apr-2019 nicm

Indicate an array option with a flag rather than a special type so that
in future will not have to be strings.


Revision tags: OPENBSD_6_5_BASE
# 1.192 18-Mar-2019 nicm

Extend the #[] style syntax and use that together with previous format
changes to allow the status line to be entirely configured with a single
option.

Now that it is possible to configure their content, enable the existing
code that lets the status line be multiple lines in height. The status
option can now take a value of 2, 3, 4 or 5 (as well as the previous on
or off) to configure more than one line. The new status-format array
option configures the format of each line, the default just references
the existing status-* options, although some of the more obscure status
options may be eliminated in time.

Additions to the #[] syntax are: "align" to specify alignment (left,
centre, right), "list" for the window list and "range" to configure
ranges of text for the mouse bindings.

The "align" keyword can also be used to specify alignment of entries in
tree mode and the pane status lines.


# 1.191 18-Mar-2019 nicm

Make array options a sparse tree instead of an array of char * and
remove the size limit.


# 1.190 18-Mar-2019 nicm

With force, kill previous job before starting new. Fixes problem
reported by Scott Mcdermott in GitHub issue 1627.


# 1.189 16-Mar-2019 nicm

Use a pointer for the active screen in the status line instead of
copying them around all the time.


# 1.188 16-Mar-2019 nicm

Give status_save_old the client so it can do the reinit too.


# 1.187 16-Mar-2019 nicm

Tidy and rename some bits of status line code.


# 1.186 15-Mar-2019 nicm

Move status line free into its own function.


# 1.185 14-Mar-2019 nicm

Store the time in the format tree rather than passing it around.


# 1.184 12-Mar-2019 nicm

DECRC and DECSC apparently need to preserve origin mode as well, based
on a fix from Marc Reisner.


# 1.183 09-Feb-2019 nicm

Completion of command-alias members.


# 1.182 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.181 29-Aug-2018 nicm

Keep any text killed in the command prompt with C-w and yank it with
C-y, only use the top buffer if no text has previously been killed. This
and previous change promped by discussion with kn@.


# 1.180 29-Aug-2018 nicm

Add C-Left and C-Right as aliases for M-b and M-f.


# 1.179 22-Aug-2018 nicm

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


# 1.178 20-Aug-2018 nicm

Move offset of window list into status struct.


# 1.177 19-Aug-2018 nicm

Add a client redraw-window flag instead of the redraw-all flag and for
all just use the three flags together (window, borders, status).


Revision tags: OPENBSD_6_3_BASE
# 1.176 22-Feb-2018 nicm

Remove an unused variable.


# 1.175 05-Feb-2018 nicm

Add struct status_line to hold status line members of struct client, not
used yet but will be soon. From Thomas Adam.


# 1.174 01-Jan-2018 nicm

Add C-g at command prompt for emacs people, GitHub issue 1213.


# 1.173 27-Dec-2017 nicm

Draw command prompt correctly with status line off.


# 1.172 18-Dec-2017 nicm

Remove unused variable from Thomas Adam.


# 1.171 02-Nov-2017 nicm

Add a "fast" version of screen_write_copy for tree mode that doesn't do
all the checks and selection and marking stuff needed for copy mode.


# 1.170 20-Oct-2017 nicm

Clear status line with spaces again so reverse works, spotted by sthen.


# 1.169 16-Oct-2017 nicm

Infrastructure for drawing status lines of more than one line in height,
still only one is allowed but this lets tmux draw bigger ones.


Revision tags: OPENBSD_6_2_BASE
# 1.168 29-May-2017 nicm

Add a flag to stop the prompt input being expanded.


# 1.167 29-May-2017 nicm

Store a copy of the old status line, will be needed soon for new choose mode.


# 1.166 17-May-2017 nicm

Tidy command prompt callbacks and pass in the client.


# 1.165 03-May-2017 nicm

Add a format for the last search string in copy mode and fix the prompt
so it can work when in -I, suggested by Suraj N Kurapati.


# 1.164 01-May-2017 nicm

In order that people can use formats like #D in #() in the status line
and not have to wait for an update when they change pane, we allow
commands to run more than once a second if the expanded form
changes. Unfortunately this can mean them being run far too often
(pretty much continually) when multiple clients exist, because some
formats (including #D) will always differ between clients.

To avoid this, give each client its own tree of jobs which means that
the same command will be different instances for each client - similar
to how we have the tag to separate commands for different panes.

GitHub issue 889; test case reported by Paul Johnson.


# 1.163 22-Apr-2017 nicm

Memory leak from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.162 09-Feb-2017 nicm

Break the message storage function into its own function, useful for
debugging.


# 1.161 03-Feb-2017 nicm

Cache status line position to reduce option lookups during output.


# 1.160 03-Feb-2017 nicm

Add a window or pane id "tag" to each format tree and use it to separate
jobs, this means that if the same job is used for different windows or
panes (for example in pane-border-format), it will be run separately for
each pane.


# 1.159 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.158 06-Jan-2017 nicm

Incremental search in copy mode (on for emacs keys by default) - much
the same as normal searching but updates the cursor position and marked
search terms as you type. C-r and C-s in the prompt repeat the search,
once finished searching (with Enter), N and n work as before.


# 1.157 05-Jan-2017 nicm

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


# 1.156 07-Dec-2016 nicm

Do not clear the prompt when a message is shown, just leave it around and
return to it when the message is finished.


# 1.155 12-Oct-2016 nicm

Drop the edit mode key tables and just use fixed key bindings for the
command prompt.


# 1.154 12-Oct-2016 nicm

The repeat prompt in both emacs and vi (and the old one in tmux) doesn't
support line editing and instead executes a command as soon as a
non-number key is pressed. Add a -N flag to command-prompt for the same
in copy mode. Reported by Theo Buehler.


# 1.153 11-Oct-2016 nicm

Fundamental change to how copy mode key bindings work:

The vi-copy and emacs-copy mode key tables are gone, and instead copy
mode commands are bound in one of two normal key tables ("copy-mode" or
"copy-mode-vi"). Keys are bound to "send-keys -X copy-mode-command". So:

bind -temacs-copy C-Up scroll-up
bind -temacs-copy -R5 WheelUpPane scroll-up

Becomes:

bind -Tcopy-mode C-Up send -X scroll-up
bind -Tcopy-mode WheelUpPane send -N5 -X scroll-up

This allows the full command parser and command set to be used - for
example, we can use the normal command prompt for searching, jumping,
and so on instead of a custom one:

bind -Tcopy-mode C-r command-prompt -p'search up' "send -X search-backward '%%'"

command-prompt also gets a -1 option to only require on key press, which
is needed for jumping.

The plan is to get rid of mode keys entirely, so more to come eventually.


# 1.152 11-Oct-2016 nicm

Support UTF-8 entry into the command prompt.


# 1.151 10-Oct-2016 nicm

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


# 1.150 12-Sep-2016 nicm

Allow repeat count to be specified in mode key tables with bind-key -R,
and set the default repeat count to 5 for WheelUp and WheelDown in
copy-mode.


Revision tags: OPENBSD_6_0_BASE
# 1.149 06-Jun-2016 nicm

Allow #[] in window-status-separator.


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

I no longer use my SourceForge address so replace it.


# 1.147 01-Jan-2016 nicm

Don't rely on a calculation wrapping when applying message-limit, and
break out of the loop early. From Nicolas Viennot.


# 1.146 11-Dec-2015 nicm

Style nits and line wrapping of function declarations.


# 1.145 11-Dec-2015 nicm

Add cmdq as an argument to format_create and add a format for the
command name (will also be used for more later).


# 1.144 08-Dec-2015 nicm

Remove format_create_flags and just pass flags to format_create.


# 1.143 22-Nov-2015 tim

If display-time is set to 0, show status messages until a key is pressed;
OK nicm@


# 1.142 20-Nov-2015 nicm

Instead of separate tables for different types of options, give each
option a scope type (server, session, window) in one table.


# 1.141 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.140 13-Nov-2015 nicm

Long overdue change to the way we store cells in the grid: now, instead
of storing a full grid_cell with UTF-8 data and everything, store a new
type grid_cell_entry. This can either be the cell itself (for ASCII
cells), or an offset into an extended array (per line) for UTF-8
data.

This avoid a large (8 byte) overhead on non-UTF-8 cells (by far the
majority for most users) without the complexity of the shadow array we
had before. Grid memory without any UTF-8 is about half.

The disadvantage that cells can no longer be modified in place and need
to be copied out of the grid and back but it turned out to be lot less
complicated than I expected.


# 1.139 12-Nov-2015 nicm

Nuke the utf8 and status-utf8 options and make tmux only a UTF-8
terminal. We still support non-UTF-8 terminals outside tmux, but inside
it is always UTF-8 (as when the utf8 and status-utf8 options were on).


# 1.138 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.137 27-Oct-2015 nicm

Move struct options into options.c.


# 1.136 20-Oct-2015 nicm

Use client pointer not file descriptor in logging.


# 1.135 14-Sep-2015 nicm

Make refresh-client force update of jobs, from Sina Siadat.


# 1.134 29-Aug-2015 nicm

Move struct paste_buffer out of tmux.h.


# 1.133 28-Aug-2015 nicm

Run status update on a per-client timer at status-interval.


Revision tags: OPENBSD_5_8_BASE
# 1.132 29-Jul-2015 nicm

status_out and associated data structures are no longer used.


# 1.131 28-Jul-2015 nicm

Tidy up the way terminals are described and move some structs out of tmux.h.


# 1.130 20-Jul-2015 nicm

Add an option (history-file) for a file to save/restore command prompt
history, from Olof-Joachim Frahm.


# 1.129 27-May-2015 nicm

Move the jobs output cache into the formats code so that #() work more
generally (for example, again working in set-titles-string).


# 1.128 06-May-2015 nicm

Remove ARRAY_* from history and expand completion to complete a) layout
names and b) targets beginning with -t or -s.


# 1.127 25-Apr-2015 nicm

Make message log a TAILQ.


# 1.126 24-Apr-2015 nicm

Set working directory for run-shell and if-shell.


# 1.125 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_7_BASE
# 1.124 06-Feb-2015 nicm

Use the same time for both calls to format_expand_time.


# 1.123 06-Feb-2015 nicm

status_replace can now become local to status.c and it no longer needs
the jobsflag argument. While here there is no need to repeat work that
format_defaults already does.


# 1.122 06-Feb-2015 nicm

Add format_expand_time and use it instead of status_replace where
command execution is not needed.


# 1.121 05-Feb-2015 nicm

Wrap all the individual format_* calls in a single format_defaults
functions.


# 1.120 01-Feb-2015 nicm

Remove two unused arguments from status_replace.


# 1.119 20-Jan-2015 sthen

typo in comment ;) ok nicm


# 1.118 05-Nov-2014 nicm

Do not put a space between status-left/status-right and the window list,
instead move the space into the defaults for the options (so status-left
now defaults to "[#S] ". From Balazs Kezes.


# 1.117 20-Oct-2014 nicm

Better format for printf format attributes.


# 1.116 08-Oct-2014 nicm

Add xreallocarray and remove nmemb argument from xrealloc.


# 1.115 02-Oct-2014 nicm

Take account of window-status-separator when checking window position,
based on diff from Balazs Kezes.


Revision tags: OPENBSD_5_6_BASE
# 1.114 24-Apr-2014 nicm

There is no longer a need for a paste_stack struct or for global_buffers
to be global. Move to paste.c.


# 1.113 17-Apr-2014 nicm

Remove the monitor-content option and associated bits and bobs. It's
never worked very well. If there is a big demand for it to return, will
consider better ways to do it.


# 1.112 02-Apr-2014 nicm

Do not replace ## with # in status_replace1 because it'll be done later
by the format code.


# 1.111 31-Mar-2014 nicm

Make message-limit a server option.


Revision tags: OPENBSD_5_5_BASE
# 1.110 14-Feb-2014 nicm

Style nit - no space between function name and bracket.


# 1.109 14-Feb-2014 nicm

Check for NULL session and whatnot in status_replace, from Thomas Adam.


# 1.108 28-Jan-2014 nicm

Allow replacing each of the many sets of separate foo-{fg,bg,attr}
options with a single foo-style option. For example:

set -g status-fg yellow
set -g status-bg red
set -g status-attr blink

Becomes:

set -g status-style fg=yellow,bg=red,blink

The -a flag to set can be used to add to rather than replace a style. So:

set -g status-bg red

Becomes:

set -ag status-style bg=red

Currently this is fully backwards compatible (all *-{fg,bg,attr} options
remain) but the plan is to deprecate them over time.

From Tiago Cunha.


Revision tags: OPENBSD_5_4_BASE
# 1.107 05-Jul-2013 nicm

Whitespace nits, from Ben Boeckel.


# 1.106 05-Jul-2013 nicm

Act like vi(1) when moving words, from Ben Boeckel.


# 1.105 05-Jul-2013 nicm

Implement s, S, C mode switch commands in vi(1) mode, from Ben Boeckel.


# 1.104 31-May-2013 nicm

Demote the old single-character replacement variables (#S and friends)
to aliases of formats. From Tiago Cunha.


# 1.103 25-Mar-2013 nicm

Extend jobs to support writing and use that for copy-pipe instead of
popen, from Chris Johnsen.


# 1.102 22-Mar-2013 nicm

evbuffer_readline returns allocated storage, don't leak it.


# 1.101 22-Mar-2013 nicm

Add copy-pipe mode command to copy selection and also pipe to a command.


# 1.100 22-Mar-2013 nicm

No more lint means no more ARGSUSED.


# 1.99 21-Mar-2013 nicm

Aargh. Spaces -> tabs.


# 1.98 21-Mar-2013 nicm

Do not leak formats in status_replace.


# 1.97 21-Mar-2013 nicm

Add a format client_prefix which is 1 if prefix key has been
pressed, used for example #{?client_prefix,X,Y}. Also a few extra
server_client_status needed.


# 1.96 21-Mar-2013 nicm

Allow formats in status options.


Revision tags: OPENBSD_5_3_BASE
# 1.95 27-Nov-2012 nicm

Add window-status-last-* options, from Boris Faure.


Revision tags: OPENBSD_5_2_BASE
# 1.94 10-Jul-2012 nicm

xfree is not particularly helpful, remove it. From Thomas Adam.


# 1.93 09-Jul-2012 nicm

Move a NULL check inside a function, from Tiago Cunha.


# 1.92 29-Apr-2012 nicm

Use int not u_char for colours from options since they may have bit 8
set to mark them as 256-colour. Reported by Chris Johnson.


# 1.91 23-Apr-2012 nicm

Add window-status-separator option, from Thomas Adam.


# 1.90 17-Mar-2012 nicm

Check event_initialized before event_del if event may not have been set
up; libevent2 complains about this. Reported by Moriyoshi Koizumi.


# 1.89 04-Mar-2012 nicm

Add A and I keys for vi status line editing.


# 1.88 03-Mar-2012 nicm

The wlmouse offset should be part of the client, not the server. From
Ailin Nemui.


Revision tags: OPENBSD_5_1_BASE
# 1.87 29-Jan-2012 nicm

Add an option to move the status line to the top of the screen,
requested by many.


# 1.86 26-Jan-2012 nicm

Terminate strftime buffer properly even if a really long format string
is given, from Tiago Cunha.


# 1.85 26-Jan-2012 nicm

Fix memory leak in error path, from Tiago Cunha.


# 1.84 20-Jan-2012 nicm

Add some trivial additional status line attributes from jwcxz at users
dot sourceforge dot net.


# 1.83 20-Jan-2012 nicm

Add space movement keys for vi mode in the status line from Ben Boeckel.


# 1.82 01-Dec-2011 nicm

Make M-f and M-b work the same at the command prompt as in copy mode,
pointed out by Romain Francoise.


# 1.81 15-Nov-2011 nicm

Add word movement and editing command for command prompt editing, from
Ben Boeckel.


# 1.80 15-Nov-2011 nicm

Make window_pane_index work the same as window_index, from Ben Boeckel.


# 1.79 05-Nov-2011 nicm

Option to change status line (message) background when using vi keys and
in command mode. From Ben Boeckel.


# 1.78 20-Aug-2011 nicm

Fix a couple of memory leaks, from marcel partap.


Revision tags: OPENBSD_5_0_BASE
# 1.77 08-Jul-2011 nicm

Make confirm-before prompt customizable with -p option like
command-prompt. Also move responsibility for calling status_replace into
status_prompt_{set,update} and add #W and #P to the default kill-window
and kill-pane prompts. By Tiago Cunha.


# 1.76 02-Jul-2011 nicm

Allow the initial context on prompts to be set with the new -I option to
command-prompt. From Tiago Cunha.


# 1.75 29-Apr-2011 nicm

Only redraw the status line on command update, not the entire client
(big DOH).


# 1.74 24-Apr-2011 nicm

Provide #h for short hostname (no domain) from Michal Mazurek.


# 1.73 18-Apr-2011 nicm

Add an option (mouse-select-window) which allows the mouse to be used by
clicking on the status line, written by hsim at gmx dot li.


# 1.72 29-Mar-2011 nicm

Change -t on display-message to be target-pane for the #[A-Z]
replacements and add -c as target-client.


Revision tags: OPENBSD_4_9_BASE
# 1.71 26-Jan-2011 nicm

Simplify the way jobs work and drop the persist type, so all jobs are
fire-and-forget.

Status jobs now managed with two trees of output (new and old), rather
than storing the output in the jobs themselves. When the status line is
processed any jobs which don't appear in the new tree are started and
the output from the old tree displayed. When a job finishes it updates
the new tree with its output and that is used for any subsequent
redraws. When the status interval expires, the new tree is moved to the
old so that all jobs are run again.

This fixes the "#(echo %H:%M:%S)" problem which would lead to thousands
of identical persistent jobs and high memory use (this can still be
achieved by adding "sleep 30" but that is much less likely to happen by
accident).


# 1.70 03-Jan-2011 nicm

Handle a # at the end of a replacement string (such as status-left)
correctly. Found by Thomas Adam.


# 1.69 01-Jan-2011 nicm

Move the user-visible parts of all options (names, types, limit, default
values) together into one set of tables in options-table.c. Also clean
up and simplify cmd-set-options.c and move a common print function into
option-table.c.


# 1.68 30-Dec-2010 nicm

Change from a per-session stack of buffers to one global stack which is
much more convenient and also simplifies lot of code. This renders
copy-buffer useless and makes buffer-limit now a server option.

By Tiago Cunha.


# 1.67 30-Dec-2010 nicm

Add a function to create window flags rather than doing the same thing
in two places. From Thomas Adam.


# 1.66 11-Dec-2010 nicm

Oops, these functions return a const char *, so make the local variable
const as well.


# 1.65 11-Dec-2010 nicm

Make the prompt history global for all clients which is much more useful than per-client history.


# 1.64 06-Dec-2010 nicm

Add an option to alert (monitor) for silence (lack of activity) in a
window. From Thomas Adam.


Revision tags: OPENBSD_4_8_BASE
# 1.63 21-Jun-2010 nicm

Having a list of winlinks->alerts for each session is stupid, just store
the alert flags directly in the winlink itself.


# 1.62 14-May-2010 nicm

Colour+attribute options for status line alerts, from Alex Alexander.


# 1.61 31-Mar-2010 nicm

Don't accept keys with modifiers as input. Fixes crash reported by Brian
R Landy.


# 1.60 27-Mar-2010 nicm

Don't leak job command in #().


# 1.59 22-Mar-2010 nicm

Dead functions, lint.


Revision tags: OPENBSD_4_7_BASE
# 1.58 27-Jan-2010 nicm

Calculate offset correctly, fixes incorrect offset and prevents crash when
status-left is empty. From Micah Cowan.


# 1.57 26-Jan-2010 nicm

Actually use the copy made when no newline is found, from martynas@.


# 1.56 14-Dec-2009 nicm

Add server options to completion as well.


# 1.55 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.54 03-Dec-2009 nicm

Eliminate duplicate code and ease the passage for server-wide options by adding
a -w flag to set-option and show-options and making setw and showw aliases to
set -w and show -w.

Note: setw and showw are still there, but now aliases for set -w and show -w.


# 1.53 26-Nov-2009 nicm

Tidy up various bits of the paste code, make the data buffer char * and add
comments.


# 1.52 26-Nov-2009 nicm

Remove a couple of unused arguments where possible, and add /* ARGSUSED */ to
the rest to reduce lint output.


# 1.51 20-Nov-2009 nicm

Display UTF-8 properly in status line messages and prompt. Cursor handling is
still way off though.


# 1.50 20-Nov-2009 nicm

Remove oldest messages from log when limit is hit, not newest.


# 1.49 19-Nov-2009 nicm

Get some brackets in the right place so ## works. Also fix a space in a
comment.


# 1.48 19-Nov-2009 nicm

Change status line drawing to create the window list in a separate screen and
then copy it into the status line screen. This allows UTF-8 in window names and
fixes some problems with #[] in window-status-format.


# 1.47 19-Nov-2009 nicm

Two new options, window-status-format and window-status-current-format, which
allow the format of each window in the status line window list to be controlled
using similar # sequences as status-left/right.

This diff also moves part of the way towards UTF-8 support in window names but
it isn't quite there yet.


# 1.46 19-Nov-2009 nicm

Tidy up by breaking the # replacement code into a separate function, also add a
few comments.


# 1.45 19-Nov-2009 nicm

Don't interpret #() for display-message, it usually doesn't make sense and may
leak commands.


# 1.44 18-Nov-2009 nicm

Add a per-client log of status line messages displayed while that client
exists. A new message-limit session option sets the maximum number of entries
and a command, show-messages, shows the log (bound to ~ by default).

This (and prompt history) might be better as a single global log but until
there are global options it is easier for them to be per client.


# 1.43 17-Nov-2009 nicm

Permit top-bit-set characters to be entered in the status line. They could
already be set from the shell and are just passed through when printing (so
invisible characters or displaying on terminals with different character sets
may cause problems).

Note that entering UTF-8 may not work and in any case currently the status line
cannot display it correctly (outside of status-left/status-right).


# 1.42 04-Nov-2009 nicm

Use timeout events for the identify and message timers.


# 1.41 04-Nov-2009 nicm

Switch jobs over to use a bufferevent.


# 1.40 04-Nov-2009 nicm

Unused (but assigned to) variable, found by lint.


# 1.39 01-Nov-2009 nicm

Add a flag for jobs that shouldn't be freed after they've died and use it for
status jobs, then only kill those jobs when status-left, status-right or
set-titles-string is changed.

Fixes problems with changing options from inside #().


# 1.38 10-Oct-2009 nicm

Rather than running status-left, status-right and window title #() with popen
immediately every redraw, queue them up and run them in the background,
starting each once every status-interval. The actual status line uses the
output from the last run.

This brings several advantages:

- tmux itself may be called from inside #() without causing the server to hang;
- likewise, sleep or similar doesn't cause the server to block;
- commands aren't run excessively often when redrawing;
- commands shared by status-left and status-right, or used multiple times, will
only be run once.

run-shell and if-shell still use system()/popen() but will be changed over to
use this too later.


# 1.37 10-Oct-2009 nicm

Add "grouped sessions" which have independent name, options, current window and
so on but where the linked windows are synchronized (ie creating, killing
windows and so on are mirrored between the sessions). A grouped session may be
created by passing -t to new-session.

Had this around for a while, tested by a couple of people.


# 1.36 23-Sep-2009 nicm

Remove PROMPT_HIDDEN code which is now unused.


# 1.35 23-Sep-2009 nicm

Remove the internal tmux locking and instead detach each client and run the
command specified by a new option "lock-command" (by default "lock -np") in
each client.

This means each terminal has to be unlocked individually but simplifies the
code and allows the system password to be used to unlock.

Note that the set-password command is gone, so it will need to be removed from
configuration files, and the -U command line flag has been removed.

This is the third protocol version change so again it is best to stop the tmux
server before upgrading.


# 1.34 20-Sep-2009 nicm

Regularise some fatal messages.


# 1.33 10-Sep-2009 nicm

Permit options such as status-bg to be configured using the entire 256 colour
palette by setting "colour0" to "colour255".


# 1.32 07-Sep-2009 nicm

Give each paste buffer a size member instead of requiring them to be
zero-terminated.


# 1.31 07-Sep-2009 nicm

Permit embedded colour and attributes in status-left and status-right using new
#[] special characters, for example #[fg=red,bg=blue,blink].


# 1.30 02-Sep-2009 nicm

Add a transpose-chars command in edit mode (C-t in emacs mode only). From Kalle
Olavi Niemitalo.


# 1.29 01-Sep-2009 nicm

Use "Password:" with no space for password prompts and don't display a *s for
the password, like pretty much everything else. From martynas@ with minor
tweaks by me.


# 1.28 31-Aug-2009 nicm

Add a new display-panes command, with two options (display-panes-colour and
display-panes-time), which displays a visual indication of the number of each
pane.


# 1.27 19-Aug-2009 nicm

Extend command-prompt with a -p option which is a comma-separated list of one
or more prompts to present in order.

The responses to the prompt are replaced in the template string: %% are
replaced in order, so the first prompt replaces the first %%, the second
replaces the second, and so on. In addition, %1 up to %9 are replaced with the
responses to the first the ninth prompts

The default template is "%1" so the response to the first prompt is processed
as a command.

Note that this changes the behaviour for %% so if there is only one prompt,
only the first %% will be replaced. Templates such as "neww -n '%%' 'ssh %%'"
should be changed to "neww -n '%1' 'ssh %1'".

From Tiago Cunha.


# 1.26 18-Aug-2009 nicm

Add a "delete line" key when editing in the status line or the search up/down
prompt. C-u with emacs keys, d with vi.


# 1.25 13-Aug-2009 nicm

Switch the prompt code to return an empty string when the user enters no
response and reserve NULL for an explicit cancel. Change all callbacks to treat
them the same so no functional change.

Also add cancel key bindings to emacs mode which were missing.


# 1.24 08-Aug-2009 nicm

Options to set the colours and attributes for status-left/-right. From Thomas
Adam, thanks.


# 1.23 05-Aug-2009 nicm

If colours are not supported by the terminal, try to emulate a coloured
background by setting or clearing the reverse attribute.

This makes a few applications which don't use the reverse attribute themselves
a little happier, and allows the status, message and mode options to have
default attributes and fg/bg options that work as expected when set as reverse.


# 1.22 30-Jul-2009 nicm

Plug some memory leaks.


# 1.21 28-Jul-2009 nicm

Next step towards customisable mode keys: build each default table of keys into
a named tree on start and use that for lookups. Also add command to string
translation tables and modify list-keys to show the the mode key bindings (new
-t argument).


# 1.20 27-Jul-2009 nicm

Change mode key bindings from big switches into a set of tables. Rather than
lumping them all together, split editing keys from those used in choice/more
mode and those for copy/scroll mode.

Tidier and clearer, and the first step towards customisable mode keys.


# 1.19 27-Jul-2009 nicm

Get rid of empty mode_key_free function.


# 1.18 27-Jul-2009 nicm

Add a key to delete to end of line at the prompt (^K in emacs mode, C/D in vi).

From Kalle Olavi Niemitalo.


# 1.17 26-Jul-2009 nicm

Calculate the space available for the prompt buffer and the cursor position
correctly, and make it work when the screen is not wide enough.

Noticed by Kalle Olavi Niemitalo.


# 1.16 21-Jul-2009 nicm

Remove a couple of unused functions and fix a type ("FALLTHOUGH"), found by
lint.


# 1.15 20-Jul-2009 nicm

Add a status-justify option to allow the window list in the status line to be
positioned at the left, centre, or right.


# 1.14 20-Jul-2009 nicm

New options, window-status-current-{fg,bg,attr}, to set the fg, bg and
attributes with which the current window is shown in the status line. From
Johan Friis, thanks.


# 1.13 17-Jul-2009 nicm

- New command display-message (alias display) to display a message in the
status line (bound to "i" and displays the current window and time by
default). The same substitutions are applied as for status-left/right.
- Add support for including the window index (#I), pane index (#P) and window
name (#W) in the message, and status-left or status-right.
- Bump protocol version.

From Tiago Cunha, thanks!


# 1.12 17-Jul-2009 nicm

Memory could be leaked if a second prompt or message appeared while another was
still present, so add a separate prompt free callback and make the _clear
function responsible for calling it if necessary (rather than the individual
prompt callbacks). Also make both messages and prompts clear any existing when
a new is set.

In addition, the screen could be modified while the prompt is there, restore
the redraw-entire-screen behaviour on prompt clear; add a comment as a
reminder.


# 1.11 16-Jul-2009 nicm

Remove some duplicate code that was causing the status line to be redrawn even
when it hadn't changed.


# 1.10 15-Jul-2009 nicm

Make status_message_set a variadic printf-like function. No functional change -
helpful for a couple of things coming soon.


# 1.9 15-Jul-2009 nicm

Having to update NSETOPTION/NSETWINDOWOPTION when adding new options is a bit
annoying and it is only use for iterating, so use a sentinel to mark the end of
each array instead. Different fix for a problem pointed out by Kalle Olavi
Niemitalo.


# 1.8 14-Jul-2009 nicm

For some reason when clearing status/message it was redrawing the entire client
not just the status line. Changing this also revealed the check for the status
line was incorrect when drawing the pane.


# 1.7 14-Jul-2009 nicm

Instead of faking up a status line in status_redraw, use the same code to
redraw it as to draw the entire screen, just skip all lines but the last.

This makes horizontal split redraw properly when the status line is off.


# 1.6 12-Jul-2009 nicm

Add a "back to indentation" key in copy mode to move the cursor to the first
non-whitespace character. ^ with vi and M-m with emacs key bindings. Another
from Kalle Olavi Niemitalo, thanks.


Revision tags: OPENBSD_4_6_BASE
# 1.5 26-Jun-2009 nicm

Status line fixes: don't truncate status-right now the length calculation is
done for UTF-8, limit to the maximum length correctly when printing, and always
print a space even if the left string is longer than the width available.


# 1.4 04-Jun-2009 nicm

If the prompt is hidden or a password is sent with -U, zero it before freeing
it.


# 1.3 03-Jun-2009 nicm

New session option, status-utf8, to control the interpretation of top-bit-set
characters in status-left and status-right (if on, they are treated as UTF-8;
otherwise passed through).


# 1.2 03-Jun-2009 nicm

Add a UTF-8 aware string length function and make UTF-8 in
status-left/status-right work properly. At the moment any top-bit-set
characters are assumed to be UTF-8: a status-utf8 option to configure this will
come shortly.


# 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.240 15-Aug-2023 nicm

Add an option menu-selected-style to configure the currently selected
menu item, from Alexis Hildebrandt.


# 1.239 08-Aug-2023 nicm

Add options and flags for menu styles similar to those existing for
popups, from Alexis Hildebrandt. GitHub issue 3650.


# 1.238 17-Apr-2023 nicm

Ignore the user keys range when checking if a key is Unicode.


Revision tags: OPENBSD_7_3_BASE
# 1.237 20-Jan-2023 nicm

Add a flag to display-menu to select the manu item chosen first, GitHub
issue 3442.


Revision tags: OPENBSD_7_2_BASE
# 1.236 10-Sep-2022 nicm

Use correct option name.


# 1.235 09-Sep-2022 nicm

Add message-line option to control where message and prompt go, from
Varun Kumar E in GitHub issue 3324.


# 1.234 30-May-2022 nicm

Remove duplicates from completion list, GitHub issue 3178.


Revision tags: OPENBSD_7_1_BASE
# 1.233 07-Mar-2022 nicm

Pass client when adding menu item, GitHub issue 3103.


# 1.232 03-Feb-2022 nicm

Use format_draw for command prompt prefix to allow styles, GitHub issue
3054.


# 1.231 15-Nov-2021 nicm

Leave the hardware cursor at the position of the selected line in choose
modes and current editing position and at the command prompt. It is
invisible but this is helpful for people using screen readers. GitHub
issue 2970.


# 1.230 01-Nov-2021 nicm

Fix a comparison, from Ben Boeckel, and a crash when opening completion
menu, from Anindya Mukherjee.


# 1.229 26-Oct-2021 nicm

Accept some emacs control keys in vi normal mode, from Alexis
Hildebrandt in GitHub issue 2922.


# 1.228 26-Oct-2021 nicm

Do not allow inline styles to replace mode-style for the selected item,
from Alexis Hildebrandt in GitHub issue 2946.


Revision tags: OPENBSD_7_0_BASE
# 1.227 20-Aug-2021 nicm

Remove stray spaces after function names.


# 1.226 12-Aug-2021 nicm

Use COLOUR_DEFAULT not hardcoded 8.


# 1.225 10-Jun-2021 nicm

More accurate vi(1) word navigation in copy mode and on the status line.
This changes the meaning of the word-separators option - setting it to
the empty string is equivalent to the previous behavior. From Will Noble
in GitHub issue 2693.


# 1.224 10-Jun-2021 nicm

Add different command historys for different types of prompts
("command", "search" etc). From Anindya Mukherjee.


# 1.223 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.222 10-Jun-2021 nicm

Include current client in size calculation for new sessions, GitHub
issue 2662.


Revision tags: OPENBSD_6_9_BASE
# 1.221 12-Apr-2021 nicm

Add a flag to disable keys to close a message, GitHub issue 2625.


# 1.220 22-Feb-2021 nicm

Move jump commands to grid reader, make them UTF-8 aware, and tidy up,
from Anindya Mukherjee.


# 1.219 08-Jan-2021 nicm

With incremental search, start empty and only repeat the previous search
if the user tries to search again with an empty prompt. This matches
emacs behaviour more closely.


Revision tags: OPENBSD_6_8_BASE
# 1.218 27-Jul-2020 nicm

Add a -d option to display-message to set delay, from theonekeyg at
gmail dot com in GitHub issue 2322.


# 1.217 11-Jun-2020 nicm

Fix a crash when completing sessions, from Anindya Mukherjee.


# 1.216 26-May-2020 nicm

Remove leftover debug logging and fix comparison.


# 1.215 26-May-2020 nicm

Set up UTF-8 data for ASCII keys correctly.


# 1.214 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.213 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.212 16-May-2020 nicm

Rename KEYC_ESCAPE to KEYC_META.


# 1.211 16-May-2020 nicm

Expand target from client and use it to expand the prompt.


# 1.210 16-May-2020 nicm

Support embedded styles in the display-message message, GitHub issue
2206.


# 1.209 16-May-2020 nicm

Change message log to be per server rather than per client and include
every command that is run.


# 1.208 16-May-2020 nicm

Do not hoke into struct window_pane from the tty code and instead set
everything up in tty_ctx. Provide a way to initialize the tty_ctx from a
callback and use it to let popups draw directly through input_parse in
the same way as panes do, rather than forcing a full redraw on every
change.


# 1.207 16-May-2020 nicm

Use formats for status-style and message-style.


# 1.206 16-May-2020 nicm

Complete partial window indexes properly.


# 1.205 16-May-2020 nicm

Add -W and -T flags to command-prompt to only complete a window and a
target, also complete aliases.


# 1.204 16-May-2020 nicm

Improve command prompt completion:

- Show a menu with completions if there are multiple.

- Don't complete argument stuff (options, layouts) at start of text.

- For -t and -s, if there is no : then complete sessions but if there is
a :, show a menu of all windows in the session rather than trying to
complete the window name which is a bit useless if there are
duplicates.


# 1.203 16-May-2020 nicm

Drop having a separate type for style options and make them all strings,
which allows formats to be expanded. Any styles without a '#{' are still
validated when they are set but any with a '#{' are not. Formats are not
expanded usefully in many cases yet, that will be changed later.

To make this work, a few other changes:

- set-option -a with a style option automatically appends a ",".

- OSC 10 and 11 don't set the window-style option anymore, instead the
fg and bg are stored in the pane struct and act as the defaults that
can be overridden by window-style.

- status-fg and -bg now override status-style instead of trying to keep
them in sync.


Revision tags: OPENBSD_6_7_BASE
# 1.202 12-Mar-2020 nicm

Add C-g to cancel command prompt with vi(1) keys as well as emacs, and q
in command mode.


# 1.201 27-Jan-2020 nicm

Add support for adding a note to a key binding (with bind-key -N) and
use this to add descriptions to the default key bindings. A new -N flag
to list-keys shows key bindings with notes rather than the default
bind-key command used to create them. Change the default ? binding to
use this to show a readable summary of keys.

Also extend command-prompt to return the name of the key pressed and add
a default binding (/) to show the note for the next key pressed

Suggested by Alex Tremblay in GitHub issue 2000.


Revision tags: OPENBSD_6_6_BASE
# 1.200 28-May-2019 nicm

Redraw status line if size changes, GitHub issue 1762. Also fix length
of target buffer when pasting into status line.


# 1.199 23-May-2019 nicm

Fix length calculation for pasting UTF-8 characters in the status line,
GitHub issue 1753.


# 1.198 11-May-2019 nicm

Do not reduce window height by status line height for control mode
clients, from George Nachman.


# 1.197 03-May-2019 nicm

Fix reverse attribute in status line, GitHub issue 1709.


# 1.196 26-Apr-2019 nicm

Merge hooks into options and make each one an array option. This allows
multiple commands to be easily bound to one hook. set-hook and
show-hooks remain but they are now variants of set-option and
show-options. show-options now has a -H flag to show hooks (by default
they are not shown).


# 1.195 25-Apr-2019 nicm

options_array_item_value cannot return NULL.


# 1.194 23-Apr-2019 nicm

Somehow missed these bits in last commit.


# 1.193 23-Apr-2019 nicm

Indicate an array option with a flag rather than a special type so that
in future will not have to be strings.


Revision tags: OPENBSD_6_5_BASE
# 1.192 18-Mar-2019 nicm

Extend the #[] style syntax and use that together with previous format
changes to allow the status line to be entirely configured with a single
option.

Now that it is possible to configure their content, enable the existing
code that lets the status line be multiple lines in height. The status
option can now take a value of 2, 3, 4 or 5 (as well as the previous on
or off) to configure more than one line. The new status-format array
option configures the format of each line, the default just references
the existing status-* options, although some of the more obscure status
options may be eliminated in time.

Additions to the #[] syntax are: "align" to specify alignment (left,
centre, right), "list" for the window list and "range" to configure
ranges of text for the mouse bindings.

The "align" keyword can also be used to specify alignment of entries in
tree mode and the pane status lines.


# 1.191 18-Mar-2019 nicm

Make array options a sparse tree instead of an array of char * and
remove the size limit.


# 1.190 18-Mar-2019 nicm

With force, kill previous job before starting new. Fixes problem
reported by Scott Mcdermott in GitHub issue 1627.


# 1.189 16-Mar-2019 nicm

Use a pointer for the active screen in the status line instead of
copying them around all the time.


# 1.188 16-Mar-2019 nicm

Give status_save_old the client so it can do the reinit too.


# 1.187 16-Mar-2019 nicm

Tidy and rename some bits of status line code.


# 1.186 15-Mar-2019 nicm

Move status line free into its own function.


# 1.185 14-Mar-2019 nicm

Store the time in the format tree rather than passing it around.


# 1.184 12-Mar-2019 nicm

DECRC and DECSC apparently need to preserve origin mode as well, based
on a fix from Marc Reisner.


# 1.183 09-Feb-2019 nicm

Completion of command-alias members.


# 1.182 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.181 29-Aug-2018 nicm

Keep any text killed in the command prompt with C-w and yank it with
C-y, only use the top buffer if no text has previously been killed. This
and previous change promped by discussion with kn@.


# 1.180 29-Aug-2018 nicm

Add C-Left and C-Right as aliases for M-b and M-f.


# 1.179 22-Aug-2018 nicm

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


# 1.178 20-Aug-2018 nicm

Move offset of window list into status struct.


# 1.177 19-Aug-2018 nicm

Add a client redraw-window flag instead of the redraw-all flag and for
all just use the three flags together (window, borders, status).


Revision tags: OPENBSD_6_3_BASE
# 1.176 22-Feb-2018 nicm

Remove an unused variable.


# 1.175 05-Feb-2018 nicm

Add struct status_line to hold status line members of struct client, not
used yet but will be soon. From Thomas Adam.


# 1.174 01-Jan-2018 nicm

Add C-g at command prompt for emacs people, GitHub issue 1213.


# 1.173 27-Dec-2017 nicm

Draw command prompt correctly with status line off.


# 1.172 18-Dec-2017 nicm

Remove unused variable from Thomas Adam.


# 1.171 02-Nov-2017 nicm

Add a "fast" version of screen_write_copy for tree mode that doesn't do
all the checks and selection and marking stuff needed for copy mode.


# 1.170 20-Oct-2017 nicm

Clear status line with spaces again so reverse works, spotted by sthen.


# 1.169 16-Oct-2017 nicm

Infrastructure for drawing status lines of more than one line in height,
still only one is allowed but this lets tmux draw bigger ones.


Revision tags: OPENBSD_6_2_BASE
# 1.168 29-May-2017 nicm

Add a flag to stop the prompt input being expanded.


# 1.167 29-May-2017 nicm

Store a copy of the old status line, will be needed soon for new choose mode.


# 1.166 17-May-2017 nicm

Tidy command prompt callbacks and pass in the client.


# 1.165 03-May-2017 nicm

Add a format for the last search string in copy mode and fix the prompt
so it can work when in -I, suggested by Suraj N Kurapati.


# 1.164 01-May-2017 nicm

In order that people can use formats like #D in #() in the status line
and not have to wait for an update when they change pane, we allow
commands to run more than once a second if the expanded form
changes. Unfortunately this can mean them being run far too often
(pretty much continually) when multiple clients exist, because some
formats (including #D) will always differ between clients.

To avoid this, give each client its own tree of jobs which means that
the same command will be different instances for each client - similar
to how we have the tag to separate commands for different panes.

GitHub issue 889; test case reported by Paul Johnson.


# 1.163 22-Apr-2017 nicm

Memory leak from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.162 09-Feb-2017 nicm

Break the message storage function into its own function, useful for
debugging.


# 1.161 03-Feb-2017 nicm

Cache status line position to reduce option lookups during output.


# 1.160 03-Feb-2017 nicm

Add a window or pane id "tag" to each format tree and use it to separate
jobs, this means that if the same job is used for different windows or
panes (for example in pane-border-format), it will be run separately for
each pane.


# 1.159 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.158 06-Jan-2017 nicm

Incremental search in copy mode (on for emacs keys by default) - much
the same as normal searching but updates the cursor position and marked
search terms as you type. C-r and C-s in the prompt repeat the search,
once finished searching (with Enter), N and n work as before.


# 1.157 05-Jan-2017 nicm

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


# 1.156 07-Dec-2016 nicm

Do not clear the prompt when a message is shown, just leave it around and
return to it when the message is finished.


# 1.155 12-Oct-2016 nicm

Drop the edit mode key tables and just use fixed key bindings for the
command prompt.


# 1.154 12-Oct-2016 nicm

The repeat prompt in both emacs and vi (and the old one in tmux) doesn't
support line editing and instead executes a command as soon as a
non-number key is pressed. Add a -N flag to command-prompt for the same
in copy mode. Reported by Theo Buehler.


# 1.153 11-Oct-2016 nicm

Fundamental change to how copy mode key bindings work:

The vi-copy and emacs-copy mode key tables are gone, and instead copy
mode commands are bound in one of two normal key tables ("copy-mode" or
"copy-mode-vi"). Keys are bound to "send-keys -X copy-mode-command". So:

bind -temacs-copy C-Up scroll-up
bind -temacs-copy -R5 WheelUpPane scroll-up

Becomes:

bind -Tcopy-mode C-Up send -X scroll-up
bind -Tcopy-mode WheelUpPane send -N5 -X scroll-up

This allows the full command parser and command set to be used - for
example, we can use the normal command prompt for searching, jumping,
and so on instead of a custom one:

bind -Tcopy-mode C-r command-prompt -p'search up' "send -X search-backward '%%'"

command-prompt also gets a -1 option to only require on key press, which
is needed for jumping.

The plan is to get rid of mode keys entirely, so more to come eventually.


# 1.152 11-Oct-2016 nicm

Support UTF-8 entry into the command prompt.


# 1.151 10-Oct-2016 nicm

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


# 1.150 12-Sep-2016 nicm

Allow repeat count to be specified in mode key tables with bind-key -R,
and set the default repeat count to 5 for WheelUp and WheelDown in
copy-mode.


Revision tags: OPENBSD_6_0_BASE
# 1.149 06-Jun-2016 nicm

Allow #[] in window-status-separator.


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

I no longer use my SourceForge address so replace it.


# 1.147 01-Jan-2016 nicm

Don't rely on a calculation wrapping when applying message-limit, and
break out of the loop early. From Nicolas Viennot.


# 1.146 11-Dec-2015 nicm

Style nits and line wrapping of function declarations.


# 1.145 11-Dec-2015 nicm

Add cmdq as an argument to format_create and add a format for the
command name (will also be used for more later).


# 1.144 08-Dec-2015 nicm

Remove format_create_flags and just pass flags to format_create.


# 1.143 22-Nov-2015 tim

If display-time is set to 0, show status messages until a key is pressed;
OK nicm@


# 1.142 20-Nov-2015 nicm

Instead of separate tables for different types of options, give each
option a scope type (server, session, window) in one table.


# 1.141 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.140 13-Nov-2015 nicm

Long overdue change to the way we store cells in the grid: now, instead
of storing a full grid_cell with UTF-8 data and everything, store a new
type grid_cell_entry. This can either be the cell itself (for ASCII
cells), or an offset into an extended array (per line) for UTF-8
data.

This avoid a large (8 byte) overhead on non-UTF-8 cells (by far the
majority for most users) without the complexity of the shadow array we
had before. Grid memory without any UTF-8 is about half.

The disadvantage that cells can no longer be modified in place and need
to be copied out of the grid and back but it turned out to be lot less
complicated than I expected.


# 1.139 12-Nov-2015 nicm

Nuke the utf8 and status-utf8 options and make tmux only a UTF-8
terminal. We still support non-UTF-8 terminals outside tmux, but inside
it is always UTF-8 (as when the utf8 and status-utf8 options were on).


# 1.138 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.137 27-Oct-2015 nicm

Move struct options into options.c.


# 1.136 20-Oct-2015 nicm

Use client pointer not file descriptor in logging.


# 1.135 14-Sep-2015 nicm

Make refresh-client force update of jobs, from Sina Siadat.


# 1.134 29-Aug-2015 nicm

Move struct paste_buffer out of tmux.h.


# 1.133 28-Aug-2015 nicm

Run status update on a per-client timer at status-interval.


Revision tags: OPENBSD_5_8_BASE
# 1.132 29-Jul-2015 nicm

status_out and associated data structures are no longer used.


# 1.131 28-Jul-2015 nicm

Tidy up the way terminals are described and move some structs out of tmux.h.


# 1.130 20-Jul-2015 nicm

Add an option (history-file) for a file to save/restore command prompt
history, from Olof-Joachim Frahm.


# 1.129 27-May-2015 nicm

Move the jobs output cache into the formats code so that #() work more
generally (for example, again working in set-titles-string).


# 1.128 06-May-2015 nicm

Remove ARRAY_* from history and expand completion to complete a) layout
names and b) targets beginning with -t or -s.


# 1.127 25-Apr-2015 nicm

Make message log a TAILQ.


# 1.126 24-Apr-2015 nicm

Set working directory for run-shell and if-shell.


# 1.125 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_7_BASE
# 1.124 06-Feb-2015 nicm

Use the same time for both calls to format_expand_time.


# 1.123 06-Feb-2015 nicm

status_replace can now become local to status.c and it no longer needs
the jobsflag argument. While here there is no need to repeat work that
format_defaults already does.


# 1.122 06-Feb-2015 nicm

Add format_expand_time and use it instead of status_replace where
command execution is not needed.


# 1.121 05-Feb-2015 nicm

Wrap all the individual format_* calls in a single format_defaults
functions.


# 1.120 01-Feb-2015 nicm

Remove two unused arguments from status_replace.


# 1.119 20-Jan-2015 sthen

typo in comment ;) ok nicm


# 1.118 05-Nov-2014 nicm

Do not put a space between status-left/status-right and the window list,
instead move the space into the defaults for the options (so status-left
now defaults to "[#S] ". From Balazs Kezes.


# 1.117 20-Oct-2014 nicm

Better format for printf format attributes.


# 1.116 08-Oct-2014 nicm

Add xreallocarray and remove nmemb argument from xrealloc.


# 1.115 02-Oct-2014 nicm

Take account of window-status-separator when checking window position,
based on diff from Balazs Kezes.


Revision tags: OPENBSD_5_6_BASE
# 1.114 24-Apr-2014 nicm

There is no longer a need for a paste_stack struct or for global_buffers
to be global. Move to paste.c.


# 1.113 17-Apr-2014 nicm

Remove the monitor-content option and associated bits and bobs. It's
never worked very well. If there is a big demand for it to return, will
consider better ways to do it.


# 1.112 02-Apr-2014 nicm

Do not replace ## with # in status_replace1 because it'll be done later
by the format code.


# 1.111 31-Mar-2014 nicm

Make message-limit a server option.


Revision tags: OPENBSD_5_5_BASE
# 1.110 14-Feb-2014 nicm

Style nit - no space between function name and bracket.


# 1.109 14-Feb-2014 nicm

Check for NULL session and whatnot in status_replace, from Thomas Adam.


# 1.108 28-Jan-2014 nicm

Allow replacing each of the many sets of separate foo-{fg,bg,attr}
options with a single foo-style option. For example:

set -g status-fg yellow
set -g status-bg red
set -g status-attr blink

Becomes:

set -g status-style fg=yellow,bg=red,blink

The -a flag to set can be used to add to rather than replace a style. So:

set -g status-bg red

Becomes:

set -ag status-style bg=red

Currently this is fully backwards compatible (all *-{fg,bg,attr} options
remain) but the plan is to deprecate them over time.

From Tiago Cunha.


Revision tags: OPENBSD_5_4_BASE
# 1.107 05-Jul-2013 nicm

Whitespace nits, from Ben Boeckel.


# 1.106 05-Jul-2013 nicm

Act like vi(1) when moving words, from Ben Boeckel.


# 1.105 05-Jul-2013 nicm

Implement s, S, C mode switch commands in vi(1) mode, from Ben Boeckel.


# 1.104 31-May-2013 nicm

Demote the old single-character replacement variables (#S and friends)
to aliases of formats. From Tiago Cunha.


# 1.103 25-Mar-2013 nicm

Extend jobs to support writing and use that for copy-pipe instead of
popen, from Chris Johnsen.


# 1.102 22-Mar-2013 nicm

evbuffer_readline returns allocated storage, don't leak it.


# 1.101 22-Mar-2013 nicm

Add copy-pipe mode command to copy selection and also pipe to a command.


# 1.100 22-Mar-2013 nicm

No more lint means no more ARGSUSED.


# 1.99 21-Mar-2013 nicm

Aargh. Spaces -> tabs.


# 1.98 21-Mar-2013 nicm

Do not leak formats in status_replace.


# 1.97 21-Mar-2013 nicm

Add a format client_prefix which is 1 if prefix key has been
pressed, used for example #{?client_prefix,X,Y}. Also a few extra
server_client_status needed.


# 1.96 21-Mar-2013 nicm

Allow formats in status options.


Revision tags: OPENBSD_5_3_BASE
# 1.95 27-Nov-2012 nicm

Add window-status-last-* options, from Boris Faure.


Revision tags: OPENBSD_5_2_BASE
# 1.94 10-Jul-2012 nicm

xfree is not particularly helpful, remove it. From Thomas Adam.


# 1.93 09-Jul-2012 nicm

Move a NULL check inside a function, from Tiago Cunha.


# 1.92 29-Apr-2012 nicm

Use int not u_char for colours from options since they may have bit 8
set to mark them as 256-colour. Reported by Chris Johnson.


# 1.91 23-Apr-2012 nicm

Add window-status-separator option, from Thomas Adam.


# 1.90 17-Mar-2012 nicm

Check event_initialized before event_del if event may not have been set
up; libevent2 complains about this. Reported by Moriyoshi Koizumi.


# 1.89 04-Mar-2012 nicm

Add A and I keys for vi status line editing.


# 1.88 03-Mar-2012 nicm

The wlmouse offset should be part of the client, not the server. From
Ailin Nemui.


Revision tags: OPENBSD_5_1_BASE
# 1.87 29-Jan-2012 nicm

Add an option to move the status line to the top of the screen,
requested by many.


# 1.86 26-Jan-2012 nicm

Terminate strftime buffer properly even if a really long format string
is given, from Tiago Cunha.


# 1.85 26-Jan-2012 nicm

Fix memory leak in error path, from Tiago Cunha.


# 1.84 20-Jan-2012 nicm

Add some trivial additional status line attributes from jwcxz at users
dot sourceforge dot net.


# 1.83 20-Jan-2012 nicm

Add space movement keys for vi mode in the status line from Ben Boeckel.


# 1.82 01-Dec-2011 nicm

Make M-f and M-b work the same at the command prompt as in copy mode,
pointed out by Romain Francoise.


# 1.81 15-Nov-2011 nicm

Add word movement and editing command for command prompt editing, from
Ben Boeckel.


# 1.80 15-Nov-2011 nicm

Make window_pane_index work the same as window_index, from Ben Boeckel.


# 1.79 05-Nov-2011 nicm

Option to change status line (message) background when using vi keys and
in command mode. From Ben Boeckel.


# 1.78 20-Aug-2011 nicm

Fix a couple of memory leaks, from marcel partap.


Revision tags: OPENBSD_5_0_BASE
# 1.77 08-Jul-2011 nicm

Make confirm-before prompt customizable with -p option like
command-prompt. Also move responsibility for calling status_replace into
status_prompt_{set,update} and add #W and #P to the default kill-window
and kill-pane prompts. By Tiago Cunha.


# 1.76 02-Jul-2011 nicm

Allow the initial context on prompts to be set with the new -I option to
command-prompt. From Tiago Cunha.


# 1.75 29-Apr-2011 nicm

Only redraw the status line on command update, not the entire client
(big DOH).


# 1.74 24-Apr-2011 nicm

Provide #h for short hostname (no domain) from Michal Mazurek.


# 1.73 18-Apr-2011 nicm

Add an option (mouse-select-window) which allows the mouse to be used by
clicking on the status line, written by hsim at gmx dot li.


# 1.72 29-Mar-2011 nicm

Change -t on display-message to be target-pane for the #[A-Z]
replacements and add -c as target-client.


Revision tags: OPENBSD_4_9_BASE
# 1.71 26-Jan-2011 nicm

Simplify the way jobs work and drop the persist type, so all jobs are
fire-and-forget.

Status jobs now managed with two trees of output (new and old), rather
than storing the output in the jobs themselves. When the status line is
processed any jobs which don't appear in the new tree are started and
the output from the old tree displayed. When a job finishes it updates
the new tree with its output and that is used for any subsequent
redraws. When the status interval expires, the new tree is moved to the
old so that all jobs are run again.

This fixes the "#(echo %H:%M:%S)" problem which would lead to thousands
of identical persistent jobs and high memory use (this can still be
achieved by adding "sleep 30" but that is much less likely to happen by
accident).


# 1.70 03-Jan-2011 nicm

Handle a # at the end of a replacement string (such as status-left)
correctly. Found by Thomas Adam.


# 1.69 01-Jan-2011 nicm

Move the user-visible parts of all options (names, types, limit, default
values) together into one set of tables in options-table.c. Also clean
up and simplify cmd-set-options.c and move a common print function into
option-table.c.


# 1.68 30-Dec-2010 nicm

Change from a per-session stack of buffers to one global stack which is
much more convenient and also simplifies lot of code. This renders
copy-buffer useless and makes buffer-limit now a server option.

By Tiago Cunha.


# 1.67 30-Dec-2010 nicm

Add a function to create window flags rather than doing the same thing
in two places. From Thomas Adam.


# 1.66 11-Dec-2010 nicm

Oops, these functions return a const char *, so make the local variable
const as well.


# 1.65 11-Dec-2010 nicm

Make the prompt history global for all clients which is much more useful than per-client history.


# 1.64 06-Dec-2010 nicm

Add an option to alert (monitor) for silence (lack of activity) in a
window. From Thomas Adam.


Revision tags: OPENBSD_4_8_BASE
# 1.63 21-Jun-2010 nicm

Having a list of winlinks->alerts for each session is stupid, just store
the alert flags directly in the winlink itself.


# 1.62 14-May-2010 nicm

Colour+attribute options for status line alerts, from Alex Alexander.


# 1.61 31-Mar-2010 nicm

Don't accept keys with modifiers as input. Fixes crash reported by Brian
R Landy.


# 1.60 27-Mar-2010 nicm

Don't leak job command in #().


# 1.59 22-Mar-2010 nicm

Dead functions, lint.


Revision tags: OPENBSD_4_7_BASE
# 1.58 27-Jan-2010 nicm

Calculate offset correctly, fixes incorrect offset and prevents crash when
status-left is empty. From Micah Cowan.


# 1.57 26-Jan-2010 nicm

Actually use the copy made when no newline is found, from martynas@.


# 1.56 14-Dec-2009 nicm

Add server options to completion as well.


# 1.55 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.54 03-Dec-2009 nicm

Eliminate duplicate code and ease the passage for server-wide options by adding
a -w flag to set-option and show-options and making setw and showw aliases to
set -w and show -w.

Note: setw and showw are still there, but now aliases for set -w and show -w.


# 1.53 26-Nov-2009 nicm

Tidy up various bits of the paste code, make the data buffer char * and add
comments.


# 1.52 26-Nov-2009 nicm

Remove a couple of unused arguments where possible, and add /* ARGSUSED */ to
the rest to reduce lint output.


# 1.51 20-Nov-2009 nicm

Display UTF-8 properly in status line messages and prompt. Cursor handling is
still way off though.


# 1.50 20-Nov-2009 nicm

Remove oldest messages from log when limit is hit, not newest.


# 1.49 19-Nov-2009 nicm

Get some brackets in the right place so ## works. Also fix a space in a
comment.


# 1.48 19-Nov-2009 nicm

Change status line drawing to create the window list in a separate screen and
then copy it into the status line screen. This allows UTF-8 in window names and
fixes some problems with #[] in window-status-format.


# 1.47 19-Nov-2009 nicm

Two new options, window-status-format and window-status-current-format, which
allow the format of each window in the status line window list to be controlled
using similar # sequences as status-left/right.

This diff also moves part of the way towards UTF-8 support in window names but
it isn't quite there yet.


# 1.46 19-Nov-2009 nicm

Tidy up by breaking the # replacement code into a separate function, also add a
few comments.


# 1.45 19-Nov-2009 nicm

Don't interpret #() for display-message, it usually doesn't make sense and may
leak commands.


# 1.44 18-Nov-2009 nicm

Add a per-client log of status line messages displayed while that client
exists. A new message-limit session option sets the maximum number of entries
and a command, show-messages, shows the log (bound to ~ by default).

This (and prompt history) might be better as a single global log but until
there are global options it is easier for them to be per client.


# 1.43 17-Nov-2009 nicm

Permit top-bit-set characters to be entered in the status line. They could
already be set from the shell and are just passed through when printing (so
invisible characters or displaying on terminals with different character sets
may cause problems).

Note that entering UTF-8 may not work and in any case currently the status line
cannot display it correctly (outside of status-left/status-right).


# 1.42 04-Nov-2009 nicm

Use timeout events for the identify and message timers.


# 1.41 04-Nov-2009 nicm

Switch jobs over to use a bufferevent.


# 1.40 04-Nov-2009 nicm

Unused (but assigned to) variable, found by lint.


# 1.39 01-Nov-2009 nicm

Add a flag for jobs that shouldn't be freed after they've died and use it for
status jobs, then only kill those jobs when status-left, status-right or
set-titles-string is changed.

Fixes problems with changing options from inside #().


# 1.38 10-Oct-2009 nicm

Rather than running status-left, status-right and window title #() with popen
immediately every redraw, queue them up and run them in the background,
starting each once every status-interval. The actual status line uses the
output from the last run.

This brings several advantages:

- tmux itself may be called from inside #() without causing the server to hang;
- likewise, sleep or similar doesn't cause the server to block;
- commands aren't run excessively often when redrawing;
- commands shared by status-left and status-right, or used multiple times, will
only be run once.

run-shell and if-shell still use system()/popen() but will be changed over to
use this too later.


# 1.37 10-Oct-2009 nicm

Add "grouped sessions" which have independent name, options, current window and
so on but where the linked windows are synchronized (ie creating, killing
windows and so on are mirrored between the sessions). A grouped session may be
created by passing -t to new-session.

Had this around for a while, tested by a couple of people.


# 1.36 23-Sep-2009 nicm

Remove PROMPT_HIDDEN code which is now unused.


# 1.35 23-Sep-2009 nicm

Remove the internal tmux locking and instead detach each client and run the
command specified by a new option "lock-command" (by default "lock -np") in
each client.

This means each terminal has to be unlocked individually but simplifies the
code and allows the system password to be used to unlock.

Note that the set-password command is gone, so it will need to be removed from
configuration files, and the -U command line flag has been removed.

This is the third protocol version change so again it is best to stop the tmux
server before upgrading.


# 1.34 20-Sep-2009 nicm

Regularise some fatal messages.


# 1.33 10-Sep-2009 nicm

Permit options such as status-bg to be configured using the entire 256 colour
palette by setting "colour0" to "colour255".


# 1.32 07-Sep-2009 nicm

Give each paste buffer a size member instead of requiring them to be
zero-terminated.


# 1.31 07-Sep-2009 nicm

Permit embedded colour and attributes in status-left and status-right using new
#[] special characters, for example #[fg=red,bg=blue,blink].


# 1.30 02-Sep-2009 nicm

Add a transpose-chars command in edit mode (C-t in emacs mode only). From Kalle
Olavi Niemitalo.


# 1.29 01-Sep-2009 nicm

Use "Password:" with no space for password prompts and don't display a *s for
the password, like pretty much everything else. From martynas@ with minor
tweaks by me.


# 1.28 31-Aug-2009 nicm

Add a new display-panes command, with two options (display-panes-colour and
display-panes-time), which displays a visual indication of the number of each
pane.


# 1.27 19-Aug-2009 nicm

Extend command-prompt with a -p option which is a comma-separated list of one
or more prompts to present in order.

The responses to the prompt are replaced in the template string: %% are
replaced in order, so the first prompt replaces the first %%, the second
replaces the second, and so on. In addition, %1 up to %9 are replaced with the
responses to the first the ninth prompts

The default template is "%1" so the response to the first prompt is processed
as a command.

Note that this changes the behaviour for %% so if there is only one prompt,
only the first %% will be replaced. Templates such as "neww -n '%%' 'ssh %%'"
should be changed to "neww -n '%1' 'ssh %1'".

From Tiago Cunha.


# 1.26 18-Aug-2009 nicm

Add a "delete line" key when editing in the status line or the search up/down
prompt. C-u with emacs keys, d with vi.


# 1.25 13-Aug-2009 nicm

Switch the prompt code to return an empty string when the user enters no
response and reserve NULL for an explicit cancel. Change all callbacks to treat
them the same so no functional change.

Also add cancel key bindings to emacs mode which were missing.


# 1.24 08-Aug-2009 nicm

Options to set the colours and attributes for status-left/-right. From Thomas
Adam, thanks.


# 1.23 05-Aug-2009 nicm

If colours are not supported by the terminal, try to emulate a coloured
background by setting or clearing the reverse attribute.

This makes a few applications which don't use the reverse attribute themselves
a little happier, and allows the status, message and mode options to have
default attributes and fg/bg options that work as expected when set as reverse.


# 1.22 30-Jul-2009 nicm

Plug some memory leaks.


# 1.21 28-Jul-2009 nicm

Next step towards customisable mode keys: build each default table of keys into
a named tree on start and use that for lookups. Also add command to string
translation tables and modify list-keys to show the the mode key bindings (new
-t argument).


# 1.20 27-Jul-2009 nicm

Change mode key bindings from big switches into a set of tables. Rather than
lumping them all together, split editing keys from those used in choice/more
mode and those for copy/scroll mode.

Tidier and clearer, and the first step towards customisable mode keys.


# 1.19 27-Jul-2009 nicm

Get rid of empty mode_key_free function.


# 1.18 27-Jul-2009 nicm

Add a key to delete to end of line at the prompt (^K in emacs mode, C/D in vi).

From Kalle Olavi Niemitalo.


# 1.17 26-Jul-2009 nicm

Calculate the space available for the prompt buffer and the cursor position
correctly, and make it work when the screen is not wide enough.

Noticed by Kalle Olavi Niemitalo.


# 1.16 21-Jul-2009 nicm

Remove a couple of unused functions and fix a type ("FALLTHOUGH"), found by
lint.


# 1.15 20-Jul-2009 nicm

Add a status-justify option to allow the window list in the status line to be
positioned at the left, centre, or right.


# 1.14 20-Jul-2009 nicm

New options, window-status-current-{fg,bg,attr}, to set the fg, bg and
attributes with which the current window is shown in the status line. From
Johan Friis, thanks.


# 1.13 17-Jul-2009 nicm

- New command display-message (alias display) to display a message in the
status line (bound to "i" and displays the current window and time by
default). The same substitutions are applied as for status-left/right.
- Add support for including the window index (#I), pane index (#P) and window
name (#W) in the message, and status-left or status-right.
- Bump protocol version.

From Tiago Cunha, thanks!


# 1.12 17-Jul-2009 nicm

Memory could be leaked if a second prompt or message appeared while another was
still present, so add a separate prompt free callback and make the _clear
function responsible for calling it if necessary (rather than the individual
prompt callbacks). Also make both messages and prompts clear any existing when
a new is set.

In addition, the screen could be modified while the prompt is there, restore
the redraw-entire-screen behaviour on prompt clear; add a comment as a
reminder.


# 1.11 16-Jul-2009 nicm

Remove some duplicate code that was causing the status line to be redrawn even
when it hadn't changed.


# 1.10 15-Jul-2009 nicm

Make status_message_set a variadic printf-like function. No functional change -
helpful for a couple of things coming soon.


# 1.9 15-Jul-2009 nicm

Having to update NSETOPTION/NSETWINDOWOPTION when adding new options is a bit
annoying and it is only use for iterating, so use a sentinel to mark the end of
each array instead. Different fix for a problem pointed out by Kalle Olavi
Niemitalo.


# 1.8 14-Jul-2009 nicm

For some reason when clearing status/message it was redrawing the entire client
not just the status line. Changing this also revealed the check for the status
line was incorrect when drawing the pane.


# 1.7 14-Jul-2009 nicm

Instead of faking up a status line in status_redraw, use the same code to
redraw it as to draw the entire screen, just skip all lines but the last.

This makes horizontal split redraw properly when the status line is off.


# 1.6 12-Jul-2009 nicm

Add a "back to indentation" key in copy mode to move the cursor to the first
non-whitespace character. ^ with vi and M-m with emacs key bindings. Another
from Kalle Olavi Niemitalo, thanks.


Revision tags: OPENBSD_4_6_BASE
# 1.5 26-Jun-2009 nicm

Status line fixes: don't truncate status-right now the length calculation is
done for UTF-8, limit to the maximum length correctly when printing, and always
print a space even if the left string is longer than the width available.


# 1.4 04-Jun-2009 nicm

If the prompt is hidden or a password is sent with -U, zero it before freeing
it.


# 1.3 03-Jun-2009 nicm

New session option, status-utf8, to control the interpretation of top-bit-set
characters in status-left and status-right (if on, they are treated as UTF-8;
otherwise passed through).


# 1.2 03-Jun-2009 nicm

Add a UTF-8 aware string length function and make UTF-8 in
status-left/status-right work properly. At the moment any top-bit-set
characters are assumed to be UTF-8: a status-utf8 option to configure this will
come shortly.


# 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.239 08-Aug-2023 nicm

Add options and flags for menu styles similar to those existing for
popups, from Alexis Hildebrandt. GitHub issue 3650.


# 1.238 17-Apr-2023 nicm

Ignore the user keys range when checking if a key is Unicode.


Revision tags: OPENBSD_7_3_BASE
# 1.237 20-Jan-2023 nicm

Add a flag to display-menu to select the manu item chosen first, GitHub
issue 3442.


Revision tags: OPENBSD_7_2_BASE
# 1.236 10-Sep-2022 nicm

Use correct option name.


# 1.235 09-Sep-2022 nicm

Add message-line option to control where message and prompt go, from
Varun Kumar E in GitHub issue 3324.


# 1.234 30-May-2022 nicm

Remove duplicates from completion list, GitHub issue 3178.


Revision tags: OPENBSD_7_1_BASE
# 1.233 07-Mar-2022 nicm

Pass client when adding menu item, GitHub issue 3103.


# 1.232 03-Feb-2022 nicm

Use format_draw for command prompt prefix to allow styles, GitHub issue
3054.


# 1.231 15-Nov-2021 nicm

Leave the hardware cursor at the position of the selected line in choose
modes and current editing position and at the command prompt. It is
invisible but this is helpful for people using screen readers. GitHub
issue 2970.


# 1.230 01-Nov-2021 nicm

Fix a comparison, from Ben Boeckel, and a crash when opening completion
menu, from Anindya Mukherjee.


# 1.229 26-Oct-2021 nicm

Accept some emacs control keys in vi normal mode, from Alexis
Hildebrandt in GitHub issue 2922.


# 1.228 26-Oct-2021 nicm

Do not allow inline styles to replace mode-style for the selected item,
from Alexis Hildebrandt in GitHub issue 2946.


Revision tags: OPENBSD_7_0_BASE
# 1.227 20-Aug-2021 nicm

Remove stray spaces after function names.


# 1.226 12-Aug-2021 nicm

Use COLOUR_DEFAULT not hardcoded 8.


# 1.225 10-Jun-2021 nicm

More accurate vi(1) word navigation in copy mode and on the status line.
This changes the meaning of the word-separators option - setting it to
the empty string is equivalent to the previous behavior. From Will Noble
in GitHub issue 2693.


# 1.224 10-Jun-2021 nicm

Add different command historys for different types of prompts
("command", "search" etc). From Anindya Mukherjee.


# 1.223 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.222 10-Jun-2021 nicm

Include current client in size calculation for new sessions, GitHub
issue 2662.


Revision tags: OPENBSD_6_9_BASE
# 1.221 12-Apr-2021 nicm

Add a flag to disable keys to close a message, GitHub issue 2625.


# 1.220 22-Feb-2021 nicm

Move jump commands to grid reader, make them UTF-8 aware, and tidy up,
from Anindya Mukherjee.


# 1.219 08-Jan-2021 nicm

With incremental search, start empty and only repeat the previous search
if the user tries to search again with an empty prompt. This matches
emacs behaviour more closely.


Revision tags: OPENBSD_6_8_BASE
# 1.218 27-Jul-2020 nicm

Add a -d option to display-message to set delay, from theonekeyg at
gmail dot com in GitHub issue 2322.


# 1.217 11-Jun-2020 nicm

Fix a crash when completing sessions, from Anindya Mukherjee.


# 1.216 26-May-2020 nicm

Remove leftover debug logging and fix comparison.


# 1.215 26-May-2020 nicm

Set up UTF-8 data for ASCII keys correctly.


# 1.214 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.213 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.212 16-May-2020 nicm

Rename KEYC_ESCAPE to KEYC_META.


# 1.211 16-May-2020 nicm

Expand target from client and use it to expand the prompt.


# 1.210 16-May-2020 nicm

Support embedded styles in the display-message message, GitHub issue
2206.


# 1.209 16-May-2020 nicm

Change message log to be per server rather than per client and include
every command that is run.


# 1.208 16-May-2020 nicm

Do not hoke into struct window_pane from the tty code and instead set
everything up in tty_ctx. Provide a way to initialize the tty_ctx from a
callback and use it to let popups draw directly through input_parse in
the same way as panes do, rather than forcing a full redraw on every
change.


# 1.207 16-May-2020 nicm

Use formats for status-style and message-style.


# 1.206 16-May-2020 nicm

Complete partial window indexes properly.


# 1.205 16-May-2020 nicm

Add -W and -T flags to command-prompt to only complete a window and a
target, also complete aliases.


# 1.204 16-May-2020 nicm

Improve command prompt completion:

- Show a menu with completions if there are multiple.

- Don't complete argument stuff (options, layouts) at start of text.

- For -t and -s, if there is no : then complete sessions but if there is
a :, show a menu of all windows in the session rather than trying to
complete the window name which is a bit useless if there are
duplicates.


# 1.203 16-May-2020 nicm

Drop having a separate type for style options and make them all strings,
which allows formats to be expanded. Any styles without a '#{' are still
validated when they are set but any with a '#{' are not. Formats are not
expanded usefully in many cases yet, that will be changed later.

To make this work, a few other changes:

- set-option -a with a style option automatically appends a ",".

- OSC 10 and 11 don't set the window-style option anymore, instead the
fg and bg are stored in the pane struct and act as the defaults that
can be overridden by window-style.

- status-fg and -bg now override status-style instead of trying to keep
them in sync.


Revision tags: OPENBSD_6_7_BASE
# 1.202 12-Mar-2020 nicm

Add C-g to cancel command prompt with vi(1) keys as well as emacs, and q
in command mode.


# 1.201 27-Jan-2020 nicm

Add support for adding a note to a key binding (with bind-key -N) and
use this to add descriptions to the default key bindings. A new -N flag
to list-keys shows key bindings with notes rather than the default
bind-key command used to create them. Change the default ? binding to
use this to show a readable summary of keys.

Also extend command-prompt to return the name of the key pressed and add
a default binding (/) to show the note for the next key pressed

Suggested by Alex Tremblay in GitHub issue 2000.


Revision tags: OPENBSD_6_6_BASE
# 1.200 28-May-2019 nicm

Redraw status line if size changes, GitHub issue 1762. Also fix length
of target buffer when pasting into status line.


# 1.199 23-May-2019 nicm

Fix length calculation for pasting UTF-8 characters in the status line,
GitHub issue 1753.


# 1.198 11-May-2019 nicm

Do not reduce window height by status line height for control mode
clients, from George Nachman.


# 1.197 03-May-2019 nicm

Fix reverse attribute in status line, GitHub issue 1709.


# 1.196 26-Apr-2019 nicm

Merge hooks into options and make each one an array option. This allows
multiple commands to be easily bound to one hook. set-hook and
show-hooks remain but they are now variants of set-option and
show-options. show-options now has a -H flag to show hooks (by default
they are not shown).


# 1.195 25-Apr-2019 nicm

options_array_item_value cannot return NULL.


# 1.194 23-Apr-2019 nicm

Somehow missed these bits in last commit.


# 1.193 23-Apr-2019 nicm

Indicate an array option with a flag rather than a special type so that
in future will not have to be strings.


Revision tags: OPENBSD_6_5_BASE
# 1.192 18-Mar-2019 nicm

Extend the #[] style syntax and use that together with previous format
changes to allow the status line to be entirely configured with a single
option.

Now that it is possible to configure their content, enable the existing
code that lets the status line be multiple lines in height. The status
option can now take a value of 2, 3, 4 or 5 (as well as the previous on
or off) to configure more than one line. The new status-format array
option configures the format of each line, the default just references
the existing status-* options, although some of the more obscure status
options may be eliminated in time.

Additions to the #[] syntax are: "align" to specify alignment (left,
centre, right), "list" for the window list and "range" to configure
ranges of text for the mouse bindings.

The "align" keyword can also be used to specify alignment of entries in
tree mode and the pane status lines.


# 1.191 18-Mar-2019 nicm

Make array options a sparse tree instead of an array of char * and
remove the size limit.


# 1.190 18-Mar-2019 nicm

With force, kill previous job before starting new. Fixes problem
reported by Scott Mcdermott in GitHub issue 1627.


# 1.189 16-Mar-2019 nicm

Use a pointer for the active screen in the status line instead of
copying them around all the time.


# 1.188 16-Mar-2019 nicm

Give status_save_old the client so it can do the reinit too.


# 1.187 16-Mar-2019 nicm

Tidy and rename some bits of status line code.


# 1.186 15-Mar-2019 nicm

Move status line free into its own function.


# 1.185 14-Mar-2019 nicm

Store the time in the format tree rather than passing it around.


# 1.184 12-Mar-2019 nicm

DECRC and DECSC apparently need to preserve origin mode as well, based
on a fix from Marc Reisner.


# 1.183 09-Feb-2019 nicm

Completion of command-alias members.


# 1.182 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.181 29-Aug-2018 nicm

Keep any text killed in the command prompt with C-w and yank it with
C-y, only use the top buffer if no text has previously been killed. This
and previous change promped by discussion with kn@.


# 1.180 29-Aug-2018 nicm

Add C-Left and C-Right as aliases for M-b and M-f.


# 1.179 22-Aug-2018 nicm

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


# 1.178 20-Aug-2018 nicm

Move offset of window list into status struct.


# 1.177 19-Aug-2018 nicm

Add a client redraw-window flag instead of the redraw-all flag and for
all just use the three flags together (window, borders, status).


Revision tags: OPENBSD_6_3_BASE
# 1.176 22-Feb-2018 nicm

Remove an unused variable.


# 1.175 05-Feb-2018 nicm

Add struct status_line to hold status line members of struct client, not
used yet but will be soon. From Thomas Adam.


# 1.174 01-Jan-2018 nicm

Add C-g at command prompt for emacs people, GitHub issue 1213.


# 1.173 27-Dec-2017 nicm

Draw command prompt correctly with status line off.


# 1.172 18-Dec-2017 nicm

Remove unused variable from Thomas Adam.


# 1.171 02-Nov-2017 nicm

Add a "fast" version of screen_write_copy for tree mode that doesn't do
all the checks and selection and marking stuff needed for copy mode.


# 1.170 20-Oct-2017 nicm

Clear status line with spaces again so reverse works, spotted by sthen.


# 1.169 16-Oct-2017 nicm

Infrastructure for drawing status lines of more than one line in height,
still only one is allowed but this lets tmux draw bigger ones.


Revision tags: OPENBSD_6_2_BASE
# 1.168 29-May-2017 nicm

Add a flag to stop the prompt input being expanded.


# 1.167 29-May-2017 nicm

Store a copy of the old status line, will be needed soon for new choose mode.


# 1.166 17-May-2017 nicm

Tidy command prompt callbacks and pass in the client.


# 1.165 03-May-2017 nicm

Add a format for the last search string in copy mode and fix the prompt
so it can work when in -I, suggested by Suraj N Kurapati.


# 1.164 01-May-2017 nicm

In order that people can use formats like #D in #() in the status line
and not have to wait for an update when they change pane, we allow
commands to run more than once a second if the expanded form
changes. Unfortunately this can mean them being run far too often
(pretty much continually) when multiple clients exist, because some
formats (including #D) will always differ between clients.

To avoid this, give each client its own tree of jobs which means that
the same command will be different instances for each client - similar
to how we have the tag to separate commands for different panes.

GitHub issue 889; test case reported by Paul Johnson.


# 1.163 22-Apr-2017 nicm

Memory leak from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.162 09-Feb-2017 nicm

Break the message storage function into its own function, useful for
debugging.


# 1.161 03-Feb-2017 nicm

Cache status line position to reduce option lookups during output.


# 1.160 03-Feb-2017 nicm

Add a window or pane id "tag" to each format tree and use it to separate
jobs, this means that if the same job is used for different windows or
panes (for example in pane-border-format), it will be run separately for
each pane.


# 1.159 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.158 06-Jan-2017 nicm

Incremental search in copy mode (on for emacs keys by default) - much
the same as normal searching but updates the cursor position and marked
search terms as you type. C-r and C-s in the prompt repeat the search,
once finished searching (with Enter), N and n work as before.


# 1.157 05-Jan-2017 nicm

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


# 1.156 07-Dec-2016 nicm

Do not clear the prompt when a message is shown, just leave it around and
return to it when the message is finished.


# 1.155 12-Oct-2016 nicm

Drop the edit mode key tables and just use fixed key bindings for the
command prompt.


# 1.154 12-Oct-2016 nicm

The repeat prompt in both emacs and vi (and the old one in tmux) doesn't
support line editing and instead executes a command as soon as a
non-number key is pressed. Add a -N flag to command-prompt for the same
in copy mode. Reported by Theo Buehler.


# 1.153 11-Oct-2016 nicm

Fundamental change to how copy mode key bindings work:

The vi-copy and emacs-copy mode key tables are gone, and instead copy
mode commands are bound in one of two normal key tables ("copy-mode" or
"copy-mode-vi"). Keys are bound to "send-keys -X copy-mode-command". So:

bind -temacs-copy C-Up scroll-up
bind -temacs-copy -R5 WheelUpPane scroll-up

Becomes:

bind -Tcopy-mode C-Up send -X scroll-up
bind -Tcopy-mode WheelUpPane send -N5 -X scroll-up

This allows the full command parser and command set to be used - for
example, we can use the normal command prompt for searching, jumping,
and so on instead of a custom one:

bind -Tcopy-mode C-r command-prompt -p'search up' "send -X search-backward '%%'"

command-prompt also gets a -1 option to only require on key press, which
is needed for jumping.

The plan is to get rid of mode keys entirely, so more to come eventually.


# 1.152 11-Oct-2016 nicm

Support UTF-8 entry into the command prompt.


# 1.151 10-Oct-2016 nicm

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


# 1.150 12-Sep-2016 nicm

Allow repeat count to be specified in mode key tables with bind-key -R,
and set the default repeat count to 5 for WheelUp and WheelDown in
copy-mode.


Revision tags: OPENBSD_6_0_BASE
# 1.149 06-Jun-2016 nicm

Allow #[] in window-status-separator.


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

I no longer use my SourceForge address so replace it.


# 1.147 01-Jan-2016 nicm

Don't rely on a calculation wrapping when applying message-limit, and
break out of the loop early. From Nicolas Viennot.


# 1.146 11-Dec-2015 nicm

Style nits and line wrapping of function declarations.


# 1.145 11-Dec-2015 nicm

Add cmdq as an argument to format_create and add a format for the
command name (will also be used for more later).


# 1.144 08-Dec-2015 nicm

Remove format_create_flags and just pass flags to format_create.


# 1.143 22-Nov-2015 tim

If display-time is set to 0, show status messages until a key is pressed;
OK nicm@


# 1.142 20-Nov-2015 nicm

Instead of separate tables for different types of options, give each
option a scope type (server, session, window) in one table.


# 1.141 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.140 13-Nov-2015 nicm

Long overdue change to the way we store cells in the grid: now, instead
of storing a full grid_cell with UTF-8 data and everything, store a new
type grid_cell_entry. This can either be the cell itself (for ASCII
cells), or an offset into an extended array (per line) for UTF-8
data.

This avoid a large (8 byte) overhead on non-UTF-8 cells (by far the
majority for most users) without the complexity of the shadow array we
had before. Grid memory without any UTF-8 is about half.

The disadvantage that cells can no longer be modified in place and need
to be copied out of the grid and back but it turned out to be lot less
complicated than I expected.


# 1.139 12-Nov-2015 nicm

Nuke the utf8 and status-utf8 options and make tmux only a UTF-8
terminal. We still support non-UTF-8 terminals outside tmux, but inside
it is always UTF-8 (as when the utf8 and status-utf8 options were on).


# 1.138 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.137 27-Oct-2015 nicm

Move struct options into options.c.


# 1.136 20-Oct-2015 nicm

Use client pointer not file descriptor in logging.


# 1.135 14-Sep-2015 nicm

Make refresh-client force update of jobs, from Sina Siadat.


# 1.134 29-Aug-2015 nicm

Move struct paste_buffer out of tmux.h.


# 1.133 28-Aug-2015 nicm

Run status update on a per-client timer at status-interval.


Revision tags: OPENBSD_5_8_BASE
# 1.132 29-Jul-2015 nicm

status_out and associated data structures are no longer used.


# 1.131 28-Jul-2015 nicm

Tidy up the way terminals are described and move some structs out of tmux.h.


# 1.130 20-Jul-2015 nicm

Add an option (history-file) for a file to save/restore command prompt
history, from Olof-Joachim Frahm.


# 1.129 27-May-2015 nicm

Move the jobs output cache into the formats code so that #() work more
generally (for example, again working in set-titles-string).


# 1.128 06-May-2015 nicm

Remove ARRAY_* from history and expand completion to complete a) layout
names and b) targets beginning with -t or -s.


# 1.127 25-Apr-2015 nicm

Make message log a TAILQ.


# 1.126 24-Apr-2015 nicm

Set working directory for run-shell and if-shell.


# 1.125 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_7_BASE
# 1.124 06-Feb-2015 nicm

Use the same time for both calls to format_expand_time.


# 1.123 06-Feb-2015 nicm

status_replace can now become local to status.c and it no longer needs
the jobsflag argument. While here there is no need to repeat work that
format_defaults already does.


# 1.122 06-Feb-2015 nicm

Add format_expand_time and use it instead of status_replace where
command execution is not needed.


# 1.121 05-Feb-2015 nicm

Wrap all the individual format_* calls in a single format_defaults
functions.


# 1.120 01-Feb-2015 nicm

Remove two unused arguments from status_replace.


# 1.119 20-Jan-2015 sthen

typo in comment ;) ok nicm


# 1.118 05-Nov-2014 nicm

Do not put a space between status-left/status-right and the window list,
instead move the space into the defaults for the options (so status-left
now defaults to "[#S] ". From Balazs Kezes.


# 1.117 20-Oct-2014 nicm

Better format for printf format attributes.


# 1.116 08-Oct-2014 nicm

Add xreallocarray and remove nmemb argument from xrealloc.


# 1.115 02-Oct-2014 nicm

Take account of window-status-separator when checking window position,
based on diff from Balazs Kezes.


Revision tags: OPENBSD_5_6_BASE
# 1.114 24-Apr-2014 nicm

There is no longer a need for a paste_stack struct or for global_buffers
to be global. Move to paste.c.


# 1.113 17-Apr-2014 nicm

Remove the monitor-content option and associated bits and bobs. It's
never worked very well. If there is a big demand for it to return, will
consider better ways to do it.


# 1.112 02-Apr-2014 nicm

Do not replace ## with # in status_replace1 because it'll be done later
by the format code.


# 1.111 31-Mar-2014 nicm

Make message-limit a server option.


Revision tags: OPENBSD_5_5_BASE
# 1.110 14-Feb-2014 nicm

Style nit - no space between function name and bracket.


# 1.109 14-Feb-2014 nicm

Check for NULL session and whatnot in status_replace, from Thomas Adam.


# 1.108 28-Jan-2014 nicm

Allow replacing each of the many sets of separate foo-{fg,bg,attr}
options with a single foo-style option. For example:

set -g status-fg yellow
set -g status-bg red
set -g status-attr blink

Becomes:

set -g status-style fg=yellow,bg=red,blink

The -a flag to set can be used to add to rather than replace a style. So:

set -g status-bg red

Becomes:

set -ag status-style bg=red

Currently this is fully backwards compatible (all *-{fg,bg,attr} options
remain) but the plan is to deprecate them over time.

From Tiago Cunha.


Revision tags: OPENBSD_5_4_BASE
# 1.107 05-Jul-2013 nicm

Whitespace nits, from Ben Boeckel.


# 1.106 05-Jul-2013 nicm

Act like vi(1) when moving words, from Ben Boeckel.


# 1.105 05-Jul-2013 nicm

Implement s, S, C mode switch commands in vi(1) mode, from Ben Boeckel.


# 1.104 31-May-2013 nicm

Demote the old single-character replacement variables (#S and friends)
to aliases of formats. From Tiago Cunha.


# 1.103 25-Mar-2013 nicm

Extend jobs to support writing and use that for copy-pipe instead of
popen, from Chris Johnsen.


# 1.102 22-Mar-2013 nicm

evbuffer_readline returns allocated storage, don't leak it.


# 1.101 22-Mar-2013 nicm

Add copy-pipe mode command to copy selection and also pipe to a command.


# 1.100 22-Mar-2013 nicm

No more lint means no more ARGSUSED.


# 1.99 21-Mar-2013 nicm

Aargh. Spaces -> tabs.


# 1.98 21-Mar-2013 nicm

Do not leak formats in status_replace.


# 1.97 21-Mar-2013 nicm

Add a format client_prefix which is 1 if prefix key has been
pressed, used for example #{?client_prefix,X,Y}. Also a few extra
server_client_status needed.


# 1.96 21-Mar-2013 nicm

Allow formats in status options.


Revision tags: OPENBSD_5_3_BASE
# 1.95 27-Nov-2012 nicm

Add window-status-last-* options, from Boris Faure.


Revision tags: OPENBSD_5_2_BASE
# 1.94 10-Jul-2012 nicm

xfree is not particularly helpful, remove it. From Thomas Adam.


# 1.93 09-Jul-2012 nicm

Move a NULL check inside a function, from Tiago Cunha.


# 1.92 29-Apr-2012 nicm

Use int not u_char for colours from options since they may have bit 8
set to mark them as 256-colour. Reported by Chris Johnson.


# 1.91 23-Apr-2012 nicm

Add window-status-separator option, from Thomas Adam.


# 1.90 17-Mar-2012 nicm

Check event_initialized before event_del if event may not have been set
up; libevent2 complains about this. Reported by Moriyoshi Koizumi.


# 1.89 04-Mar-2012 nicm

Add A and I keys for vi status line editing.


# 1.88 03-Mar-2012 nicm

The wlmouse offset should be part of the client, not the server. From
Ailin Nemui.


Revision tags: OPENBSD_5_1_BASE
# 1.87 29-Jan-2012 nicm

Add an option to move the status line to the top of the screen,
requested by many.


# 1.86 26-Jan-2012 nicm

Terminate strftime buffer properly even if a really long format string
is given, from Tiago Cunha.


# 1.85 26-Jan-2012 nicm

Fix memory leak in error path, from Tiago Cunha.


# 1.84 20-Jan-2012 nicm

Add some trivial additional status line attributes from jwcxz at users
dot sourceforge dot net.


# 1.83 20-Jan-2012 nicm

Add space movement keys for vi mode in the status line from Ben Boeckel.


# 1.82 01-Dec-2011 nicm

Make M-f and M-b work the same at the command prompt as in copy mode,
pointed out by Romain Francoise.


# 1.81 15-Nov-2011 nicm

Add word movement and editing command for command prompt editing, from
Ben Boeckel.


# 1.80 15-Nov-2011 nicm

Make window_pane_index work the same as window_index, from Ben Boeckel.


# 1.79 05-Nov-2011 nicm

Option to change status line (message) background when using vi keys and
in command mode. From Ben Boeckel.


# 1.78 20-Aug-2011 nicm

Fix a couple of memory leaks, from marcel partap.


Revision tags: OPENBSD_5_0_BASE
# 1.77 08-Jul-2011 nicm

Make confirm-before prompt customizable with -p option like
command-prompt. Also move responsibility for calling status_replace into
status_prompt_{set,update} and add #W and #P to the default kill-window
and kill-pane prompts. By Tiago Cunha.


# 1.76 02-Jul-2011 nicm

Allow the initial context on prompts to be set with the new -I option to
command-prompt. From Tiago Cunha.


# 1.75 29-Apr-2011 nicm

Only redraw the status line on command update, not the entire client
(big DOH).


# 1.74 24-Apr-2011 nicm

Provide #h for short hostname (no domain) from Michal Mazurek.


# 1.73 18-Apr-2011 nicm

Add an option (mouse-select-window) which allows the mouse to be used by
clicking on the status line, written by hsim at gmx dot li.


# 1.72 29-Mar-2011 nicm

Change -t on display-message to be target-pane for the #[A-Z]
replacements and add -c as target-client.


Revision tags: OPENBSD_4_9_BASE
# 1.71 26-Jan-2011 nicm

Simplify the way jobs work and drop the persist type, so all jobs are
fire-and-forget.

Status jobs now managed with two trees of output (new and old), rather
than storing the output in the jobs themselves. When the status line is
processed any jobs which don't appear in the new tree are started and
the output from the old tree displayed. When a job finishes it updates
the new tree with its output and that is used for any subsequent
redraws. When the status interval expires, the new tree is moved to the
old so that all jobs are run again.

This fixes the "#(echo %H:%M:%S)" problem which would lead to thousands
of identical persistent jobs and high memory use (this can still be
achieved by adding "sleep 30" but that is much less likely to happen by
accident).


# 1.70 03-Jan-2011 nicm

Handle a # at the end of a replacement string (such as status-left)
correctly. Found by Thomas Adam.


# 1.69 01-Jan-2011 nicm

Move the user-visible parts of all options (names, types, limit, default
values) together into one set of tables in options-table.c. Also clean
up and simplify cmd-set-options.c and move a common print function into
option-table.c.


# 1.68 30-Dec-2010 nicm

Change from a per-session stack of buffers to one global stack which is
much more convenient and also simplifies lot of code. This renders
copy-buffer useless and makes buffer-limit now a server option.

By Tiago Cunha.


# 1.67 30-Dec-2010 nicm

Add a function to create window flags rather than doing the same thing
in two places. From Thomas Adam.


# 1.66 11-Dec-2010 nicm

Oops, these functions return a const char *, so make the local variable
const as well.


# 1.65 11-Dec-2010 nicm

Make the prompt history global for all clients which is much more useful than per-client history.


# 1.64 06-Dec-2010 nicm

Add an option to alert (monitor) for silence (lack of activity) in a
window. From Thomas Adam.


Revision tags: OPENBSD_4_8_BASE
# 1.63 21-Jun-2010 nicm

Having a list of winlinks->alerts for each session is stupid, just store
the alert flags directly in the winlink itself.


# 1.62 14-May-2010 nicm

Colour+attribute options for status line alerts, from Alex Alexander.


# 1.61 31-Mar-2010 nicm

Don't accept keys with modifiers as input. Fixes crash reported by Brian
R Landy.


# 1.60 27-Mar-2010 nicm

Don't leak job command in #().


# 1.59 22-Mar-2010 nicm

Dead functions, lint.


Revision tags: OPENBSD_4_7_BASE
# 1.58 27-Jan-2010 nicm

Calculate offset correctly, fixes incorrect offset and prevents crash when
status-left is empty. From Micah Cowan.


# 1.57 26-Jan-2010 nicm

Actually use the copy made when no newline is found, from martynas@.


# 1.56 14-Dec-2009 nicm

Add server options to completion as well.


# 1.55 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.54 03-Dec-2009 nicm

Eliminate duplicate code and ease the passage for server-wide options by adding
a -w flag to set-option and show-options and making setw and showw aliases to
set -w and show -w.

Note: setw and showw are still there, but now aliases for set -w and show -w.


# 1.53 26-Nov-2009 nicm

Tidy up various bits of the paste code, make the data buffer char * and add
comments.


# 1.52 26-Nov-2009 nicm

Remove a couple of unused arguments where possible, and add /* ARGSUSED */ to
the rest to reduce lint output.


# 1.51 20-Nov-2009 nicm

Display UTF-8 properly in status line messages and prompt. Cursor handling is
still way off though.


# 1.50 20-Nov-2009 nicm

Remove oldest messages from log when limit is hit, not newest.


# 1.49 19-Nov-2009 nicm

Get some brackets in the right place so ## works. Also fix a space in a
comment.


# 1.48 19-Nov-2009 nicm

Change status line drawing to create the window list in a separate screen and
then copy it into the status line screen. This allows UTF-8 in window names and
fixes some problems with #[] in window-status-format.


# 1.47 19-Nov-2009 nicm

Two new options, window-status-format and window-status-current-format, which
allow the format of each window in the status line window list to be controlled
using similar # sequences as status-left/right.

This diff also moves part of the way towards UTF-8 support in window names but
it isn't quite there yet.


# 1.46 19-Nov-2009 nicm

Tidy up by breaking the # replacement code into a separate function, also add a
few comments.


# 1.45 19-Nov-2009 nicm

Don't interpret #() for display-message, it usually doesn't make sense and may
leak commands.


# 1.44 18-Nov-2009 nicm

Add a per-client log of status line messages displayed while that client
exists. A new message-limit session option sets the maximum number of entries
and a command, show-messages, shows the log (bound to ~ by default).

This (and prompt history) might be better as a single global log but until
there are global options it is easier for them to be per client.


# 1.43 17-Nov-2009 nicm

Permit top-bit-set characters to be entered in the status line. They could
already be set from the shell and are just passed through when printing (so
invisible characters or displaying on terminals with different character sets
may cause problems).

Note that entering UTF-8 may not work and in any case currently the status line
cannot display it correctly (outside of status-left/status-right).


# 1.42 04-Nov-2009 nicm

Use timeout events for the identify and message timers.


# 1.41 04-Nov-2009 nicm

Switch jobs over to use a bufferevent.


# 1.40 04-Nov-2009 nicm

Unused (but assigned to) variable, found by lint.


# 1.39 01-Nov-2009 nicm

Add a flag for jobs that shouldn't be freed after they've died and use it for
status jobs, then only kill those jobs when status-left, status-right or
set-titles-string is changed.

Fixes problems with changing options from inside #().


# 1.38 10-Oct-2009 nicm

Rather than running status-left, status-right and window title #() with popen
immediately every redraw, queue them up and run them in the background,
starting each once every status-interval. The actual status line uses the
output from the last run.

This brings several advantages:

- tmux itself may be called from inside #() without causing the server to hang;
- likewise, sleep or similar doesn't cause the server to block;
- commands aren't run excessively often when redrawing;
- commands shared by status-left and status-right, or used multiple times, will
only be run once.

run-shell and if-shell still use system()/popen() but will be changed over to
use this too later.


# 1.37 10-Oct-2009 nicm

Add "grouped sessions" which have independent name, options, current window and
so on but where the linked windows are synchronized (ie creating, killing
windows and so on are mirrored between the sessions). A grouped session may be
created by passing -t to new-session.

Had this around for a while, tested by a couple of people.


# 1.36 23-Sep-2009 nicm

Remove PROMPT_HIDDEN code which is now unused.


# 1.35 23-Sep-2009 nicm

Remove the internal tmux locking and instead detach each client and run the
command specified by a new option "lock-command" (by default "lock -np") in
each client.

This means each terminal has to be unlocked individually but simplifies the
code and allows the system password to be used to unlock.

Note that the set-password command is gone, so it will need to be removed from
configuration files, and the -U command line flag has been removed.

This is the third protocol version change so again it is best to stop the tmux
server before upgrading.


# 1.34 20-Sep-2009 nicm

Regularise some fatal messages.


# 1.33 10-Sep-2009 nicm

Permit options such as status-bg to be configured using the entire 256 colour
palette by setting "colour0" to "colour255".


# 1.32 07-Sep-2009 nicm

Give each paste buffer a size member instead of requiring them to be
zero-terminated.


# 1.31 07-Sep-2009 nicm

Permit embedded colour and attributes in status-left and status-right using new
#[] special characters, for example #[fg=red,bg=blue,blink].


# 1.30 02-Sep-2009 nicm

Add a transpose-chars command in edit mode (C-t in emacs mode only). From Kalle
Olavi Niemitalo.


# 1.29 01-Sep-2009 nicm

Use "Password:" with no space for password prompts and don't display a *s for
the password, like pretty much everything else. From martynas@ with minor
tweaks by me.


# 1.28 31-Aug-2009 nicm

Add a new display-panes command, with two options (display-panes-colour and
display-panes-time), which displays a visual indication of the number of each
pane.


# 1.27 19-Aug-2009 nicm

Extend command-prompt with a -p option which is a comma-separated list of one
or more prompts to present in order.

The responses to the prompt are replaced in the template string: %% are
replaced in order, so the first prompt replaces the first %%, the second
replaces the second, and so on. In addition, %1 up to %9 are replaced with the
responses to the first the ninth prompts

The default template is "%1" so the response to the first prompt is processed
as a command.

Note that this changes the behaviour for %% so if there is only one prompt,
only the first %% will be replaced. Templates such as "neww -n '%%' 'ssh %%'"
should be changed to "neww -n '%1' 'ssh %1'".

From Tiago Cunha.


# 1.26 18-Aug-2009 nicm

Add a "delete line" key when editing in the status line or the search up/down
prompt. C-u with emacs keys, d with vi.


# 1.25 13-Aug-2009 nicm

Switch the prompt code to return an empty string when the user enters no
response and reserve NULL for an explicit cancel. Change all callbacks to treat
them the same so no functional change.

Also add cancel key bindings to emacs mode which were missing.


# 1.24 08-Aug-2009 nicm

Options to set the colours and attributes for status-left/-right. From Thomas
Adam, thanks.


# 1.23 05-Aug-2009 nicm

If colours are not supported by the terminal, try to emulate a coloured
background by setting or clearing the reverse attribute.

This makes a few applications which don't use the reverse attribute themselves
a little happier, and allows the status, message and mode options to have
default attributes and fg/bg options that work as expected when set as reverse.


# 1.22 30-Jul-2009 nicm

Plug some memory leaks.


# 1.21 28-Jul-2009 nicm

Next step towards customisable mode keys: build each default table of keys into
a named tree on start and use that for lookups. Also add command to string
translation tables and modify list-keys to show the the mode key bindings (new
-t argument).


# 1.20 27-Jul-2009 nicm

Change mode key bindings from big switches into a set of tables. Rather than
lumping them all together, split editing keys from those used in choice/more
mode and those for copy/scroll mode.

Tidier and clearer, and the first step towards customisable mode keys.


# 1.19 27-Jul-2009 nicm

Get rid of empty mode_key_free function.


# 1.18 27-Jul-2009 nicm

Add a key to delete to end of line at the prompt (^K in emacs mode, C/D in vi).

From Kalle Olavi Niemitalo.


# 1.17 26-Jul-2009 nicm

Calculate the space available for the prompt buffer and the cursor position
correctly, and make it work when the screen is not wide enough.

Noticed by Kalle Olavi Niemitalo.


# 1.16 21-Jul-2009 nicm

Remove a couple of unused functions and fix a type ("FALLTHOUGH"), found by
lint.


# 1.15 20-Jul-2009 nicm

Add a status-justify option to allow the window list in the status line to be
positioned at the left, centre, or right.


# 1.14 20-Jul-2009 nicm

New options, window-status-current-{fg,bg,attr}, to set the fg, bg and
attributes with which the current window is shown in the status line. From
Johan Friis, thanks.


# 1.13 17-Jul-2009 nicm

- New command display-message (alias display) to display a message in the
status line (bound to "i" and displays the current window and time by
default). The same substitutions are applied as for status-left/right.
- Add support for including the window index (#I), pane index (#P) and window
name (#W) in the message, and status-left or status-right.
- Bump protocol version.

From Tiago Cunha, thanks!


# 1.12 17-Jul-2009 nicm

Memory could be leaked if a second prompt or message appeared while another was
still present, so add a separate prompt free callback and make the _clear
function responsible for calling it if necessary (rather than the individual
prompt callbacks). Also make both messages and prompts clear any existing when
a new is set.

In addition, the screen could be modified while the prompt is there, restore
the redraw-entire-screen behaviour on prompt clear; add a comment as a
reminder.


# 1.11 16-Jul-2009 nicm

Remove some duplicate code that was causing the status line to be redrawn even
when it hadn't changed.


# 1.10 15-Jul-2009 nicm

Make status_message_set a variadic printf-like function. No functional change -
helpful for a couple of things coming soon.


# 1.9 15-Jul-2009 nicm

Having to update NSETOPTION/NSETWINDOWOPTION when adding new options is a bit
annoying and it is only use for iterating, so use a sentinel to mark the end of
each array instead. Different fix for a problem pointed out by Kalle Olavi
Niemitalo.


# 1.8 14-Jul-2009 nicm

For some reason when clearing status/message it was redrawing the entire client
not just the status line. Changing this also revealed the check for the status
line was incorrect when drawing the pane.


# 1.7 14-Jul-2009 nicm

Instead of faking up a status line in status_redraw, use the same code to
redraw it as to draw the entire screen, just skip all lines but the last.

This makes horizontal split redraw properly when the status line is off.


# 1.6 12-Jul-2009 nicm

Add a "back to indentation" key in copy mode to move the cursor to the first
non-whitespace character. ^ with vi and M-m with emacs key bindings. Another
from Kalle Olavi Niemitalo, thanks.


Revision tags: OPENBSD_4_6_BASE
# 1.5 26-Jun-2009 nicm

Status line fixes: don't truncate status-right now the length calculation is
done for UTF-8, limit to the maximum length correctly when printing, and always
print a space even if the left string is longer than the width available.


# 1.4 04-Jun-2009 nicm

If the prompt is hidden or a password is sent with -U, zero it before freeing
it.


# 1.3 03-Jun-2009 nicm

New session option, status-utf8, to control the interpretation of top-bit-set
characters in status-left and status-right (if on, they are treated as UTF-8;
otherwise passed through).


# 1.2 03-Jun-2009 nicm

Add a UTF-8 aware string length function and make UTF-8 in
status-left/status-right work properly. At the moment any top-bit-set
characters are assumed to be UTF-8: a status-utf8 option to configure this will
come shortly.


# 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.238 17-Apr-2023 nicm

Ignore the user keys range when checking if a key is Unicode.


Revision tags: OPENBSD_7_3_BASE
# 1.237 20-Jan-2023 nicm

Add a flag to display-menu to select the manu item chosen first, GitHub
issue 3442.


Revision tags: OPENBSD_7_2_BASE
# 1.236 10-Sep-2022 nicm

Use correct option name.


# 1.235 09-Sep-2022 nicm

Add message-line option to control where message and prompt go, from
Varun Kumar E in GitHub issue 3324.


# 1.234 30-May-2022 nicm

Remove duplicates from completion list, GitHub issue 3178.


Revision tags: OPENBSD_7_1_BASE
# 1.233 07-Mar-2022 nicm

Pass client when adding menu item, GitHub issue 3103.


# 1.232 03-Feb-2022 nicm

Use format_draw for command prompt prefix to allow styles, GitHub issue
3054.


# 1.231 15-Nov-2021 nicm

Leave the hardware cursor at the position of the selected line in choose
modes and current editing position and at the command prompt. It is
invisible but this is helpful for people using screen readers. GitHub
issue 2970.


# 1.230 01-Nov-2021 nicm

Fix a comparison, from Ben Boeckel, and a crash when opening completion
menu, from Anindya Mukherjee.


# 1.229 26-Oct-2021 nicm

Accept some emacs control keys in vi normal mode, from Alexis
Hildebrandt in GitHub issue 2922.


# 1.228 26-Oct-2021 nicm

Do not allow inline styles to replace mode-style for the selected item,
from Alexis Hildebrandt in GitHub issue 2946.


Revision tags: OPENBSD_7_0_BASE
# 1.227 20-Aug-2021 nicm

Remove stray spaces after function names.


# 1.226 12-Aug-2021 nicm

Use COLOUR_DEFAULT not hardcoded 8.


# 1.225 10-Jun-2021 nicm

More accurate vi(1) word navigation in copy mode and on the status line.
This changes the meaning of the word-separators option - setting it to
the empty string is equivalent to the previous behavior. From Will Noble
in GitHub issue 2693.


# 1.224 10-Jun-2021 nicm

Add different command historys for different types of prompts
("command", "search" etc). From Anindya Mukherjee.


# 1.223 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.222 10-Jun-2021 nicm

Include current client in size calculation for new sessions, GitHub
issue 2662.


Revision tags: OPENBSD_6_9_BASE
# 1.221 12-Apr-2021 nicm

Add a flag to disable keys to close a message, GitHub issue 2625.


# 1.220 22-Feb-2021 nicm

Move jump commands to grid reader, make them UTF-8 aware, and tidy up,
from Anindya Mukherjee.


# 1.219 08-Jan-2021 nicm

With incremental search, start empty and only repeat the previous search
if the user tries to search again with an empty prompt. This matches
emacs behaviour more closely.


Revision tags: OPENBSD_6_8_BASE
# 1.218 27-Jul-2020 nicm

Add a -d option to display-message to set delay, from theonekeyg at
gmail dot com in GitHub issue 2322.


# 1.217 11-Jun-2020 nicm

Fix a crash when completing sessions, from Anindya Mukherjee.


# 1.216 26-May-2020 nicm

Remove leftover debug logging and fix comparison.


# 1.215 26-May-2020 nicm

Set up UTF-8 data for ASCII keys correctly.


# 1.214 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.213 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.212 16-May-2020 nicm

Rename KEYC_ESCAPE to KEYC_META.


# 1.211 16-May-2020 nicm

Expand target from client and use it to expand the prompt.


# 1.210 16-May-2020 nicm

Support embedded styles in the display-message message, GitHub issue
2206.


# 1.209 16-May-2020 nicm

Change message log to be per server rather than per client and include
every command that is run.


# 1.208 16-May-2020 nicm

Do not hoke into struct window_pane from the tty code and instead set
everything up in tty_ctx. Provide a way to initialize the tty_ctx from a
callback and use it to let popups draw directly through input_parse in
the same way as panes do, rather than forcing a full redraw on every
change.


# 1.207 16-May-2020 nicm

Use formats for status-style and message-style.


# 1.206 16-May-2020 nicm

Complete partial window indexes properly.


# 1.205 16-May-2020 nicm

Add -W and -T flags to command-prompt to only complete a window and a
target, also complete aliases.


# 1.204 16-May-2020 nicm

Improve command prompt completion:

- Show a menu with completions if there are multiple.

- Don't complete argument stuff (options, layouts) at start of text.

- For -t and -s, if there is no : then complete sessions but if there is
a :, show a menu of all windows in the session rather than trying to
complete the window name which is a bit useless if there are
duplicates.


# 1.203 16-May-2020 nicm

Drop having a separate type for style options and make them all strings,
which allows formats to be expanded. Any styles without a '#{' are still
validated when they are set but any with a '#{' are not. Formats are not
expanded usefully in many cases yet, that will be changed later.

To make this work, a few other changes:

- set-option -a with a style option automatically appends a ",".

- OSC 10 and 11 don't set the window-style option anymore, instead the
fg and bg are stored in the pane struct and act as the defaults that
can be overridden by window-style.

- status-fg and -bg now override status-style instead of trying to keep
them in sync.


Revision tags: OPENBSD_6_7_BASE
# 1.202 12-Mar-2020 nicm

Add C-g to cancel command prompt with vi(1) keys as well as emacs, and q
in command mode.


# 1.201 27-Jan-2020 nicm

Add support for adding a note to a key binding (with bind-key -N) and
use this to add descriptions to the default key bindings. A new -N flag
to list-keys shows key bindings with notes rather than the default
bind-key command used to create them. Change the default ? binding to
use this to show a readable summary of keys.

Also extend command-prompt to return the name of the key pressed and add
a default binding (/) to show the note for the next key pressed

Suggested by Alex Tremblay in GitHub issue 2000.


Revision tags: OPENBSD_6_6_BASE
# 1.200 28-May-2019 nicm

Redraw status line if size changes, GitHub issue 1762. Also fix length
of target buffer when pasting into status line.


# 1.199 23-May-2019 nicm

Fix length calculation for pasting UTF-8 characters in the status line,
GitHub issue 1753.


# 1.198 11-May-2019 nicm

Do not reduce window height by status line height for control mode
clients, from George Nachman.


# 1.197 03-May-2019 nicm

Fix reverse attribute in status line, GitHub issue 1709.


# 1.196 26-Apr-2019 nicm

Merge hooks into options and make each one an array option. This allows
multiple commands to be easily bound to one hook. set-hook and
show-hooks remain but they are now variants of set-option and
show-options. show-options now has a -H flag to show hooks (by default
they are not shown).


# 1.195 25-Apr-2019 nicm

options_array_item_value cannot return NULL.


# 1.194 23-Apr-2019 nicm

Somehow missed these bits in last commit.


# 1.193 23-Apr-2019 nicm

Indicate an array option with a flag rather than a special type so that
in future will not have to be strings.


Revision tags: OPENBSD_6_5_BASE
# 1.192 18-Mar-2019 nicm

Extend the #[] style syntax and use that together with previous format
changes to allow the status line to be entirely configured with a single
option.

Now that it is possible to configure their content, enable the existing
code that lets the status line be multiple lines in height. The status
option can now take a value of 2, 3, 4 or 5 (as well as the previous on
or off) to configure more than one line. The new status-format array
option configures the format of each line, the default just references
the existing status-* options, although some of the more obscure status
options may be eliminated in time.

Additions to the #[] syntax are: "align" to specify alignment (left,
centre, right), "list" for the window list and "range" to configure
ranges of text for the mouse bindings.

The "align" keyword can also be used to specify alignment of entries in
tree mode and the pane status lines.


# 1.191 18-Mar-2019 nicm

Make array options a sparse tree instead of an array of char * and
remove the size limit.


# 1.190 18-Mar-2019 nicm

With force, kill previous job before starting new. Fixes problem
reported by Scott Mcdermott in GitHub issue 1627.


# 1.189 16-Mar-2019 nicm

Use a pointer for the active screen in the status line instead of
copying them around all the time.


# 1.188 16-Mar-2019 nicm

Give status_save_old the client so it can do the reinit too.


# 1.187 16-Mar-2019 nicm

Tidy and rename some bits of status line code.


# 1.186 15-Mar-2019 nicm

Move status line free into its own function.


# 1.185 14-Mar-2019 nicm

Store the time in the format tree rather than passing it around.


# 1.184 12-Mar-2019 nicm

DECRC and DECSC apparently need to preserve origin mode as well, based
on a fix from Marc Reisner.


# 1.183 09-Feb-2019 nicm

Completion of command-alias members.


# 1.182 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.181 29-Aug-2018 nicm

Keep any text killed in the command prompt with C-w and yank it with
C-y, only use the top buffer if no text has previously been killed. This
and previous change promped by discussion with kn@.


# 1.180 29-Aug-2018 nicm

Add C-Left and C-Right as aliases for M-b and M-f.


# 1.179 22-Aug-2018 nicm

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


# 1.178 20-Aug-2018 nicm

Move offset of window list into status struct.


# 1.177 19-Aug-2018 nicm

Add a client redraw-window flag instead of the redraw-all flag and for
all just use the three flags together (window, borders, status).


Revision tags: OPENBSD_6_3_BASE
# 1.176 22-Feb-2018 nicm

Remove an unused variable.


# 1.175 05-Feb-2018 nicm

Add struct status_line to hold status line members of struct client, not
used yet but will be soon. From Thomas Adam.


# 1.174 01-Jan-2018 nicm

Add C-g at command prompt for emacs people, GitHub issue 1213.


# 1.173 27-Dec-2017 nicm

Draw command prompt correctly with status line off.


# 1.172 18-Dec-2017 nicm

Remove unused variable from Thomas Adam.


# 1.171 02-Nov-2017 nicm

Add a "fast" version of screen_write_copy for tree mode that doesn't do
all the checks and selection and marking stuff needed for copy mode.


# 1.170 20-Oct-2017 nicm

Clear status line with spaces again so reverse works, spotted by sthen.


# 1.169 16-Oct-2017 nicm

Infrastructure for drawing status lines of more than one line in height,
still only one is allowed but this lets tmux draw bigger ones.


Revision tags: OPENBSD_6_2_BASE
# 1.168 29-May-2017 nicm

Add a flag to stop the prompt input being expanded.


# 1.167 29-May-2017 nicm

Store a copy of the old status line, will be needed soon for new choose mode.


# 1.166 17-May-2017 nicm

Tidy command prompt callbacks and pass in the client.


# 1.165 03-May-2017 nicm

Add a format for the last search string in copy mode and fix the prompt
so it can work when in -I, suggested by Suraj N Kurapati.


# 1.164 01-May-2017 nicm

In order that people can use formats like #D in #() in the status line
and not have to wait for an update when they change pane, we allow
commands to run more than once a second if the expanded form
changes. Unfortunately this can mean them being run far too often
(pretty much continually) when multiple clients exist, because some
formats (including #D) will always differ between clients.

To avoid this, give each client its own tree of jobs which means that
the same command will be different instances for each client - similar
to how we have the tag to separate commands for different panes.

GitHub issue 889; test case reported by Paul Johnson.


# 1.163 22-Apr-2017 nicm

Memory leak from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.162 09-Feb-2017 nicm

Break the message storage function into its own function, useful for
debugging.


# 1.161 03-Feb-2017 nicm

Cache status line position to reduce option lookups during output.


# 1.160 03-Feb-2017 nicm

Add a window or pane id "tag" to each format tree and use it to separate
jobs, this means that if the same job is used for different windows or
panes (for example in pane-border-format), it will be run separately for
each pane.


# 1.159 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.158 06-Jan-2017 nicm

Incremental search in copy mode (on for emacs keys by default) - much
the same as normal searching but updates the cursor position and marked
search terms as you type. C-r and C-s in the prompt repeat the search,
once finished searching (with Enter), N and n work as before.


# 1.157 05-Jan-2017 nicm

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


# 1.156 07-Dec-2016 nicm

Do not clear the prompt when a message is shown, just leave it around and
return to it when the message is finished.


# 1.155 12-Oct-2016 nicm

Drop the edit mode key tables and just use fixed key bindings for the
command prompt.


# 1.154 12-Oct-2016 nicm

The repeat prompt in both emacs and vi (and the old one in tmux) doesn't
support line editing and instead executes a command as soon as a
non-number key is pressed. Add a -N flag to command-prompt for the same
in copy mode. Reported by Theo Buehler.


# 1.153 11-Oct-2016 nicm

Fundamental change to how copy mode key bindings work:

The vi-copy and emacs-copy mode key tables are gone, and instead copy
mode commands are bound in one of two normal key tables ("copy-mode" or
"copy-mode-vi"). Keys are bound to "send-keys -X copy-mode-command". So:

bind -temacs-copy C-Up scroll-up
bind -temacs-copy -R5 WheelUpPane scroll-up

Becomes:

bind -Tcopy-mode C-Up send -X scroll-up
bind -Tcopy-mode WheelUpPane send -N5 -X scroll-up

This allows the full command parser and command set to be used - for
example, we can use the normal command prompt for searching, jumping,
and so on instead of a custom one:

bind -Tcopy-mode C-r command-prompt -p'search up' "send -X search-backward '%%'"

command-prompt also gets a -1 option to only require on key press, which
is needed for jumping.

The plan is to get rid of mode keys entirely, so more to come eventually.


# 1.152 11-Oct-2016 nicm

Support UTF-8 entry into the command prompt.


# 1.151 10-Oct-2016 nicm

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


# 1.150 12-Sep-2016 nicm

Allow repeat count to be specified in mode key tables with bind-key -R,
and set the default repeat count to 5 for WheelUp and WheelDown in
copy-mode.


Revision tags: OPENBSD_6_0_BASE
# 1.149 06-Jun-2016 nicm

Allow #[] in window-status-separator.


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

I no longer use my SourceForge address so replace it.


# 1.147 01-Jan-2016 nicm

Don't rely on a calculation wrapping when applying message-limit, and
break out of the loop early. From Nicolas Viennot.


# 1.146 11-Dec-2015 nicm

Style nits and line wrapping of function declarations.


# 1.145 11-Dec-2015 nicm

Add cmdq as an argument to format_create and add a format for the
command name (will also be used for more later).


# 1.144 08-Dec-2015 nicm

Remove format_create_flags and just pass flags to format_create.


# 1.143 22-Nov-2015 tim

If display-time is set to 0, show status messages until a key is pressed;
OK nicm@


# 1.142 20-Nov-2015 nicm

Instead of separate tables for different types of options, give each
option a scope type (server, session, window) in one table.


# 1.141 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.140 13-Nov-2015 nicm

Long overdue change to the way we store cells in the grid: now, instead
of storing a full grid_cell with UTF-8 data and everything, store a new
type grid_cell_entry. This can either be the cell itself (for ASCII
cells), or an offset into an extended array (per line) for UTF-8
data.

This avoid a large (8 byte) overhead on non-UTF-8 cells (by far the
majority for most users) without the complexity of the shadow array we
had before. Grid memory without any UTF-8 is about half.

The disadvantage that cells can no longer be modified in place and need
to be copied out of the grid and back but it turned out to be lot less
complicated than I expected.


# 1.139 12-Nov-2015 nicm

Nuke the utf8 and status-utf8 options and make tmux only a UTF-8
terminal. We still support non-UTF-8 terminals outside tmux, but inside
it is always UTF-8 (as when the utf8 and status-utf8 options were on).


# 1.138 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.137 27-Oct-2015 nicm

Move struct options into options.c.


# 1.136 20-Oct-2015 nicm

Use client pointer not file descriptor in logging.


# 1.135 14-Sep-2015 nicm

Make refresh-client force update of jobs, from Sina Siadat.


# 1.134 29-Aug-2015 nicm

Move struct paste_buffer out of tmux.h.


# 1.133 28-Aug-2015 nicm

Run status update on a per-client timer at status-interval.


Revision tags: OPENBSD_5_8_BASE
# 1.132 29-Jul-2015 nicm

status_out and associated data structures are no longer used.


# 1.131 28-Jul-2015 nicm

Tidy up the way terminals are described and move some structs out of tmux.h.


# 1.130 20-Jul-2015 nicm

Add an option (history-file) for a file to save/restore command prompt
history, from Olof-Joachim Frahm.


# 1.129 27-May-2015 nicm

Move the jobs output cache into the formats code so that #() work more
generally (for example, again working in set-titles-string).


# 1.128 06-May-2015 nicm

Remove ARRAY_* from history and expand completion to complete a) layout
names and b) targets beginning with -t or -s.


# 1.127 25-Apr-2015 nicm

Make message log a TAILQ.


# 1.126 24-Apr-2015 nicm

Set working directory for run-shell and if-shell.


# 1.125 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_7_BASE
# 1.124 06-Feb-2015 nicm

Use the same time for both calls to format_expand_time.


# 1.123 06-Feb-2015 nicm

status_replace can now become local to status.c and it no longer needs
the jobsflag argument. While here there is no need to repeat work that
format_defaults already does.


# 1.122 06-Feb-2015 nicm

Add format_expand_time and use it instead of status_replace where
command execution is not needed.


# 1.121 05-Feb-2015 nicm

Wrap all the individual format_* calls in a single format_defaults
functions.


# 1.120 01-Feb-2015 nicm

Remove two unused arguments from status_replace.


# 1.119 20-Jan-2015 sthen

typo in comment ;) ok nicm


# 1.118 05-Nov-2014 nicm

Do not put a space between status-left/status-right and the window list,
instead move the space into the defaults for the options (so status-left
now defaults to "[#S] ". From Balazs Kezes.


# 1.117 20-Oct-2014 nicm

Better format for printf format attributes.


# 1.116 08-Oct-2014 nicm

Add xreallocarray and remove nmemb argument from xrealloc.


# 1.115 02-Oct-2014 nicm

Take account of window-status-separator when checking window position,
based on diff from Balazs Kezes.


Revision tags: OPENBSD_5_6_BASE
# 1.114 24-Apr-2014 nicm

There is no longer a need for a paste_stack struct or for global_buffers
to be global. Move to paste.c.


# 1.113 17-Apr-2014 nicm

Remove the monitor-content option and associated bits and bobs. It's
never worked very well. If there is a big demand for it to return, will
consider better ways to do it.


# 1.112 02-Apr-2014 nicm

Do not replace ## with # in status_replace1 because it'll be done later
by the format code.


# 1.111 31-Mar-2014 nicm

Make message-limit a server option.


Revision tags: OPENBSD_5_5_BASE
# 1.110 14-Feb-2014 nicm

Style nit - no space between function name and bracket.


# 1.109 14-Feb-2014 nicm

Check for NULL session and whatnot in status_replace, from Thomas Adam.


# 1.108 28-Jan-2014 nicm

Allow replacing each of the many sets of separate foo-{fg,bg,attr}
options with a single foo-style option. For example:

set -g status-fg yellow
set -g status-bg red
set -g status-attr blink

Becomes:

set -g status-style fg=yellow,bg=red,blink

The -a flag to set can be used to add to rather than replace a style. So:

set -g status-bg red

Becomes:

set -ag status-style bg=red

Currently this is fully backwards compatible (all *-{fg,bg,attr} options
remain) but the plan is to deprecate them over time.

From Tiago Cunha.


Revision tags: OPENBSD_5_4_BASE
# 1.107 05-Jul-2013 nicm

Whitespace nits, from Ben Boeckel.


# 1.106 05-Jul-2013 nicm

Act like vi(1) when moving words, from Ben Boeckel.


# 1.105 05-Jul-2013 nicm

Implement s, S, C mode switch commands in vi(1) mode, from Ben Boeckel.


# 1.104 31-May-2013 nicm

Demote the old single-character replacement variables (#S and friends)
to aliases of formats. From Tiago Cunha.


# 1.103 25-Mar-2013 nicm

Extend jobs to support writing and use that for copy-pipe instead of
popen, from Chris Johnsen.


# 1.102 22-Mar-2013 nicm

evbuffer_readline returns allocated storage, don't leak it.


# 1.101 22-Mar-2013 nicm

Add copy-pipe mode command to copy selection and also pipe to a command.


# 1.100 22-Mar-2013 nicm

No more lint means no more ARGSUSED.


# 1.99 21-Mar-2013 nicm

Aargh. Spaces -> tabs.


# 1.98 21-Mar-2013 nicm

Do not leak formats in status_replace.


# 1.97 21-Mar-2013 nicm

Add a format client_prefix which is 1 if prefix key has been
pressed, used for example #{?client_prefix,X,Y}. Also a few extra
server_client_status needed.


# 1.96 21-Mar-2013 nicm

Allow formats in status options.


Revision tags: OPENBSD_5_3_BASE
# 1.95 27-Nov-2012 nicm

Add window-status-last-* options, from Boris Faure.


Revision tags: OPENBSD_5_2_BASE
# 1.94 10-Jul-2012 nicm

xfree is not particularly helpful, remove it. From Thomas Adam.


# 1.93 09-Jul-2012 nicm

Move a NULL check inside a function, from Tiago Cunha.


# 1.92 29-Apr-2012 nicm

Use int not u_char for colours from options since they may have bit 8
set to mark them as 256-colour. Reported by Chris Johnson.


# 1.91 23-Apr-2012 nicm

Add window-status-separator option, from Thomas Adam.


# 1.90 17-Mar-2012 nicm

Check event_initialized before event_del if event may not have been set
up; libevent2 complains about this. Reported by Moriyoshi Koizumi.


# 1.89 04-Mar-2012 nicm

Add A and I keys for vi status line editing.


# 1.88 03-Mar-2012 nicm

The wlmouse offset should be part of the client, not the server. From
Ailin Nemui.


Revision tags: OPENBSD_5_1_BASE
# 1.87 29-Jan-2012 nicm

Add an option to move the status line to the top of the screen,
requested by many.


# 1.86 26-Jan-2012 nicm

Terminate strftime buffer properly even if a really long format string
is given, from Tiago Cunha.


# 1.85 26-Jan-2012 nicm

Fix memory leak in error path, from Tiago Cunha.


# 1.84 20-Jan-2012 nicm

Add some trivial additional status line attributes from jwcxz at users
dot sourceforge dot net.


# 1.83 20-Jan-2012 nicm

Add space movement keys for vi mode in the status line from Ben Boeckel.


# 1.82 01-Dec-2011 nicm

Make M-f and M-b work the same at the command prompt as in copy mode,
pointed out by Romain Francoise.


# 1.81 15-Nov-2011 nicm

Add word movement and editing command for command prompt editing, from
Ben Boeckel.


# 1.80 15-Nov-2011 nicm

Make window_pane_index work the same as window_index, from Ben Boeckel.


# 1.79 05-Nov-2011 nicm

Option to change status line (message) background when using vi keys and
in command mode. From Ben Boeckel.


# 1.78 20-Aug-2011 nicm

Fix a couple of memory leaks, from marcel partap.


Revision tags: OPENBSD_5_0_BASE
# 1.77 08-Jul-2011 nicm

Make confirm-before prompt customizable with -p option like
command-prompt. Also move responsibility for calling status_replace into
status_prompt_{set,update} and add #W and #P to the default kill-window
and kill-pane prompts. By Tiago Cunha.


# 1.76 02-Jul-2011 nicm

Allow the initial context on prompts to be set with the new -I option to
command-prompt. From Tiago Cunha.


# 1.75 29-Apr-2011 nicm

Only redraw the status line on command update, not the entire client
(big DOH).


# 1.74 24-Apr-2011 nicm

Provide #h for short hostname (no domain) from Michal Mazurek.


# 1.73 18-Apr-2011 nicm

Add an option (mouse-select-window) which allows the mouse to be used by
clicking on the status line, written by hsim at gmx dot li.


# 1.72 29-Mar-2011 nicm

Change -t on display-message to be target-pane for the #[A-Z]
replacements and add -c as target-client.


Revision tags: OPENBSD_4_9_BASE
# 1.71 26-Jan-2011 nicm

Simplify the way jobs work and drop the persist type, so all jobs are
fire-and-forget.

Status jobs now managed with two trees of output (new and old), rather
than storing the output in the jobs themselves. When the status line is
processed any jobs which don't appear in the new tree are started and
the output from the old tree displayed. When a job finishes it updates
the new tree with its output and that is used for any subsequent
redraws. When the status interval expires, the new tree is moved to the
old so that all jobs are run again.

This fixes the "#(echo %H:%M:%S)" problem which would lead to thousands
of identical persistent jobs and high memory use (this can still be
achieved by adding "sleep 30" but that is much less likely to happen by
accident).


# 1.70 03-Jan-2011 nicm

Handle a # at the end of a replacement string (such as status-left)
correctly. Found by Thomas Adam.


# 1.69 01-Jan-2011 nicm

Move the user-visible parts of all options (names, types, limit, default
values) together into one set of tables in options-table.c. Also clean
up and simplify cmd-set-options.c and move a common print function into
option-table.c.


# 1.68 30-Dec-2010 nicm

Change from a per-session stack of buffers to one global stack which is
much more convenient and also simplifies lot of code. This renders
copy-buffer useless and makes buffer-limit now a server option.

By Tiago Cunha.


# 1.67 30-Dec-2010 nicm

Add a function to create window flags rather than doing the same thing
in two places. From Thomas Adam.


# 1.66 11-Dec-2010 nicm

Oops, these functions return a const char *, so make the local variable
const as well.


# 1.65 11-Dec-2010 nicm

Make the prompt history global for all clients which is much more useful than per-client history.


# 1.64 06-Dec-2010 nicm

Add an option to alert (monitor) for silence (lack of activity) in a
window. From Thomas Adam.


Revision tags: OPENBSD_4_8_BASE
# 1.63 21-Jun-2010 nicm

Having a list of winlinks->alerts for each session is stupid, just store
the alert flags directly in the winlink itself.


# 1.62 14-May-2010 nicm

Colour+attribute options for status line alerts, from Alex Alexander.


# 1.61 31-Mar-2010 nicm

Don't accept keys with modifiers as input. Fixes crash reported by Brian
R Landy.


# 1.60 27-Mar-2010 nicm

Don't leak job command in #().


# 1.59 22-Mar-2010 nicm

Dead functions, lint.


Revision tags: OPENBSD_4_7_BASE
# 1.58 27-Jan-2010 nicm

Calculate offset correctly, fixes incorrect offset and prevents crash when
status-left is empty. From Micah Cowan.


# 1.57 26-Jan-2010 nicm

Actually use the copy made when no newline is found, from martynas@.


# 1.56 14-Dec-2009 nicm

Add server options to completion as well.


# 1.55 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.54 03-Dec-2009 nicm

Eliminate duplicate code and ease the passage for server-wide options by adding
a -w flag to set-option and show-options and making setw and showw aliases to
set -w and show -w.

Note: setw and showw are still there, but now aliases for set -w and show -w.


# 1.53 26-Nov-2009 nicm

Tidy up various bits of the paste code, make the data buffer char * and add
comments.


# 1.52 26-Nov-2009 nicm

Remove a couple of unused arguments where possible, and add /* ARGSUSED */ to
the rest to reduce lint output.


# 1.51 20-Nov-2009 nicm

Display UTF-8 properly in status line messages and prompt. Cursor handling is
still way off though.


# 1.50 20-Nov-2009 nicm

Remove oldest messages from log when limit is hit, not newest.


# 1.49 19-Nov-2009 nicm

Get some brackets in the right place so ## works. Also fix a space in a
comment.


# 1.48 19-Nov-2009 nicm

Change status line drawing to create the window list in a separate screen and
then copy it into the status line screen. This allows UTF-8 in window names and
fixes some problems with #[] in window-status-format.


# 1.47 19-Nov-2009 nicm

Two new options, window-status-format and window-status-current-format, which
allow the format of each window in the status line window list to be controlled
using similar # sequences as status-left/right.

This diff also moves part of the way towards UTF-8 support in window names but
it isn't quite there yet.


# 1.46 19-Nov-2009 nicm

Tidy up by breaking the # replacement code into a separate function, also add a
few comments.


# 1.45 19-Nov-2009 nicm

Don't interpret #() for display-message, it usually doesn't make sense and may
leak commands.


# 1.44 18-Nov-2009 nicm

Add a per-client log of status line messages displayed while that client
exists. A new message-limit session option sets the maximum number of entries
and a command, show-messages, shows the log (bound to ~ by default).

This (and prompt history) might be better as a single global log but until
there are global options it is easier for them to be per client.


# 1.43 17-Nov-2009 nicm

Permit top-bit-set characters to be entered in the status line. They could
already be set from the shell and are just passed through when printing (so
invisible characters or displaying on terminals with different character sets
may cause problems).

Note that entering UTF-8 may not work and in any case currently the status line
cannot display it correctly (outside of status-left/status-right).


# 1.42 04-Nov-2009 nicm

Use timeout events for the identify and message timers.


# 1.41 04-Nov-2009 nicm

Switch jobs over to use a bufferevent.


# 1.40 04-Nov-2009 nicm

Unused (but assigned to) variable, found by lint.


# 1.39 01-Nov-2009 nicm

Add a flag for jobs that shouldn't be freed after they've died and use it for
status jobs, then only kill those jobs when status-left, status-right or
set-titles-string is changed.

Fixes problems with changing options from inside #().


# 1.38 10-Oct-2009 nicm

Rather than running status-left, status-right and window title #() with popen
immediately every redraw, queue them up and run them in the background,
starting each once every status-interval. The actual status line uses the
output from the last run.

This brings several advantages:

- tmux itself may be called from inside #() without causing the server to hang;
- likewise, sleep or similar doesn't cause the server to block;
- commands aren't run excessively often when redrawing;
- commands shared by status-left and status-right, or used multiple times, will
only be run once.

run-shell and if-shell still use system()/popen() but will be changed over to
use this too later.


# 1.37 10-Oct-2009 nicm

Add "grouped sessions" which have independent name, options, current window and
so on but where the linked windows are synchronized (ie creating, killing
windows and so on are mirrored between the sessions). A grouped session may be
created by passing -t to new-session.

Had this around for a while, tested by a couple of people.


# 1.36 23-Sep-2009 nicm

Remove PROMPT_HIDDEN code which is now unused.


# 1.35 23-Sep-2009 nicm

Remove the internal tmux locking and instead detach each client and run the
command specified by a new option "lock-command" (by default "lock -np") in
each client.

This means each terminal has to be unlocked individually but simplifies the
code and allows the system password to be used to unlock.

Note that the set-password command is gone, so it will need to be removed from
configuration files, and the -U command line flag has been removed.

This is the third protocol version change so again it is best to stop the tmux
server before upgrading.


# 1.34 20-Sep-2009 nicm

Regularise some fatal messages.


# 1.33 10-Sep-2009 nicm

Permit options such as status-bg to be configured using the entire 256 colour
palette by setting "colour0" to "colour255".


# 1.32 07-Sep-2009 nicm

Give each paste buffer a size member instead of requiring them to be
zero-terminated.


# 1.31 07-Sep-2009 nicm

Permit embedded colour and attributes in status-left and status-right using new
#[] special characters, for example #[fg=red,bg=blue,blink].


# 1.30 02-Sep-2009 nicm

Add a transpose-chars command in edit mode (C-t in emacs mode only). From Kalle
Olavi Niemitalo.


# 1.29 01-Sep-2009 nicm

Use "Password:" with no space for password prompts and don't display a *s for
the password, like pretty much everything else. From martynas@ with minor
tweaks by me.


# 1.28 31-Aug-2009 nicm

Add a new display-panes command, with two options (display-panes-colour and
display-panes-time), which displays a visual indication of the number of each
pane.


# 1.27 19-Aug-2009 nicm

Extend command-prompt with a -p option which is a comma-separated list of one
or more prompts to present in order.

The responses to the prompt are replaced in the template string: %% are
replaced in order, so the first prompt replaces the first %%, the second
replaces the second, and so on. In addition, %1 up to %9 are replaced with the
responses to the first the ninth prompts

The default template is "%1" so the response to the first prompt is processed
as a command.

Note that this changes the behaviour for %% so if there is only one prompt,
only the first %% will be replaced. Templates such as "neww -n '%%' 'ssh %%'"
should be changed to "neww -n '%1' 'ssh %1'".

From Tiago Cunha.


# 1.26 18-Aug-2009 nicm

Add a "delete line" key when editing in the status line or the search up/down
prompt. C-u with emacs keys, d with vi.


# 1.25 13-Aug-2009 nicm

Switch the prompt code to return an empty string when the user enters no
response and reserve NULL for an explicit cancel. Change all callbacks to treat
them the same so no functional change.

Also add cancel key bindings to emacs mode which were missing.


# 1.24 08-Aug-2009 nicm

Options to set the colours and attributes for status-left/-right. From Thomas
Adam, thanks.


# 1.23 05-Aug-2009 nicm

If colours are not supported by the terminal, try to emulate a coloured
background by setting or clearing the reverse attribute.

This makes a few applications which don't use the reverse attribute themselves
a little happier, and allows the status, message and mode options to have
default attributes and fg/bg options that work as expected when set as reverse.


# 1.22 30-Jul-2009 nicm

Plug some memory leaks.


# 1.21 28-Jul-2009 nicm

Next step towards customisable mode keys: build each default table of keys into
a named tree on start and use that for lookups. Also add command to string
translation tables and modify list-keys to show the the mode key bindings (new
-t argument).


# 1.20 27-Jul-2009 nicm

Change mode key bindings from big switches into a set of tables. Rather than
lumping them all together, split editing keys from those used in choice/more
mode and those for copy/scroll mode.

Tidier and clearer, and the first step towards customisable mode keys.


# 1.19 27-Jul-2009 nicm

Get rid of empty mode_key_free function.


# 1.18 27-Jul-2009 nicm

Add a key to delete to end of line at the prompt (^K in emacs mode, C/D in vi).

From Kalle Olavi Niemitalo.


# 1.17 26-Jul-2009 nicm

Calculate the space available for the prompt buffer and the cursor position
correctly, and make it work when the screen is not wide enough.

Noticed by Kalle Olavi Niemitalo.


# 1.16 21-Jul-2009 nicm

Remove a couple of unused functions and fix a type ("FALLTHOUGH"), found by
lint.


# 1.15 20-Jul-2009 nicm

Add a status-justify option to allow the window list in the status line to be
positioned at the left, centre, or right.


# 1.14 20-Jul-2009 nicm

New options, window-status-current-{fg,bg,attr}, to set the fg, bg and
attributes with which the current window is shown in the status line. From
Johan Friis, thanks.


# 1.13 17-Jul-2009 nicm

- New command display-message (alias display) to display a message in the
status line (bound to "i" and displays the current window and time by
default). The same substitutions are applied as for status-left/right.
- Add support for including the window index (#I), pane index (#P) and window
name (#W) in the message, and status-left or status-right.
- Bump protocol version.

From Tiago Cunha, thanks!


# 1.12 17-Jul-2009 nicm

Memory could be leaked if a second prompt or message appeared while another was
still present, so add a separate prompt free callback and make the _clear
function responsible for calling it if necessary (rather than the individual
prompt callbacks). Also make both messages and prompts clear any existing when
a new is set.

In addition, the screen could be modified while the prompt is there, restore
the redraw-entire-screen behaviour on prompt clear; add a comment as a
reminder.


# 1.11 16-Jul-2009 nicm

Remove some duplicate code that was causing the status line to be redrawn even
when it hadn't changed.


# 1.10 15-Jul-2009 nicm

Make status_message_set a variadic printf-like function. No functional change -
helpful for a couple of things coming soon.


# 1.9 15-Jul-2009 nicm

Having to update NSETOPTION/NSETWINDOWOPTION when adding new options is a bit
annoying and it is only use for iterating, so use a sentinel to mark the end of
each array instead. Different fix for a problem pointed out by Kalle Olavi
Niemitalo.


# 1.8 14-Jul-2009 nicm

For some reason when clearing status/message it was redrawing the entire client
not just the status line. Changing this also revealed the check for the status
line was incorrect when drawing the pane.


# 1.7 14-Jul-2009 nicm

Instead of faking up a status line in status_redraw, use the same code to
redraw it as to draw the entire screen, just skip all lines but the last.

This makes horizontal split redraw properly when the status line is off.


# 1.6 12-Jul-2009 nicm

Add a "back to indentation" key in copy mode to move the cursor to the first
non-whitespace character. ^ with vi and M-m with emacs key bindings. Another
from Kalle Olavi Niemitalo, thanks.


Revision tags: OPENBSD_4_6_BASE
# 1.5 26-Jun-2009 nicm

Status line fixes: don't truncate status-right now the length calculation is
done for UTF-8, limit to the maximum length correctly when printing, and always
print a space even if the left string is longer than the width available.


# 1.4 04-Jun-2009 nicm

If the prompt is hidden or a password is sent with -U, zero it before freeing
it.


# 1.3 03-Jun-2009 nicm

New session option, status-utf8, to control the interpretation of top-bit-set
characters in status-left and status-right (if on, they are treated as UTF-8;
otherwise passed through).


# 1.2 03-Jun-2009 nicm

Add a UTF-8 aware string length function and make UTF-8 in
status-left/status-right work properly. At the moment any top-bit-set
characters are assumed to be UTF-8: a status-utf8 option to configure this will
come shortly.


# 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.237 20-Jan-2023 nicm

Add a flag to display-menu to select the manu item chosen first, GitHub
issue 3442.


Revision tags: OPENBSD_7_2_BASE
# 1.236 10-Sep-2022 nicm

Use correct option name.


# 1.235 09-Sep-2022 nicm

Add message-line option to control where message and prompt go, from
Varun Kumar E in GitHub issue 3324.


# 1.234 30-May-2022 nicm

Remove duplicates from completion list, GitHub issue 3178.


Revision tags: OPENBSD_7_1_BASE
# 1.233 07-Mar-2022 nicm

Pass client when adding menu item, GitHub issue 3103.


# 1.232 03-Feb-2022 nicm

Use format_draw for command prompt prefix to allow styles, GitHub issue
3054.


# 1.231 15-Nov-2021 nicm

Leave the hardware cursor at the position of the selected line in choose
modes and current editing position and at the command prompt. It is
invisible but this is helpful for people using screen readers. GitHub
issue 2970.


# 1.230 01-Nov-2021 nicm

Fix a comparison, from Ben Boeckel, and a crash when opening completion
menu, from Anindya Mukherjee.


# 1.229 26-Oct-2021 nicm

Accept some emacs control keys in vi normal mode, from Alexis
Hildebrandt in GitHub issue 2922.


# 1.228 26-Oct-2021 nicm

Do not allow inline styles to replace mode-style for the selected item,
from Alexis Hildebrandt in GitHub issue 2946.


Revision tags: OPENBSD_7_0_BASE
# 1.227 20-Aug-2021 nicm

Remove stray spaces after function names.


# 1.226 12-Aug-2021 nicm

Use COLOUR_DEFAULT not hardcoded 8.


# 1.225 10-Jun-2021 nicm

More accurate vi(1) word navigation in copy mode and on the status line.
This changes the meaning of the word-separators option - setting it to
the empty string is equivalent to the previous behavior. From Will Noble
in GitHub issue 2693.


# 1.224 10-Jun-2021 nicm

Add different command historys for different types of prompts
("command", "search" etc). From Anindya Mukherjee.


# 1.223 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.222 10-Jun-2021 nicm

Include current client in size calculation for new sessions, GitHub
issue 2662.


Revision tags: OPENBSD_6_9_BASE
# 1.221 12-Apr-2021 nicm

Add a flag to disable keys to close a message, GitHub issue 2625.


# 1.220 22-Feb-2021 nicm

Move jump commands to grid reader, make them UTF-8 aware, and tidy up,
from Anindya Mukherjee.


# 1.219 08-Jan-2021 nicm

With incremental search, start empty and only repeat the previous search
if the user tries to search again with an empty prompt. This matches
emacs behaviour more closely.


Revision tags: OPENBSD_6_8_BASE
# 1.218 27-Jul-2020 nicm

Add a -d option to display-message to set delay, from theonekeyg at
gmail dot com in GitHub issue 2322.


# 1.217 11-Jun-2020 nicm

Fix a crash when completing sessions, from Anindya Mukherjee.


# 1.216 26-May-2020 nicm

Remove leftover debug logging and fix comparison.


# 1.215 26-May-2020 nicm

Set up UTF-8 data for ASCII keys correctly.


# 1.214 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.213 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.212 16-May-2020 nicm

Rename KEYC_ESCAPE to KEYC_META.


# 1.211 16-May-2020 nicm

Expand target from client and use it to expand the prompt.


# 1.210 16-May-2020 nicm

Support embedded styles in the display-message message, GitHub issue
2206.


# 1.209 16-May-2020 nicm

Change message log to be per server rather than per client and include
every command that is run.


# 1.208 16-May-2020 nicm

Do not hoke into struct window_pane from the tty code and instead set
everything up in tty_ctx. Provide a way to initialize the tty_ctx from a
callback and use it to let popups draw directly through input_parse in
the same way as panes do, rather than forcing a full redraw on every
change.


# 1.207 16-May-2020 nicm

Use formats for status-style and message-style.


# 1.206 16-May-2020 nicm

Complete partial window indexes properly.


# 1.205 16-May-2020 nicm

Add -W and -T flags to command-prompt to only complete a window and a
target, also complete aliases.


# 1.204 16-May-2020 nicm

Improve command prompt completion:

- Show a menu with completions if there are multiple.

- Don't complete argument stuff (options, layouts) at start of text.

- For -t and -s, if there is no : then complete sessions but if there is
a :, show a menu of all windows in the session rather than trying to
complete the window name which is a bit useless if there are
duplicates.


# 1.203 16-May-2020 nicm

Drop having a separate type for style options and make them all strings,
which allows formats to be expanded. Any styles without a '#{' are still
validated when they are set but any with a '#{' are not. Formats are not
expanded usefully in many cases yet, that will be changed later.

To make this work, a few other changes:

- set-option -a with a style option automatically appends a ",".

- OSC 10 and 11 don't set the window-style option anymore, instead the
fg and bg are stored in the pane struct and act as the defaults that
can be overridden by window-style.

- status-fg and -bg now override status-style instead of trying to keep
them in sync.


Revision tags: OPENBSD_6_7_BASE
# 1.202 12-Mar-2020 nicm

Add C-g to cancel command prompt with vi(1) keys as well as emacs, and q
in command mode.


# 1.201 27-Jan-2020 nicm

Add support for adding a note to a key binding (with bind-key -N) and
use this to add descriptions to the default key bindings. A new -N flag
to list-keys shows key bindings with notes rather than the default
bind-key command used to create them. Change the default ? binding to
use this to show a readable summary of keys.

Also extend command-prompt to return the name of the key pressed and add
a default binding (/) to show the note for the next key pressed

Suggested by Alex Tremblay in GitHub issue 2000.


Revision tags: OPENBSD_6_6_BASE
# 1.200 28-May-2019 nicm

Redraw status line if size changes, GitHub issue 1762. Also fix length
of target buffer when pasting into status line.


# 1.199 23-May-2019 nicm

Fix length calculation for pasting UTF-8 characters in the status line,
GitHub issue 1753.


# 1.198 11-May-2019 nicm

Do not reduce window height by status line height for control mode
clients, from George Nachman.


# 1.197 03-May-2019 nicm

Fix reverse attribute in status line, GitHub issue 1709.


# 1.196 26-Apr-2019 nicm

Merge hooks into options and make each one an array option. This allows
multiple commands to be easily bound to one hook. set-hook and
show-hooks remain but they are now variants of set-option and
show-options. show-options now has a -H flag to show hooks (by default
they are not shown).


# 1.195 25-Apr-2019 nicm

options_array_item_value cannot return NULL.


# 1.194 23-Apr-2019 nicm

Somehow missed these bits in last commit.


# 1.193 23-Apr-2019 nicm

Indicate an array option with a flag rather than a special type so that
in future will not have to be strings.


Revision tags: OPENBSD_6_5_BASE
# 1.192 18-Mar-2019 nicm

Extend the #[] style syntax and use that together with previous format
changes to allow the status line to be entirely configured with a single
option.

Now that it is possible to configure their content, enable the existing
code that lets the status line be multiple lines in height. The status
option can now take a value of 2, 3, 4 or 5 (as well as the previous on
or off) to configure more than one line. The new status-format array
option configures the format of each line, the default just references
the existing status-* options, although some of the more obscure status
options may be eliminated in time.

Additions to the #[] syntax are: "align" to specify alignment (left,
centre, right), "list" for the window list and "range" to configure
ranges of text for the mouse bindings.

The "align" keyword can also be used to specify alignment of entries in
tree mode and the pane status lines.


# 1.191 18-Mar-2019 nicm

Make array options a sparse tree instead of an array of char * and
remove the size limit.


# 1.190 18-Mar-2019 nicm

With force, kill previous job before starting new. Fixes problem
reported by Scott Mcdermott in GitHub issue 1627.


# 1.189 16-Mar-2019 nicm

Use a pointer for the active screen in the status line instead of
copying them around all the time.


# 1.188 16-Mar-2019 nicm

Give status_save_old the client so it can do the reinit too.


# 1.187 16-Mar-2019 nicm

Tidy and rename some bits of status line code.


# 1.186 15-Mar-2019 nicm

Move status line free into its own function.


# 1.185 14-Mar-2019 nicm

Store the time in the format tree rather than passing it around.


# 1.184 12-Mar-2019 nicm

DECRC and DECSC apparently need to preserve origin mode as well, based
on a fix from Marc Reisner.


# 1.183 09-Feb-2019 nicm

Completion of command-alias members.


# 1.182 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.181 29-Aug-2018 nicm

Keep any text killed in the command prompt with C-w and yank it with
C-y, only use the top buffer if no text has previously been killed. This
and previous change promped by discussion with kn@.


# 1.180 29-Aug-2018 nicm

Add C-Left and C-Right as aliases for M-b and M-f.


# 1.179 22-Aug-2018 nicm

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


# 1.178 20-Aug-2018 nicm

Move offset of window list into status struct.


# 1.177 19-Aug-2018 nicm

Add a client redraw-window flag instead of the redraw-all flag and for
all just use the three flags together (window, borders, status).


Revision tags: OPENBSD_6_3_BASE
# 1.176 22-Feb-2018 nicm

Remove an unused variable.


# 1.175 05-Feb-2018 nicm

Add struct status_line to hold status line members of struct client, not
used yet but will be soon. From Thomas Adam.


# 1.174 01-Jan-2018 nicm

Add C-g at command prompt for emacs people, GitHub issue 1213.


# 1.173 27-Dec-2017 nicm

Draw command prompt correctly with status line off.


# 1.172 18-Dec-2017 nicm

Remove unused variable from Thomas Adam.


# 1.171 02-Nov-2017 nicm

Add a "fast" version of screen_write_copy for tree mode that doesn't do
all the checks and selection and marking stuff needed for copy mode.


# 1.170 20-Oct-2017 nicm

Clear status line with spaces again so reverse works, spotted by sthen.


# 1.169 16-Oct-2017 nicm

Infrastructure for drawing status lines of more than one line in height,
still only one is allowed but this lets tmux draw bigger ones.


Revision tags: OPENBSD_6_2_BASE
# 1.168 29-May-2017 nicm

Add a flag to stop the prompt input being expanded.


# 1.167 29-May-2017 nicm

Store a copy of the old status line, will be needed soon for new choose mode.


# 1.166 17-May-2017 nicm

Tidy command prompt callbacks and pass in the client.


# 1.165 03-May-2017 nicm

Add a format for the last search string in copy mode and fix the prompt
so it can work when in -I, suggested by Suraj N Kurapati.


# 1.164 01-May-2017 nicm

In order that people can use formats like #D in #() in the status line
and not have to wait for an update when they change pane, we allow
commands to run more than once a second if the expanded form
changes. Unfortunately this can mean them being run far too often
(pretty much continually) when multiple clients exist, because some
formats (including #D) will always differ between clients.

To avoid this, give each client its own tree of jobs which means that
the same command will be different instances for each client - similar
to how we have the tag to separate commands for different panes.

GitHub issue 889; test case reported by Paul Johnson.


# 1.163 22-Apr-2017 nicm

Memory leak from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.162 09-Feb-2017 nicm

Break the message storage function into its own function, useful for
debugging.


# 1.161 03-Feb-2017 nicm

Cache status line position to reduce option lookups during output.


# 1.160 03-Feb-2017 nicm

Add a window or pane id "tag" to each format tree and use it to separate
jobs, this means that if the same job is used for different windows or
panes (for example in pane-border-format), it will be run separately for
each pane.


# 1.159 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.158 06-Jan-2017 nicm

Incremental search in copy mode (on for emacs keys by default) - much
the same as normal searching but updates the cursor position and marked
search terms as you type. C-r and C-s in the prompt repeat the search,
once finished searching (with Enter), N and n work as before.


# 1.157 05-Jan-2017 nicm

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


# 1.156 07-Dec-2016 nicm

Do not clear the prompt when a message is shown, just leave it around and
return to it when the message is finished.


# 1.155 12-Oct-2016 nicm

Drop the edit mode key tables and just use fixed key bindings for the
command prompt.


# 1.154 12-Oct-2016 nicm

The repeat prompt in both emacs and vi (and the old one in tmux) doesn't
support line editing and instead executes a command as soon as a
non-number key is pressed. Add a -N flag to command-prompt for the same
in copy mode. Reported by Theo Buehler.


# 1.153 11-Oct-2016 nicm

Fundamental change to how copy mode key bindings work:

The vi-copy and emacs-copy mode key tables are gone, and instead copy
mode commands are bound in one of two normal key tables ("copy-mode" or
"copy-mode-vi"). Keys are bound to "send-keys -X copy-mode-command". So:

bind -temacs-copy C-Up scroll-up
bind -temacs-copy -R5 WheelUpPane scroll-up

Becomes:

bind -Tcopy-mode C-Up send -X scroll-up
bind -Tcopy-mode WheelUpPane send -N5 -X scroll-up

This allows the full command parser and command set to be used - for
example, we can use the normal command prompt for searching, jumping,
and so on instead of a custom one:

bind -Tcopy-mode C-r command-prompt -p'search up' "send -X search-backward '%%'"

command-prompt also gets a -1 option to only require on key press, which
is needed for jumping.

The plan is to get rid of mode keys entirely, so more to come eventually.


# 1.152 11-Oct-2016 nicm

Support UTF-8 entry into the command prompt.


# 1.151 10-Oct-2016 nicm

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


# 1.150 12-Sep-2016 nicm

Allow repeat count to be specified in mode key tables with bind-key -R,
and set the default repeat count to 5 for WheelUp and WheelDown in
copy-mode.


Revision tags: OPENBSD_6_0_BASE
# 1.149 06-Jun-2016 nicm

Allow #[] in window-status-separator.


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

I no longer use my SourceForge address so replace it.


# 1.147 01-Jan-2016 nicm

Don't rely on a calculation wrapping when applying message-limit, and
break out of the loop early. From Nicolas Viennot.


# 1.146 11-Dec-2015 nicm

Style nits and line wrapping of function declarations.


# 1.145 11-Dec-2015 nicm

Add cmdq as an argument to format_create and add a format for the
command name (will also be used for more later).


# 1.144 08-Dec-2015 nicm

Remove format_create_flags and just pass flags to format_create.


# 1.143 22-Nov-2015 tim

If display-time is set to 0, show status messages until a key is pressed;
OK nicm@


# 1.142 20-Nov-2015 nicm

Instead of separate tables for different types of options, give each
option a scope type (server, session, window) in one table.


# 1.141 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.140 13-Nov-2015 nicm

Long overdue change to the way we store cells in the grid: now, instead
of storing a full grid_cell with UTF-8 data and everything, store a new
type grid_cell_entry. This can either be the cell itself (for ASCII
cells), or an offset into an extended array (per line) for UTF-8
data.

This avoid a large (8 byte) overhead on non-UTF-8 cells (by far the
majority for most users) without the complexity of the shadow array we
had before. Grid memory without any UTF-8 is about half.

The disadvantage that cells can no longer be modified in place and need
to be copied out of the grid and back but it turned out to be lot less
complicated than I expected.


# 1.139 12-Nov-2015 nicm

Nuke the utf8 and status-utf8 options and make tmux only a UTF-8
terminal. We still support non-UTF-8 terminals outside tmux, but inside
it is always UTF-8 (as when the utf8 and status-utf8 options were on).


# 1.138 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.137 27-Oct-2015 nicm

Move struct options into options.c.


# 1.136 20-Oct-2015 nicm

Use client pointer not file descriptor in logging.


# 1.135 14-Sep-2015 nicm

Make refresh-client force update of jobs, from Sina Siadat.


# 1.134 29-Aug-2015 nicm

Move struct paste_buffer out of tmux.h.


# 1.133 28-Aug-2015 nicm

Run status update on a per-client timer at status-interval.


Revision tags: OPENBSD_5_8_BASE
# 1.132 29-Jul-2015 nicm

status_out and associated data structures are no longer used.


# 1.131 28-Jul-2015 nicm

Tidy up the way terminals are described and move some structs out of tmux.h.


# 1.130 20-Jul-2015 nicm

Add an option (history-file) for a file to save/restore command prompt
history, from Olof-Joachim Frahm.


# 1.129 27-May-2015 nicm

Move the jobs output cache into the formats code so that #() work more
generally (for example, again working in set-titles-string).


# 1.128 06-May-2015 nicm

Remove ARRAY_* from history and expand completion to complete a) layout
names and b) targets beginning with -t or -s.


# 1.127 25-Apr-2015 nicm

Make message log a TAILQ.


# 1.126 24-Apr-2015 nicm

Set working directory for run-shell and if-shell.


# 1.125 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_7_BASE
# 1.124 06-Feb-2015 nicm

Use the same time for both calls to format_expand_time.


# 1.123 06-Feb-2015 nicm

status_replace can now become local to status.c and it no longer needs
the jobsflag argument. While here there is no need to repeat work that
format_defaults already does.


# 1.122 06-Feb-2015 nicm

Add format_expand_time and use it instead of status_replace where
command execution is not needed.


# 1.121 05-Feb-2015 nicm

Wrap all the individual format_* calls in a single format_defaults
functions.


# 1.120 01-Feb-2015 nicm

Remove two unused arguments from status_replace.


# 1.119 20-Jan-2015 sthen

typo in comment ;) ok nicm


# 1.118 05-Nov-2014 nicm

Do not put a space between status-left/status-right and the window list,
instead move the space into the defaults for the options (so status-left
now defaults to "[#S] ". From Balazs Kezes.


# 1.117 20-Oct-2014 nicm

Better format for printf format attributes.


# 1.116 08-Oct-2014 nicm

Add xreallocarray and remove nmemb argument from xrealloc.


# 1.115 02-Oct-2014 nicm

Take account of window-status-separator when checking window position,
based on diff from Balazs Kezes.


Revision tags: OPENBSD_5_6_BASE
# 1.114 24-Apr-2014 nicm

There is no longer a need for a paste_stack struct or for global_buffers
to be global. Move to paste.c.


# 1.113 17-Apr-2014 nicm

Remove the monitor-content option and associated bits and bobs. It's
never worked very well. If there is a big demand for it to return, will
consider better ways to do it.


# 1.112 02-Apr-2014 nicm

Do not replace ## with # in status_replace1 because it'll be done later
by the format code.


# 1.111 31-Mar-2014 nicm

Make message-limit a server option.


Revision tags: OPENBSD_5_5_BASE
# 1.110 14-Feb-2014 nicm

Style nit - no space between function name and bracket.


# 1.109 14-Feb-2014 nicm

Check for NULL session and whatnot in status_replace, from Thomas Adam.


# 1.108 28-Jan-2014 nicm

Allow replacing each of the many sets of separate foo-{fg,bg,attr}
options with a single foo-style option. For example:

set -g status-fg yellow
set -g status-bg red
set -g status-attr blink

Becomes:

set -g status-style fg=yellow,bg=red,blink

The -a flag to set can be used to add to rather than replace a style. So:

set -g status-bg red

Becomes:

set -ag status-style bg=red

Currently this is fully backwards compatible (all *-{fg,bg,attr} options
remain) but the plan is to deprecate them over time.

From Tiago Cunha.


Revision tags: OPENBSD_5_4_BASE
# 1.107 05-Jul-2013 nicm

Whitespace nits, from Ben Boeckel.


# 1.106 05-Jul-2013 nicm

Act like vi(1) when moving words, from Ben Boeckel.


# 1.105 05-Jul-2013 nicm

Implement s, S, C mode switch commands in vi(1) mode, from Ben Boeckel.


# 1.104 31-May-2013 nicm

Demote the old single-character replacement variables (#S and friends)
to aliases of formats. From Tiago Cunha.


# 1.103 25-Mar-2013 nicm

Extend jobs to support writing and use that for copy-pipe instead of
popen, from Chris Johnsen.


# 1.102 22-Mar-2013 nicm

evbuffer_readline returns allocated storage, don't leak it.


# 1.101 22-Mar-2013 nicm

Add copy-pipe mode command to copy selection and also pipe to a command.


# 1.100 22-Mar-2013 nicm

No more lint means no more ARGSUSED.


# 1.99 21-Mar-2013 nicm

Aargh. Spaces -> tabs.


# 1.98 21-Mar-2013 nicm

Do not leak formats in status_replace.


# 1.97 21-Mar-2013 nicm

Add a format client_prefix which is 1 if prefix key has been
pressed, used for example #{?client_prefix,X,Y}. Also a few extra
server_client_status needed.


# 1.96 21-Mar-2013 nicm

Allow formats in status options.


Revision tags: OPENBSD_5_3_BASE
# 1.95 27-Nov-2012 nicm

Add window-status-last-* options, from Boris Faure.


Revision tags: OPENBSD_5_2_BASE
# 1.94 10-Jul-2012 nicm

xfree is not particularly helpful, remove it. From Thomas Adam.


# 1.93 09-Jul-2012 nicm

Move a NULL check inside a function, from Tiago Cunha.


# 1.92 29-Apr-2012 nicm

Use int not u_char for colours from options since they may have bit 8
set to mark them as 256-colour. Reported by Chris Johnson.


# 1.91 23-Apr-2012 nicm

Add window-status-separator option, from Thomas Adam.


# 1.90 17-Mar-2012 nicm

Check event_initialized before event_del if event may not have been set
up; libevent2 complains about this. Reported by Moriyoshi Koizumi.


# 1.89 04-Mar-2012 nicm

Add A and I keys for vi status line editing.


# 1.88 03-Mar-2012 nicm

The wlmouse offset should be part of the client, not the server. From
Ailin Nemui.


Revision tags: OPENBSD_5_1_BASE
# 1.87 29-Jan-2012 nicm

Add an option to move the status line to the top of the screen,
requested by many.


# 1.86 26-Jan-2012 nicm

Terminate strftime buffer properly even if a really long format string
is given, from Tiago Cunha.


# 1.85 26-Jan-2012 nicm

Fix memory leak in error path, from Tiago Cunha.


# 1.84 20-Jan-2012 nicm

Add some trivial additional status line attributes from jwcxz at users
dot sourceforge dot net.


# 1.83 20-Jan-2012 nicm

Add space movement keys for vi mode in the status line from Ben Boeckel.


# 1.82 01-Dec-2011 nicm

Make M-f and M-b work the same at the command prompt as in copy mode,
pointed out by Romain Francoise.


# 1.81 15-Nov-2011 nicm

Add word movement and editing command for command prompt editing, from
Ben Boeckel.


# 1.80 15-Nov-2011 nicm

Make window_pane_index work the same as window_index, from Ben Boeckel.


# 1.79 05-Nov-2011 nicm

Option to change status line (message) background when using vi keys and
in command mode. From Ben Boeckel.


# 1.78 20-Aug-2011 nicm

Fix a couple of memory leaks, from marcel partap.


Revision tags: OPENBSD_5_0_BASE
# 1.77 08-Jul-2011 nicm

Make confirm-before prompt customizable with -p option like
command-prompt. Also move responsibility for calling status_replace into
status_prompt_{set,update} and add #W and #P to the default kill-window
and kill-pane prompts. By Tiago Cunha.


# 1.76 02-Jul-2011 nicm

Allow the initial context on prompts to be set with the new -I option to
command-prompt. From Tiago Cunha.


# 1.75 29-Apr-2011 nicm

Only redraw the status line on command update, not the entire client
(big DOH).


# 1.74 24-Apr-2011 nicm

Provide #h for short hostname (no domain) from Michal Mazurek.


# 1.73 18-Apr-2011 nicm

Add an option (mouse-select-window) which allows the mouse to be used by
clicking on the status line, written by hsim at gmx dot li.


# 1.72 29-Mar-2011 nicm

Change -t on display-message to be target-pane for the #[A-Z]
replacements and add -c as target-client.


Revision tags: OPENBSD_4_9_BASE
# 1.71 26-Jan-2011 nicm

Simplify the way jobs work and drop the persist type, so all jobs are
fire-and-forget.

Status jobs now managed with two trees of output (new and old), rather
than storing the output in the jobs themselves. When the status line is
processed any jobs which don't appear in the new tree are started and
the output from the old tree displayed. When a job finishes it updates
the new tree with its output and that is used for any subsequent
redraws. When the status interval expires, the new tree is moved to the
old so that all jobs are run again.

This fixes the "#(echo %H:%M:%S)" problem which would lead to thousands
of identical persistent jobs and high memory use (this can still be
achieved by adding "sleep 30" but that is much less likely to happen by
accident).


# 1.70 03-Jan-2011 nicm

Handle a # at the end of a replacement string (such as status-left)
correctly. Found by Thomas Adam.


# 1.69 01-Jan-2011 nicm

Move the user-visible parts of all options (names, types, limit, default
values) together into one set of tables in options-table.c. Also clean
up and simplify cmd-set-options.c and move a common print function into
option-table.c.


# 1.68 30-Dec-2010 nicm

Change from a per-session stack of buffers to one global stack which is
much more convenient and also simplifies lot of code. This renders
copy-buffer useless and makes buffer-limit now a server option.

By Tiago Cunha.


# 1.67 30-Dec-2010 nicm

Add a function to create window flags rather than doing the same thing
in two places. From Thomas Adam.


# 1.66 11-Dec-2010 nicm

Oops, these functions return a const char *, so make the local variable
const as well.


# 1.65 11-Dec-2010 nicm

Make the prompt history global for all clients which is much more useful than per-client history.


# 1.64 06-Dec-2010 nicm

Add an option to alert (monitor) for silence (lack of activity) in a
window. From Thomas Adam.


Revision tags: OPENBSD_4_8_BASE
# 1.63 21-Jun-2010 nicm

Having a list of winlinks->alerts for each session is stupid, just store
the alert flags directly in the winlink itself.


# 1.62 14-May-2010 nicm

Colour+attribute options for status line alerts, from Alex Alexander.


# 1.61 31-Mar-2010 nicm

Don't accept keys with modifiers as input. Fixes crash reported by Brian
R Landy.


# 1.60 27-Mar-2010 nicm

Don't leak job command in #().


# 1.59 22-Mar-2010 nicm

Dead functions, lint.


Revision tags: OPENBSD_4_7_BASE
# 1.58 27-Jan-2010 nicm

Calculate offset correctly, fixes incorrect offset and prevents crash when
status-left is empty. From Micah Cowan.


# 1.57 26-Jan-2010 nicm

Actually use the copy made when no newline is found, from martynas@.


# 1.56 14-Dec-2009 nicm

Add server options to completion as well.


# 1.55 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.54 03-Dec-2009 nicm

Eliminate duplicate code and ease the passage for server-wide options by adding
a -w flag to set-option and show-options and making setw and showw aliases to
set -w and show -w.

Note: setw and showw are still there, but now aliases for set -w and show -w.


# 1.53 26-Nov-2009 nicm

Tidy up various bits of the paste code, make the data buffer char * and add
comments.


# 1.52 26-Nov-2009 nicm

Remove a couple of unused arguments where possible, and add /* ARGSUSED */ to
the rest to reduce lint output.


# 1.51 20-Nov-2009 nicm

Display UTF-8 properly in status line messages and prompt. Cursor handling is
still way off though.


# 1.50 20-Nov-2009 nicm

Remove oldest messages from log when limit is hit, not newest.


# 1.49 19-Nov-2009 nicm

Get some brackets in the right place so ## works. Also fix a space in a
comment.


# 1.48 19-Nov-2009 nicm

Change status line drawing to create the window list in a separate screen and
then copy it into the status line screen. This allows UTF-8 in window names and
fixes some problems with #[] in window-status-format.


# 1.47 19-Nov-2009 nicm

Two new options, window-status-format and window-status-current-format, which
allow the format of each window in the status line window list to be controlled
using similar # sequences as status-left/right.

This diff also moves part of the way towards UTF-8 support in window names but
it isn't quite there yet.


# 1.46 19-Nov-2009 nicm

Tidy up by breaking the # replacement code into a separate function, also add a
few comments.


# 1.45 19-Nov-2009 nicm

Don't interpret #() for display-message, it usually doesn't make sense and may
leak commands.


# 1.44 18-Nov-2009 nicm

Add a per-client log of status line messages displayed while that client
exists. A new message-limit session option sets the maximum number of entries
and a command, show-messages, shows the log (bound to ~ by default).

This (and prompt history) might be better as a single global log but until
there are global options it is easier for them to be per client.


# 1.43 17-Nov-2009 nicm

Permit top-bit-set characters to be entered in the status line. They could
already be set from the shell and are just passed through when printing (so
invisible characters or displaying on terminals with different character sets
may cause problems).

Note that entering UTF-8 may not work and in any case currently the status line
cannot display it correctly (outside of status-left/status-right).


# 1.42 04-Nov-2009 nicm

Use timeout events for the identify and message timers.


# 1.41 04-Nov-2009 nicm

Switch jobs over to use a bufferevent.


# 1.40 04-Nov-2009 nicm

Unused (but assigned to) variable, found by lint.


# 1.39 01-Nov-2009 nicm

Add a flag for jobs that shouldn't be freed after they've died and use it for
status jobs, then only kill those jobs when status-left, status-right or
set-titles-string is changed.

Fixes problems with changing options from inside #().


# 1.38 10-Oct-2009 nicm

Rather than running status-left, status-right and window title #() with popen
immediately every redraw, queue them up and run them in the background,
starting each once every status-interval. The actual status line uses the
output from the last run.

This brings several advantages:

- tmux itself may be called from inside #() without causing the server to hang;
- likewise, sleep or similar doesn't cause the server to block;
- commands aren't run excessively often when redrawing;
- commands shared by status-left and status-right, or used multiple times, will
only be run once.

run-shell and if-shell still use system()/popen() but will be changed over to
use this too later.


# 1.37 10-Oct-2009 nicm

Add "grouped sessions" which have independent name, options, current window and
so on but where the linked windows are synchronized (ie creating, killing
windows and so on are mirrored between the sessions). A grouped session may be
created by passing -t to new-session.

Had this around for a while, tested by a couple of people.


# 1.36 23-Sep-2009 nicm

Remove PROMPT_HIDDEN code which is now unused.


# 1.35 23-Sep-2009 nicm

Remove the internal tmux locking and instead detach each client and run the
command specified by a new option "lock-command" (by default "lock -np") in
each client.

This means each terminal has to be unlocked individually but simplifies the
code and allows the system password to be used to unlock.

Note that the set-password command is gone, so it will need to be removed from
configuration files, and the -U command line flag has been removed.

This is the third protocol version change so again it is best to stop the tmux
server before upgrading.


# 1.34 20-Sep-2009 nicm

Regularise some fatal messages.


# 1.33 10-Sep-2009 nicm

Permit options such as status-bg to be configured using the entire 256 colour
palette by setting "colour0" to "colour255".


# 1.32 07-Sep-2009 nicm

Give each paste buffer a size member instead of requiring them to be
zero-terminated.


# 1.31 07-Sep-2009 nicm

Permit embedded colour and attributes in status-left and status-right using new
#[] special characters, for example #[fg=red,bg=blue,blink].


# 1.30 02-Sep-2009 nicm

Add a transpose-chars command in edit mode (C-t in emacs mode only). From Kalle
Olavi Niemitalo.


# 1.29 01-Sep-2009 nicm

Use "Password:" with no space for password prompts and don't display a *s for
the password, like pretty much everything else. From martynas@ with minor
tweaks by me.


# 1.28 31-Aug-2009 nicm

Add a new display-panes command, with two options (display-panes-colour and
display-panes-time), which displays a visual indication of the number of each
pane.


# 1.27 19-Aug-2009 nicm

Extend command-prompt with a -p option which is a comma-separated list of one
or more prompts to present in order.

The responses to the prompt are replaced in the template string: %% are
replaced in order, so the first prompt replaces the first %%, the second
replaces the second, and so on. In addition, %1 up to %9 are replaced with the
responses to the first the ninth prompts

The default template is "%1" so the response to the first prompt is processed
as a command.

Note that this changes the behaviour for %% so if there is only one prompt,
only the first %% will be replaced. Templates such as "neww -n '%%' 'ssh %%'"
should be changed to "neww -n '%1' 'ssh %1'".

From Tiago Cunha.


# 1.26 18-Aug-2009 nicm

Add a "delete line" key when editing in the status line or the search up/down
prompt. C-u with emacs keys, d with vi.


# 1.25 13-Aug-2009 nicm

Switch the prompt code to return an empty string when the user enters no
response and reserve NULL for an explicit cancel. Change all callbacks to treat
them the same so no functional change.

Also add cancel key bindings to emacs mode which were missing.


# 1.24 08-Aug-2009 nicm

Options to set the colours and attributes for status-left/-right. From Thomas
Adam, thanks.


# 1.23 05-Aug-2009 nicm

If colours are not supported by the terminal, try to emulate a coloured
background by setting or clearing the reverse attribute.

This makes a few applications which don't use the reverse attribute themselves
a little happier, and allows the status, message and mode options to have
default attributes and fg/bg options that work as expected when set as reverse.


# 1.22 30-Jul-2009 nicm

Plug some memory leaks.


# 1.21 28-Jul-2009 nicm

Next step towards customisable mode keys: build each default table of keys into
a named tree on start and use that for lookups. Also add command to string
translation tables and modify list-keys to show the the mode key bindings (new
-t argument).


# 1.20 27-Jul-2009 nicm

Change mode key bindings from big switches into a set of tables. Rather than
lumping them all together, split editing keys from those used in choice/more
mode and those for copy/scroll mode.

Tidier and clearer, and the first step towards customisable mode keys.


# 1.19 27-Jul-2009 nicm

Get rid of empty mode_key_free function.


# 1.18 27-Jul-2009 nicm

Add a key to delete to end of line at the prompt (^K in emacs mode, C/D in vi).

From Kalle Olavi Niemitalo.


# 1.17 26-Jul-2009 nicm

Calculate the space available for the prompt buffer and the cursor position
correctly, and make it work when the screen is not wide enough.

Noticed by Kalle Olavi Niemitalo.


# 1.16 21-Jul-2009 nicm

Remove a couple of unused functions and fix a type ("FALLTHOUGH"), found by
lint.


# 1.15 20-Jul-2009 nicm

Add a status-justify option to allow the window list in the status line to be
positioned at the left, centre, or right.


# 1.14 20-Jul-2009 nicm

New options, window-status-current-{fg,bg,attr}, to set the fg, bg and
attributes with which the current window is shown in the status line. From
Johan Friis, thanks.


# 1.13 17-Jul-2009 nicm

- New command display-message (alias display) to display a message in the
status line (bound to "i" and displays the current window and time by
default). The same substitutions are applied as for status-left/right.
- Add support for including the window index (#I), pane index (#P) and window
name (#W) in the message, and status-left or status-right.
- Bump protocol version.

From Tiago Cunha, thanks!


# 1.12 17-Jul-2009 nicm

Memory could be leaked if a second prompt or message appeared while another was
still present, so add a separate prompt free callback and make the _clear
function responsible for calling it if necessary (rather than the individual
prompt callbacks). Also make both messages and prompts clear any existing when
a new is set.

In addition, the screen could be modified while the prompt is there, restore
the redraw-entire-screen behaviour on prompt clear; add a comment as a
reminder.


# 1.11 16-Jul-2009 nicm

Remove some duplicate code that was causing the status line to be redrawn even
when it hadn't changed.


# 1.10 15-Jul-2009 nicm

Make status_message_set a variadic printf-like function. No functional change -
helpful for a couple of things coming soon.


# 1.9 15-Jul-2009 nicm

Having to update NSETOPTION/NSETWINDOWOPTION when adding new options is a bit
annoying and it is only use for iterating, so use a sentinel to mark the end of
each array instead. Different fix for a problem pointed out by Kalle Olavi
Niemitalo.


# 1.8 14-Jul-2009 nicm

For some reason when clearing status/message it was redrawing the entire client
not just the status line. Changing this also revealed the check for the status
line was incorrect when drawing the pane.


# 1.7 14-Jul-2009 nicm

Instead of faking up a status line in status_redraw, use the same code to
redraw it as to draw the entire screen, just skip all lines but the last.

This makes horizontal split redraw properly when the status line is off.


# 1.6 12-Jul-2009 nicm

Add a "back to indentation" key in copy mode to move the cursor to the first
non-whitespace character. ^ with vi and M-m with emacs key bindings. Another
from Kalle Olavi Niemitalo, thanks.


Revision tags: OPENBSD_4_6_BASE
# 1.5 26-Jun-2009 nicm

Status line fixes: don't truncate status-right now the length calculation is
done for UTF-8, limit to the maximum length correctly when printing, and always
print a space even if the left string is longer than the width available.


# 1.4 04-Jun-2009 nicm

If the prompt is hidden or a password is sent with -U, zero it before freeing
it.


# 1.3 03-Jun-2009 nicm

New session option, status-utf8, to control the interpretation of top-bit-set
characters in status-left and status-right (if on, they are treated as UTF-8;
otherwise passed through).


# 1.2 03-Jun-2009 nicm

Add a UTF-8 aware string length function and make UTF-8 in
status-left/status-right work properly. At the moment any top-bit-set
characters are assumed to be UTF-8: a status-utf8 option to configure this will
come shortly.


# 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.236 10-Sep-2022 nicm

Use correct option name.


# 1.235 09-Sep-2022 nicm

Add message-line option to control where message and prompt go, from
Varun Kumar E in GitHub issue 3324.


# 1.234 30-May-2022 nicm

Remove duplicates from completion list, GitHub issue 3178.


Revision tags: OPENBSD_7_1_BASE
# 1.233 07-Mar-2022 nicm

Pass client when adding menu item, GitHub issue 3103.


# 1.232 03-Feb-2022 nicm

Use format_draw for command prompt prefix to allow styles, GitHub issue
3054.


# 1.231 15-Nov-2021 nicm

Leave the hardware cursor at the position of the selected line in choose
modes and current editing position and at the command prompt. It is
invisible but this is helpful for people using screen readers. GitHub
issue 2970.


# 1.230 01-Nov-2021 nicm

Fix a comparison, from Ben Boeckel, and a crash when opening completion
menu, from Anindya Mukherjee.


# 1.229 26-Oct-2021 nicm

Accept some emacs control keys in vi normal mode, from Alexis
Hildebrandt in GitHub issue 2922.


# 1.228 26-Oct-2021 nicm

Do not allow inline styles to replace mode-style for the selected item,
from Alexis Hildebrandt in GitHub issue 2946.


Revision tags: OPENBSD_7_0_BASE
# 1.227 20-Aug-2021 nicm

Remove stray spaces after function names.


# 1.226 12-Aug-2021 nicm

Use COLOUR_DEFAULT not hardcoded 8.


# 1.225 10-Jun-2021 nicm

More accurate vi(1) word navigation in copy mode and on the status line.
This changes the meaning of the word-separators option - setting it to
the empty string is equivalent to the previous behavior. From Will Noble
in GitHub issue 2693.


# 1.224 10-Jun-2021 nicm

Add different command historys for different types of prompts
("command", "search" etc). From Anindya Mukherjee.


# 1.223 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.222 10-Jun-2021 nicm

Include current client in size calculation for new sessions, GitHub
issue 2662.


Revision tags: OPENBSD_6_9_BASE
# 1.221 12-Apr-2021 nicm

Add a flag to disable keys to close a message, GitHub issue 2625.


# 1.220 22-Feb-2021 nicm

Move jump commands to grid reader, make them UTF-8 aware, and tidy up,
from Anindya Mukherjee.


# 1.219 08-Jan-2021 nicm

With incremental search, start empty and only repeat the previous search
if the user tries to search again with an empty prompt. This matches
emacs behaviour more closely.


Revision tags: OPENBSD_6_8_BASE
# 1.218 27-Jul-2020 nicm

Add a -d option to display-message to set delay, from theonekeyg at
gmail dot com in GitHub issue 2322.


# 1.217 11-Jun-2020 nicm

Fix a crash when completing sessions, from Anindya Mukherjee.


# 1.216 26-May-2020 nicm

Remove leftover debug logging and fix comparison.


# 1.215 26-May-2020 nicm

Set up UTF-8 data for ASCII keys correctly.


# 1.214 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.213 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.212 16-May-2020 nicm

Rename KEYC_ESCAPE to KEYC_META.


# 1.211 16-May-2020 nicm

Expand target from client and use it to expand the prompt.


# 1.210 16-May-2020 nicm

Support embedded styles in the display-message message, GitHub issue
2206.


# 1.209 16-May-2020 nicm

Change message log to be per server rather than per client and include
every command that is run.


# 1.208 16-May-2020 nicm

Do not hoke into struct window_pane from the tty code and instead set
everything up in tty_ctx. Provide a way to initialize the tty_ctx from a
callback and use it to let popups draw directly through input_parse in
the same way as panes do, rather than forcing a full redraw on every
change.


# 1.207 16-May-2020 nicm

Use formats for status-style and message-style.


# 1.206 16-May-2020 nicm

Complete partial window indexes properly.


# 1.205 16-May-2020 nicm

Add -W and -T flags to command-prompt to only complete a window and a
target, also complete aliases.


# 1.204 16-May-2020 nicm

Improve command prompt completion:

- Show a menu with completions if there are multiple.

- Don't complete argument stuff (options, layouts) at start of text.

- For -t and -s, if there is no : then complete sessions but if there is
a :, show a menu of all windows in the session rather than trying to
complete the window name which is a bit useless if there are
duplicates.


# 1.203 16-May-2020 nicm

Drop having a separate type for style options and make them all strings,
which allows formats to be expanded. Any styles without a '#{' are still
validated when they are set but any with a '#{' are not. Formats are not
expanded usefully in many cases yet, that will be changed later.

To make this work, a few other changes:

- set-option -a with a style option automatically appends a ",".

- OSC 10 and 11 don't set the window-style option anymore, instead the
fg and bg are stored in the pane struct and act as the defaults that
can be overridden by window-style.

- status-fg and -bg now override status-style instead of trying to keep
them in sync.


Revision tags: OPENBSD_6_7_BASE
# 1.202 12-Mar-2020 nicm

Add C-g to cancel command prompt with vi(1) keys as well as emacs, and q
in command mode.


# 1.201 27-Jan-2020 nicm

Add support for adding a note to a key binding (with bind-key -N) and
use this to add descriptions to the default key bindings. A new -N flag
to list-keys shows key bindings with notes rather than the default
bind-key command used to create them. Change the default ? binding to
use this to show a readable summary of keys.

Also extend command-prompt to return the name of the key pressed and add
a default binding (/) to show the note for the next key pressed

Suggested by Alex Tremblay in GitHub issue 2000.


Revision tags: OPENBSD_6_6_BASE
# 1.200 28-May-2019 nicm

Redraw status line if size changes, GitHub issue 1762. Also fix length
of target buffer when pasting into status line.


# 1.199 23-May-2019 nicm

Fix length calculation for pasting UTF-8 characters in the status line,
GitHub issue 1753.


# 1.198 11-May-2019 nicm

Do not reduce window height by status line height for control mode
clients, from George Nachman.


# 1.197 03-May-2019 nicm

Fix reverse attribute in status line, GitHub issue 1709.


# 1.196 26-Apr-2019 nicm

Merge hooks into options and make each one an array option. This allows
multiple commands to be easily bound to one hook. set-hook and
show-hooks remain but they are now variants of set-option and
show-options. show-options now has a -H flag to show hooks (by default
they are not shown).


# 1.195 25-Apr-2019 nicm

options_array_item_value cannot return NULL.


# 1.194 23-Apr-2019 nicm

Somehow missed these bits in last commit.


# 1.193 23-Apr-2019 nicm

Indicate an array option with a flag rather than a special type so that
in future will not have to be strings.


Revision tags: OPENBSD_6_5_BASE
# 1.192 18-Mar-2019 nicm

Extend the #[] style syntax and use that together with previous format
changes to allow the status line to be entirely configured with a single
option.

Now that it is possible to configure their content, enable the existing
code that lets the status line be multiple lines in height. The status
option can now take a value of 2, 3, 4 or 5 (as well as the previous on
or off) to configure more than one line. The new status-format array
option configures the format of each line, the default just references
the existing status-* options, although some of the more obscure status
options may be eliminated in time.

Additions to the #[] syntax are: "align" to specify alignment (left,
centre, right), "list" for the window list and "range" to configure
ranges of text for the mouse bindings.

The "align" keyword can also be used to specify alignment of entries in
tree mode and the pane status lines.


# 1.191 18-Mar-2019 nicm

Make array options a sparse tree instead of an array of char * and
remove the size limit.


# 1.190 18-Mar-2019 nicm

With force, kill previous job before starting new. Fixes problem
reported by Scott Mcdermott in GitHub issue 1627.


# 1.189 16-Mar-2019 nicm

Use a pointer for the active screen in the status line instead of
copying them around all the time.


# 1.188 16-Mar-2019 nicm

Give status_save_old the client so it can do the reinit too.


# 1.187 16-Mar-2019 nicm

Tidy and rename some bits of status line code.


# 1.186 15-Mar-2019 nicm

Move status line free into its own function.


# 1.185 14-Mar-2019 nicm

Store the time in the format tree rather than passing it around.


# 1.184 12-Mar-2019 nicm

DECRC and DECSC apparently need to preserve origin mode as well, based
on a fix from Marc Reisner.


# 1.183 09-Feb-2019 nicm

Completion of command-alias members.


# 1.182 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.181 29-Aug-2018 nicm

Keep any text killed in the command prompt with C-w and yank it with
C-y, only use the top buffer if no text has previously been killed. This
and previous change promped by discussion with kn@.


# 1.180 29-Aug-2018 nicm

Add C-Left and C-Right as aliases for M-b and M-f.


# 1.179 22-Aug-2018 nicm

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


# 1.178 20-Aug-2018 nicm

Move offset of window list into status struct.


# 1.177 19-Aug-2018 nicm

Add a client redraw-window flag instead of the redraw-all flag and for
all just use the three flags together (window, borders, status).


Revision tags: OPENBSD_6_3_BASE
# 1.176 22-Feb-2018 nicm

Remove an unused variable.


# 1.175 05-Feb-2018 nicm

Add struct status_line to hold status line members of struct client, not
used yet but will be soon. From Thomas Adam.


# 1.174 01-Jan-2018 nicm

Add C-g at command prompt for emacs people, GitHub issue 1213.


# 1.173 27-Dec-2017 nicm

Draw command prompt correctly with status line off.


# 1.172 18-Dec-2017 nicm

Remove unused variable from Thomas Adam.


# 1.171 02-Nov-2017 nicm

Add a "fast" version of screen_write_copy for tree mode that doesn't do
all the checks and selection and marking stuff needed for copy mode.


# 1.170 20-Oct-2017 nicm

Clear status line with spaces again so reverse works, spotted by sthen.


# 1.169 16-Oct-2017 nicm

Infrastructure for drawing status lines of more than one line in height,
still only one is allowed but this lets tmux draw bigger ones.


Revision tags: OPENBSD_6_2_BASE
# 1.168 29-May-2017 nicm

Add a flag to stop the prompt input being expanded.


# 1.167 29-May-2017 nicm

Store a copy of the old status line, will be needed soon for new choose mode.


# 1.166 17-May-2017 nicm

Tidy command prompt callbacks and pass in the client.


# 1.165 03-May-2017 nicm

Add a format for the last search string in copy mode and fix the prompt
so it can work when in -I, suggested by Suraj N Kurapati.


# 1.164 01-May-2017 nicm

In order that people can use formats like #D in #() in the status line
and not have to wait for an update when they change pane, we allow
commands to run more than once a second if the expanded form
changes. Unfortunately this can mean them being run far too often
(pretty much continually) when multiple clients exist, because some
formats (including #D) will always differ between clients.

To avoid this, give each client its own tree of jobs which means that
the same command will be different instances for each client - similar
to how we have the tag to separate commands for different panes.

GitHub issue 889; test case reported by Paul Johnson.


# 1.163 22-Apr-2017 nicm

Memory leak from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.162 09-Feb-2017 nicm

Break the message storage function into its own function, useful for
debugging.


# 1.161 03-Feb-2017 nicm

Cache status line position to reduce option lookups during output.


# 1.160 03-Feb-2017 nicm

Add a window or pane id "tag" to each format tree and use it to separate
jobs, this means that if the same job is used for different windows or
panes (for example in pane-border-format), it will be run separately for
each pane.


# 1.159 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.158 06-Jan-2017 nicm

Incremental search in copy mode (on for emacs keys by default) - much
the same as normal searching but updates the cursor position and marked
search terms as you type. C-r and C-s in the prompt repeat the search,
once finished searching (with Enter), N and n work as before.


# 1.157 05-Jan-2017 nicm

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


# 1.156 07-Dec-2016 nicm

Do not clear the prompt when a message is shown, just leave it around and
return to it when the message is finished.


# 1.155 12-Oct-2016 nicm

Drop the edit mode key tables and just use fixed key bindings for the
command prompt.


# 1.154 12-Oct-2016 nicm

The repeat prompt in both emacs and vi (and the old one in tmux) doesn't
support line editing and instead executes a command as soon as a
non-number key is pressed. Add a -N flag to command-prompt for the same
in copy mode. Reported by Theo Buehler.


# 1.153 11-Oct-2016 nicm

Fundamental change to how copy mode key bindings work:

The vi-copy and emacs-copy mode key tables are gone, and instead copy
mode commands are bound in one of two normal key tables ("copy-mode" or
"copy-mode-vi"). Keys are bound to "send-keys -X copy-mode-command". So:

bind -temacs-copy C-Up scroll-up
bind -temacs-copy -R5 WheelUpPane scroll-up

Becomes:

bind -Tcopy-mode C-Up send -X scroll-up
bind -Tcopy-mode WheelUpPane send -N5 -X scroll-up

This allows the full command parser and command set to be used - for
example, we can use the normal command prompt for searching, jumping,
and so on instead of a custom one:

bind -Tcopy-mode C-r command-prompt -p'search up' "send -X search-backward '%%'"

command-prompt also gets a -1 option to only require on key press, which
is needed for jumping.

The plan is to get rid of mode keys entirely, so more to come eventually.


# 1.152 11-Oct-2016 nicm

Support UTF-8 entry into the command prompt.


# 1.151 10-Oct-2016 nicm

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


# 1.150 12-Sep-2016 nicm

Allow repeat count to be specified in mode key tables with bind-key -R,
and set the default repeat count to 5 for WheelUp and WheelDown in
copy-mode.


Revision tags: OPENBSD_6_0_BASE
# 1.149 06-Jun-2016 nicm

Allow #[] in window-status-separator.


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

I no longer use my SourceForge address so replace it.


# 1.147 01-Jan-2016 nicm

Don't rely on a calculation wrapping when applying message-limit, and
break out of the loop early. From Nicolas Viennot.


# 1.146 11-Dec-2015 nicm

Style nits and line wrapping of function declarations.


# 1.145 11-Dec-2015 nicm

Add cmdq as an argument to format_create and add a format for the
command name (will also be used for more later).


# 1.144 08-Dec-2015 nicm

Remove format_create_flags and just pass flags to format_create.


# 1.143 22-Nov-2015 tim

If display-time is set to 0, show status messages until a key is pressed;
OK nicm@


# 1.142 20-Nov-2015 nicm

Instead of separate tables for different types of options, give each
option a scope type (server, session, window) in one table.


# 1.141 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.140 13-Nov-2015 nicm

Long overdue change to the way we store cells in the grid: now, instead
of storing a full grid_cell with UTF-8 data and everything, store a new
type grid_cell_entry. This can either be the cell itself (for ASCII
cells), or an offset into an extended array (per line) for UTF-8
data.

This avoid a large (8 byte) overhead on non-UTF-8 cells (by far the
majority for most users) without the complexity of the shadow array we
had before. Grid memory without any UTF-8 is about half.

The disadvantage that cells can no longer be modified in place and need
to be copied out of the grid and back but it turned out to be lot less
complicated than I expected.


# 1.139 12-Nov-2015 nicm

Nuke the utf8 and status-utf8 options and make tmux only a UTF-8
terminal. We still support non-UTF-8 terminals outside tmux, but inside
it is always UTF-8 (as when the utf8 and status-utf8 options were on).


# 1.138 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.137 27-Oct-2015 nicm

Move struct options into options.c.


# 1.136 20-Oct-2015 nicm

Use client pointer not file descriptor in logging.


# 1.135 14-Sep-2015 nicm

Make refresh-client force update of jobs, from Sina Siadat.


# 1.134 29-Aug-2015 nicm

Move struct paste_buffer out of tmux.h.


# 1.133 28-Aug-2015 nicm

Run status update on a per-client timer at status-interval.


Revision tags: OPENBSD_5_8_BASE
# 1.132 29-Jul-2015 nicm

status_out and associated data structures are no longer used.


# 1.131 28-Jul-2015 nicm

Tidy up the way terminals are described and move some structs out of tmux.h.


# 1.130 20-Jul-2015 nicm

Add an option (history-file) for a file to save/restore command prompt
history, from Olof-Joachim Frahm.


# 1.129 27-May-2015 nicm

Move the jobs output cache into the formats code so that #() work more
generally (for example, again working in set-titles-string).


# 1.128 06-May-2015 nicm

Remove ARRAY_* from history and expand completion to complete a) layout
names and b) targets beginning with -t or -s.


# 1.127 25-Apr-2015 nicm

Make message log a TAILQ.


# 1.126 24-Apr-2015 nicm

Set working directory for run-shell and if-shell.


# 1.125 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_7_BASE
# 1.124 06-Feb-2015 nicm

Use the same time for both calls to format_expand_time.


# 1.123 06-Feb-2015 nicm

status_replace can now become local to status.c and it no longer needs
the jobsflag argument. While here there is no need to repeat work that
format_defaults already does.


# 1.122 06-Feb-2015 nicm

Add format_expand_time and use it instead of status_replace where
command execution is not needed.


# 1.121 05-Feb-2015 nicm

Wrap all the individual format_* calls in a single format_defaults
functions.


# 1.120 01-Feb-2015 nicm

Remove two unused arguments from status_replace.


# 1.119 20-Jan-2015 sthen

typo in comment ;) ok nicm


# 1.118 05-Nov-2014 nicm

Do not put a space between status-left/status-right and the window list,
instead move the space into the defaults for the options (so status-left
now defaults to "[#S] ". From Balazs Kezes.


# 1.117 20-Oct-2014 nicm

Better format for printf format attributes.


# 1.116 08-Oct-2014 nicm

Add xreallocarray and remove nmemb argument from xrealloc.


# 1.115 02-Oct-2014 nicm

Take account of window-status-separator when checking window position,
based on diff from Balazs Kezes.


Revision tags: OPENBSD_5_6_BASE
# 1.114 24-Apr-2014 nicm

There is no longer a need for a paste_stack struct or for global_buffers
to be global. Move to paste.c.


# 1.113 17-Apr-2014 nicm

Remove the monitor-content option and associated bits and bobs. It's
never worked very well. If there is a big demand for it to return, will
consider better ways to do it.


# 1.112 02-Apr-2014 nicm

Do not replace ## with # in status_replace1 because it'll be done later
by the format code.


# 1.111 31-Mar-2014 nicm

Make message-limit a server option.


Revision tags: OPENBSD_5_5_BASE
# 1.110 14-Feb-2014 nicm

Style nit - no space between function name and bracket.


# 1.109 14-Feb-2014 nicm

Check for NULL session and whatnot in status_replace, from Thomas Adam.


# 1.108 28-Jan-2014 nicm

Allow replacing each of the many sets of separate foo-{fg,bg,attr}
options with a single foo-style option. For example:

set -g status-fg yellow
set -g status-bg red
set -g status-attr blink

Becomes:

set -g status-style fg=yellow,bg=red,blink

The -a flag to set can be used to add to rather than replace a style. So:

set -g status-bg red

Becomes:

set -ag status-style bg=red

Currently this is fully backwards compatible (all *-{fg,bg,attr} options
remain) but the plan is to deprecate them over time.

From Tiago Cunha.


Revision tags: OPENBSD_5_4_BASE
# 1.107 05-Jul-2013 nicm

Whitespace nits, from Ben Boeckel.


# 1.106 05-Jul-2013 nicm

Act like vi(1) when moving words, from Ben Boeckel.


# 1.105 05-Jul-2013 nicm

Implement s, S, C mode switch commands in vi(1) mode, from Ben Boeckel.


# 1.104 31-May-2013 nicm

Demote the old single-character replacement variables (#S and friends)
to aliases of formats. From Tiago Cunha.


# 1.103 25-Mar-2013 nicm

Extend jobs to support writing and use that for copy-pipe instead of
popen, from Chris Johnsen.


# 1.102 22-Mar-2013 nicm

evbuffer_readline returns allocated storage, don't leak it.


# 1.101 22-Mar-2013 nicm

Add copy-pipe mode command to copy selection and also pipe to a command.


# 1.100 22-Mar-2013 nicm

No more lint means no more ARGSUSED.


# 1.99 21-Mar-2013 nicm

Aargh. Spaces -> tabs.


# 1.98 21-Mar-2013 nicm

Do not leak formats in status_replace.


# 1.97 21-Mar-2013 nicm

Add a format client_prefix which is 1 if prefix key has been
pressed, used for example #{?client_prefix,X,Y}. Also a few extra
server_client_status needed.


# 1.96 21-Mar-2013 nicm

Allow formats in status options.


Revision tags: OPENBSD_5_3_BASE
# 1.95 27-Nov-2012 nicm

Add window-status-last-* options, from Boris Faure.


Revision tags: OPENBSD_5_2_BASE
# 1.94 10-Jul-2012 nicm

xfree is not particularly helpful, remove it. From Thomas Adam.


# 1.93 09-Jul-2012 nicm

Move a NULL check inside a function, from Tiago Cunha.


# 1.92 29-Apr-2012 nicm

Use int not u_char for colours from options since they may have bit 8
set to mark them as 256-colour. Reported by Chris Johnson.


# 1.91 23-Apr-2012 nicm

Add window-status-separator option, from Thomas Adam.


# 1.90 17-Mar-2012 nicm

Check event_initialized before event_del if event may not have been set
up; libevent2 complains about this. Reported by Moriyoshi Koizumi.


# 1.89 04-Mar-2012 nicm

Add A and I keys for vi status line editing.


# 1.88 03-Mar-2012 nicm

The wlmouse offset should be part of the client, not the server. From
Ailin Nemui.


Revision tags: OPENBSD_5_1_BASE
# 1.87 29-Jan-2012 nicm

Add an option to move the status line to the top of the screen,
requested by many.


# 1.86 26-Jan-2012 nicm

Terminate strftime buffer properly even if a really long format string
is given, from Tiago Cunha.


# 1.85 26-Jan-2012 nicm

Fix memory leak in error path, from Tiago Cunha.


# 1.84 20-Jan-2012 nicm

Add some trivial additional status line attributes from jwcxz at users
dot sourceforge dot net.


# 1.83 20-Jan-2012 nicm

Add space movement keys for vi mode in the status line from Ben Boeckel.


# 1.82 01-Dec-2011 nicm

Make M-f and M-b work the same at the command prompt as in copy mode,
pointed out by Romain Francoise.


# 1.81 15-Nov-2011 nicm

Add word movement and editing command for command prompt editing, from
Ben Boeckel.


# 1.80 15-Nov-2011 nicm

Make window_pane_index work the same as window_index, from Ben Boeckel.


# 1.79 05-Nov-2011 nicm

Option to change status line (message) background when using vi keys and
in command mode. From Ben Boeckel.


# 1.78 20-Aug-2011 nicm

Fix a couple of memory leaks, from marcel partap.


Revision tags: OPENBSD_5_0_BASE
# 1.77 08-Jul-2011 nicm

Make confirm-before prompt customizable with -p option like
command-prompt. Also move responsibility for calling status_replace into
status_prompt_{set,update} and add #W and #P to the default kill-window
and kill-pane prompts. By Tiago Cunha.


# 1.76 02-Jul-2011 nicm

Allow the initial context on prompts to be set with the new -I option to
command-prompt. From Tiago Cunha.


# 1.75 29-Apr-2011 nicm

Only redraw the status line on command update, not the entire client
(big DOH).


# 1.74 24-Apr-2011 nicm

Provide #h for short hostname (no domain) from Michal Mazurek.


# 1.73 18-Apr-2011 nicm

Add an option (mouse-select-window) which allows the mouse to be used by
clicking on the status line, written by hsim at gmx dot li.


# 1.72 29-Mar-2011 nicm

Change -t on display-message to be target-pane for the #[A-Z]
replacements and add -c as target-client.


Revision tags: OPENBSD_4_9_BASE
# 1.71 26-Jan-2011 nicm

Simplify the way jobs work and drop the persist type, so all jobs are
fire-and-forget.

Status jobs now managed with two trees of output (new and old), rather
than storing the output in the jobs themselves. When the status line is
processed any jobs which don't appear in the new tree are started and
the output from the old tree displayed. When a job finishes it updates
the new tree with its output and that is used for any subsequent
redraws. When the status interval expires, the new tree is moved to the
old so that all jobs are run again.

This fixes the "#(echo %H:%M:%S)" problem which would lead to thousands
of identical persistent jobs and high memory use (this can still be
achieved by adding "sleep 30" but that is much less likely to happen by
accident).


# 1.70 03-Jan-2011 nicm

Handle a # at the end of a replacement string (such as status-left)
correctly. Found by Thomas Adam.


# 1.69 01-Jan-2011 nicm

Move the user-visible parts of all options (names, types, limit, default
values) together into one set of tables in options-table.c. Also clean
up and simplify cmd-set-options.c and move a common print function into
option-table.c.


# 1.68 30-Dec-2010 nicm

Change from a per-session stack of buffers to one global stack which is
much more convenient and also simplifies lot of code. This renders
copy-buffer useless and makes buffer-limit now a server option.

By Tiago Cunha.


# 1.67 30-Dec-2010 nicm

Add a function to create window flags rather than doing the same thing
in two places. From Thomas Adam.


# 1.66 11-Dec-2010 nicm

Oops, these functions return a const char *, so make the local variable
const as well.


# 1.65 11-Dec-2010 nicm

Make the prompt history global for all clients which is much more useful than per-client history.


# 1.64 06-Dec-2010 nicm

Add an option to alert (monitor) for silence (lack of activity) in a
window. From Thomas Adam.


Revision tags: OPENBSD_4_8_BASE
# 1.63 21-Jun-2010 nicm

Having a list of winlinks->alerts for each session is stupid, just store
the alert flags directly in the winlink itself.


# 1.62 14-May-2010 nicm

Colour+attribute options for status line alerts, from Alex Alexander.


# 1.61 31-Mar-2010 nicm

Don't accept keys with modifiers as input. Fixes crash reported by Brian
R Landy.


# 1.60 27-Mar-2010 nicm

Don't leak job command in #().


# 1.59 22-Mar-2010 nicm

Dead functions, lint.


Revision tags: OPENBSD_4_7_BASE
# 1.58 27-Jan-2010 nicm

Calculate offset correctly, fixes incorrect offset and prevents crash when
status-left is empty. From Micah Cowan.


# 1.57 26-Jan-2010 nicm

Actually use the copy made when no newline is found, from martynas@.


# 1.56 14-Dec-2009 nicm

Add server options to completion as well.


# 1.55 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.54 03-Dec-2009 nicm

Eliminate duplicate code and ease the passage for server-wide options by adding
a -w flag to set-option and show-options and making setw and showw aliases to
set -w and show -w.

Note: setw and showw are still there, but now aliases for set -w and show -w.


# 1.53 26-Nov-2009 nicm

Tidy up various bits of the paste code, make the data buffer char * and add
comments.


# 1.52 26-Nov-2009 nicm

Remove a couple of unused arguments where possible, and add /* ARGSUSED */ to
the rest to reduce lint output.


# 1.51 20-Nov-2009 nicm

Display UTF-8 properly in status line messages and prompt. Cursor handling is
still way off though.


# 1.50 20-Nov-2009 nicm

Remove oldest messages from log when limit is hit, not newest.


# 1.49 19-Nov-2009 nicm

Get some brackets in the right place so ## works. Also fix a space in a
comment.


# 1.48 19-Nov-2009 nicm

Change status line drawing to create the window list in a separate screen and
then copy it into the status line screen. This allows UTF-8 in window names and
fixes some problems with #[] in window-status-format.


# 1.47 19-Nov-2009 nicm

Two new options, window-status-format and window-status-current-format, which
allow the format of each window in the status line window list to be controlled
using similar # sequences as status-left/right.

This diff also moves part of the way towards UTF-8 support in window names but
it isn't quite there yet.


# 1.46 19-Nov-2009 nicm

Tidy up by breaking the # replacement code into a separate function, also add a
few comments.


# 1.45 19-Nov-2009 nicm

Don't interpret #() for display-message, it usually doesn't make sense and may
leak commands.


# 1.44 18-Nov-2009 nicm

Add a per-client log of status line messages displayed while that client
exists. A new message-limit session option sets the maximum number of entries
and a command, show-messages, shows the log (bound to ~ by default).

This (and prompt history) might be better as a single global log but until
there are global options it is easier for them to be per client.


# 1.43 17-Nov-2009 nicm

Permit top-bit-set characters to be entered in the status line. They could
already be set from the shell and are just passed through when printing (so
invisible characters or displaying on terminals with different character sets
may cause problems).

Note that entering UTF-8 may not work and in any case currently the status line
cannot display it correctly (outside of status-left/status-right).


# 1.42 04-Nov-2009 nicm

Use timeout events for the identify and message timers.


# 1.41 04-Nov-2009 nicm

Switch jobs over to use a bufferevent.


# 1.40 04-Nov-2009 nicm

Unused (but assigned to) variable, found by lint.


# 1.39 01-Nov-2009 nicm

Add a flag for jobs that shouldn't be freed after they've died and use it for
status jobs, then only kill those jobs when status-left, status-right or
set-titles-string is changed.

Fixes problems with changing options from inside #().


# 1.38 10-Oct-2009 nicm

Rather than running status-left, status-right and window title #() with popen
immediately every redraw, queue them up and run them in the background,
starting each once every status-interval. The actual status line uses the
output from the last run.

This brings several advantages:

- tmux itself may be called from inside #() without causing the server to hang;
- likewise, sleep or similar doesn't cause the server to block;
- commands aren't run excessively often when redrawing;
- commands shared by status-left and status-right, or used multiple times, will
only be run once.

run-shell and if-shell still use system()/popen() but will be changed over to
use this too later.


# 1.37 10-Oct-2009 nicm

Add "grouped sessions" which have independent name, options, current window and
so on but where the linked windows are synchronized (ie creating, killing
windows and so on are mirrored between the sessions). A grouped session may be
created by passing -t to new-session.

Had this around for a while, tested by a couple of people.


# 1.36 23-Sep-2009 nicm

Remove PROMPT_HIDDEN code which is now unused.


# 1.35 23-Sep-2009 nicm

Remove the internal tmux locking and instead detach each client and run the
command specified by a new option "lock-command" (by default "lock -np") in
each client.

This means each terminal has to be unlocked individually but simplifies the
code and allows the system password to be used to unlock.

Note that the set-password command is gone, so it will need to be removed from
configuration files, and the -U command line flag has been removed.

This is the third protocol version change so again it is best to stop the tmux
server before upgrading.


# 1.34 20-Sep-2009 nicm

Regularise some fatal messages.


# 1.33 10-Sep-2009 nicm

Permit options such as status-bg to be configured using the entire 256 colour
palette by setting "colour0" to "colour255".


# 1.32 07-Sep-2009 nicm

Give each paste buffer a size member instead of requiring them to be
zero-terminated.


# 1.31 07-Sep-2009 nicm

Permit embedded colour and attributes in status-left and status-right using new
#[] special characters, for example #[fg=red,bg=blue,blink].


# 1.30 02-Sep-2009 nicm

Add a transpose-chars command in edit mode (C-t in emacs mode only). From Kalle
Olavi Niemitalo.


# 1.29 01-Sep-2009 nicm

Use "Password:" with no space for password prompts and don't display a *s for
the password, like pretty much everything else. From martynas@ with minor
tweaks by me.


# 1.28 31-Aug-2009 nicm

Add a new display-panes command, with two options (display-panes-colour and
display-panes-time), which displays a visual indication of the number of each
pane.


# 1.27 19-Aug-2009 nicm

Extend command-prompt with a -p option which is a comma-separated list of one
or more prompts to present in order.

The responses to the prompt are replaced in the template string: %% are
replaced in order, so the first prompt replaces the first %%, the second
replaces the second, and so on. In addition, %1 up to %9 are replaced with the
responses to the first the ninth prompts

The default template is "%1" so the response to the first prompt is processed
as a command.

Note that this changes the behaviour for %% so if there is only one prompt,
only the first %% will be replaced. Templates such as "neww -n '%%' 'ssh %%'"
should be changed to "neww -n '%1' 'ssh %1'".

From Tiago Cunha.


# 1.26 18-Aug-2009 nicm

Add a "delete line" key when editing in the status line or the search up/down
prompt. C-u with emacs keys, d with vi.


# 1.25 13-Aug-2009 nicm

Switch the prompt code to return an empty string when the user enters no
response and reserve NULL for an explicit cancel. Change all callbacks to treat
them the same so no functional change.

Also add cancel key bindings to emacs mode which were missing.


# 1.24 08-Aug-2009 nicm

Options to set the colours and attributes for status-left/-right. From Thomas
Adam, thanks.


# 1.23 05-Aug-2009 nicm

If colours are not supported by the terminal, try to emulate a coloured
background by setting or clearing the reverse attribute.

This makes a few applications which don't use the reverse attribute themselves
a little happier, and allows the status, message and mode options to have
default attributes and fg/bg options that work as expected when set as reverse.


# 1.22 30-Jul-2009 nicm

Plug some memory leaks.


# 1.21 28-Jul-2009 nicm

Next step towards customisable mode keys: build each default table of keys into
a named tree on start and use that for lookups. Also add command to string
translation tables and modify list-keys to show the the mode key bindings (new
-t argument).


# 1.20 27-Jul-2009 nicm

Change mode key bindings from big switches into a set of tables. Rather than
lumping them all together, split editing keys from those used in choice/more
mode and those for copy/scroll mode.

Tidier and clearer, and the first step towards customisable mode keys.


# 1.19 27-Jul-2009 nicm

Get rid of empty mode_key_free function.


# 1.18 27-Jul-2009 nicm

Add a key to delete to end of line at the prompt (^K in emacs mode, C/D in vi).

From Kalle Olavi Niemitalo.


# 1.17 26-Jul-2009 nicm

Calculate the space available for the prompt buffer and the cursor position
correctly, and make it work when the screen is not wide enough.

Noticed by Kalle Olavi Niemitalo.


# 1.16 21-Jul-2009 nicm

Remove a couple of unused functions and fix a type ("FALLTHOUGH"), found by
lint.


# 1.15 20-Jul-2009 nicm

Add a status-justify option to allow the window list in the status line to be
positioned at the left, centre, or right.


# 1.14 20-Jul-2009 nicm

New options, window-status-current-{fg,bg,attr}, to set the fg, bg and
attributes with which the current window is shown in the status line. From
Johan Friis, thanks.


# 1.13 17-Jul-2009 nicm

- New command display-message (alias display) to display a message in the
status line (bound to "i" and displays the current window and time by
default). The same substitutions are applied as for status-left/right.
- Add support for including the window index (#I), pane index (#P) and window
name (#W) in the message, and status-left or status-right.
- Bump protocol version.

From Tiago Cunha, thanks!


# 1.12 17-Jul-2009 nicm

Memory could be leaked if a second prompt or message appeared while another was
still present, so add a separate prompt free callback and make the _clear
function responsible for calling it if necessary (rather than the individual
prompt callbacks). Also make both messages and prompts clear any existing when
a new is set.

In addition, the screen could be modified while the prompt is there, restore
the redraw-entire-screen behaviour on prompt clear; add a comment as a
reminder.


# 1.11 16-Jul-2009 nicm

Remove some duplicate code that was causing the status line to be redrawn even
when it hadn't changed.


# 1.10 15-Jul-2009 nicm

Make status_message_set a variadic printf-like function. No functional change -
helpful for a couple of things coming soon.


# 1.9 15-Jul-2009 nicm

Having to update NSETOPTION/NSETWINDOWOPTION when adding new options is a bit
annoying and it is only use for iterating, so use a sentinel to mark the end of
each array instead. Different fix for a problem pointed out by Kalle Olavi
Niemitalo.


# 1.8 14-Jul-2009 nicm

For some reason when clearing status/message it was redrawing the entire client
not just the status line. Changing this also revealed the check for the status
line was incorrect when drawing the pane.


# 1.7 14-Jul-2009 nicm

Instead of faking up a status line in status_redraw, use the same code to
redraw it as to draw the entire screen, just skip all lines but the last.

This makes horizontal split redraw properly when the status line is off.


# 1.6 12-Jul-2009 nicm

Add a "back to indentation" key in copy mode to move the cursor to the first
non-whitespace character. ^ with vi and M-m with emacs key bindings. Another
from Kalle Olavi Niemitalo, thanks.


Revision tags: OPENBSD_4_6_BASE
# 1.5 26-Jun-2009 nicm

Status line fixes: don't truncate status-right now the length calculation is
done for UTF-8, limit to the maximum length correctly when printing, and always
print a space even if the left string is longer than the width available.


# 1.4 04-Jun-2009 nicm

If the prompt is hidden or a password is sent with -U, zero it before freeing
it.


# 1.3 03-Jun-2009 nicm

New session option, status-utf8, to control the interpretation of top-bit-set
characters in status-left and status-right (if on, they are treated as UTF-8;
otherwise passed through).


# 1.2 03-Jun-2009 nicm

Add a UTF-8 aware string length function and make UTF-8 in
status-left/status-right work properly. At the moment any top-bit-set
characters are assumed to be UTF-8: a status-utf8 option to configure this will
come shortly.


# 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.235 09-Sep-2022 nicm

Add message-line option to control where message and prompt go, from
Varun Kumar E in GitHub issue 3324.


# 1.234 30-May-2022 nicm

Remove duplicates from completion list, GitHub issue 3178.


Revision tags: OPENBSD_7_1_BASE
# 1.233 07-Mar-2022 nicm

Pass client when adding menu item, GitHub issue 3103.


# 1.232 03-Feb-2022 nicm

Use format_draw for command prompt prefix to allow styles, GitHub issue
3054.


# 1.231 15-Nov-2021 nicm

Leave the hardware cursor at the position of the selected line in choose
modes and current editing position and at the command prompt. It is
invisible but this is helpful for people using screen readers. GitHub
issue 2970.


# 1.230 01-Nov-2021 nicm

Fix a comparison, from Ben Boeckel, and a crash when opening completion
menu, from Anindya Mukherjee.


# 1.229 26-Oct-2021 nicm

Accept some emacs control keys in vi normal mode, from Alexis
Hildebrandt in GitHub issue 2922.


# 1.228 26-Oct-2021 nicm

Do not allow inline styles to replace mode-style for the selected item,
from Alexis Hildebrandt in GitHub issue 2946.


Revision tags: OPENBSD_7_0_BASE
# 1.227 20-Aug-2021 nicm

Remove stray spaces after function names.


# 1.226 12-Aug-2021 nicm

Use COLOUR_DEFAULT not hardcoded 8.


# 1.225 10-Jun-2021 nicm

More accurate vi(1) word navigation in copy mode and on the status line.
This changes the meaning of the word-separators option - setting it to
the empty string is equivalent to the previous behavior. From Will Noble
in GitHub issue 2693.


# 1.224 10-Jun-2021 nicm

Add different command historys for different types of prompts
("command", "search" etc). From Anindya Mukherjee.


# 1.223 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.222 10-Jun-2021 nicm

Include current client in size calculation for new sessions, GitHub
issue 2662.


Revision tags: OPENBSD_6_9_BASE
# 1.221 12-Apr-2021 nicm

Add a flag to disable keys to close a message, GitHub issue 2625.


# 1.220 22-Feb-2021 nicm

Move jump commands to grid reader, make them UTF-8 aware, and tidy up,
from Anindya Mukherjee.


# 1.219 08-Jan-2021 nicm

With incremental search, start empty and only repeat the previous search
if the user tries to search again with an empty prompt. This matches
emacs behaviour more closely.


Revision tags: OPENBSD_6_8_BASE
# 1.218 27-Jul-2020 nicm

Add a -d option to display-message to set delay, from theonekeyg at
gmail dot com in GitHub issue 2322.


# 1.217 11-Jun-2020 nicm

Fix a crash when completing sessions, from Anindya Mukherjee.


# 1.216 26-May-2020 nicm

Remove leftover debug logging and fix comparison.


# 1.215 26-May-2020 nicm

Set up UTF-8 data for ASCII keys correctly.


# 1.214 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.213 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.212 16-May-2020 nicm

Rename KEYC_ESCAPE to KEYC_META.


# 1.211 16-May-2020 nicm

Expand target from client and use it to expand the prompt.


# 1.210 16-May-2020 nicm

Support embedded styles in the display-message message, GitHub issue
2206.


# 1.209 16-May-2020 nicm

Change message log to be per server rather than per client and include
every command that is run.


# 1.208 16-May-2020 nicm

Do not hoke into struct window_pane from the tty code and instead set
everything up in tty_ctx. Provide a way to initialize the tty_ctx from a
callback and use it to let popups draw directly through input_parse in
the same way as panes do, rather than forcing a full redraw on every
change.


# 1.207 16-May-2020 nicm

Use formats for status-style and message-style.


# 1.206 16-May-2020 nicm

Complete partial window indexes properly.


# 1.205 16-May-2020 nicm

Add -W and -T flags to command-prompt to only complete a window and a
target, also complete aliases.


# 1.204 16-May-2020 nicm

Improve command prompt completion:

- Show a menu with completions if there are multiple.

- Don't complete argument stuff (options, layouts) at start of text.

- For -t and -s, if there is no : then complete sessions but if there is
a :, show a menu of all windows in the session rather than trying to
complete the window name which is a bit useless if there are
duplicates.


# 1.203 16-May-2020 nicm

Drop having a separate type for style options and make them all strings,
which allows formats to be expanded. Any styles without a '#{' are still
validated when they are set but any with a '#{' are not. Formats are not
expanded usefully in many cases yet, that will be changed later.

To make this work, a few other changes:

- set-option -a with a style option automatically appends a ",".

- OSC 10 and 11 don't set the window-style option anymore, instead the
fg and bg are stored in the pane struct and act as the defaults that
can be overridden by window-style.

- status-fg and -bg now override status-style instead of trying to keep
them in sync.


Revision tags: OPENBSD_6_7_BASE
# 1.202 12-Mar-2020 nicm

Add C-g to cancel command prompt with vi(1) keys as well as emacs, and q
in command mode.


# 1.201 27-Jan-2020 nicm

Add support for adding a note to a key binding (with bind-key -N) and
use this to add descriptions to the default key bindings. A new -N flag
to list-keys shows key bindings with notes rather than the default
bind-key command used to create them. Change the default ? binding to
use this to show a readable summary of keys.

Also extend command-prompt to return the name of the key pressed and add
a default binding (/) to show the note for the next key pressed

Suggested by Alex Tremblay in GitHub issue 2000.


Revision tags: OPENBSD_6_6_BASE
# 1.200 28-May-2019 nicm

Redraw status line if size changes, GitHub issue 1762. Also fix length
of target buffer when pasting into status line.


# 1.199 23-May-2019 nicm

Fix length calculation for pasting UTF-8 characters in the status line,
GitHub issue 1753.


# 1.198 11-May-2019 nicm

Do not reduce window height by status line height for control mode
clients, from George Nachman.


# 1.197 03-May-2019 nicm

Fix reverse attribute in status line, GitHub issue 1709.


# 1.196 26-Apr-2019 nicm

Merge hooks into options and make each one an array option. This allows
multiple commands to be easily bound to one hook. set-hook and
show-hooks remain but they are now variants of set-option and
show-options. show-options now has a -H flag to show hooks (by default
they are not shown).


# 1.195 25-Apr-2019 nicm

options_array_item_value cannot return NULL.


# 1.194 23-Apr-2019 nicm

Somehow missed these bits in last commit.


# 1.193 23-Apr-2019 nicm

Indicate an array option with a flag rather than a special type so that
in future will not have to be strings.


Revision tags: OPENBSD_6_5_BASE
# 1.192 18-Mar-2019 nicm

Extend the #[] style syntax and use that together with previous format
changes to allow the status line to be entirely configured with a single
option.

Now that it is possible to configure their content, enable the existing
code that lets the status line be multiple lines in height. The status
option can now take a value of 2, 3, 4 or 5 (as well as the previous on
or off) to configure more than one line. The new status-format array
option configures the format of each line, the default just references
the existing status-* options, although some of the more obscure status
options may be eliminated in time.

Additions to the #[] syntax are: "align" to specify alignment (left,
centre, right), "list" for the window list and "range" to configure
ranges of text for the mouse bindings.

The "align" keyword can also be used to specify alignment of entries in
tree mode and the pane status lines.


# 1.191 18-Mar-2019 nicm

Make array options a sparse tree instead of an array of char * and
remove the size limit.


# 1.190 18-Mar-2019 nicm

With force, kill previous job before starting new. Fixes problem
reported by Scott Mcdermott in GitHub issue 1627.


# 1.189 16-Mar-2019 nicm

Use a pointer for the active screen in the status line instead of
copying them around all the time.


# 1.188 16-Mar-2019 nicm

Give status_save_old the client so it can do the reinit too.


# 1.187 16-Mar-2019 nicm

Tidy and rename some bits of status line code.


# 1.186 15-Mar-2019 nicm

Move status line free into its own function.


# 1.185 14-Mar-2019 nicm

Store the time in the format tree rather than passing it around.


# 1.184 12-Mar-2019 nicm

DECRC and DECSC apparently need to preserve origin mode as well, based
on a fix from Marc Reisner.


# 1.183 09-Feb-2019 nicm

Completion of command-alias members.


# 1.182 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.181 29-Aug-2018 nicm

Keep any text killed in the command prompt with C-w and yank it with
C-y, only use the top buffer if no text has previously been killed. This
and previous change promped by discussion with kn@.


# 1.180 29-Aug-2018 nicm

Add C-Left and C-Right as aliases for M-b and M-f.


# 1.179 22-Aug-2018 nicm

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


# 1.178 20-Aug-2018 nicm

Move offset of window list into status struct.


# 1.177 19-Aug-2018 nicm

Add a client redraw-window flag instead of the redraw-all flag and for
all just use the three flags together (window, borders, status).


Revision tags: OPENBSD_6_3_BASE
# 1.176 22-Feb-2018 nicm

Remove an unused variable.


# 1.175 05-Feb-2018 nicm

Add struct status_line to hold status line members of struct client, not
used yet but will be soon. From Thomas Adam.


# 1.174 01-Jan-2018 nicm

Add C-g at command prompt for emacs people, GitHub issue 1213.


# 1.173 27-Dec-2017 nicm

Draw command prompt correctly with status line off.


# 1.172 18-Dec-2017 nicm

Remove unused variable from Thomas Adam.


# 1.171 02-Nov-2017 nicm

Add a "fast" version of screen_write_copy for tree mode that doesn't do
all the checks and selection and marking stuff needed for copy mode.


# 1.170 20-Oct-2017 nicm

Clear status line with spaces again so reverse works, spotted by sthen.


# 1.169 16-Oct-2017 nicm

Infrastructure for drawing status lines of more than one line in height,
still only one is allowed but this lets tmux draw bigger ones.


Revision tags: OPENBSD_6_2_BASE
# 1.168 29-May-2017 nicm

Add a flag to stop the prompt input being expanded.


# 1.167 29-May-2017 nicm

Store a copy of the old status line, will be needed soon for new choose mode.


# 1.166 17-May-2017 nicm

Tidy command prompt callbacks and pass in the client.


# 1.165 03-May-2017 nicm

Add a format for the last search string in copy mode and fix the prompt
so it can work when in -I, suggested by Suraj N Kurapati.


# 1.164 01-May-2017 nicm

In order that people can use formats like #D in #() in the status line
and not have to wait for an update when they change pane, we allow
commands to run more than once a second if the expanded form
changes. Unfortunately this can mean them being run far too often
(pretty much continually) when multiple clients exist, because some
formats (including #D) will always differ between clients.

To avoid this, give each client its own tree of jobs which means that
the same command will be different instances for each client - similar
to how we have the tag to separate commands for different panes.

GitHub issue 889; test case reported by Paul Johnson.


# 1.163 22-Apr-2017 nicm

Memory leak from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.162 09-Feb-2017 nicm

Break the message storage function into its own function, useful for
debugging.


# 1.161 03-Feb-2017 nicm

Cache status line position to reduce option lookups during output.


# 1.160 03-Feb-2017 nicm

Add a window or pane id "tag" to each format tree and use it to separate
jobs, this means that if the same job is used for different windows or
panes (for example in pane-border-format), it will be run separately for
each pane.


# 1.159 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.158 06-Jan-2017 nicm

Incremental search in copy mode (on for emacs keys by default) - much
the same as normal searching but updates the cursor position and marked
search terms as you type. C-r and C-s in the prompt repeat the search,
once finished searching (with Enter), N and n work as before.


# 1.157 05-Jan-2017 nicm

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


# 1.156 07-Dec-2016 nicm

Do not clear the prompt when a message is shown, just leave it around and
return to it when the message is finished.


# 1.155 12-Oct-2016 nicm

Drop the edit mode key tables and just use fixed key bindings for the
command prompt.


# 1.154 12-Oct-2016 nicm

The repeat prompt in both emacs and vi (and the old one in tmux) doesn't
support line editing and instead executes a command as soon as a
non-number key is pressed. Add a -N flag to command-prompt for the same
in copy mode. Reported by Theo Buehler.


# 1.153 11-Oct-2016 nicm

Fundamental change to how copy mode key bindings work:

The vi-copy and emacs-copy mode key tables are gone, and instead copy
mode commands are bound in one of two normal key tables ("copy-mode" or
"copy-mode-vi"). Keys are bound to "send-keys -X copy-mode-command". So:

bind -temacs-copy C-Up scroll-up
bind -temacs-copy -R5 WheelUpPane scroll-up

Becomes:

bind -Tcopy-mode C-Up send -X scroll-up
bind -Tcopy-mode WheelUpPane send -N5 -X scroll-up

This allows the full command parser and command set to be used - for
example, we can use the normal command prompt for searching, jumping,
and so on instead of a custom one:

bind -Tcopy-mode C-r command-prompt -p'search up' "send -X search-backward '%%'"

command-prompt also gets a -1 option to only require on key press, which
is needed for jumping.

The plan is to get rid of mode keys entirely, so more to come eventually.


# 1.152 11-Oct-2016 nicm

Support UTF-8 entry into the command prompt.


# 1.151 10-Oct-2016 nicm

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


# 1.150 12-Sep-2016 nicm

Allow repeat count to be specified in mode key tables with bind-key -R,
and set the default repeat count to 5 for WheelUp and WheelDown in
copy-mode.


Revision tags: OPENBSD_6_0_BASE
# 1.149 06-Jun-2016 nicm

Allow #[] in window-status-separator.


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

I no longer use my SourceForge address so replace it.


# 1.147 01-Jan-2016 nicm

Don't rely on a calculation wrapping when applying message-limit, and
break out of the loop early. From Nicolas Viennot.


# 1.146 11-Dec-2015 nicm

Style nits and line wrapping of function declarations.


# 1.145 11-Dec-2015 nicm

Add cmdq as an argument to format_create and add a format for the
command name (will also be used for more later).


# 1.144 08-Dec-2015 nicm

Remove format_create_flags and just pass flags to format_create.


# 1.143 22-Nov-2015 tim

If display-time is set to 0, show status messages until a key is pressed;
OK nicm@


# 1.142 20-Nov-2015 nicm

Instead of separate tables for different types of options, give each
option a scope type (server, session, window) in one table.


# 1.141 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.140 13-Nov-2015 nicm

Long overdue change to the way we store cells in the grid: now, instead
of storing a full grid_cell with UTF-8 data and everything, store a new
type grid_cell_entry. This can either be the cell itself (for ASCII
cells), or an offset into an extended array (per line) for UTF-8
data.

This avoid a large (8 byte) overhead on non-UTF-8 cells (by far the
majority for most users) without the complexity of the shadow array we
had before. Grid memory without any UTF-8 is about half.

The disadvantage that cells can no longer be modified in place and need
to be copied out of the grid and back but it turned out to be lot less
complicated than I expected.


# 1.139 12-Nov-2015 nicm

Nuke the utf8 and status-utf8 options and make tmux only a UTF-8
terminal. We still support non-UTF-8 terminals outside tmux, but inside
it is always UTF-8 (as when the utf8 and status-utf8 options were on).


# 1.138 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.137 27-Oct-2015 nicm

Move struct options into options.c.


# 1.136 20-Oct-2015 nicm

Use client pointer not file descriptor in logging.


# 1.135 14-Sep-2015 nicm

Make refresh-client force update of jobs, from Sina Siadat.


# 1.134 29-Aug-2015 nicm

Move struct paste_buffer out of tmux.h.


# 1.133 28-Aug-2015 nicm

Run status update on a per-client timer at status-interval.


Revision tags: OPENBSD_5_8_BASE
# 1.132 29-Jul-2015 nicm

status_out and associated data structures are no longer used.


# 1.131 28-Jul-2015 nicm

Tidy up the way terminals are described and move some structs out of tmux.h.


# 1.130 20-Jul-2015 nicm

Add an option (history-file) for a file to save/restore command prompt
history, from Olof-Joachim Frahm.


# 1.129 27-May-2015 nicm

Move the jobs output cache into the formats code so that #() work more
generally (for example, again working in set-titles-string).


# 1.128 06-May-2015 nicm

Remove ARRAY_* from history and expand completion to complete a) layout
names and b) targets beginning with -t or -s.


# 1.127 25-Apr-2015 nicm

Make message log a TAILQ.


# 1.126 24-Apr-2015 nicm

Set working directory for run-shell and if-shell.


# 1.125 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_7_BASE
# 1.124 06-Feb-2015 nicm

Use the same time for both calls to format_expand_time.


# 1.123 06-Feb-2015 nicm

status_replace can now become local to status.c and it no longer needs
the jobsflag argument. While here there is no need to repeat work that
format_defaults already does.


# 1.122 06-Feb-2015 nicm

Add format_expand_time and use it instead of status_replace where
command execution is not needed.


# 1.121 05-Feb-2015 nicm

Wrap all the individual format_* calls in a single format_defaults
functions.


# 1.120 01-Feb-2015 nicm

Remove two unused arguments from status_replace.


# 1.119 20-Jan-2015 sthen

typo in comment ;) ok nicm


# 1.118 05-Nov-2014 nicm

Do not put a space between status-left/status-right and the window list,
instead move the space into the defaults for the options (so status-left
now defaults to "[#S] ". From Balazs Kezes.


# 1.117 20-Oct-2014 nicm

Better format for printf format attributes.


# 1.116 08-Oct-2014 nicm

Add xreallocarray and remove nmemb argument from xrealloc.


# 1.115 02-Oct-2014 nicm

Take account of window-status-separator when checking window position,
based on diff from Balazs Kezes.


Revision tags: OPENBSD_5_6_BASE
# 1.114 24-Apr-2014 nicm

There is no longer a need for a paste_stack struct or for global_buffers
to be global. Move to paste.c.


# 1.113 17-Apr-2014 nicm

Remove the monitor-content option and associated bits and bobs. It's
never worked very well. If there is a big demand for it to return, will
consider better ways to do it.


# 1.112 02-Apr-2014 nicm

Do not replace ## with # in status_replace1 because it'll be done later
by the format code.


# 1.111 31-Mar-2014 nicm

Make message-limit a server option.


Revision tags: OPENBSD_5_5_BASE
# 1.110 14-Feb-2014 nicm

Style nit - no space between function name and bracket.


# 1.109 14-Feb-2014 nicm

Check for NULL session and whatnot in status_replace, from Thomas Adam.


# 1.108 28-Jan-2014 nicm

Allow replacing each of the many sets of separate foo-{fg,bg,attr}
options with a single foo-style option. For example:

set -g status-fg yellow
set -g status-bg red
set -g status-attr blink

Becomes:

set -g status-style fg=yellow,bg=red,blink

The -a flag to set can be used to add to rather than replace a style. So:

set -g status-bg red

Becomes:

set -ag status-style bg=red

Currently this is fully backwards compatible (all *-{fg,bg,attr} options
remain) but the plan is to deprecate them over time.

From Tiago Cunha.


Revision tags: OPENBSD_5_4_BASE
# 1.107 05-Jul-2013 nicm

Whitespace nits, from Ben Boeckel.


# 1.106 05-Jul-2013 nicm

Act like vi(1) when moving words, from Ben Boeckel.


# 1.105 05-Jul-2013 nicm

Implement s, S, C mode switch commands in vi(1) mode, from Ben Boeckel.


# 1.104 31-May-2013 nicm

Demote the old single-character replacement variables (#S and friends)
to aliases of formats. From Tiago Cunha.


# 1.103 25-Mar-2013 nicm

Extend jobs to support writing and use that for copy-pipe instead of
popen, from Chris Johnsen.


# 1.102 22-Mar-2013 nicm

evbuffer_readline returns allocated storage, don't leak it.


# 1.101 22-Mar-2013 nicm

Add copy-pipe mode command to copy selection and also pipe to a command.


# 1.100 22-Mar-2013 nicm

No more lint means no more ARGSUSED.


# 1.99 21-Mar-2013 nicm

Aargh. Spaces -> tabs.


# 1.98 21-Mar-2013 nicm

Do not leak formats in status_replace.


# 1.97 21-Mar-2013 nicm

Add a format client_prefix which is 1 if prefix key has been
pressed, used for example #{?client_prefix,X,Y}. Also a few extra
server_client_status needed.


# 1.96 21-Mar-2013 nicm

Allow formats in status options.


Revision tags: OPENBSD_5_3_BASE
# 1.95 27-Nov-2012 nicm

Add window-status-last-* options, from Boris Faure.


Revision tags: OPENBSD_5_2_BASE
# 1.94 10-Jul-2012 nicm

xfree is not particularly helpful, remove it. From Thomas Adam.


# 1.93 09-Jul-2012 nicm

Move a NULL check inside a function, from Tiago Cunha.


# 1.92 29-Apr-2012 nicm

Use int not u_char for colours from options since they may have bit 8
set to mark them as 256-colour. Reported by Chris Johnson.


# 1.91 23-Apr-2012 nicm

Add window-status-separator option, from Thomas Adam.


# 1.90 17-Mar-2012 nicm

Check event_initialized before event_del if event may not have been set
up; libevent2 complains about this. Reported by Moriyoshi Koizumi.


# 1.89 04-Mar-2012 nicm

Add A and I keys for vi status line editing.


# 1.88 03-Mar-2012 nicm

The wlmouse offset should be part of the client, not the server. From
Ailin Nemui.


Revision tags: OPENBSD_5_1_BASE
# 1.87 29-Jan-2012 nicm

Add an option to move the status line to the top of the screen,
requested by many.


# 1.86 26-Jan-2012 nicm

Terminate strftime buffer properly even if a really long format string
is given, from Tiago Cunha.


# 1.85 26-Jan-2012 nicm

Fix memory leak in error path, from Tiago Cunha.


# 1.84 20-Jan-2012 nicm

Add some trivial additional status line attributes from jwcxz at users
dot sourceforge dot net.


# 1.83 20-Jan-2012 nicm

Add space movement keys for vi mode in the status line from Ben Boeckel.


# 1.82 01-Dec-2011 nicm

Make M-f and M-b work the same at the command prompt as in copy mode,
pointed out by Romain Francoise.


# 1.81 15-Nov-2011 nicm

Add word movement and editing command for command prompt editing, from
Ben Boeckel.


# 1.80 15-Nov-2011 nicm

Make window_pane_index work the same as window_index, from Ben Boeckel.


# 1.79 05-Nov-2011 nicm

Option to change status line (message) background when using vi keys and
in command mode. From Ben Boeckel.


# 1.78 20-Aug-2011 nicm

Fix a couple of memory leaks, from marcel partap.


Revision tags: OPENBSD_5_0_BASE
# 1.77 08-Jul-2011 nicm

Make confirm-before prompt customizable with -p option like
command-prompt. Also move responsibility for calling status_replace into
status_prompt_{set,update} and add #W and #P to the default kill-window
and kill-pane prompts. By Tiago Cunha.


# 1.76 02-Jul-2011 nicm

Allow the initial context on prompts to be set with the new -I option to
command-prompt. From Tiago Cunha.


# 1.75 29-Apr-2011 nicm

Only redraw the status line on command update, not the entire client
(big DOH).


# 1.74 24-Apr-2011 nicm

Provide #h for short hostname (no domain) from Michal Mazurek.


# 1.73 18-Apr-2011 nicm

Add an option (mouse-select-window) which allows the mouse to be used by
clicking on the status line, written by hsim at gmx dot li.


# 1.72 29-Mar-2011 nicm

Change -t on display-message to be target-pane for the #[A-Z]
replacements and add -c as target-client.


Revision tags: OPENBSD_4_9_BASE
# 1.71 26-Jan-2011 nicm

Simplify the way jobs work and drop the persist type, so all jobs are
fire-and-forget.

Status jobs now managed with two trees of output (new and old), rather
than storing the output in the jobs themselves. When the status line is
processed any jobs which don't appear in the new tree are started and
the output from the old tree displayed. When a job finishes it updates
the new tree with its output and that is used for any subsequent
redraws. When the status interval expires, the new tree is moved to the
old so that all jobs are run again.

This fixes the "#(echo %H:%M:%S)" problem which would lead to thousands
of identical persistent jobs and high memory use (this can still be
achieved by adding "sleep 30" but that is much less likely to happen by
accident).


# 1.70 03-Jan-2011 nicm

Handle a # at the end of a replacement string (such as status-left)
correctly. Found by Thomas Adam.


# 1.69 01-Jan-2011 nicm

Move the user-visible parts of all options (names, types, limit, default
values) together into one set of tables in options-table.c. Also clean
up and simplify cmd-set-options.c and move a common print function into
option-table.c.


# 1.68 30-Dec-2010 nicm

Change from a per-session stack of buffers to one global stack which is
much more convenient and also simplifies lot of code. This renders
copy-buffer useless and makes buffer-limit now a server option.

By Tiago Cunha.


# 1.67 30-Dec-2010 nicm

Add a function to create window flags rather than doing the same thing
in two places. From Thomas Adam.


# 1.66 11-Dec-2010 nicm

Oops, these functions return a const char *, so make the local variable
const as well.


# 1.65 11-Dec-2010 nicm

Make the prompt history global for all clients which is much more useful than per-client history.


# 1.64 06-Dec-2010 nicm

Add an option to alert (monitor) for silence (lack of activity) in a
window. From Thomas Adam.


Revision tags: OPENBSD_4_8_BASE
# 1.63 21-Jun-2010 nicm

Having a list of winlinks->alerts for each session is stupid, just store
the alert flags directly in the winlink itself.


# 1.62 14-May-2010 nicm

Colour+attribute options for status line alerts, from Alex Alexander.


# 1.61 31-Mar-2010 nicm

Don't accept keys with modifiers as input. Fixes crash reported by Brian
R Landy.


# 1.60 27-Mar-2010 nicm

Don't leak job command in #().


# 1.59 22-Mar-2010 nicm

Dead functions, lint.


Revision tags: OPENBSD_4_7_BASE
# 1.58 27-Jan-2010 nicm

Calculate offset correctly, fixes incorrect offset and prevents crash when
status-left is empty. From Micah Cowan.


# 1.57 26-Jan-2010 nicm

Actually use the copy made when no newline is found, from martynas@.


# 1.56 14-Dec-2009 nicm

Add server options to completion as well.


# 1.55 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.54 03-Dec-2009 nicm

Eliminate duplicate code and ease the passage for server-wide options by adding
a -w flag to set-option and show-options and making setw and showw aliases to
set -w and show -w.

Note: setw and showw are still there, but now aliases for set -w and show -w.


# 1.53 26-Nov-2009 nicm

Tidy up various bits of the paste code, make the data buffer char * and add
comments.


# 1.52 26-Nov-2009 nicm

Remove a couple of unused arguments where possible, and add /* ARGSUSED */ to
the rest to reduce lint output.


# 1.51 20-Nov-2009 nicm

Display UTF-8 properly in status line messages and prompt. Cursor handling is
still way off though.


# 1.50 20-Nov-2009 nicm

Remove oldest messages from log when limit is hit, not newest.


# 1.49 19-Nov-2009 nicm

Get some brackets in the right place so ## works. Also fix a space in a
comment.


# 1.48 19-Nov-2009 nicm

Change status line drawing to create the window list in a separate screen and
then copy it into the status line screen. This allows UTF-8 in window names and
fixes some problems with #[] in window-status-format.


# 1.47 19-Nov-2009 nicm

Two new options, window-status-format and window-status-current-format, which
allow the format of each window in the status line window list to be controlled
using similar # sequences as status-left/right.

This diff also moves part of the way towards UTF-8 support in window names but
it isn't quite there yet.


# 1.46 19-Nov-2009 nicm

Tidy up by breaking the # replacement code into a separate function, also add a
few comments.


# 1.45 19-Nov-2009 nicm

Don't interpret #() for display-message, it usually doesn't make sense and may
leak commands.


# 1.44 18-Nov-2009 nicm

Add a per-client log of status line messages displayed while that client
exists. A new message-limit session option sets the maximum number of entries
and a command, show-messages, shows the log (bound to ~ by default).

This (and prompt history) might be better as a single global log but until
there are global options it is easier for them to be per client.


# 1.43 17-Nov-2009 nicm

Permit top-bit-set characters to be entered in the status line. They could
already be set from the shell and are just passed through when printing (so
invisible characters or displaying on terminals with different character sets
may cause problems).

Note that entering UTF-8 may not work and in any case currently the status line
cannot display it correctly (outside of status-left/status-right).


# 1.42 04-Nov-2009 nicm

Use timeout events for the identify and message timers.


# 1.41 04-Nov-2009 nicm

Switch jobs over to use a bufferevent.


# 1.40 04-Nov-2009 nicm

Unused (but assigned to) variable, found by lint.


# 1.39 01-Nov-2009 nicm

Add a flag for jobs that shouldn't be freed after they've died and use it for
status jobs, then only kill those jobs when status-left, status-right or
set-titles-string is changed.

Fixes problems with changing options from inside #().


# 1.38 10-Oct-2009 nicm

Rather than running status-left, status-right and window title #() with popen
immediately every redraw, queue them up and run them in the background,
starting each once every status-interval. The actual status line uses the
output from the last run.

This brings several advantages:

- tmux itself may be called from inside #() without causing the server to hang;
- likewise, sleep or similar doesn't cause the server to block;
- commands aren't run excessively often when redrawing;
- commands shared by status-left and status-right, or used multiple times, will
only be run once.

run-shell and if-shell still use system()/popen() but will be changed over to
use this too later.


# 1.37 10-Oct-2009 nicm

Add "grouped sessions" which have independent name, options, current window and
so on but where the linked windows are synchronized (ie creating, killing
windows and so on are mirrored between the sessions). A grouped session may be
created by passing -t to new-session.

Had this around for a while, tested by a couple of people.


# 1.36 23-Sep-2009 nicm

Remove PROMPT_HIDDEN code which is now unused.


# 1.35 23-Sep-2009 nicm

Remove the internal tmux locking and instead detach each client and run the
command specified by a new option "lock-command" (by default "lock -np") in
each client.

This means each terminal has to be unlocked individually but simplifies the
code and allows the system password to be used to unlock.

Note that the set-password command is gone, so it will need to be removed from
configuration files, and the -U command line flag has been removed.

This is the third protocol version change so again it is best to stop the tmux
server before upgrading.


# 1.34 20-Sep-2009 nicm

Regularise some fatal messages.


# 1.33 10-Sep-2009 nicm

Permit options such as status-bg to be configured using the entire 256 colour
palette by setting "colour0" to "colour255".


# 1.32 07-Sep-2009 nicm

Give each paste buffer a size member instead of requiring them to be
zero-terminated.


# 1.31 07-Sep-2009 nicm

Permit embedded colour and attributes in status-left and status-right using new
#[] special characters, for example #[fg=red,bg=blue,blink].


# 1.30 02-Sep-2009 nicm

Add a transpose-chars command in edit mode (C-t in emacs mode only). From Kalle
Olavi Niemitalo.


# 1.29 01-Sep-2009 nicm

Use "Password:" with no space for password prompts and don't display a *s for
the password, like pretty much everything else. From martynas@ with minor
tweaks by me.


# 1.28 31-Aug-2009 nicm

Add a new display-panes command, with two options (display-panes-colour and
display-panes-time), which displays a visual indication of the number of each
pane.


# 1.27 19-Aug-2009 nicm

Extend command-prompt with a -p option which is a comma-separated list of one
or more prompts to present in order.

The responses to the prompt are replaced in the template string: %% are
replaced in order, so the first prompt replaces the first %%, the second
replaces the second, and so on. In addition, %1 up to %9 are replaced with the
responses to the first the ninth prompts

The default template is "%1" so the response to the first prompt is processed
as a command.

Note that this changes the behaviour for %% so if there is only one prompt,
only the first %% will be replaced. Templates such as "neww -n '%%' 'ssh %%'"
should be changed to "neww -n '%1' 'ssh %1'".

From Tiago Cunha.


# 1.26 18-Aug-2009 nicm

Add a "delete line" key when editing in the status line or the search up/down
prompt. C-u with emacs keys, d with vi.


# 1.25 13-Aug-2009 nicm

Switch the prompt code to return an empty string when the user enters no
response and reserve NULL for an explicit cancel. Change all callbacks to treat
them the same so no functional change.

Also add cancel key bindings to emacs mode which were missing.


# 1.24 08-Aug-2009 nicm

Options to set the colours and attributes for status-left/-right. From Thomas
Adam, thanks.


# 1.23 05-Aug-2009 nicm

If colours are not supported by the terminal, try to emulate a coloured
background by setting or clearing the reverse attribute.

This makes a few applications which don't use the reverse attribute themselves
a little happier, and allows the status, message and mode options to have
default attributes and fg/bg options that work as expected when set as reverse.


# 1.22 30-Jul-2009 nicm

Plug some memory leaks.


# 1.21 28-Jul-2009 nicm

Next step towards customisable mode keys: build each default table of keys into
a named tree on start and use that for lookups. Also add command to string
translation tables and modify list-keys to show the the mode key bindings (new
-t argument).


# 1.20 27-Jul-2009 nicm

Change mode key bindings from big switches into a set of tables. Rather than
lumping them all together, split editing keys from those used in choice/more
mode and those for copy/scroll mode.

Tidier and clearer, and the first step towards customisable mode keys.


# 1.19 27-Jul-2009 nicm

Get rid of empty mode_key_free function.


# 1.18 27-Jul-2009 nicm

Add a key to delete to end of line at the prompt (^K in emacs mode, C/D in vi).

From Kalle Olavi Niemitalo.


# 1.17 26-Jul-2009 nicm

Calculate the space available for the prompt buffer and the cursor position
correctly, and make it work when the screen is not wide enough.

Noticed by Kalle Olavi Niemitalo.


# 1.16 21-Jul-2009 nicm

Remove a couple of unused functions and fix a type ("FALLTHOUGH"), found by
lint.


# 1.15 20-Jul-2009 nicm

Add a status-justify option to allow the window list in the status line to be
positioned at the left, centre, or right.


# 1.14 20-Jul-2009 nicm

New options, window-status-current-{fg,bg,attr}, to set the fg, bg and
attributes with which the current window is shown in the status line. From
Johan Friis, thanks.


# 1.13 17-Jul-2009 nicm

- New command display-message (alias display) to display a message in the
status line (bound to "i" and displays the current window and time by
default). The same substitutions are applied as for status-left/right.
- Add support for including the window index (#I), pane index (#P) and window
name (#W) in the message, and status-left or status-right.
- Bump protocol version.

From Tiago Cunha, thanks!


# 1.12 17-Jul-2009 nicm

Memory could be leaked if a second prompt or message appeared while another was
still present, so add a separate prompt free callback and make the _clear
function responsible for calling it if necessary (rather than the individual
prompt callbacks). Also make both messages and prompts clear any existing when
a new is set.

In addition, the screen could be modified while the prompt is there, restore
the redraw-entire-screen behaviour on prompt clear; add a comment as a
reminder.


# 1.11 16-Jul-2009 nicm

Remove some duplicate code that was causing the status line to be redrawn even
when it hadn't changed.


# 1.10 15-Jul-2009 nicm

Make status_message_set a variadic printf-like function. No functional change -
helpful for a couple of things coming soon.


# 1.9 15-Jul-2009 nicm

Having to update NSETOPTION/NSETWINDOWOPTION when adding new options is a bit
annoying and it is only use for iterating, so use a sentinel to mark the end of
each array instead. Different fix for a problem pointed out by Kalle Olavi
Niemitalo.


# 1.8 14-Jul-2009 nicm

For some reason when clearing status/message it was redrawing the entire client
not just the status line. Changing this also revealed the check for the status
line was incorrect when drawing the pane.


# 1.7 14-Jul-2009 nicm

Instead of faking up a status line in status_redraw, use the same code to
redraw it as to draw the entire screen, just skip all lines but the last.

This makes horizontal split redraw properly when the status line is off.


# 1.6 12-Jul-2009 nicm

Add a "back to indentation" key in copy mode to move the cursor to the first
non-whitespace character. ^ with vi and M-m with emacs key bindings. Another
from Kalle Olavi Niemitalo, thanks.


Revision tags: OPENBSD_4_6_BASE
# 1.5 26-Jun-2009 nicm

Status line fixes: don't truncate status-right now the length calculation is
done for UTF-8, limit to the maximum length correctly when printing, and always
print a space even if the left string is longer than the width available.


# 1.4 04-Jun-2009 nicm

If the prompt is hidden or a password is sent with -U, zero it before freeing
it.


# 1.3 03-Jun-2009 nicm

New session option, status-utf8, to control the interpretation of top-bit-set
characters in status-left and status-right (if on, they are treated as UTF-8;
otherwise passed through).


# 1.2 03-Jun-2009 nicm

Add a UTF-8 aware string length function and make UTF-8 in
status-left/status-right work properly. At the moment any top-bit-set
characters are assumed to be UTF-8: a status-utf8 option to configure this will
come shortly.


# 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.234 30-May-2022 nicm

Remove duplicates from completion list, GitHub issue 3178.


Revision tags: OPENBSD_7_1_BASE
# 1.233 07-Mar-2022 nicm

Pass client when adding menu item, GitHub issue 3103.


# 1.232 03-Feb-2022 nicm

Use format_draw for command prompt prefix to allow styles, GitHub issue
3054.


# 1.231 15-Nov-2021 nicm

Leave the hardware cursor at the position of the selected line in choose
modes and current editing position and at the command prompt. It is
invisible but this is helpful for people using screen readers. GitHub
issue 2970.


# 1.230 01-Nov-2021 nicm

Fix a comparison, from Ben Boeckel, and a crash when opening completion
menu, from Anindya Mukherjee.


# 1.229 26-Oct-2021 nicm

Accept some emacs control keys in vi normal mode, from Alexis
Hildebrandt in GitHub issue 2922.


# 1.228 26-Oct-2021 nicm

Do not allow inline styles to replace mode-style for the selected item,
from Alexis Hildebrandt in GitHub issue 2946.


Revision tags: OPENBSD_7_0_BASE
# 1.227 20-Aug-2021 nicm

Remove stray spaces after function names.


# 1.226 12-Aug-2021 nicm

Use COLOUR_DEFAULT not hardcoded 8.


# 1.225 10-Jun-2021 nicm

More accurate vi(1) word navigation in copy mode and on the status line.
This changes the meaning of the word-separators option - setting it to
the empty string is equivalent to the previous behavior. From Will Noble
in GitHub issue 2693.


# 1.224 10-Jun-2021 nicm

Add different command historys for different types of prompts
("command", "search" etc). From Anindya Mukherjee.


# 1.223 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.222 10-Jun-2021 nicm

Include current client in size calculation for new sessions, GitHub
issue 2662.


Revision tags: OPENBSD_6_9_BASE
# 1.221 12-Apr-2021 nicm

Add a flag to disable keys to close a message, GitHub issue 2625.


# 1.220 22-Feb-2021 nicm

Move jump commands to grid reader, make them UTF-8 aware, and tidy up,
from Anindya Mukherjee.


# 1.219 08-Jan-2021 nicm

With incremental search, start empty and only repeat the previous search
if the user tries to search again with an empty prompt. This matches
emacs behaviour more closely.


Revision tags: OPENBSD_6_8_BASE
# 1.218 27-Jul-2020 nicm

Add a -d option to display-message to set delay, from theonekeyg at
gmail dot com in GitHub issue 2322.


# 1.217 11-Jun-2020 nicm

Fix a crash when completing sessions, from Anindya Mukherjee.


# 1.216 26-May-2020 nicm

Remove leftover debug logging and fix comparison.


# 1.215 26-May-2020 nicm

Set up UTF-8 data for ASCII keys correctly.


# 1.214 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.213 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.212 16-May-2020 nicm

Rename KEYC_ESCAPE to KEYC_META.


# 1.211 16-May-2020 nicm

Expand target from client and use it to expand the prompt.


# 1.210 16-May-2020 nicm

Support embedded styles in the display-message message, GitHub issue
2206.


# 1.209 16-May-2020 nicm

Change message log to be per server rather than per client and include
every command that is run.


# 1.208 16-May-2020 nicm

Do not hoke into struct window_pane from the tty code and instead set
everything up in tty_ctx. Provide a way to initialize the tty_ctx from a
callback and use it to let popups draw directly through input_parse in
the same way as panes do, rather than forcing a full redraw on every
change.


# 1.207 16-May-2020 nicm

Use formats for status-style and message-style.


# 1.206 16-May-2020 nicm

Complete partial window indexes properly.


# 1.205 16-May-2020 nicm

Add -W and -T flags to command-prompt to only complete a window and a
target, also complete aliases.


# 1.204 16-May-2020 nicm

Improve command prompt completion:

- Show a menu with completions if there are multiple.

- Don't complete argument stuff (options, layouts) at start of text.

- For -t and -s, if there is no : then complete sessions but if there is
a :, show a menu of all windows in the session rather than trying to
complete the window name which is a bit useless if there are
duplicates.


# 1.203 16-May-2020 nicm

Drop having a separate type for style options and make them all strings,
which allows formats to be expanded. Any styles without a '#{' are still
validated when they are set but any with a '#{' are not. Formats are not
expanded usefully in many cases yet, that will be changed later.

To make this work, a few other changes:

- set-option -a with a style option automatically appends a ",".

- OSC 10 and 11 don't set the window-style option anymore, instead the
fg and bg are stored in the pane struct and act as the defaults that
can be overridden by window-style.

- status-fg and -bg now override status-style instead of trying to keep
them in sync.


Revision tags: OPENBSD_6_7_BASE
# 1.202 12-Mar-2020 nicm

Add C-g to cancel command prompt with vi(1) keys as well as emacs, and q
in command mode.


# 1.201 27-Jan-2020 nicm

Add support for adding a note to a key binding (with bind-key -N) and
use this to add descriptions to the default key bindings. A new -N flag
to list-keys shows key bindings with notes rather than the default
bind-key command used to create them. Change the default ? binding to
use this to show a readable summary of keys.

Also extend command-prompt to return the name of the key pressed and add
a default binding (/) to show the note for the next key pressed

Suggested by Alex Tremblay in GitHub issue 2000.


Revision tags: OPENBSD_6_6_BASE
# 1.200 28-May-2019 nicm

Redraw status line if size changes, GitHub issue 1762. Also fix length
of target buffer when pasting into status line.


# 1.199 23-May-2019 nicm

Fix length calculation for pasting UTF-8 characters in the status line,
GitHub issue 1753.


# 1.198 11-May-2019 nicm

Do not reduce window height by status line height for control mode
clients, from George Nachman.


# 1.197 03-May-2019 nicm

Fix reverse attribute in status line, GitHub issue 1709.


# 1.196 26-Apr-2019 nicm

Merge hooks into options and make each one an array option. This allows
multiple commands to be easily bound to one hook. set-hook and
show-hooks remain but they are now variants of set-option and
show-options. show-options now has a -H flag to show hooks (by default
they are not shown).


# 1.195 25-Apr-2019 nicm

options_array_item_value cannot return NULL.


# 1.194 23-Apr-2019 nicm

Somehow missed these bits in last commit.


# 1.193 23-Apr-2019 nicm

Indicate an array option with a flag rather than a special type so that
in future will not have to be strings.


Revision tags: OPENBSD_6_5_BASE
# 1.192 18-Mar-2019 nicm

Extend the #[] style syntax and use that together with previous format
changes to allow the status line to be entirely configured with a single
option.

Now that it is possible to configure their content, enable the existing
code that lets the status line be multiple lines in height. The status
option can now take a value of 2, 3, 4 or 5 (as well as the previous on
or off) to configure more than one line. The new status-format array
option configures the format of each line, the default just references
the existing status-* options, although some of the more obscure status
options may be eliminated in time.

Additions to the #[] syntax are: "align" to specify alignment (left,
centre, right), "list" for the window list and "range" to configure
ranges of text for the mouse bindings.

The "align" keyword can also be used to specify alignment of entries in
tree mode and the pane status lines.


# 1.191 18-Mar-2019 nicm

Make array options a sparse tree instead of an array of char * and
remove the size limit.


# 1.190 18-Mar-2019 nicm

With force, kill previous job before starting new. Fixes problem
reported by Scott Mcdermott in GitHub issue 1627.


# 1.189 16-Mar-2019 nicm

Use a pointer for the active screen in the status line instead of
copying them around all the time.


# 1.188 16-Mar-2019 nicm

Give status_save_old the client so it can do the reinit too.


# 1.187 16-Mar-2019 nicm

Tidy and rename some bits of status line code.


# 1.186 15-Mar-2019 nicm

Move status line free into its own function.


# 1.185 14-Mar-2019 nicm

Store the time in the format tree rather than passing it around.


# 1.184 12-Mar-2019 nicm

DECRC and DECSC apparently need to preserve origin mode as well, based
on a fix from Marc Reisner.


# 1.183 09-Feb-2019 nicm

Completion of command-alias members.


# 1.182 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.181 29-Aug-2018 nicm

Keep any text killed in the command prompt with C-w and yank it with
C-y, only use the top buffer if no text has previously been killed. This
and previous change promped by discussion with kn@.


# 1.180 29-Aug-2018 nicm

Add C-Left and C-Right as aliases for M-b and M-f.


# 1.179 22-Aug-2018 nicm

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


# 1.178 20-Aug-2018 nicm

Move offset of window list into status struct.


# 1.177 19-Aug-2018 nicm

Add a client redraw-window flag instead of the redraw-all flag and for
all just use the three flags together (window, borders, status).


Revision tags: OPENBSD_6_3_BASE
# 1.176 22-Feb-2018 nicm

Remove an unused variable.


# 1.175 05-Feb-2018 nicm

Add struct status_line to hold status line members of struct client, not
used yet but will be soon. From Thomas Adam.


# 1.174 01-Jan-2018 nicm

Add C-g at command prompt for emacs people, GitHub issue 1213.


# 1.173 27-Dec-2017 nicm

Draw command prompt correctly with status line off.


# 1.172 18-Dec-2017 nicm

Remove unused variable from Thomas Adam.


# 1.171 02-Nov-2017 nicm

Add a "fast" version of screen_write_copy for tree mode that doesn't do
all the checks and selection and marking stuff needed for copy mode.


# 1.170 20-Oct-2017 nicm

Clear status line with spaces again so reverse works, spotted by sthen.


# 1.169 16-Oct-2017 nicm

Infrastructure for drawing status lines of more than one line in height,
still only one is allowed but this lets tmux draw bigger ones.


Revision tags: OPENBSD_6_2_BASE
# 1.168 29-May-2017 nicm

Add a flag to stop the prompt input being expanded.


# 1.167 29-May-2017 nicm

Store a copy of the old status line, will be needed soon for new choose mode.


# 1.166 17-May-2017 nicm

Tidy command prompt callbacks and pass in the client.


# 1.165 03-May-2017 nicm

Add a format for the last search string in copy mode and fix the prompt
so it can work when in -I, suggested by Suraj N Kurapati.


# 1.164 01-May-2017 nicm

In order that people can use formats like #D in #() in the status line
and not have to wait for an update when they change pane, we allow
commands to run more than once a second if the expanded form
changes. Unfortunately this can mean them being run far too often
(pretty much continually) when multiple clients exist, because some
formats (including #D) will always differ between clients.

To avoid this, give each client its own tree of jobs which means that
the same command will be different instances for each client - similar
to how we have the tag to separate commands for different panes.

GitHub issue 889; test case reported by Paul Johnson.


# 1.163 22-Apr-2017 nicm

Memory leak from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.162 09-Feb-2017 nicm

Break the message storage function into its own function, useful for
debugging.


# 1.161 03-Feb-2017 nicm

Cache status line position to reduce option lookups during output.


# 1.160 03-Feb-2017 nicm

Add a window or pane id "tag" to each format tree and use it to separate
jobs, this means that if the same job is used for different windows or
panes (for example in pane-border-format), it will be run separately for
each pane.


# 1.159 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.158 06-Jan-2017 nicm

Incremental search in copy mode (on for emacs keys by default) - much
the same as normal searching but updates the cursor position and marked
search terms as you type. C-r and C-s in the prompt repeat the search,
once finished searching (with Enter), N and n work as before.


# 1.157 05-Jan-2017 nicm

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


# 1.156 07-Dec-2016 nicm

Do not clear the prompt when a message is shown, just leave it around and
return to it when the message is finished.


# 1.155 12-Oct-2016 nicm

Drop the edit mode key tables and just use fixed key bindings for the
command prompt.


# 1.154 12-Oct-2016 nicm

The repeat prompt in both emacs and vi (and the old one in tmux) doesn't
support line editing and instead executes a command as soon as a
non-number key is pressed. Add a -N flag to command-prompt for the same
in copy mode. Reported by Theo Buehler.


# 1.153 11-Oct-2016 nicm

Fundamental change to how copy mode key bindings work:

The vi-copy and emacs-copy mode key tables are gone, and instead copy
mode commands are bound in one of two normal key tables ("copy-mode" or
"copy-mode-vi"). Keys are bound to "send-keys -X copy-mode-command". So:

bind -temacs-copy C-Up scroll-up
bind -temacs-copy -R5 WheelUpPane scroll-up

Becomes:

bind -Tcopy-mode C-Up send -X scroll-up
bind -Tcopy-mode WheelUpPane send -N5 -X scroll-up

This allows the full command parser and command set to be used - for
example, we can use the normal command prompt for searching, jumping,
and so on instead of a custom one:

bind -Tcopy-mode C-r command-prompt -p'search up' "send -X search-backward '%%'"

command-prompt also gets a -1 option to only require on key press, which
is needed for jumping.

The plan is to get rid of mode keys entirely, so more to come eventually.


# 1.152 11-Oct-2016 nicm

Support UTF-8 entry into the command prompt.


# 1.151 10-Oct-2016 nicm

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


# 1.150 12-Sep-2016 nicm

Allow repeat count to be specified in mode key tables with bind-key -R,
and set the default repeat count to 5 for WheelUp and WheelDown in
copy-mode.


Revision tags: OPENBSD_6_0_BASE
# 1.149 06-Jun-2016 nicm

Allow #[] in window-status-separator.


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

I no longer use my SourceForge address so replace it.


# 1.147 01-Jan-2016 nicm

Don't rely on a calculation wrapping when applying message-limit, and
break out of the loop early. From Nicolas Viennot.


# 1.146 11-Dec-2015 nicm

Style nits and line wrapping of function declarations.


# 1.145 11-Dec-2015 nicm

Add cmdq as an argument to format_create and add a format for the
command name (will also be used for more later).


# 1.144 08-Dec-2015 nicm

Remove format_create_flags and just pass flags to format_create.


# 1.143 22-Nov-2015 tim

If display-time is set to 0, show status messages until a key is pressed;
OK nicm@


# 1.142 20-Nov-2015 nicm

Instead of separate tables for different types of options, give each
option a scope type (server, session, window) in one table.


# 1.141 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.140 13-Nov-2015 nicm

Long overdue change to the way we store cells in the grid: now, instead
of storing a full grid_cell with UTF-8 data and everything, store a new
type grid_cell_entry. This can either be the cell itself (for ASCII
cells), or an offset into an extended array (per line) for UTF-8
data.

This avoid a large (8 byte) overhead on non-UTF-8 cells (by far the
majority for most users) without the complexity of the shadow array we
had before. Grid memory without any UTF-8 is about half.

The disadvantage that cells can no longer be modified in place and need
to be copied out of the grid and back but it turned out to be lot less
complicated than I expected.


# 1.139 12-Nov-2015 nicm

Nuke the utf8 and status-utf8 options and make tmux only a UTF-8
terminal. We still support non-UTF-8 terminals outside tmux, but inside
it is always UTF-8 (as when the utf8 and status-utf8 options were on).


# 1.138 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.137 27-Oct-2015 nicm

Move struct options into options.c.


# 1.136 20-Oct-2015 nicm

Use client pointer not file descriptor in logging.


# 1.135 14-Sep-2015 nicm

Make refresh-client force update of jobs, from Sina Siadat.


# 1.134 29-Aug-2015 nicm

Move struct paste_buffer out of tmux.h.


# 1.133 28-Aug-2015 nicm

Run status update on a per-client timer at status-interval.


Revision tags: OPENBSD_5_8_BASE
# 1.132 29-Jul-2015 nicm

status_out and associated data structures are no longer used.


# 1.131 28-Jul-2015 nicm

Tidy up the way terminals are described and move some structs out of tmux.h.


# 1.130 20-Jul-2015 nicm

Add an option (history-file) for a file to save/restore command prompt
history, from Olof-Joachim Frahm.


# 1.129 27-May-2015 nicm

Move the jobs output cache into the formats code so that #() work more
generally (for example, again working in set-titles-string).


# 1.128 06-May-2015 nicm

Remove ARRAY_* from history and expand completion to complete a) layout
names and b) targets beginning with -t or -s.


# 1.127 25-Apr-2015 nicm

Make message log a TAILQ.


# 1.126 24-Apr-2015 nicm

Set working directory for run-shell and if-shell.


# 1.125 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_7_BASE
# 1.124 06-Feb-2015 nicm

Use the same time for both calls to format_expand_time.


# 1.123 06-Feb-2015 nicm

status_replace can now become local to status.c and it no longer needs
the jobsflag argument. While here there is no need to repeat work that
format_defaults already does.


# 1.122 06-Feb-2015 nicm

Add format_expand_time and use it instead of status_replace where
command execution is not needed.


# 1.121 05-Feb-2015 nicm

Wrap all the individual format_* calls in a single format_defaults
functions.


# 1.120 01-Feb-2015 nicm

Remove two unused arguments from status_replace.


# 1.119 20-Jan-2015 sthen

typo in comment ;) ok nicm


# 1.118 05-Nov-2014 nicm

Do not put a space between status-left/status-right and the window list,
instead move the space into the defaults for the options (so status-left
now defaults to "[#S] ". From Balazs Kezes.


# 1.117 20-Oct-2014 nicm

Better format for printf format attributes.


# 1.116 08-Oct-2014 nicm

Add xreallocarray and remove nmemb argument from xrealloc.


# 1.115 02-Oct-2014 nicm

Take account of window-status-separator when checking window position,
based on diff from Balazs Kezes.


Revision tags: OPENBSD_5_6_BASE
# 1.114 24-Apr-2014 nicm

There is no longer a need for a paste_stack struct or for global_buffers
to be global. Move to paste.c.


# 1.113 17-Apr-2014 nicm

Remove the monitor-content option and associated bits and bobs. It's
never worked very well. If there is a big demand for it to return, will
consider better ways to do it.


# 1.112 02-Apr-2014 nicm

Do not replace ## with # in status_replace1 because it'll be done later
by the format code.


# 1.111 31-Mar-2014 nicm

Make message-limit a server option.


Revision tags: OPENBSD_5_5_BASE
# 1.110 14-Feb-2014 nicm

Style nit - no space between function name and bracket.


# 1.109 14-Feb-2014 nicm

Check for NULL session and whatnot in status_replace, from Thomas Adam.


# 1.108 28-Jan-2014 nicm

Allow replacing each of the many sets of separate foo-{fg,bg,attr}
options with a single foo-style option. For example:

set -g status-fg yellow
set -g status-bg red
set -g status-attr blink

Becomes:

set -g status-style fg=yellow,bg=red,blink

The -a flag to set can be used to add to rather than replace a style. So:

set -g status-bg red

Becomes:

set -ag status-style bg=red

Currently this is fully backwards compatible (all *-{fg,bg,attr} options
remain) but the plan is to deprecate them over time.

From Tiago Cunha.


Revision tags: OPENBSD_5_4_BASE
# 1.107 05-Jul-2013 nicm

Whitespace nits, from Ben Boeckel.


# 1.106 05-Jul-2013 nicm

Act like vi(1) when moving words, from Ben Boeckel.


# 1.105 05-Jul-2013 nicm

Implement s, S, C mode switch commands in vi(1) mode, from Ben Boeckel.


# 1.104 31-May-2013 nicm

Demote the old single-character replacement variables (#S and friends)
to aliases of formats. From Tiago Cunha.


# 1.103 25-Mar-2013 nicm

Extend jobs to support writing and use that for copy-pipe instead of
popen, from Chris Johnsen.


# 1.102 22-Mar-2013 nicm

evbuffer_readline returns allocated storage, don't leak it.


# 1.101 22-Mar-2013 nicm

Add copy-pipe mode command to copy selection and also pipe to a command.


# 1.100 22-Mar-2013 nicm

No more lint means no more ARGSUSED.


# 1.99 21-Mar-2013 nicm

Aargh. Spaces -> tabs.


# 1.98 21-Mar-2013 nicm

Do not leak formats in status_replace.


# 1.97 21-Mar-2013 nicm

Add a format client_prefix which is 1 if prefix key has been
pressed, used for example #{?client_prefix,X,Y}. Also a few extra
server_client_status needed.


# 1.96 21-Mar-2013 nicm

Allow formats in status options.


Revision tags: OPENBSD_5_3_BASE
# 1.95 27-Nov-2012 nicm

Add window-status-last-* options, from Boris Faure.


Revision tags: OPENBSD_5_2_BASE
# 1.94 10-Jul-2012 nicm

xfree is not particularly helpful, remove it. From Thomas Adam.


# 1.93 09-Jul-2012 nicm

Move a NULL check inside a function, from Tiago Cunha.


# 1.92 29-Apr-2012 nicm

Use int not u_char for colours from options since they may have bit 8
set to mark them as 256-colour. Reported by Chris Johnson.


# 1.91 23-Apr-2012 nicm

Add window-status-separator option, from Thomas Adam.


# 1.90 17-Mar-2012 nicm

Check event_initialized before event_del if event may not have been set
up; libevent2 complains about this. Reported by Moriyoshi Koizumi.


# 1.89 04-Mar-2012 nicm

Add A and I keys for vi status line editing.


# 1.88 03-Mar-2012 nicm

The wlmouse offset should be part of the client, not the server. From
Ailin Nemui.


Revision tags: OPENBSD_5_1_BASE
# 1.87 29-Jan-2012 nicm

Add an option to move the status line to the top of the screen,
requested by many.


# 1.86 26-Jan-2012 nicm

Terminate strftime buffer properly even if a really long format string
is given, from Tiago Cunha.


# 1.85 26-Jan-2012 nicm

Fix memory leak in error path, from Tiago Cunha.


# 1.84 20-Jan-2012 nicm

Add some trivial additional status line attributes from jwcxz at users
dot sourceforge dot net.


# 1.83 20-Jan-2012 nicm

Add space movement keys for vi mode in the status line from Ben Boeckel.


# 1.82 01-Dec-2011 nicm

Make M-f and M-b work the same at the command prompt as in copy mode,
pointed out by Romain Francoise.


# 1.81 15-Nov-2011 nicm

Add word movement and editing command for command prompt editing, from
Ben Boeckel.


# 1.80 15-Nov-2011 nicm

Make window_pane_index work the same as window_index, from Ben Boeckel.


# 1.79 05-Nov-2011 nicm

Option to change status line (message) background when using vi keys and
in command mode. From Ben Boeckel.


# 1.78 20-Aug-2011 nicm

Fix a couple of memory leaks, from marcel partap.


Revision tags: OPENBSD_5_0_BASE
# 1.77 08-Jul-2011 nicm

Make confirm-before prompt customizable with -p option like
command-prompt. Also move responsibility for calling status_replace into
status_prompt_{set,update} and add #W and #P to the default kill-window
and kill-pane prompts. By Tiago Cunha.


# 1.76 02-Jul-2011 nicm

Allow the initial context on prompts to be set with the new -I option to
command-prompt. From Tiago Cunha.


# 1.75 29-Apr-2011 nicm

Only redraw the status line on command update, not the entire client
(big DOH).


# 1.74 24-Apr-2011 nicm

Provide #h for short hostname (no domain) from Michal Mazurek.


# 1.73 18-Apr-2011 nicm

Add an option (mouse-select-window) which allows the mouse to be used by
clicking on the status line, written by hsim at gmx dot li.


# 1.72 29-Mar-2011 nicm

Change -t on display-message to be target-pane for the #[A-Z]
replacements and add -c as target-client.


Revision tags: OPENBSD_4_9_BASE
# 1.71 26-Jan-2011 nicm

Simplify the way jobs work and drop the persist type, so all jobs are
fire-and-forget.

Status jobs now managed with two trees of output (new and old), rather
than storing the output in the jobs themselves. When the status line is
processed any jobs which don't appear in the new tree are started and
the output from the old tree displayed. When a job finishes it updates
the new tree with its output and that is used for any subsequent
redraws. When the status interval expires, the new tree is moved to the
old so that all jobs are run again.

This fixes the "#(echo %H:%M:%S)" problem which would lead to thousands
of identical persistent jobs and high memory use (this can still be
achieved by adding "sleep 30" but that is much less likely to happen by
accident).


# 1.70 03-Jan-2011 nicm

Handle a # at the end of a replacement string (such as status-left)
correctly. Found by Thomas Adam.


# 1.69 01-Jan-2011 nicm

Move the user-visible parts of all options (names, types, limit, default
values) together into one set of tables in options-table.c. Also clean
up and simplify cmd-set-options.c and move a common print function into
option-table.c.


# 1.68 30-Dec-2010 nicm

Change from a per-session stack of buffers to one global stack which is
much more convenient and also simplifies lot of code. This renders
copy-buffer useless and makes buffer-limit now a server option.

By Tiago Cunha.


# 1.67 30-Dec-2010 nicm

Add a function to create window flags rather than doing the same thing
in two places. From Thomas Adam.


# 1.66 11-Dec-2010 nicm

Oops, these functions return a const char *, so make the local variable
const as well.


# 1.65 11-Dec-2010 nicm

Make the prompt history global for all clients which is much more useful than per-client history.


# 1.64 06-Dec-2010 nicm

Add an option to alert (monitor) for silence (lack of activity) in a
window. From Thomas Adam.


Revision tags: OPENBSD_4_8_BASE
# 1.63 21-Jun-2010 nicm

Having a list of winlinks->alerts for each session is stupid, just store
the alert flags directly in the winlink itself.


# 1.62 14-May-2010 nicm

Colour+attribute options for status line alerts, from Alex Alexander.


# 1.61 31-Mar-2010 nicm

Don't accept keys with modifiers as input. Fixes crash reported by Brian
R Landy.


# 1.60 27-Mar-2010 nicm

Don't leak job command in #().


# 1.59 22-Mar-2010 nicm

Dead functions, lint.


Revision tags: OPENBSD_4_7_BASE
# 1.58 27-Jan-2010 nicm

Calculate offset correctly, fixes incorrect offset and prevents crash when
status-left is empty. From Micah Cowan.


# 1.57 26-Jan-2010 nicm

Actually use the copy made when no newline is found, from martynas@.


# 1.56 14-Dec-2009 nicm

Add server options to completion as well.


# 1.55 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.54 03-Dec-2009 nicm

Eliminate duplicate code and ease the passage for server-wide options by adding
a -w flag to set-option and show-options and making setw and showw aliases to
set -w and show -w.

Note: setw and showw are still there, but now aliases for set -w and show -w.


# 1.53 26-Nov-2009 nicm

Tidy up various bits of the paste code, make the data buffer char * and add
comments.


# 1.52 26-Nov-2009 nicm

Remove a couple of unused arguments where possible, and add /* ARGSUSED */ to
the rest to reduce lint output.


# 1.51 20-Nov-2009 nicm

Display UTF-8 properly in status line messages and prompt. Cursor handling is
still way off though.


# 1.50 20-Nov-2009 nicm

Remove oldest messages from log when limit is hit, not newest.


# 1.49 19-Nov-2009 nicm

Get some brackets in the right place so ## works. Also fix a space in a
comment.


# 1.48 19-Nov-2009 nicm

Change status line drawing to create the window list in a separate screen and
then copy it into the status line screen. This allows UTF-8 in window names and
fixes some problems with #[] in window-status-format.


# 1.47 19-Nov-2009 nicm

Two new options, window-status-format and window-status-current-format, which
allow the format of each window in the status line window list to be controlled
using similar # sequences as status-left/right.

This diff also moves part of the way towards UTF-8 support in window names but
it isn't quite there yet.


# 1.46 19-Nov-2009 nicm

Tidy up by breaking the # replacement code into a separate function, also add a
few comments.


# 1.45 19-Nov-2009 nicm

Don't interpret #() for display-message, it usually doesn't make sense and may
leak commands.


# 1.44 18-Nov-2009 nicm

Add a per-client log of status line messages displayed while that client
exists. A new message-limit session option sets the maximum number of entries
and a command, show-messages, shows the log (bound to ~ by default).

This (and prompt history) might be better as a single global log but until
there are global options it is easier for them to be per client.


# 1.43 17-Nov-2009 nicm

Permit top-bit-set characters to be entered in the status line. They could
already be set from the shell and are just passed through when printing (so
invisible characters or displaying on terminals with different character sets
may cause problems).

Note that entering UTF-8 may not work and in any case currently the status line
cannot display it correctly (outside of status-left/status-right).


# 1.42 04-Nov-2009 nicm

Use timeout events for the identify and message timers.


# 1.41 04-Nov-2009 nicm

Switch jobs over to use a bufferevent.


# 1.40 04-Nov-2009 nicm

Unused (but assigned to) variable, found by lint.


# 1.39 01-Nov-2009 nicm

Add a flag for jobs that shouldn't be freed after they've died and use it for
status jobs, then only kill those jobs when status-left, status-right or
set-titles-string is changed.

Fixes problems with changing options from inside #().


# 1.38 10-Oct-2009 nicm

Rather than running status-left, status-right and window title #() with popen
immediately every redraw, queue them up and run them in the background,
starting each once every status-interval. The actual status line uses the
output from the last run.

This brings several advantages:

- tmux itself may be called from inside #() without causing the server to hang;
- likewise, sleep or similar doesn't cause the server to block;
- commands aren't run excessively often when redrawing;
- commands shared by status-left and status-right, or used multiple times, will
only be run once.

run-shell and if-shell still use system()/popen() but will be changed over to
use this too later.


# 1.37 10-Oct-2009 nicm

Add "grouped sessions" which have independent name, options, current window and
so on but where the linked windows are synchronized (ie creating, killing
windows and so on are mirrored between the sessions). A grouped session may be
created by passing -t to new-session.

Had this around for a while, tested by a couple of people.


# 1.36 23-Sep-2009 nicm

Remove PROMPT_HIDDEN code which is now unused.


# 1.35 23-Sep-2009 nicm

Remove the internal tmux locking and instead detach each client and run the
command specified by a new option "lock-command" (by default "lock -np") in
each client.

This means each terminal has to be unlocked individually but simplifies the
code and allows the system password to be used to unlock.

Note that the set-password command is gone, so it will need to be removed from
configuration files, and the -U command line flag has been removed.

This is the third protocol version change so again it is best to stop the tmux
server before upgrading.


# 1.34 20-Sep-2009 nicm

Regularise some fatal messages.


# 1.33 10-Sep-2009 nicm

Permit options such as status-bg to be configured using the entire 256 colour
palette by setting "colour0" to "colour255".


# 1.32 07-Sep-2009 nicm

Give each paste buffer a size member instead of requiring them to be
zero-terminated.


# 1.31 07-Sep-2009 nicm

Permit embedded colour and attributes in status-left and status-right using new
#[] special characters, for example #[fg=red,bg=blue,blink].


# 1.30 02-Sep-2009 nicm

Add a transpose-chars command in edit mode (C-t in emacs mode only). From Kalle
Olavi Niemitalo.


# 1.29 01-Sep-2009 nicm

Use "Password:" with no space for password prompts and don't display a *s for
the password, like pretty much everything else. From martynas@ with minor
tweaks by me.


# 1.28 31-Aug-2009 nicm

Add a new display-panes command, with two options (display-panes-colour and
display-panes-time), which displays a visual indication of the number of each
pane.


# 1.27 19-Aug-2009 nicm

Extend command-prompt with a -p option which is a comma-separated list of one
or more prompts to present in order.

The responses to the prompt are replaced in the template string: %% are
replaced in order, so the first prompt replaces the first %%, the second
replaces the second, and so on. In addition, %1 up to %9 are replaced with the
responses to the first the ninth prompts

The default template is "%1" so the response to the first prompt is processed
as a command.

Note that this changes the behaviour for %% so if there is only one prompt,
only the first %% will be replaced. Templates such as "neww -n '%%' 'ssh %%'"
should be changed to "neww -n '%1' 'ssh %1'".

From Tiago Cunha.


# 1.26 18-Aug-2009 nicm

Add a "delete line" key when editing in the status line or the search up/down
prompt. C-u with emacs keys, d with vi.


# 1.25 13-Aug-2009 nicm

Switch the prompt code to return an empty string when the user enters no
response and reserve NULL for an explicit cancel. Change all callbacks to treat
them the same so no functional change.

Also add cancel key bindings to emacs mode which were missing.


# 1.24 08-Aug-2009 nicm

Options to set the colours and attributes for status-left/-right. From Thomas
Adam, thanks.


# 1.23 05-Aug-2009 nicm

If colours are not supported by the terminal, try to emulate a coloured
background by setting or clearing the reverse attribute.

This makes a few applications which don't use the reverse attribute themselves
a little happier, and allows the status, message and mode options to have
default attributes and fg/bg options that work as expected when set as reverse.


# 1.22 30-Jul-2009 nicm

Plug some memory leaks.


# 1.21 28-Jul-2009 nicm

Next step towards customisable mode keys: build each default table of keys into
a named tree on start and use that for lookups. Also add command to string
translation tables and modify list-keys to show the the mode key bindings (new
-t argument).


# 1.20 27-Jul-2009 nicm

Change mode key bindings from big switches into a set of tables. Rather than
lumping them all together, split editing keys from those used in choice/more
mode and those for copy/scroll mode.

Tidier and clearer, and the first step towards customisable mode keys.


# 1.19 27-Jul-2009 nicm

Get rid of empty mode_key_free function.


# 1.18 27-Jul-2009 nicm

Add a key to delete to end of line at the prompt (^K in emacs mode, C/D in vi).

From Kalle Olavi Niemitalo.


# 1.17 26-Jul-2009 nicm

Calculate the space available for the prompt buffer and the cursor position
correctly, and make it work when the screen is not wide enough.

Noticed by Kalle Olavi Niemitalo.


# 1.16 21-Jul-2009 nicm

Remove a couple of unused functions and fix a type ("FALLTHOUGH"), found by
lint.


# 1.15 20-Jul-2009 nicm

Add a status-justify option to allow the window list in the status line to be
positioned at the left, centre, or right.


# 1.14 20-Jul-2009 nicm

New options, window-status-current-{fg,bg,attr}, to set the fg, bg and
attributes with which the current window is shown in the status line. From
Johan Friis, thanks.


# 1.13 17-Jul-2009 nicm

- New command display-message (alias display) to display a message in the
status line (bound to "i" and displays the current window and time by
default). The same substitutions are applied as for status-left/right.
- Add support for including the window index (#I), pane index (#P) and window
name (#W) in the message, and status-left or status-right.
- Bump protocol version.

From Tiago Cunha, thanks!


# 1.12 17-Jul-2009 nicm

Memory could be leaked if a second prompt or message appeared while another was
still present, so add a separate prompt free callback and make the _clear
function responsible for calling it if necessary (rather than the individual
prompt callbacks). Also make both messages and prompts clear any existing when
a new is set.

In addition, the screen could be modified while the prompt is there, restore
the redraw-entire-screen behaviour on prompt clear; add a comment as a
reminder.


# 1.11 16-Jul-2009 nicm

Remove some duplicate code that was causing the status line to be redrawn even
when it hadn't changed.


# 1.10 15-Jul-2009 nicm

Make status_message_set a variadic printf-like function. No functional change -
helpful for a couple of things coming soon.


# 1.9 15-Jul-2009 nicm

Having to update NSETOPTION/NSETWINDOWOPTION when adding new options is a bit
annoying and it is only use for iterating, so use a sentinel to mark the end of
each array instead. Different fix for a problem pointed out by Kalle Olavi
Niemitalo.


# 1.8 14-Jul-2009 nicm

For some reason when clearing status/message it was redrawing the entire client
not just the status line. Changing this also revealed the check for the status
line was incorrect when drawing the pane.


# 1.7 14-Jul-2009 nicm

Instead of faking up a status line in status_redraw, use the same code to
redraw it as to draw the entire screen, just skip all lines but the last.

This makes horizontal split redraw properly when the status line is off.


# 1.6 12-Jul-2009 nicm

Add a "back to indentation" key in copy mode to move the cursor to the first
non-whitespace character. ^ with vi and M-m with emacs key bindings. Another
from Kalle Olavi Niemitalo, thanks.


Revision tags: OPENBSD_4_6_BASE
# 1.5 26-Jun-2009 nicm

Status line fixes: don't truncate status-right now the length calculation is
done for UTF-8, limit to the maximum length correctly when printing, and always
print a space even if the left string is longer than the width available.


# 1.4 04-Jun-2009 nicm

If the prompt is hidden or a password is sent with -U, zero it before freeing
it.


# 1.3 03-Jun-2009 nicm

New session option, status-utf8, to control the interpretation of top-bit-set
characters in status-left and status-right (if on, they are treated as UTF-8;
otherwise passed through).


# 1.2 03-Jun-2009 nicm

Add a UTF-8 aware string length function and make UTF-8 in
status-left/status-right work properly. At the moment any top-bit-set
characters are assumed to be UTF-8: a status-utf8 option to configure this will
come shortly.


# 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.233 07-Mar-2022 nicm

Pass client when adding menu item, GitHub issue 3103.


# 1.232 03-Feb-2022 nicm

Use format_draw for command prompt prefix to allow styles, GitHub issue
3054.


# 1.231 15-Nov-2021 nicm

Leave the hardware cursor at the position of the selected line in choose
modes and current editing position and at the command prompt. It is
invisible but this is helpful for people using screen readers. GitHub
issue 2970.


# 1.230 01-Nov-2021 nicm

Fix a comparison, from Ben Boeckel, and a crash when opening completion
menu, from Anindya Mukherjee.


# 1.229 26-Oct-2021 nicm

Accept some emacs control keys in vi normal mode, from Alexis
Hildebrandt in GitHub issue 2922.


# 1.228 26-Oct-2021 nicm

Do not allow inline styles to replace mode-style for the selected item,
from Alexis Hildebrandt in GitHub issue 2946.


Revision tags: OPENBSD_7_0_BASE
# 1.227 20-Aug-2021 nicm

Remove stray spaces after function names.


# 1.226 12-Aug-2021 nicm

Use COLOUR_DEFAULT not hardcoded 8.


# 1.225 10-Jun-2021 nicm

More accurate vi(1) word navigation in copy mode and on the status line.
This changes the meaning of the word-separators option - setting it to
the empty string is equivalent to the previous behavior. From Will Noble
in GitHub issue 2693.


# 1.224 10-Jun-2021 nicm

Add different command historys for different types of prompts
("command", "search" etc). From Anindya Mukherjee.


# 1.223 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.222 10-Jun-2021 nicm

Include current client in size calculation for new sessions, GitHub
issue 2662.


Revision tags: OPENBSD_6_9_BASE
# 1.221 12-Apr-2021 nicm

Add a flag to disable keys to close a message, GitHub issue 2625.


# 1.220 22-Feb-2021 nicm

Move jump commands to grid reader, make them UTF-8 aware, and tidy up,
from Anindya Mukherjee.


# 1.219 08-Jan-2021 nicm

With incremental search, start empty and only repeat the previous search
if the user tries to search again with an empty prompt. This matches
emacs behaviour more closely.


Revision tags: OPENBSD_6_8_BASE
# 1.218 27-Jul-2020 nicm

Add a -d option to display-message to set delay, from theonekeyg at
gmail dot com in GitHub issue 2322.


# 1.217 11-Jun-2020 nicm

Fix a crash when completing sessions, from Anindya Mukherjee.


# 1.216 26-May-2020 nicm

Remove leftover debug logging and fix comparison.


# 1.215 26-May-2020 nicm

Set up UTF-8 data for ASCII keys correctly.


# 1.214 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.213 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.212 16-May-2020 nicm

Rename KEYC_ESCAPE to KEYC_META.


# 1.211 16-May-2020 nicm

Expand target from client and use it to expand the prompt.


# 1.210 16-May-2020 nicm

Support embedded styles in the display-message message, GitHub issue
2206.


# 1.209 16-May-2020 nicm

Change message log to be per server rather than per client and include
every command that is run.


# 1.208 16-May-2020 nicm

Do not hoke into struct window_pane from the tty code and instead set
everything up in tty_ctx. Provide a way to initialize the tty_ctx from a
callback and use it to let popups draw directly through input_parse in
the same way as panes do, rather than forcing a full redraw on every
change.


# 1.207 16-May-2020 nicm

Use formats for status-style and message-style.


# 1.206 16-May-2020 nicm

Complete partial window indexes properly.


# 1.205 16-May-2020 nicm

Add -W and -T flags to command-prompt to only complete a window and a
target, also complete aliases.


# 1.204 16-May-2020 nicm

Improve command prompt completion:

- Show a menu with completions if there are multiple.

- Don't complete argument stuff (options, layouts) at start of text.

- For -t and -s, if there is no : then complete sessions but if there is
a :, show a menu of all windows in the session rather than trying to
complete the window name which is a bit useless if there are
duplicates.


# 1.203 16-May-2020 nicm

Drop having a separate type for style options and make them all strings,
which allows formats to be expanded. Any styles without a '#{' are still
validated when they are set but any with a '#{' are not. Formats are not
expanded usefully in many cases yet, that will be changed later.

To make this work, a few other changes:

- set-option -a with a style option automatically appends a ",".

- OSC 10 and 11 don't set the window-style option anymore, instead the
fg and bg are stored in the pane struct and act as the defaults that
can be overridden by window-style.

- status-fg and -bg now override status-style instead of trying to keep
them in sync.


Revision tags: OPENBSD_6_7_BASE
# 1.202 12-Mar-2020 nicm

Add C-g to cancel command prompt with vi(1) keys as well as emacs, and q
in command mode.


# 1.201 27-Jan-2020 nicm

Add support for adding a note to a key binding (with bind-key -N) and
use this to add descriptions to the default key bindings. A new -N flag
to list-keys shows key bindings with notes rather than the default
bind-key command used to create them. Change the default ? binding to
use this to show a readable summary of keys.

Also extend command-prompt to return the name of the key pressed and add
a default binding (/) to show the note for the next key pressed

Suggested by Alex Tremblay in GitHub issue 2000.


Revision tags: OPENBSD_6_6_BASE
# 1.200 28-May-2019 nicm

Redraw status line if size changes, GitHub issue 1762. Also fix length
of target buffer when pasting into status line.


# 1.199 23-May-2019 nicm

Fix length calculation for pasting UTF-8 characters in the status line,
GitHub issue 1753.


# 1.198 11-May-2019 nicm

Do not reduce window height by status line height for control mode
clients, from George Nachman.


# 1.197 03-May-2019 nicm

Fix reverse attribute in status line, GitHub issue 1709.


# 1.196 26-Apr-2019 nicm

Merge hooks into options and make each one an array option. This allows
multiple commands to be easily bound to one hook. set-hook and
show-hooks remain but they are now variants of set-option and
show-options. show-options now has a -H flag to show hooks (by default
they are not shown).


# 1.195 25-Apr-2019 nicm

options_array_item_value cannot return NULL.


# 1.194 23-Apr-2019 nicm

Somehow missed these bits in last commit.


# 1.193 23-Apr-2019 nicm

Indicate an array option with a flag rather than a special type so that
in future will not have to be strings.


Revision tags: OPENBSD_6_5_BASE
# 1.192 18-Mar-2019 nicm

Extend the #[] style syntax and use that together with previous format
changes to allow the status line to be entirely configured with a single
option.

Now that it is possible to configure their content, enable the existing
code that lets the status line be multiple lines in height. The status
option can now take a value of 2, 3, 4 or 5 (as well as the previous on
or off) to configure more than one line. The new status-format array
option configures the format of each line, the default just references
the existing status-* options, although some of the more obscure status
options may be eliminated in time.

Additions to the #[] syntax are: "align" to specify alignment (left,
centre, right), "list" for the window list and "range" to configure
ranges of text for the mouse bindings.

The "align" keyword can also be used to specify alignment of entries in
tree mode and the pane status lines.


# 1.191 18-Mar-2019 nicm

Make array options a sparse tree instead of an array of char * and
remove the size limit.


# 1.190 18-Mar-2019 nicm

With force, kill previous job before starting new. Fixes problem
reported by Scott Mcdermott in GitHub issue 1627.


# 1.189 16-Mar-2019 nicm

Use a pointer for the active screen in the status line instead of
copying them around all the time.


# 1.188 16-Mar-2019 nicm

Give status_save_old the client so it can do the reinit too.


# 1.187 16-Mar-2019 nicm

Tidy and rename some bits of status line code.


# 1.186 15-Mar-2019 nicm

Move status line free into its own function.


# 1.185 14-Mar-2019 nicm

Store the time in the format tree rather than passing it around.


# 1.184 12-Mar-2019 nicm

DECRC and DECSC apparently need to preserve origin mode as well, based
on a fix from Marc Reisner.


# 1.183 09-Feb-2019 nicm

Completion of command-alias members.


# 1.182 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.181 29-Aug-2018 nicm

Keep any text killed in the command prompt with C-w and yank it with
C-y, only use the top buffer if no text has previously been killed. This
and previous change promped by discussion with kn@.


# 1.180 29-Aug-2018 nicm

Add C-Left and C-Right as aliases for M-b and M-f.


# 1.179 22-Aug-2018 nicm

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


# 1.178 20-Aug-2018 nicm

Move offset of window list into status struct.


# 1.177 19-Aug-2018 nicm

Add a client redraw-window flag instead of the redraw-all flag and for
all just use the three flags together (window, borders, status).


Revision tags: OPENBSD_6_3_BASE
# 1.176 22-Feb-2018 nicm

Remove an unused variable.


# 1.175 05-Feb-2018 nicm

Add struct status_line to hold status line members of struct client, not
used yet but will be soon. From Thomas Adam.


# 1.174 01-Jan-2018 nicm

Add C-g at command prompt for emacs people, GitHub issue 1213.


# 1.173 27-Dec-2017 nicm

Draw command prompt correctly with status line off.


# 1.172 18-Dec-2017 nicm

Remove unused variable from Thomas Adam.


# 1.171 02-Nov-2017 nicm

Add a "fast" version of screen_write_copy for tree mode that doesn't do
all the checks and selection and marking stuff needed for copy mode.


# 1.170 20-Oct-2017 nicm

Clear status line with spaces again so reverse works, spotted by sthen.


# 1.169 16-Oct-2017 nicm

Infrastructure for drawing status lines of more than one line in height,
still only one is allowed but this lets tmux draw bigger ones.


Revision tags: OPENBSD_6_2_BASE
# 1.168 29-May-2017 nicm

Add a flag to stop the prompt input being expanded.


# 1.167 29-May-2017 nicm

Store a copy of the old status line, will be needed soon for new choose mode.


# 1.166 17-May-2017 nicm

Tidy command prompt callbacks and pass in the client.


# 1.165 03-May-2017 nicm

Add a format for the last search string in copy mode and fix the prompt
so it can work when in -I, suggested by Suraj N Kurapati.


# 1.164 01-May-2017 nicm

In order that people can use formats like #D in #() in the status line
and not have to wait for an update when they change pane, we allow
commands to run more than once a second if the expanded form
changes. Unfortunately this can mean them being run far too often
(pretty much continually) when multiple clients exist, because some
formats (including #D) will always differ between clients.

To avoid this, give each client its own tree of jobs which means that
the same command will be different instances for each client - similar
to how we have the tag to separate commands for different panes.

GitHub issue 889; test case reported by Paul Johnson.


# 1.163 22-Apr-2017 nicm

Memory leak from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.162 09-Feb-2017 nicm

Break the message storage function into its own function, useful for
debugging.


# 1.161 03-Feb-2017 nicm

Cache status line position to reduce option lookups during output.


# 1.160 03-Feb-2017 nicm

Add a window or pane id "tag" to each format tree and use it to separate
jobs, this means that if the same job is used for different windows or
panes (for example in pane-border-format), it will be run separately for
each pane.


# 1.159 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.158 06-Jan-2017 nicm

Incremental search in copy mode (on for emacs keys by default) - much
the same as normal searching but updates the cursor position and marked
search terms as you type. C-r and C-s in the prompt repeat the search,
once finished searching (with Enter), N and n work as before.


# 1.157 05-Jan-2017 nicm

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


# 1.156 07-Dec-2016 nicm

Do not clear the prompt when a message is shown, just leave it around and
return to it when the message is finished.


# 1.155 12-Oct-2016 nicm

Drop the edit mode key tables and just use fixed key bindings for the
command prompt.


# 1.154 12-Oct-2016 nicm

The repeat prompt in both emacs and vi (and the old one in tmux) doesn't
support line editing and instead executes a command as soon as a
non-number key is pressed. Add a -N flag to command-prompt for the same
in copy mode. Reported by Theo Buehler.


# 1.153 11-Oct-2016 nicm

Fundamental change to how copy mode key bindings work:

The vi-copy and emacs-copy mode key tables are gone, and instead copy
mode commands are bound in one of two normal key tables ("copy-mode" or
"copy-mode-vi"). Keys are bound to "send-keys -X copy-mode-command". So:

bind -temacs-copy C-Up scroll-up
bind -temacs-copy -R5 WheelUpPane scroll-up

Becomes:

bind -Tcopy-mode C-Up send -X scroll-up
bind -Tcopy-mode WheelUpPane send -N5 -X scroll-up

This allows the full command parser and command set to be used - for
example, we can use the normal command prompt for searching, jumping,
and so on instead of a custom one:

bind -Tcopy-mode C-r command-prompt -p'search up' "send -X search-backward '%%'"

command-prompt also gets a -1 option to only require on key press, which
is needed for jumping.

The plan is to get rid of mode keys entirely, so more to come eventually.


# 1.152 11-Oct-2016 nicm

Support UTF-8 entry into the command prompt.


# 1.151 10-Oct-2016 nicm

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


# 1.150 12-Sep-2016 nicm

Allow repeat count to be specified in mode key tables with bind-key -R,
and set the default repeat count to 5 for WheelUp and WheelDown in
copy-mode.


Revision tags: OPENBSD_6_0_BASE
# 1.149 06-Jun-2016 nicm

Allow #[] in window-status-separator.


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

I no longer use my SourceForge address so replace it.


# 1.147 01-Jan-2016 nicm

Don't rely on a calculation wrapping when applying message-limit, and
break out of the loop early. From Nicolas Viennot.


# 1.146 11-Dec-2015 nicm

Style nits and line wrapping of function declarations.


# 1.145 11-Dec-2015 nicm

Add cmdq as an argument to format_create and add a format for the
command name (will also be used for more later).


# 1.144 08-Dec-2015 nicm

Remove format_create_flags and just pass flags to format_create.


# 1.143 22-Nov-2015 tim

If display-time is set to 0, show status messages until a key is pressed;
OK nicm@


# 1.142 20-Nov-2015 nicm

Instead of separate tables for different types of options, give each
option a scope type (server, session, window) in one table.


# 1.141 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.140 13-Nov-2015 nicm

Long overdue change to the way we store cells in the grid: now, instead
of storing a full grid_cell with UTF-8 data and everything, store a new
type grid_cell_entry. This can either be the cell itself (for ASCII
cells), or an offset into an extended array (per line) for UTF-8
data.

This avoid a large (8 byte) overhead on non-UTF-8 cells (by far the
majority for most users) without the complexity of the shadow array we
had before. Grid memory without any UTF-8 is about half.

The disadvantage that cells can no longer be modified in place and need
to be copied out of the grid and back but it turned out to be lot less
complicated than I expected.


# 1.139 12-Nov-2015 nicm

Nuke the utf8 and status-utf8 options and make tmux only a UTF-8
terminal. We still support non-UTF-8 terminals outside tmux, but inside
it is always UTF-8 (as when the utf8 and status-utf8 options were on).


# 1.138 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.137 27-Oct-2015 nicm

Move struct options into options.c.


# 1.136 20-Oct-2015 nicm

Use client pointer not file descriptor in logging.


# 1.135 14-Sep-2015 nicm

Make refresh-client force update of jobs, from Sina Siadat.


# 1.134 29-Aug-2015 nicm

Move struct paste_buffer out of tmux.h.


# 1.133 28-Aug-2015 nicm

Run status update on a per-client timer at status-interval.


Revision tags: OPENBSD_5_8_BASE
# 1.132 29-Jul-2015 nicm

status_out and associated data structures are no longer used.


# 1.131 28-Jul-2015 nicm

Tidy up the way terminals are described and move some structs out of tmux.h.


# 1.130 20-Jul-2015 nicm

Add an option (history-file) for a file to save/restore command prompt
history, from Olof-Joachim Frahm.


# 1.129 27-May-2015 nicm

Move the jobs output cache into the formats code so that #() work more
generally (for example, again working in set-titles-string).


# 1.128 06-May-2015 nicm

Remove ARRAY_* from history and expand completion to complete a) layout
names and b) targets beginning with -t or -s.


# 1.127 25-Apr-2015 nicm

Make message log a TAILQ.


# 1.126 24-Apr-2015 nicm

Set working directory for run-shell and if-shell.


# 1.125 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_7_BASE
# 1.124 06-Feb-2015 nicm

Use the same time for both calls to format_expand_time.


# 1.123 06-Feb-2015 nicm

status_replace can now become local to status.c and it no longer needs
the jobsflag argument. While here there is no need to repeat work that
format_defaults already does.


# 1.122 06-Feb-2015 nicm

Add format_expand_time and use it instead of status_replace where
command execution is not needed.


# 1.121 05-Feb-2015 nicm

Wrap all the individual format_* calls in a single format_defaults
functions.


# 1.120 01-Feb-2015 nicm

Remove two unused arguments from status_replace.


# 1.119 20-Jan-2015 sthen

typo in comment ;) ok nicm


# 1.118 05-Nov-2014 nicm

Do not put a space between status-left/status-right and the window list,
instead move the space into the defaults for the options (so status-left
now defaults to "[#S] ". From Balazs Kezes.


# 1.117 20-Oct-2014 nicm

Better format for printf format attributes.


# 1.116 08-Oct-2014 nicm

Add xreallocarray and remove nmemb argument from xrealloc.


# 1.115 02-Oct-2014 nicm

Take account of window-status-separator when checking window position,
based on diff from Balazs Kezes.


Revision tags: OPENBSD_5_6_BASE
# 1.114 24-Apr-2014 nicm

There is no longer a need for a paste_stack struct or for global_buffers
to be global. Move to paste.c.


# 1.113 17-Apr-2014 nicm

Remove the monitor-content option and associated bits and bobs. It's
never worked very well. If there is a big demand for it to return, will
consider better ways to do it.


# 1.112 02-Apr-2014 nicm

Do not replace ## with # in status_replace1 because it'll be done later
by the format code.


# 1.111 31-Mar-2014 nicm

Make message-limit a server option.


Revision tags: OPENBSD_5_5_BASE
# 1.110 14-Feb-2014 nicm

Style nit - no space between function name and bracket.


# 1.109 14-Feb-2014 nicm

Check for NULL session and whatnot in status_replace, from Thomas Adam.


# 1.108 28-Jan-2014 nicm

Allow replacing each of the many sets of separate foo-{fg,bg,attr}
options with a single foo-style option. For example:

set -g status-fg yellow
set -g status-bg red
set -g status-attr blink

Becomes:

set -g status-style fg=yellow,bg=red,blink

The -a flag to set can be used to add to rather than replace a style. So:

set -g status-bg red

Becomes:

set -ag status-style bg=red

Currently this is fully backwards compatible (all *-{fg,bg,attr} options
remain) but the plan is to deprecate them over time.

From Tiago Cunha.


Revision tags: OPENBSD_5_4_BASE
# 1.107 05-Jul-2013 nicm

Whitespace nits, from Ben Boeckel.


# 1.106 05-Jul-2013 nicm

Act like vi(1) when moving words, from Ben Boeckel.


# 1.105 05-Jul-2013 nicm

Implement s, S, C mode switch commands in vi(1) mode, from Ben Boeckel.


# 1.104 31-May-2013 nicm

Demote the old single-character replacement variables (#S and friends)
to aliases of formats. From Tiago Cunha.


# 1.103 25-Mar-2013 nicm

Extend jobs to support writing and use that for copy-pipe instead of
popen, from Chris Johnsen.


# 1.102 22-Mar-2013 nicm

evbuffer_readline returns allocated storage, don't leak it.


# 1.101 22-Mar-2013 nicm

Add copy-pipe mode command to copy selection and also pipe to a command.


# 1.100 22-Mar-2013 nicm

No more lint means no more ARGSUSED.


# 1.99 21-Mar-2013 nicm

Aargh. Spaces -> tabs.


# 1.98 21-Mar-2013 nicm

Do not leak formats in status_replace.


# 1.97 21-Mar-2013 nicm

Add a format client_prefix which is 1 if prefix key has been
pressed, used for example #{?client_prefix,X,Y}. Also a few extra
server_client_status needed.


# 1.96 21-Mar-2013 nicm

Allow formats in status options.


Revision tags: OPENBSD_5_3_BASE
# 1.95 27-Nov-2012 nicm

Add window-status-last-* options, from Boris Faure.


Revision tags: OPENBSD_5_2_BASE
# 1.94 10-Jul-2012 nicm

xfree is not particularly helpful, remove it. From Thomas Adam.


# 1.93 09-Jul-2012 nicm

Move a NULL check inside a function, from Tiago Cunha.


# 1.92 29-Apr-2012 nicm

Use int not u_char for colours from options since they may have bit 8
set to mark them as 256-colour. Reported by Chris Johnson.


# 1.91 23-Apr-2012 nicm

Add window-status-separator option, from Thomas Adam.


# 1.90 17-Mar-2012 nicm

Check event_initialized before event_del if event may not have been set
up; libevent2 complains about this. Reported by Moriyoshi Koizumi.


# 1.89 04-Mar-2012 nicm

Add A and I keys for vi status line editing.


# 1.88 03-Mar-2012 nicm

The wlmouse offset should be part of the client, not the server. From
Ailin Nemui.


Revision tags: OPENBSD_5_1_BASE
# 1.87 29-Jan-2012 nicm

Add an option to move the status line to the top of the screen,
requested by many.


# 1.86 26-Jan-2012 nicm

Terminate strftime buffer properly even if a really long format string
is given, from Tiago Cunha.


# 1.85 26-Jan-2012 nicm

Fix memory leak in error path, from Tiago Cunha.


# 1.84 20-Jan-2012 nicm

Add some trivial additional status line attributes from jwcxz at users
dot sourceforge dot net.


# 1.83 20-Jan-2012 nicm

Add space movement keys for vi mode in the status line from Ben Boeckel.


# 1.82 01-Dec-2011 nicm

Make M-f and M-b work the same at the command prompt as in copy mode,
pointed out by Romain Francoise.


# 1.81 15-Nov-2011 nicm

Add word movement and editing command for command prompt editing, from
Ben Boeckel.


# 1.80 15-Nov-2011 nicm

Make window_pane_index work the same as window_index, from Ben Boeckel.


# 1.79 05-Nov-2011 nicm

Option to change status line (message) background when using vi keys and
in command mode. From Ben Boeckel.


# 1.78 20-Aug-2011 nicm

Fix a couple of memory leaks, from marcel partap.


Revision tags: OPENBSD_5_0_BASE
# 1.77 08-Jul-2011 nicm

Make confirm-before prompt customizable with -p option like
command-prompt. Also move responsibility for calling status_replace into
status_prompt_{set,update} and add #W and #P to the default kill-window
and kill-pane prompts. By Tiago Cunha.


# 1.76 02-Jul-2011 nicm

Allow the initial context on prompts to be set with the new -I option to
command-prompt. From Tiago Cunha.


# 1.75 29-Apr-2011 nicm

Only redraw the status line on command update, not the entire client
(big DOH).


# 1.74 24-Apr-2011 nicm

Provide #h for short hostname (no domain) from Michal Mazurek.


# 1.73 18-Apr-2011 nicm

Add an option (mouse-select-window) which allows the mouse to be used by
clicking on the status line, written by hsim at gmx dot li.


# 1.72 29-Mar-2011 nicm

Change -t on display-message to be target-pane for the #[A-Z]
replacements and add -c as target-client.


Revision tags: OPENBSD_4_9_BASE
# 1.71 26-Jan-2011 nicm

Simplify the way jobs work and drop the persist type, so all jobs are
fire-and-forget.

Status jobs now managed with two trees of output (new and old), rather
than storing the output in the jobs themselves. When the status line is
processed any jobs which don't appear in the new tree are started and
the output from the old tree displayed. When a job finishes it updates
the new tree with its output and that is used for any subsequent
redraws. When the status interval expires, the new tree is moved to the
old so that all jobs are run again.

This fixes the "#(echo %H:%M:%S)" problem which would lead to thousands
of identical persistent jobs and high memory use (this can still be
achieved by adding "sleep 30" but that is much less likely to happen by
accident).


# 1.70 03-Jan-2011 nicm

Handle a # at the end of a replacement string (such as status-left)
correctly. Found by Thomas Adam.


# 1.69 01-Jan-2011 nicm

Move the user-visible parts of all options (names, types, limit, default
values) together into one set of tables in options-table.c. Also clean
up and simplify cmd-set-options.c and move a common print function into
option-table.c.


# 1.68 30-Dec-2010 nicm

Change from a per-session stack of buffers to one global stack which is
much more convenient and also simplifies lot of code. This renders
copy-buffer useless and makes buffer-limit now a server option.

By Tiago Cunha.


# 1.67 30-Dec-2010 nicm

Add a function to create window flags rather than doing the same thing
in two places. From Thomas Adam.


# 1.66 11-Dec-2010 nicm

Oops, these functions return a const char *, so make the local variable
const as well.


# 1.65 11-Dec-2010 nicm

Make the prompt history global for all clients which is much more useful than per-client history.


# 1.64 06-Dec-2010 nicm

Add an option to alert (monitor) for silence (lack of activity) in a
window. From Thomas Adam.


Revision tags: OPENBSD_4_8_BASE
# 1.63 21-Jun-2010 nicm

Having a list of winlinks->alerts for each session is stupid, just store
the alert flags directly in the winlink itself.


# 1.62 14-May-2010 nicm

Colour+attribute options for status line alerts, from Alex Alexander.


# 1.61 31-Mar-2010 nicm

Don't accept keys with modifiers as input. Fixes crash reported by Brian
R Landy.


# 1.60 27-Mar-2010 nicm

Don't leak job command in #().


# 1.59 22-Mar-2010 nicm

Dead functions, lint.


Revision tags: OPENBSD_4_7_BASE
# 1.58 27-Jan-2010 nicm

Calculate offset correctly, fixes incorrect offset and prevents crash when
status-left is empty. From Micah Cowan.


# 1.57 26-Jan-2010 nicm

Actually use the copy made when no newline is found, from martynas@.


# 1.56 14-Dec-2009 nicm

Add server options to completion as well.


# 1.55 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.54 03-Dec-2009 nicm

Eliminate duplicate code and ease the passage for server-wide options by adding
a -w flag to set-option and show-options and making setw and showw aliases to
set -w and show -w.

Note: setw and showw are still there, but now aliases for set -w and show -w.


# 1.53 26-Nov-2009 nicm

Tidy up various bits of the paste code, make the data buffer char * and add
comments.


# 1.52 26-Nov-2009 nicm

Remove a couple of unused arguments where possible, and add /* ARGSUSED */ to
the rest to reduce lint output.


# 1.51 20-Nov-2009 nicm

Display UTF-8 properly in status line messages and prompt. Cursor handling is
still way off though.


# 1.50 20-Nov-2009 nicm

Remove oldest messages from log when limit is hit, not newest.


# 1.49 19-Nov-2009 nicm

Get some brackets in the right place so ## works. Also fix a space in a
comment.


# 1.48 19-Nov-2009 nicm

Change status line drawing to create the window list in a separate screen and
then copy it into the status line screen. This allows UTF-8 in window names and
fixes some problems with #[] in window-status-format.


# 1.47 19-Nov-2009 nicm

Two new options, window-status-format and window-status-current-format, which
allow the format of each window in the status line window list to be controlled
using similar # sequences as status-left/right.

This diff also moves part of the way towards UTF-8 support in window names but
it isn't quite there yet.


# 1.46 19-Nov-2009 nicm

Tidy up by breaking the # replacement code into a separate function, also add a
few comments.


# 1.45 19-Nov-2009 nicm

Don't interpret #() for display-message, it usually doesn't make sense and may
leak commands.


# 1.44 18-Nov-2009 nicm

Add a per-client log of status line messages displayed while that client
exists. A new message-limit session option sets the maximum number of entries
and a command, show-messages, shows the log (bound to ~ by default).

This (and prompt history) might be better as a single global log but until
there are global options it is easier for them to be per client.


# 1.43 17-Nov-2009 nicm

Permit top-bit-set characters to be entered in the status line. They could
already be set from the shell and are just passed through when printing (so
invisible characters or displaying on terminals with different character sets
may cause problems).

Note that entering UTF-8 may not work and in any case currently the status line
cannot display it correctly (outside of status-left/status-right).


# 1.42 04-Nov-2009 nicm

Use timeout events for the identify and message timers.


# 1.41 04-Nov-2009 nicm

Switch jobs over to use a bufferevent.


# 1.40 04-Nov-2009 nicm

Unused (but assigned to) variable, found by lint.


# 1.39 01-Nov-2009 nicm

Add a flag for jobs that shouldn't be freed after they've died and use it for
status jobs, then only kill those jobs when status-left, status-right or
set-titles-string is changed.

Fixes problems with changing options from inside #().


# 1.38 10-Oct-2009 nicm

Rather than running status-left, status-right and window title #() with popen
immediately every redraw, queue them up and run them in the background,
starting each once every status-interval. The actual status line uses the
output from the last run.

This brings several advantages:

- tmux itself may be called from inside #() without causing the server to hang;
- likewise, sleep or similar doesn't cause the server to block;
- commands aren't run excessively often when redrawing;
- commands shared by status-left and status-right, or used multiple times, will
only be run once.

run-shell and if-shell still use system()/popen() but will be changed over to
use this too later.


# 1.37 10-Oct-2009 nicm

Add "grouped sessions" which have independent name, options, current window and
so on but where the linked windows are synchronized (ie creating, killing
windows and so on are mirrored between the sessions). A grouped session may be
created by passing -t to new-session.

Had this around for a while, tested by a couple of people.


# 1.36 23-Sep-2009 nicm

Remove PROMPT_HIDDEN code which is now unused.


# 1.35 23-Sep-2009 nicm

Remove the internal tmux locking and instead detach each client and run the
command specified by a new option "lock-command" (by default "lock -np") in
each client.

This means each terminal has to be unlocked individually but simplifies the
code and allows the system password to be used to unlock.

Note that the set-password command is gone, so it will need to be removed from
configuration files, and the -U command line flag has been removed.

This is the third protocol version change so again it is best to stop the tmux
server before upgrading.


# 1.34 20-Sep-2009 nicm

Regularise some fatal messages.


# 1.33 10-Sep-2009 nicm

Permit options such as status-bg to be configured using the entire 256 colour
palette by setting "colour0" to "colour255".


# 1.32 07-Sep-2009 nicm

Give each paste buffer a size member instead of requiring them to be
zero-terminated.


# 1.31 07-Sep-2009 nicm

Permit embedded colour and attributes in status-left and status-right using new
#[] special characters, for example #[fg=red,bg=blue,blink].


# 1.30 02-Sep-2009 nicm

Add a transpose-chars command in edit mode (C-t in emacs mode only). From Kalle
Olavi Niemitalo.


# 1.29 01-Sep-2009 nicm

Use "Password:" with no space for password prompts and don't display a *s for
the password, like pretty much everything else. From martynas@ with minor
tweaks by me.


# 1.28 31-Aug-2009 nicm

Add a new display-panes command, with two options (display-panes-colour and
display-panes-time), which displays a visual indication of the number of each
pane.


# 1.27 19-Aug-2009 nicm

Extend command-prompt with a -p option which is a comma-separated list of one
or more prompts to present in order.

The responses to the prompt are replaced in the template string: %% are
replaced in order, so the first prompt replaces the first %%, the second
replaces the second, and so on. In addition, %1 up to %9 are replaced with the
responses to the first the ninth prompts

The default template is "%1" so the response to the first prompt is processed
as a command.

Note that this changes the behaviour for %% so if there is only one prompt,
only the first %% will be replaced. Templates such as "neww -n '%%' 'ssh %%'"
should be changed to "neww -n '%1' 'ssh %1'".

From Tiago Cunha.


# 1.26 18-Aug-2009 nicm

Add a "delete line" key when editing in the status line or the search up/down
prompt. C-u with emacs keys, d with vi.


# 1.25 13-Aug-2009 nicm

Switch the prompt code to return an empty string when the user enters no
response and reserve NULL for an explicit cancel. Change all callbacks to treat
them the same so no functional change.

Also add cancel key bindings to emacs mode which were missing.


# 1.24 08-Aug-2009 nicm

Options to set the colours and attributes for status-left/-right. From Thomas
Adam, thanks.


# 1.23 05-Aug-2009 nicm

If colours are not supported by the terminal, try to emulate a coloured
background by setting or clearing the reverse attribute.

This makes a few applications which don't use the reverse attribute themselves
a little happier, and allows the status, message and mode options to have
default attributes and fg/bg options that work as expected when set as reverse.


# 1.22 30-Jul-2009 nicm

Plug some memory leaks.


# 1.21 28-Jul-2009 nicm

Next step towards customisable mode keys: build each default table of keys into
a named tree on start and use that for lookups. Also add command to string
translation tables and modify list-keys to show the the mode key bindings (new
-t argument).


# 1.20 27-Jul-2009 nicm

Change mode key bindings from big switches into a set of tables. Rather than
lumping them all together, split editing keys from those used in choice/more
mode and those for copy/scroll mode.

Tidier and clearer, and the first step towards customisable mode keys.


# 1.19 27-Jul-2009 nicm

Get rid of empty mode_key_free function.


# 1.18 27-Jul-2009 nicm

Add a key to delete to end of line at the prompt (^K in emacs mode, C/D in vi).

From Kalle Olavi Niemitalo.


# 1.17 26-Jul-2009 nicm

Calculate the space available for the prompt buffer and the cursor position
correctly, and make it work when the screen is not wide enough.

Noticed by Kalle Olavi Niemitalo.


# 1.16 21-Jul-2009 nicm

Remove a couple of unused functions and fix a type ("FALLTHOUGH"), found by
lint.


# 1.15 20-Jul-2009 nicm

Add a status-justify option to allow the window list in the status line to be
positioned at the left, centre, or right.


# 1.14 20-Jul-2009 nicm

New options, window-status-current-{fg,bg,attr}, to set the fg, bg and
attributes with which the current window is shown in the status line. From
Johan Friis, thanks.


# 1.13 17-Jul-2009 nicm

- New command display-message (alias display) to display a message in the
status line (bound to "i" and displays the current window and time by
default). The same substitutions are applied as for status-left/right.
- Add support for including the window index (#I), pane index (#P) and window
name (#W) in the message, and status-left or status-right.
- Bump protocol version.

From Tiago Cunha, thanks!


# 1.12 17-Jul-2009 nicm

Memory could be leaked if a second prompt or message appeared while another was
still present, so add a separate prompt free callback and make the _clear
function responsible for calling it if necessary (rather than the individual
prompt callbacks). Also make both messages and prompts clear any existing when
a new is set.

In addition, the screen could be modified while the prompt is there, restore
the redraw-entire-screen behaviour on prompt clear; add a comment as a
reminder.


# 1.11 16-Jul-2009 nicm

Remove some duplicate code that was causing the status line to be redrawn even
when it hadn't changed.


# 1.10 15-Jul-2009 nicm

Make status_message_set a variadic printf-like function. No functional change -
helpful for a couple of things coming soon.


# 1.9 15-Jul-2009 nicm

Having to update NSETOPTION/NSETWINDOWOPTION when adding new options is a bit
annoying and it is only use for iterating, so use a sentinel to mark the end of
each array instead. Different fix for a problem pointed out by Kalle Olavi
Niemitalo.


# 1.8 14-Jul-2009 nicm

For some reason when clearing status/message it was redrawing the entire client
not just the status line. Changing this also revealed the check for the status
line was incorrect when drawing the pane.


# 1.7 14-Jul-2009 nicm

Instead of faking up a status line in status_redraw, use the same code to
redraw it as to draw the entire screen, just skip all lines but the last.

This makes horizontal split redraw properly when the status line is off.


# 1.6 12-Jul-2009 nicm

Add a "back to indentation" key in copy mode to move the cursor to the first
non-whitespace character. ^ with vi and M-m with emacs key bindings. Another
from Kalle Olavi Niemitalo, thanks.


Revision tags: OPENBSD_4_6_BASE
# 1.5 26-Jun-2009 nicm

Status line fixes: don't truncate status-right now the length calculation is
done for UTF-8, limit to the maximum length correctly when printing, and always
print a space even if the left string is longer than the width available.


# 1.4 04-Jun-2009 nicm

If the prompt is hidden or a password is sent with -U, zero it before freeing
it.


# 1.3 03-Jun-2009 nicm

New session option, status-utf8, to control the interpretation of top-bit-set
characters in status-left and status-right (if on, they are treated as UTF-8;
otherwise passed through).


# 1.2 03-Jun-2009 nicm

Add a UTF-8 aware string length function and make UTF-8 in
status-left/status-right work properly. At the moment any top-bit-set
characters are assumed to be UTF-8: a status-utf8 option to configure this will
come shortly.


# 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.232 03-Feb-2022 nicm

Use format_draw for command prompt prefix to allow styles, GitHub issue
3054.


# 1.231 15-Nov-2021 nicm

Leave the hardware cursor at the position of the selected line in choose
modes and current editing position and at the command prompt. It is
invisible but this is helpful for people using screen readers. GitHub
issue 2970.


# 1.230 01-Nov-2021 nicm

Fix a comparison, from Ben Boeckel, and a crash when opening completion
menu, from Anindya Mukherjee.


# 1.229 26-Oct-2021 nicm

Accept some emacs control keys in vi normal mode, from Alexis
Hildebrandt in GitHub issue 2922.


# 1.228 26-Oct-2021 nicm

Do not allow inline styles to replace mode-style for the selected item,
from Alexis Hildebrandt in GitHub issue 2946.


Revision tags: OPENBSD_7_0_BASE
# 1.227 20-Aug-2021 nicm

Remove stray spaces after function names.


# 1.226 12-Aug-2021 nicm

Use COLOUR_DEFAULT not hardcoded 8.


# 1.225 10-Jun-2021 nicm

More accurate vi(1) word navigation in copy mode and on the status line.
This changes the meaning of the word-separators option - setting it to
the empty string is equivalent to the previous behavior. From Will Noble
in GitHub issue 2693.


# 1.224 10-Jun-2021 nicm

Add different command historys for different types of prompts
("command", "search" etc). From Anindya Mukherjee.


# 1.223 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.222 10-Jun-2021 nicm

Include current client in size calculation for new sessions, GitHub
issue 2662.


Revision tags: OPENBSD_6_9_BASE
# 1.221 12-Apr-2021 nicm

Add a flag to disable keys to close a message, GitHub issue 2625.


# 1.220 22-Feb-2021 nicm

Move jump commands to grid reader, make them UTF-8 aware, and tidy up,
from Anindya Mukherjee.


# 1.219 08-Jan-2021 nicm

With incremental search, start empty and only repeat the previous search
if the user tries to search again with an empty prompt. This matches
emacs behaviour more closely.


Revision tags: OPENBSD_6_8_BASE
# 1.218 27-Jul-2020 nicm

Add a -d option to display-message to set delay, from theonekeyg at
gmail dot com in GitHub issue 2322.


# 1.217 11-Jun-2020 nicm

Fix a crash when completing sessions, from Anindya Mukherjee.


# 1.216 26-May-2020 nicm

Remove leftover debug logging and fix comparison.


# 1.215 26-May-2020 nicm

Set up UTF-8 data for ASCII keys correctly.


# 1.214 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.213 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.212 16-May-2020 nicm

Rename KEYC_ESCAPE to KEYC_META.


# 1.211 16-May-2020 nicm

Expand target from client and use it to expand the prompt.


# 1.210 16-May-2020 nicm

Support embedded styles in the display-message message, GitHub issue
2206.


# 1.209 16-May-2020 nicm

Change message log to be per server rather than per client and include
every command that is run.


# 1.208 16-May-2020 nicm

Do not hoke into struct window_pane from the tty code and instead set
everything up in tty_ctx. Provide a way to initialize the tty_ctx from a
callback and use it to let popups draw directly through input_parse in
the same way as panes do, rather than forcing a full redraw on every
change.


# 1.207 16-May-2020 nicm

Use formats for status-style and message-style.


# 1.206 16-May-2020 nicm

Complete partial window indexes properly.


# 1.205 16-May-2020 nicm

Add -W and -T flags to command-prompt to only complete a window and a
target, also complete aliases.


# 1.204 16-May-2020 nicm

Improve command prompt completion:

- Show a menu with completions if there are multiple.

- Don't complete argument stuff (options, layouts) at start of text.

- For -t and -s, if there is no : then complete sessions but if there is
a :, show a menu of all windows in the session rather than trying to
complete the window name which is a bit useless if there are
duplicates.


# 1.203 16-May-2020 nicm

Drop having a separate type for style options and make them all strings,
which allows formats to be expanded. Any styles without a '#{' are still
validated when they are set but any with a '#{' are not. Formats are not
expanded usefully in many cases yet, that will be changed later.

To make this work, a few other changes:

- set-option -a with a style option automatically appends a ",".

- OSC 10 and 11 don't set the window-style option anymore, instead the
fg and bg are stored in the pane struct and act as the defaults that
can be overridden by window-style.

- status-fg and -bg now override status-style instead of trying to keep
them in sync.


Revision tags: OPENBSD_6_7_BASE
# 1.202 12-Mar-2020 nicm

Add C-g to cancel command prompt with vi(1) keys as well as emacs, and q
in command mode.


# 1.201 27-Jan-2020 nicm

Add support for adding a note to a key binding (with bind-key -N) and
use this to add descriptions to the default key bindings. A new -N flag
to list-keys shows key bindings with notes rather than the default
bind-key command used to create them. Change the default ? binding to
use this to show a readable summary of keys.

Also extend command-prompt to return the name of the key pressed and add
a default binding (/) to show the note for the next key pressed

Suggested by Alex Tremblay in GitHub issue 2000.


Revision tags: OPENBSD_6_6_BASE
# 1.200 28-May-2019 nicm

Redraw status line if size changes, GitHub issue 1762. Also fix length
of target buffer when pasting into status line.


# 1.199 23-May-2019 nicm

Fix length calculation for pasting UTF-8 characters in the status line,
GitHub issue 1753.


# 1.198 11-May-2019 nicm

Do not reduce window height by status line height for control mode
clients, from George Nachman.


# 1.197 03-May-2019 nicm

Fix reverse attribute in status line, GitHub issue 1709.


# 1.196 26-Apr-2019 nicm

Merge hooks into options and make each one an array option. This allows
multiple commands to be easily bound to one hook. set-hook and
show-hooks remain but they are now variants of set-option and
show-options. show-options now has a -H flag to show hooks (by default
they are not shown).


# 1.195 25-Apr-2019 nicm

options_array_item_value cannot return NULL.


# 1.194 23-Apr-2019 nicm

Somehow missed these bits in last commit.


# 1.193 23-Apr-2019 nicm

Indicate an array option with a flag rather than a special type so that
in future will not have to be strings.


Revision tags: OPENBSD_6_5_BASE
# 1.192 18-Mar-2019 nicm

Extend the #[] style syntax and use that together with previous format
changes to allow the status line to be entirely configured with a single
option.

Now that it is possible to configure their content, enable the existing
code that lets the status line be multiple lines in height. The status
option can now take a value of 2, 3, 4 or 5 (as well as the previous on
or off) to configure more than one line. The new status-format array
option configures the format of each line, the default just references
the existing status-* options, although some of the more obscure status
options may be eliminated in time.

Additions to the #[] syntax are: "align" to specify alignment (left,
centre, right), "list" for the window list and "range" to configure
ranges of text for the mouse bindings.

The "align" keyword can also be used to specify alignment of entries in
tree mode and the pane status lines.


# 1.191 18-Mar-2019 nicm

Make array options a sparse tree instead of an array of char * and
remove the size limit.


# 1.190 18-Mar-2019 nicm

With force, kill previous job before starting new. Fixes problem
reported by Scott Mcdermott in GitHub issue 1627.


# 1.189 16-Mar-2019 nicm

Use a pointer for the active screen in the status line instead of
copying them around all the time.


# 1.188 16-Mar-2019 nicm

Give status_save_old the client so it can do the reinit too.


# 1.187 16-Mar-2019 nicm

Tidy and rename some bits of status line code.


# 1.186 15-Mar-2019 nicm

Move status line free into its own function.


# 1.185 14-Mar-2019 nicm

Store the time in the format tree rather than passing it around.


# 1.184 12-Mar-2019 nicm

DECRC and DECSC apparently need to preserve origin mode as well, based
on a fix from Marc Reisner.


# 1.183 09-Feb-2019 nicm

Completion of command-alias members.


# 1.182 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.181 29-Aug-2018 nicm

Keep any text killed in the command prompt with C-w and yank it with
C-y, only use the top buffer if no text has previously been killed. This
and previous change promped by discussion with kn@.


# 1.180 29-Aug-2018 nicm

Add C-Left and C-Right as aliases for M-b and M-f.


# 1.179 22-Aug-2018 nicm

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


# 1.178 20-Aug-2018 nicm

Move offset of window list into status struct.


# 1.177 19-Aug-2018 nicm

Add a client redraw-window flag instead of the redraw-all flag and for
all just use the three flags together (window, borders, status).


Revision tags: OPENBSD_6_3_BASE
# 1.176 22-Feb-2018 nicm

Remove an unused variable.


# 1.175 05-Feb-2018 nicm

Add struct status_line to hold status line members of struct client, not
used yet but will be soon. From Thomas Adam.


# 1.174 01-Jan-2018 nicm

Add C-g at command prompt for emacs people, GitHub issue 1213.


# 1.173 27-Dec-2017 nicm

Draw command prompt correctly with status line off.


# 1.172 18-Dec-2017 nicm

Remove unused variable from Thomas Adam.


# 1.171 02-Nov-2017 nicm

Add a "fast" version of screen_write_copy for tree mode that doesn't do
all the checks and selection and marking stuff needed for copy mode.


# 1.170 20-Oct-2017 nicm

Clear status line with spaces again so reverse works, spotted by sthen.


# 1.169 16-Oct-2017 nicm

Infrastructure for drawing status lines of more than one line in height,
still only one is allowed but this lets tmux draw bigger ones.


Revision tags: OPENBSD_6_2_BASE
# 1.168 29-May-2017 nicm

Add a flag to stop the prompt input being expanded.


# 1.167 29-May-2017 nicm

Store a copy of the old status line, will be needed soon for new choose mode.


# 1.166 17-May-2017 nicm

Tidy command prompt callbacks and pass in the client.


# 1.165 03-May-2017 nicm

Add a format for the last search string in copy mode and fix the prompt
so it can work when in -I, suggested by Suraj N Kurapati.


# 1.164 01-May-2017 nicm

In order that people can use formats like #D in #() in the status line
and not have to wait for an update when they change pane, we allow
commands to run more than once a second if the expanded form
changes. Unfortunately this can mean them being run far too often
(pretty much continually) when multiple clients exist, because some
formats (including #D) will always differ between clients.

To avoid this, give each client its own tree of jobs which means that
the same command will be different instances for each client - similar
to how we have the tag to separate commands for different panes.

GitHub issue 889; test case reported by Paul Johnson.


# 1.163 22-Apr-2017 nicm

Memory leak from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.162 09-Feb-2017 nicm

Break the message storage function into its own function, useful for
debugging.


# 1.161 03-Feb-2017 nicm

Cache status line position to reduce option lookups during output.


# 1.160 03-Feb-2017 nicm

Add a window or pane id "tag" to each format tree and use it to separate
jobs, this means that if the same job is used for different windows or
panes (for example in pane-border-format), it will be run separately for
each pane.


# 1.159 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.158 06-Jan-2017 nicm

Incremental search in copy mode (on for emacs keys by default) - much
the same as normal searching but updates the cursor position and marked
search terms as you type. C-r and C-s in the prompt repeat the search,
once finished searching (with Enter), N and n work as before.


# 1.157 05-Jan-2017 nicm

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


# 1.156 07-Dec-2016 nicm

Do not clear the prompt when a message is shown, just leave it around and
return to it when the message is finished.


# 1.155 12-Oct-2016 nicm

Drop the edit mode key tables and just use fixed key bindings for the
command prompt.


# 1.154 12-Oct-2016 nicm

The repeat prompt in both emacs and vi (and the old one in tmux) doesn't
support line editing and instead executes a command as soon as a
non-number key is pressed. Add a -N flag to command-prompt for the same
in copy mode. Reported by Theo Buehler.


# 1.153 11-Oct-2016 nicm

Fundamental change to how copy mode key bindings work:

The vi-copy and emacs-copy mode key tables are gone, and instead copy
mode commands are bound in one of two normal key tables ("copy-mode" or
"copy-mode-vi"). Keys are bound to "send-keys -X copy-mode-command". So:

bind -temacs-copy C-Up scroll-up
bind -temacs-copy -R5 WheelUpPane scroll-up

Becomes:

bind -Tcopy-mode C-Up send -X scroll-up
bind -Tcopy-mode WheelUpPane send -N5 -X scroll-up

This allows the full command parser and command set to be used - for
example, we can use the normal command prompt for searching, jumping,
and so on instead of a custom one:

bind -Tcopy-mode C-r command-prompt -p'search up' "send -X search-backward '%%'"

command-prompt also gets a -1 option to only require on key press, which
is needed for jumping.

The plan is to get rid of mode keys entirely, so more to come eventually.


# 1.152 11-Oct-2016 nicm

Support UTF-8 entry into the command prompt.


# 1.151 10-Oct-2016 nicm

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


# 1.150 12-Sep-2016 nicm

Allow repeat count to be specified in mode key tables with bind-key -R,
and set the default repeat count to 5 for WheelUp and WheelDown in
copy-mode.


Revision tags: OPENBSD_6_0_BASE
# 1.149 06-Jun-2016 nicm

Allow #[] in window-status-separator.


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

I no longer use my SourceForge address so replace it.


# 1.147 01-Jan-2016 nicm

Don't rely on a calculation wrapping when applying message-limit, and
break out of the loop early. From Nicolas Viennot.


# 1.146 11-Dec-2015 nicm

Style nits and line wrapping of function declarations.


# 1.145 11-Dec-2015 nicm

Add cmdq as an argument to format_create and add a format for the
command name (will also be used for more later).


# 1.144 08-Dec-2015 nicm

Remove format_create_flags and just pass flags to format_create.


# 1.143 22-Nov-2015 tim

If display-time is set to 0, show status messages until a key is pressed;
OK nicm@


# 1.142 20-Nov-2015 nicm

Instead of separate tables for different types of options, give each
option a scope type (server, session, window) in one table.


# 1.141 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.140 13-Nov-2015 nicm

Long overdue change to the way we store cells in the grid: now, instead
of storing a full grid_cell with UTF-8 data and everything, store a new
type grid_cell_entry. This can either be the cell itself (for ASCII
cells), or an offset into an extended array (per line) for UTF-8
data.

This avoid a large (8 byte) overhead on non-UTF-8 cells (by far the
majority for most users) without the complexity of the shadow array we
had before. Grid memory without any UTF-8 is about half.

The disadvantage that cells can no longer be modified in place and need
to be copied out of the grid and back but it turned out to be lot less
complicated than I expected.


# 1.139 12-Nov-2015 nicm

Nuke the utf8 and status-utf8 options and make tmux only a UTF-8
terminal. We still support non-UTF-8 terminals outside tmux, but inside
it is always UTF-8 (as when the utf8 and status-utf8 options were on).


# 1.138 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.137 27-Oct-2015 nicm

Move struct options into options.c.


# 1.136 20-Oct-2015 nicm

Use client pointer not file descriptor in logging.


# 1.135 14-Sep-2015 nicm

Make refresh-client force update of jobs, from Sina Siadat.


# 1.134 29-Aug-2015 nicm

Move struct paste_buffer out of tmux.h.


# 1.133 28-Aug-2015 nicm

Run status update on a per-client timer at status-interval.


Revision tags: OPENBSD_5_8_BASE
# 1.132 29-Jul-2015 nicm

status_out and associated data structures are no longer used.


# 1.131 28-Jul-2015 nicm

Tidy up the way terminals are described and move some structs out of tmux.h.


# 1.130 20-Jul-2015 nicm

Add an option (history-file) for a file to save/restore command prompt
history, from Olof-Joachim Frahm.


# 1.129 27-May-2015 nicm

Move the jobs output cache into the formats code so that #() work more
generally (for example, again working in set-titles-string).


# 1.128 06-May-2015 nicm

Remove ARRAY_* from history and expand completion to complete a) layout
names and b) targets beginning with -t or -s.


# 1.127 25-Apr-2015 nicm

Make message log a TAILQ.


# 1.126 24-Apr-2015 nicm

Set working directory for run-shell and if-shell.


# 1.125 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_7_BASE
# 1.124 06-Feb-2015 nicm

Use the same time for both calls to format_expand_time.


# 1.123 06-Feb-2015 nicm

status_replace can now become local to status.c and it no longer needs
the jobsflag argument. While here there is no need to repeat work that
format_defaults already does.


# 1.122 06-Feb-2015 nicm

Add format_expand_time and use it instead of status_replace where
command execution is not needed.


# 1.121 05-Feb-2015 nicm

Wrap all the individual format_* calls in a single format_defaults
functions.


# 1.120 01-Feb-2015 nicm

Remove two unused arguments from status_replace.


# 1.119 20-Jan-2015 sthen

typo in comment ;) ok nicm


# 1.118 05-Nov-2014 nicm

Do not put a space between status-left/status-right and the window list,
instead move the space into the defaults for the options (so status-left
now defaults to "[#S] ". From Balazs Kezes.


# 1.117 20-Oct-2014 nicm

Better format for printf format attributes.


# 1.116 08-Oct-2014 nicm

Add xreallocarray and remove nmemb argument from xrealloc.


# 1.115 02-Oct-2014 nicm

Take account of window-status-separator when checking window position,
based on diff from Balazs Kezes.


Revision tags: OPENBSD_5_6_BASE
# 1.114 24-Apr-2014 nicm

There is no longer a need for a paste_stack struct or for global_buffers
to be global. Move to paste.c.


# 1.113 17-Apr-2014 nicm

Remove the monitor-content option and associated bits and bobs. It's
never worked very well. If there is a big demand for it to return, will
consider better ways to do it.


# 1.112 02-Apr-2014 nicm

Do not replace ## with # in status_replace1 because it'll be done later
by the format code.


# 1.111 31-Mar-2014 nicm

Make message-limit a server option.


Revision tags: OPENBSD_5_5_BASE
# 1.110 14-Feb-2014 nicm

Style nit - no space between function name and bracket.


# 1.109 14-Feb-2014 nicm

Check for NULL session and whatnot in status_replace, from Thomas Adam.


# 1.108 28-Jan-2014 nicm

Allow replacing each of the many sets of separate foo-{fg,bg,attr}
options with a single foo-style option. For example:

set -g status-fg yellow
set -g status-bg red
set -g status-attr blink

Becomes:

set -g status-style fg=yellow,bg=red,blink

The -a flag to set can be used to add to rather than replace a style. So:

set -g status-bg red

Becomes:

set -ag status-style bg=red

Currently this is fully backwards compatible (all *-{fg,bg,attr} options
remain) but the plan is to deprecate them over time.

From Tiago Cunha.


Revision tags: OPENBSD_5_4_BASE
# 1.107 05-Jul-2013 nicm

Whitespace nits, from Ben Boeckel.


# 1.106 05-Jul-2013 nicm

Act like vi(1) when moving words, from Ben Boeckel.


# 1.105 05-Jul-2013 nicm

Implement s, S, C mode switch commands in vi(1) mode, from Ben Boeckel.


# 1.104 31-May-2013 nicm

Demote the old single-character replacement variables (#S and friends)
to aliases of formats. From Tiago Cunha.


# 1.103 25-Mar-2013 nicm

Extend jobs to support writing and use that for copy-pipe instead of
popen, from Chris Johnsen.


# 1.102 22-Mar-2013 nicm

evbuffer_readline returns allocated storage, don't leak it.


# 1.101 22-Mar-2013 nicm

Add copy-pipe mode command to copy selection and also pipe to a command.


# 1.100 22-Mar-2013 nicm

No more lint means no more ARGSUSED.


# 1.99 21-Mar-2013 nicm

Aargh. Spaces -> tabs.


# 1.98 21-Mar-2013 nicm

Do not leak formats in status_replace.


# 1.97 21-Mar-2013 nicm

Add a format client_prefix which is 1 if prefix key has been
pressed, used for example #{?client_prefix,X,Y}. Also a few extra
server_client_status needed.


# 1.96 21-Mar-2013 nicm

Allow formats in status options.


Revision tags: OPENBSD_5_3_BASE
# 1.95 27-Nov-2012 nicm

Add window-status-last-* options, from Boris Faure.


Revision tags: OPENBSD_5_2_BASE
# 1.94 10-Jul-2012 nicm

xfree is not particularly helpful, remove it. From Thomas Adam.


# 1.93 09-Jul-2012 nicm

Move a NULL check inside a function, from Tiago Cunha.


# 1.92 29-Apr-2012 nicm

Use int not u_char for colours from options since they may have bit 8
set to mark them as 256-colour. Reported by Chris Johnson.


# 1.91 23-Apr-2012 nicm

Add window-status-separator option, from Thomas Adam.


# 1.90 17-Mar-2012 nicm

Check event_initialized before event_del if event may not have been set
up; libevent2 complains about this. Reported by Moriyoshi Koizumi.


# 1.89 04-Mar-2012 nicm

Add A and I keys for vi status line editing.


# 1.88 03-Mar-2012 nicm

The wlmouse offset should be part of the client, not the server. From
Ailin Nemui.


Revision tags: OPENBSD_5_1_BASE
# 1.87 29-Jan-2012 nicm

Add an option to move the status line to the top of the screen,
requested by many.


# 1.86 26-Jan-2012 nicm

Terminate strftime buffer properly even if a really long format string
is given, from Tiago Cunha.


# 1.85 26-Jan-2012 nicm

Fix memory leak in error path, from Tiago Cunha.


# 1.84 20-Jan-2012 nicm

Add some trivial additional status line attributes from jwcxz at users
dot sourceforge dot net.


# 1.83 20-Jan-2012 nicm

Add space movement keys for vi mode in the status line from Ben Boeckel.


# 1.82 01-Dec-2011 nicm

Make M-f and M-b work the same at the command prompt as in copy mode,
pointed out by Romain Francoise.


# 1.81 15-Nov-2011 nicm

Add word movement and editing command for command prompt editing, from
Ben Boeckel.


# 1.80 15-Nov-2011 nicm

Make window_pane_index work the same as window_index, from Ben Boeckel.


# 1.79 05-Nov-2011 nicm

Option to change status line (message) background when using vi keys and
in command mode. From Ben Boeckel.


# 1.78 20-Aug-2011 nicm

Fix a couple of memory leaks, from marcel partap.


Revision tags: OPENBSD_5_0_BASE
# 1.77 08-Jul-2011 nicm

Make confirm-before prompt customizable with -p option like
command-prompt. Also move responsibility for calling status_replace into
status_prompt_{set,update} and add #W and #P to the default kill-window
and kill-pane prompts. By Tiago Cunha.


# 1.76 02-Jul-2011 nicm

Allow the initial context on prompts to be set with the new -I option to
command-prompt. From Tiago Cunha.


# 1.75 29-Apr-2011 nicm

Only redraw the status line on command update, not the entire client
(big DOH).


# 1.74 24-Apr-2011 nicm

Provide #h for short hostname (no domain) from Michal Mazurek.


# 1.73 18-Apr-2011 nicm

Add an option (mouse-select-window) which allows the mouse to be used by
clicking on the status line, written by hsim at gmx dot li.


# 1.72 29-Mar-2011 nicm

Change -t on display-message to be target-pane for the #[A-Z]
replacements and add -c as target-client.


Revision tags: OPENBSD_4_9_BASE
# 1.71 26-Jan-2011 nicm

Simplify the way jobs work and drop the persist type, so all jobs are
fire-and-forget.

Status jobs now managed with two trees of output (new and old), rather
than storing the output in the jobs themselves. When the status line is
processed any jobs which don't appear in the new tree are started and
the output from the old tree displayed. When a job finishes it updates
the new tree with its output and that is used for any subsequent
redraws. When the status interval expires, the new tree is moved to the
old so that all jobs are run again.

This fixes the "#(echo %H:%M:%S)" problem which would lead to thousands
of identical persistent jobs and high memory use (this can still be
achieved by adding "sleep 30" but that is much less likely to happen by
accident).


# 1.70 03-Jan-2011 nicm

Handle a # at the end of a replacement string (such as status-left)
correctly. Found by Thomas Adam.


# 1.69 01-Jan-2011 nicm

Move the user-visible parts of all options (names, types, limit, default
values) together into one set of tables in options-table.c. Also clean
up and simplify cmd-set-options.c and move a common print function into
option-table.c.


# 1.68 30-Dec-2010 nicm

Change from a per-session stack of buffers to one global stack which is
much more convenient and also simplifies lot of code. This renders
copy-buffer useless and makes buffer-limit now a server option.

By Tiago Cunha.


# 1.67 30-Dec-2010 nicm

Add a function to create window flags rather than doing the same thing
in two places. From Thomas Adam.


# 1.66 11-Dec-2010 nicm

Oops, these functions return a const char *, so make the local variable
const as well.


# 1.65 11-Dec-2010 nicm

Make the prompt history global for all clients which is much more useful than per-client history.


# 1.64 06-Dec-2010 nicm

Add an option to alert (monitor) for silence (lack of activity) in a
window. From Thomas Adam.


Revision tags: OPENBSD_4_8_BASE
# 1.63 21-Jun-2010 nicm

Having a list of winlinks->alerts for each session is stupid, just store
the alert flags directly in the winlink itself.


# 1.62 14-May-2010 nicm

Colour+attribute options for status line alerts, from Alex Alexander.


# 1.61 31-Mar-2010 nicm

Don't accept keys with modifiers as input. Fixes crash reported by Brian
R Landy.


# 1.60 27-Mar-2010 nicm

Don't leak job command in #().


# 1.59 22-Mar-2010 nicm

Dead functions, lint.


Revision tags: OPENBSD_4_7_BASE
# 1.58 27-Jan-2010 nicm

Calculate offset correctly, fixes incorrect offset and prevents crash when
status-left is empty. From Micah Cowan.


# 1.57 26-Jan-2010 nicm

Actually use the copy made when no newline is found, from martynas@.


# 1.56 14-Dec-2009 nicm

Add server options to completion as well.


# 1.55 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.54 03-Dec-2009 nicm

Eliminate duplicate code and ease the passage for server-wide options by adding
a -w flag to set-option and show-options and making setw and showw aliases to
set -w and show -w.

Note: setw and showw are still there, but now aliases for set -w and show -w.


# 1.53 26-Nov-2009 nicm

Tidy up various bits of the paste code, make the data buffer char * and add
comments.


# 1.52 26-Nov-2009 nicm

Remove a couple of unused arguments where possible, and add /* ARGSUSED */ to
the rest to reduce lint output.


# 1.51 20-Nov-2009 nicm

Display UTF-8 properly in status line messages and prompt. Cursor handling is
still way off though.


# 1.50 20-Nov-2009 nicm

Remove oldest messages from log when limit is hit, not newest.


# 1.49 19-Nov-2009 nicm

Get some brackets in the right place so ## works. Also fix a space in a
comment.


# 1.48 19-Nov-2009 nicm

Change status line drawing to create the window list in a separate screen and
then copy it into the status line screen. This allows UTF-8 in window names and
fixes some problems with #[] in window-status-format.


# 1.47 19-Nov-2009 nicm

Two new options, window-status-format and window-status-current-format, which
allow the format of each window in the status line window list to be controlled
using similar # sequences as status-left/right.

This diff also moves part of the way towards UTF-8 support in window names but
it isn't quite there yet.


# 1.46 19-Nov-2009 nicm

Tidy up by breaking the # replacement code into a separate function, also add a
few comments.


# 1.45 19-Nov-2009 nicm

Don't interpret #() for display-message, it usually doesn't make sense and may
leak commands.


# 1.44 18-Nov-2009 nicm

Add a per-client log of status line messages displayed while that client
exists. A new message-limit session option sets the maximum number of entries
and a command, show-messages, shows the log (bound to ~ by default).

This (and prompt history) might be better as a single global log but until
there are global options it is easier for them to be per client.


# 1.43 17-Nov-2009 nicm

Permit top-bit-set characters to be entered in the status line. They could
already be set from the shell and are just passed through when printing (so
invisible characters or displaying on terminals with different character sets
may cause problems).

Note that entering UTF-8 may not work and in any case currently the status line
cannot display it correctly (outside of status-left/status-right).


# 1.42 04-Nov-2009 nicm

Use timeout events for the identify and message timers.


# 1.41 04-Nov-2009 nicm

Switch jobs over to use a bufferevent.


# 1.40 04-Nov-2009 nicm

Unused (but assigned to) variable, found by lint.


# 1.39 01-Nov-2009 nicm

Add a flag for jobs that shouldn't be freed after they've died and use it for
status jobs, then only kill those jobs when status-left, status-right or
set-titles-string is changed.

Fixes problems with changing options from inside #().


# 1.38 10-Oct-2009 nicm

Rather than running status-left, status-right and window title #() with popen
immediately every redraw, queue them up and run them in the background,
starting each once every status-interval. The actual status line uses the
output from the last run.

This brings several advantages:

- tmux itself may be called from inside #() without causing the server to hang;
- likewise, sleep or similar doesn't cause the server to block;
- commands aren't run excessively often when redrawing;
- commands shared by status-left and status-right, or used multiple times, will
only be run once.

run-shell and if-shell still use system()/popen() but will be changed over to
use this too later.


# 1.37 10-Oct-2009 nicm

Add "grouped sessions" which have independent name, options, current window and
so on but where the linked windows are synchronized (ie creating, killing
windows and so on are mirrored between the sessions). A grouped session may be
created by passing -t to new-session.

Had this around for a while, tested by a couple of people.


# 1.36 23-Sep-2009 nicm

Remove PROMPT_HIDDEN code which is now unused.


# 1.35 23-Sep-2009 nicm

Remove the internal tmux locking and instead detach each client and run the
command specified by a new option "lock-command" (by default "lock -np") in
each client.

This means each terminal has to be unlocked individually but simplifies the
code and allows the system password to be used to unlock.

Note that the set-password command is gone, so it will need to be removed from
configuration files, and the -U command line flag has been removed.

This is the third protocol version change so again it is best to stop the tmux
server before upgrading.


# 1.34 20-Sep-2009 nicm

Regularise some fatal messages.


# 1.33 10-Sep-2009 nicm

Permit options such as status-bg to be configured using the entire 256 colour
palette by setting "colour0" to "colour255".


# 1.32 07-Sep-2009 nicm

Give each paste buffer a size member instead of requiring them to be
zero-terminated.


# 1.31 07-Sep-2009 nicm

Permit embedded colour and attributes in status-left and status-right using new
#[] special characters, for example #[fg=red,bg=blue,blink].


# 1.30 02-Sep-2009 nicm

Add a transpose-chars command in edit mode (C-t in emacs mode only). From Kalle
Olavi Niemitalo.


# 1.29 01-Sep-2009 nicm

Use "Password:" with no space for password prompts and don't display a *s for
the password, like pretty much everything else. From martynas@ with minor
tweaks by me.


# 1.28 31-Aug-2009 nicm

Add a new display-panes command, with two options (display-panes-colour and
display-panes-time), which displays a visual indication of the number of each
pane.


# 1.27 19-Aug-2009 nicm

Extend command-prompt with a -p option which is a comma-separated list of one
or more prompts to present in order.

The responses to the prompt are replaced in the template string: %% are
replaced in order, so the first prompt replaces the first %%, the second
replaces the second, and so on. In addition, %1 up to %9 are replaced with the
responses to the first the ninth prompts

The default template is "%1" so the response to the first prompt is processed
as a command.

Note that this changes the behaviour for %% so if there is only one prompt,
only the first %% will be replaced. Templates such as "neww -n '%%' 'ssh %%'"
should be changed to "neww -n '%1' 'ssh %1'".

From Tiago Cunha.


# 1.26 18-Aug-2009 nicm

Add a "delete line" key when editing in the status line or the search up/down
prompt. C-u with emacs keys, d with vi.


# 1.25 13-Aug-2009 nicm

Switch the prompt code to return an empty string when the user enters no
response and reserve NULL for an explicit cancel. Change all callbacks to treat
them the same so no functional change.

Also add cancel key bindings to emacs mode which were missing.


# 1.24 08-Aug-2009 nicm

Options to set the colours and attributes for status-left/-right. From Thomas
Adam, thanks.


# 1.23 05-Aug-2009 nicm

If colours are not supported by the terminal, try to emulate a coloured
background by setting or clearing the reverse attribute.

This makes a few applications which don't use the reverse attribute themselves
a little happier, and allows the status, message and mode options to have
default attributes and fg/bg options that work as expected when set as reverse.


# 1.22 30-Jul-2009 nicm

Plug some memory leaks.


# 1.21 28-Jul-2009 nicm

Next step towards customisable mode keys: build each default table of keys into
a named tree on start and use that for lookups. Also add command to string
translation tables and modify list-keys to show the the mode key bindings (new
-t argument).


# 1.20 27-Jul-2009 nicm

Change mode key bindings from big switches into a set of tables. Rather than
lumping them all together, split editing keys from those used in choice/more
mode and those for copy/scroll mode.

Tidier and clearer, and the first step towards customisable mode keys.


# 1.19 27-Jul-2009 nicm

Get rid of empty mode_key_free function.


# 1.18 27-Jul-2009 nicm

Add a key to delete to end of line at the prompt (^K in emacs mode, C/D in vi).

From Kalle Olavi Niemitalo.


# 1.17 26-Jul-2009 nicm

Calculate the space available for the prompt buffer and the cursor position
correctly, and make it work when the screen is not wide enough.

Noticed by Kalle Olavi Niemitalo.


# 1.16 21-Jul-2009 nicm

Remove a couple of unused functions and fix a type ("FALLTHOUGH"), found by
lint.


# 1.15 20-Jul-2009 nicm

Add a status-justify option to allow the window list in the status line to be
positioned at the left, centre, or right.


# 1.14 20-Jul-2009 nicm

New options, window-status-current-{fg,bg,attr}, to set the fg, bg and
attributes with which the current window is shown in the status line. From
Johan Friis, thanks.


# 1.13 17-Jul-2009 nicm

- New command display-message (alias display) to display a message in the
status line (bound to "i" and displays the current window and time by
default). The same substitutions are applied as for status-left/right.
- Add support for including the window index (#I), pane index (#P) and window
name (#W) in the message, and status-left or status-right.
- Bump protocol version.

From Tiago Cunha, thanks!


# 1.12 17-Jul-2009 nicm

Memory could be leaked if a second prompt or message appeared while another was
still present, so add a separate prompt free callback and make the _clear
function responsible for calling it if necessary (rather than the individual
prompt callbacks). Also make both messages and prompts clear any existing when
a new is set.

In addition, the screen could be modified while the prompt is there, restore
the redraw-entire-screen behaviour on prompt clear; add a comment as a
reminder.


# 1.11 16-Jul-2009 nicm

Remove some duplicate code that was causing the status line to be redrawn even
when it hadn't changed.


# 1.10 15-Jul-2009 nicm

Make status_message_set a variadic printf-like function. No functional change -
helpful for a couple of things coming soon.


# 1.9 15-Jul-2009 nicm

Having to update NSETOPTION/NSETWINDOWOPTION when adding new options is a bit
annoying and it is only use for iterating, so use a sentinel to mark the end of
each array instead. Different fix for a problem pointed out by Kalle Olavi
Niemitalo.


# 1.8 14-Jul-2009 nicm

For some reason when clearing status/message it was redrawing the entire client
not just the status line. Changing this also revealed the check for the status
line was incorrect when drawing the pane.


# 1.7 14-Jul-2009 nicm

Instead of faking up a status line in status_redraw, use the same code to
redraw it as to draw the entire screen, just skip all lines but the last.

This makes horizontal split redraw properly when the status line is off.


# 1.6 12-Jul-2009 nicm

Add a "back to indentation" key in copy mode to move the cursor to the first
non-whitespace character. ^ with vi and M-m with emacs key bindings. Another
from Kalle Olavi Niemitalo, thanks.


Revision tags: OPENBSD_4_6_BASE
# 1.5 26-Jun-2009 nicm

Status line fixes: don't truncate status-right now the length calculation is
done for UTF-8, limit to the maximum length correctly when printing, and always
print a space even if the left string is longer than the width available.


# 1.4 04-Jun-2009 nicm

If the prompt is hidden or a password is sent with -U, zero it before freeing
it.


# 1.3 03-Jun-2009 nicm

New session option, status-utf8, to control the interpretation of top-bit-set
characters in status-left and status-right (if on, they are treated as UTF-8;
otherwise passed through).


# 1.2 03-Jun-2009 nicm

Add a UTF-8 aware string length function and make UTF-8 in
status-left/status-right work properly. At the moment any top-bit-set
characters are assumed to be UTF-8: a status-utf8 option to configure this will
come shortly.


# 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.231 15-Nov-2021 nicm

Leave the hardware cursor at the position of the selected line in choose
modes and current editing position and at the command prompt. It is
invisible but this is helpful for people using screen readers. GitHub
issue 2970.


# 1.230 01-Nov-2021 nicm

Fix a comparison, from Ben Boeckel, and a crash when opening completion
menu, from Anindya Mukherjee.


# 1.229 26-Oct-2021 nicm

Accept some emacs control keys in vi normal mode, from Alexis
Hildebrandt in GitHub issue 2922.


# 1.228 26-Oct-2021 nicm

Do not allow inline styles to replace mode-style for the selected item,
from Alexis Hildebrandt in GitHub issue 2946.


Revision tags: OPENBSD_7_0_BASE
# 1.227 20-Aug-2021 nicm

Remove stray spaces after function names.


# 1.226 12-Aug-2021 nicm

Use COLOUR_DEFAULT not hardcoded 8.


# 1.225 10-Jun-2021 nicm

More accurate vi(1) word navigation in copy mode and on the status line.
This changes the meaning of the word-separators option - setting it to
the empty string is equivalent to the previous behavior. From Will Noble
in GitHub issue 2693.


# 1.224 10-Jun-2021 nicm

Add different command historys for different types of prompts
("command", "search" etc). From Anindya Mukherjee.


# 1.223 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.222 10-Jun-2021 nicm

Include current client in size calculation for new sessions, GitHub
issue 2662.


Revision tags: OPENBSD_6_9_BASE
# 1.221 12-Apr-2021 nicm

Add a flag to disable keys to close a message, GitHub issue 2625.


# 1.220 22-Feb-2021 nicm

Move jump commands to grid reader, make them UTF-8 aware, and tidy up,
from Anindya Mukherjee.


# 1.219 08-Jan-2021 nicm

With incremental search, start empty and only repeat the previous search
if the user tries to search again with an empty prompt. This matches
emacs behaviour more closely.


Revision tags: OPENBSD_6_8_BASE
# 1.218 27-Jul-2020 nicm

Add a -d option to display-message to set delay, from theonekeyg at
gmail dot com in GitHub issue 2322.


# 1.217 11-Jun-2020 nicm

Fix a crash when completing sessions, from Anindya Mukherjee.


# 1.216 26-May-2020 nicm

Remove leftover debug logging and fix comparison.


# 1.215 26-May-2020 nicm

Set up UTF-8 data for ASCII keys correctly.


# 1.214 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.213 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.212 16-May-2020 nicm

Rename KEYC_ESCAPE to KEYC_META.


# 1.211 16-May-2020 nicm

Expand target from client and use it to expand the prompt.


# 1.210 16-May-2020 nicm

Support embedded styles in the display-message message, GitHub issue
2206.


# 1.209 16-May-2020 nicm

Change message log to be per server rather than per client and include
every command that is run.


# 1.208 16-May-2020 nicm

Do not hoke into struct window_pane from the tty code and instead set
everything up in tty_ctx. Provide a way to initialize the tty_ctx from a
callback and use it to let popups draw directly through input_parse in
the same way as panes do, rather than forcing a full redraw on every
change.


# 1.207 16-May-2020 nicm

Use formats for status-style and message-style.


# 1.206 16-May-2020 nicm

Complete partial window indexes properly.


# 1.205 16-May-2020 nicm

Add -W and -T flags to command-prompt to only complete a window and a
target, also complete aliases.


# 1.204 16-May-2020 nicm

Improve command prompt completion:

- Show a menu with completions if there are multiple.

- Don't complete argument stuff (options, layouts) at start of text.

- For -t and -s, if there is no : then complete sessions but if there is
a :, show a menu of all windows in the session rather than trying to
complete the window name which is a bit useless if there are
duplicates.


# 1.203 16-May-2020 nicm

Drop having a separate type for style options and make them all strings,
which allows formats to be expanded. Any styles without a '#{' are still
validated when they are set but any with a '#{' are not. Formats are not
expanded usefully in many cases yet, that will be changed later.

To make this work, a few other changes:

- set-option -a with a style option automatically appends a ",".

- OSC 10 and 11 don't set the window-style option anymore, instead the
fg and bg are stored in the pane struct and act as the defaults that
can be overridden by window-style.

- status-fg and -bg now override status-style instead of trying to keep
them in sync.


Revision tags: OPENBSD_6_7_BASE
# 1.202 12-Mar-2020 nicm

Add C-g to cancel command prompt with vi(1) keys as well as emacs, and q
in command mode.


# 1.201 27-Jan-2020 nicm

Add support for adding a note to a key binding (with bind-key -N) and
use this to add descriptions to the default key bindings. A new -N flag
to list-keys shows key bindings with notes rather than the default
bind-key command used to create them. Change the default ? binding to
use this to show a readable summary of keys.

Also extend command-prompt to return the name of the key pressed and add
a default binding (/) to show the note for the next key pressed

Suggested by Alex Tremblay in GitHub issue 2000.


Revision tags: OPENBSD_6_6_BASE
# 1.200 28-May-2019 nicm

Redraw status line if size changes, GitHub issue 1762. Also fix length
of target buffer when pasting into status line.


# 1.199 23-May-2019 nicm

Fix length calculation for pasting UTF-8 characters in the status line,
GitHub issue 1753.


# 1.198 11-May-2019 nicm

Do not reduce window height by status line height for control mode
clients, from George Nachman.


# 1.197 03-May-2019 nicm

Fix reverse attribute in status line, GitHub issue 1709.


# 1.196 26-Apr-2019 nicm

Merge hooks into options and make each one an array option. This allows
multiple commands to be easily bound to one hook. set-hook and
show-hooks remain but they are now variants of set-option and
show-options. show-options now has a -H flag to show hooks (by default
they are not shown).


# 1.195 25-Apr-2019 nicm

options_array_item_value cannot return NULL.


# 1.194 23-Apr-2019 nicm

Somehow missed these bits in last commit.


# 1.193 23-Apr-2019 nicm

Indicate an array option with a flag rather than a special type so that
in future will not have to be strings.


Revision tags: OPENBSD_6_5_BASE
# 1.192 18-Mar-2019 nicm

Extend the #[] style syntax and use that together with previous format
changes to allow the status line to be entirely configured with a single
option.

Now that it is possible to configure their content, enable the existing
code that lets the status line be multiple lines in height. The status
option can now take a value of 2, 3, 4 or 5 (as well as the previous on
or off) to configure more than one line. The new status-format array
option configures the format of each line, the default just references
the existing status-* options, although some of the more obscure status
options may be eliminated in time.

Additions to the #[] syntax are: "align" to specify alignment (left,
centre, right), "list" for the window list and "range" to configure
ranges of text for the mouse bindings.

The "align" keyword can also be used to specify alignment of entries in
tree mode and the pane status lines.


# 1.191 18-Mar-2019 nicm

Make array options a sparse tree instead of an array of char * and
remove the size limit.


# 1.190 18-Mar-2019 nicm

With force, kill previous job before starting new. Fixes problem
reported by Scott Mcdermott in GitHub issue 1627.


# 1.189 16-Mar-2019 nicm

Use a pointer for the active screen in the status line instead of
copying them around all the time.


# 1.188 16-Mar-2019 nicm

Give status_save_old the client so it can do the reinit too.


# 1.187 16-Mar-2019 nicm

Tidy and rename some bits of status line code.


# 1.186 15-Mar-2019 nicm

Move status line free into its own function.


# 1.185 14-Mar-2019 nicm

Store the time in the format tree rather than passing it around.


# 1.184 12-Mar-2019 nicm

DECRC and DECSC apparently need to preserve origin mode as well, based
on a fix from Marc Reisner.


# 1.183 09-Feb-2019 nicm

Completion of command-alias members.


# 1.182 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.181 29-Aug-2018 nicm

Keep any text killed in the command prompt with C-w and yank it with
C-y, only use the top buffer if no text has previously been killed. This
and previous change promped by discussion with kn@.


# 1.180 29-Aug-2018 nicm

Add C-Left and C-Right as aliases for M-b and M-f.


# 1.179 22-Aug-2018 nicm

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


# 1.178 20-Aug-2018 nicm

Move offset of window list into status struct.


# 1.177 19-Aug-2018 nicm

Add a client redraw-window flag instead of the redraw-all flag and for
all just use the three flags together (window, borders, status).


Revision tags: OPENBSD_6_3_BASE
# 1.176 22-Feb-2018 nicm

Remove an unused variable.


# 1.175 05-Feb-2018 nicm

Add struct status_line to hold status line members of struct client, not
used yet but will be soon. From Thomas Adam.


# 1.174 01-Jan-2018 nicm

Add C-g at command prompt for emacs people, GitHub issue 1213.


# 1.173 27-Dec-2017 nicm

Draw command prompt correctly with status line off.


# 1.172 18-Dec-2017 nicm

Remove unused variable from Thomas Adam.


# 1.171 02-Nov-2017 nicm

Add a "fast" version of screen_write_copy for tree mode that doesn't do
all the checks and selection and marking stuff needed for copy mode.


# 1.170 20-Oct-2017 nicm

Clear status line with spaces again so reverse works, spotted by sthen.


# 1.169 16-Oct-2017 nicm

Infrastructure for drawing status lines of more than one line in height,
still only one is allowed but this lets tmux draw bigger ones.


Revision tags: OPENBSD_6_2_BASE
# 1.168 29-May-2017 nicm

Add a flag to stop the prompt input being expanded.


# 1.167 29-May-2017 nicm

Store a copy of the old status line, will be needed soon for new choose mode.


# 1.166 17-May-2017 nicm

Tidy command prompt callbacks and pass in the client.


# 1.165 03-May-2017 nicm

Add a format for the last search string in copy mode and fix the prompt
so it can work when in -I, suggested by Suraj N Kurapati.


# 1.164 01-May-2017 nicm

In order that people can use formats like #D in #() in the status line
and not have to wait for an update when they change pane, we allow
commands to run more than once a second if the expanded form
changes. Unfortunately this can mean them being run far too often
(pretty much continually) when multiple clients exist, because some
formats (including #D) will always differ between clients.

To avoid this, give each client its own tree of jobs which means that
the same command will be different instances for each client - similar
to how we have the tag to separate commands for different panes.

GitHub issue 889; test case reported by Paul Johnson.


# 1.163 22-Apr-2017 nicm

Memory leak from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.162 09-Feb-2017 nicm

Break the message storage function into its own function, useful for
debugging.


# 1.161 03-Feb-2017 nicm

Cache status line position to reduce option lookups during output.


# 1.160 03-Feb-2017 nicm

Add a window or pane id "tag" to each format tree and use it to separate
jobs, this means that if the same job is used for different windows or
panes (for example in pane-border-format), it will be run separately for
each pane.


# 1.159 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.158 06-Jan-2017 nicm

Incremental search in copy mode (on for emacs keys by default) - much
the same as normal searching but updates the cursor position and marked
search terms as you type. C-r and C-s in the prompt repeat the search,
once finished searching (with Enter), N and n work as before.


# 1.157 05-Jan-2017 nicm

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


# 1.156 07-Dec-2016 nicm

Do not clear the prompt when a message is shown, just leave it around and
return to it when the message is finished.


# 1.155 12-Oct-2016 nicm

Drop the edit mode key tables and just use fixed key bindings for the
command prompt.


# 1.154 12-Oct-2016 nicm

The repeat prompt in both emacs and vi (and the old one in tmux) doesn't
support line editing and instead executes a command as soon as a
non-number key is pressed. Add a -N flag to command-prompt for the same
in copy mode. Reported by Theo Buehler.


# 1.153 11-Oct-2016 nicm

Fundamental change to how copy mode key bindings work:

The vi-copy and emacs-copy mode key tables are gone, and instead copy
mode commands are bound in one of two normal key tables ("copy-mode" or
"copy-mode-vi"). Keys are bound to "send-keys -X copy-mode-command". So:

bind -temacs-copy C-Up scroll-up
bind -temacs-copy -R5 WheelUpPane scroll-up

Becomes:

bind -Tcopy-mode C-Up send -X scroll-up
bind -Tcopy-mode WheelUpPane send -N5 -X scroll-up

This allows the full command parser and command set to be used - for
example, we can use the normal command prompt for searching, jumping,
and so on instead of a custom one:

bind -Tcopy-mode C-r command-prompt -p'search up' "send -X search-backward '%%'"

command-prompt also gets a -1 option to only require on key press, which
is needed for jumping.

The plan is to get rid of mode keys entirely, so more to come eventually.


# 1.152 11-Oct-2016 nicm

Support UTF-8 entry into the command prompt.


# 1.151 10-Oct-2016 nicm

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


# 1.150 12-Sep-2016 nicm

Allow repeat count to be specified in mode key tables with bind-key -R,
and set the default repeat count to 5 for WheelUp and WheelDown in
copy-mode.


Revision tags: OPENBSD_6_0_BASE
# 1.149 06-Jun-2016 nicm

Allow #[] in window-status-separator.


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

I no longer use my SourceForge address so replace it.


# 1.147 01-Jan-2016 nicm

Don't rely on a calculation wrapping when applying message-limit, and
break out of the loop early. From Nicolas Viennot.


# 1.146 11-Dec-2015 nicm

Style nits and line wrapping of function declarations.


# 1.145 11-Dec-2015 nicm

Add cmdq as an argument to format_create and add a format for the
command name (will also be used for more later).


# 1.144 08-Dec-2015 nicm

Remove format_create_flags and just pass flags to format_create.


# 1.143 22-Nov-2015 tim

If display-time is set to 0, show status messages until a key is pressed;
OK nicm@


# 1.142 20-Nov-2015 nicm

Instead of separate tables for different types of options, give each
option a scope type (server, session, window) in one table.


# 1.141 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.140 13-Nov-2015 nicm

Long overdue change to the way we store cells in the grid: now, instead
of storing a full grid_cell with UTF-8 data and everything, store a new
type grid_cell_entry. This can either be the cell itself (for ASCII
cells), or an offset into an extended array (per line) for UTF-8
data.

This avoid a large (8 byte) overhead on non-UTF-8 cells (by far the
majority for most users) without the complexity of the shadow array we
had before. Grid memory without any UTF-8 is about half.

The disadvantage that cells can no longer be modified in place and need
to be copied out of the grid and back but it turned out to be lot less
complicated than I expected.


# 1.139 12-Nov-2015 nicm

Nuke the utf8 and status-utf8 options and make tmux only a UTF-8
terminal. We still support non-UTF-8 terminals outside tmux, but inside
it is always UTF-8 (as when the utf8 and status-utf8 options were on).


# 1.138 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.137 27-Oct-2015 nicm

Move struct options into options.c.


# 1.136 20-Oct-2015 nicm

Use client pointer not file descriptor in logging.


# 1.135 14-Sep-2015 nicm

Make refresh-client force update of jobs, from Sina Siadat.


# 1.134 29-Aug-2015 nicm

Move struct paste_buffer out of tmux.h.


# 1.133 28-Aug-2015 nicm

Run status update on a per-client timer at status-interval.


Revision tags: OPENBSD_5_8_BASE
# 1.132 29-Jul-2015 nicm

status_out and associated data structures are no longer used.


# 1.131 28-Jul-2015 nicm

Tidy up the way terminals are described and move some structs out of tmux.h.


# 1.130 20-Jul-2015 nicm

Add an option (history-file) for a file to save/restore command prompt
history, from Olof-Joachim Frahm.


# 1.129 27-May-2015 nicm

Move the jobs output cache into the formats code so that #() work more
generally (for example, again working in set-titles-string).


# 1.128 06-May-2015 nicm

Remove ARRAY_* from history and expand completion to complete a) layout
names and b) targets beginning with -t or -s.


# 1.127 25-Apr-2015 nicm

Make message log a TAILQ.


# 1.126 24-Apr-2015 nicm

Set working directory for run-shell and if-shell.


# 1.125 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_7_BASE
# 1.124 06-Feb-2015 nicm

Use the same time for both calls to format_expand_time.


# 1.123 06-Feb-2015 nicm

status_replace can now become local to status.c and it no longer needs
the jobsflag argument. While here there is no need to repeat work that
format_defaults already does.


# 1.122 06-Feb-2015 nicm

Add format_expand_time and use it instead of status_replace where
command execution is not needed.


# 1.121 05-Feb-2015 nicm

Wrap all the individual format_* calls in a single format_defaults
functions.


# 1.120 01-Feb-2015 nicm

Remove two unused arguments from status_replace.


# 1.119 20-Jan-2015 sthen

typo in comment ;) ok nicm


# 1.118 05-Nov-2014 nicm

Do not put a space between status-left/status-right and the window list,
instead move the space into the defaults for the options (so status-left
now defaults to "[#S] ". From Balazs Kezes.


# 1.117 20-Oct-2014 nicm

Better format for printf format attributes.


# 1.116 08-Oct-2014 nicm

Add xreallocarray and remove nmemb argument from xrealloc.


# 1.115 02-Oct-2014 nicm

Take account of window-status-separator when checking window position,
based on diff from Balazs Kezes.


Revision tags: OPENBSD_5_6_BASE
# 1.114 24-Apr-2014 nicm

There is no longer a need for a paste_stack struct or for global_buffers
to be global. Move to paste.c.


# 1.113 17-Apr-2014 nicm

Remove the monitor-content option and associated bits and bobs. It's
never worked very well. If there is a big demand for it to return, will
consider better ways to do it.


# 1.112 02-Apr-2014 nicm

Do not replace ## with # in status_replace1 because it'll be done later
by the format code.


# 1.111 31-Mar-2014 nicm

Make message-limit a server option.


Revision tags: OPENBSD_5_5_BASE
# 1.110 14-Feb-2014 nicm

Style nit - no space between function name and bracket.


# 1.109 14-Feb-2014 nicm

Check for NULL session and whatnot in status_replace, from Thomas Adam.


# 1.108 28-Jan-2014 nicm

Allow replacing each of the many sets of separate foo-{fg,bg,attr}
options with a single foo-style option. For example:

set -g status-fg yellow
set -g status-bg red
set -g status-attr blink

Becomes:

set -g status-style fg=yellow,bg=red,blink

The -a flag to set can be used to add to rather than replace a style. So:

set -g status-bg red

Becomes:

set -ag status-style bg=red

Currently this is fully backwards compatible (all *-{fg,bg,attr} options
remain) but the plan is to deprecate them over time.

From Tiago Cunha.


Revision tags: OPENBSD_5_4_BASE
# 1.107 05-Jul-2013 nicm

Whitespace nits, from Ben Boeckel.


# 1.106 05-Jul-2013 nicm

Act like vi(1) when moving words, from Ben Boeckel.


# 1.105 05-Jul-2013 nicm

Implement s, S, C mode switch commands in vi(1) mode, from Ben Boeckel.


# 1.104 31-May-2013 nicm

Demote the old single-character replacement variables (#S and friends)
to aliases of formats. From Tiago Cunha.


# 1.103 25-Mar-2013 nicm

Extend jobs to support writing and use that for copy-pipe instead of
popen, from Chris Johnsen.


# 1.102 22-Mar-2013 nicm

evbuffer_readline returns allocated storage, don't leak it.


# 1.101 22-Mar-2013 nicm

Add copy-pipe mode command to copy selection and also pipe to a command.


# 1.100 22-Mar-2013 nicm

No more lint means no more ARGSUSED.


# 1.99 21-Mar-2013 nicm

Aargh. Spaces -> tabs.


# 1.98 21-Mar-2013 nicm

Do not leak formats in status_replace.


# 1.97 21-Mar-2013 nicm

Add a format client_prefix which is 1 if prefix key has been
pressed, used for example #{?client_prefix,X,Y}. Also a few extra
server_client_status needed.


# 1.96 21-Mar-2013 nicm

Allow formats in status options.


Revision tags: OPENBSD_5_3_BASE
# 1.95 27-Nov-2012 nicm

Add window-status-last-* options, from Boris Faure.


Revision tags: OPENBSD_5_2_BASE
# 1.94 10-Jul-2012 nicm

xfree is not particularly helpful, remove it. From Thomas Adam.


# 1.93 09-Jul-2012 nicm

Move a NULL check inside a function, from Tiago Cunha.


# 1.92 29-Apr-2012 nicm

Use int not u_char for colours from options since they may have bit 8
set to mark them as 256-colour. Reported by Chris Johnson.


# 1.91 23-Apr-2012 nicm

Add window-status-separator option, from Thomas Adam.


# 1.90 17-Mar-2012 nicm

Check event_initialized before event_del if event may not have been set
up; libevent2 complains about this. Reported by Moriyoshi Koizumi.


# 1.89 04-Mar-2012 nicm

Add A and I keys for vi status line editing.


# 1.88 03-Mar-2012 nicm

The wlmouse offset should be part of the client, not the server. From
Ailin Nemui.


Revision tags: OPENBSD_5_1_BASE
# 1.87 29-Jan-2012 nicm

Add an option to move the status line to the top of the screen,
requested by many.


# 1.86 26-Jan-2012 nicm

Terminate strftime buffer properly even if a really long format string
is given, from Tiago Cunha.


# 1.85 26-Jan-2012 nicm

Fix memory leak in error path, from Tiago Cunha.


# 1.84 20-Jan-2012 nicm

Add some trivial additional status line attributes from jwcxz at users
dot sourceforge dot net.


# 1.83 20-Jan-2012 nicm

Add space movement keys for vi mode in the status line from Ben Boeckel.


# 1.82 01-Dec-2011 nicm

Make M-f and M-b work the same at the command prompt as in copy mode,
pointed out by Romain Francoise.


# 1.81 15-Nov-2011 nicm

Add word movement and editing command for command prompt editing, from
Ben Boeckel.


# 1.80 15-Nov-2011 nicm

Make window_pane_index work the same as window_index, from Ben Boeckel.


# 1.79 05-Nov-2011 nicm

Option to change status line (message) background when using vi keys and
in command mode. From Ben Boeckel.


# 1.78 20-Aug-2011 nicm

Fix a couple of memory leaks, from marcel partap.


Revision tags: OPENBSD_5_0_BASE
# 1.77 08-Jul-2011 nicm

Make confirm-before prompt customizable with -p option like
command-prompt. Also move responsibility for calling status_replace into
status_prompt_{set,update} and add #W and #P to the default kill-window
and kill-pane prompts. By Tiago Cunha.


# 1.76 02-Jul-2011 nicm

Allow the initial context on prompts to be set with the new -I option to
command-prompt. From Tiago Cunha.


# 1.75 29-Apr-2011 nicm

Only redraw the status line on command update, not the entire client
(big DOH).


# 1.74 24-Apr-2011 nicm

Provide #h for short hostname (no domain) from Michal Mazurek.


# 1.73 18-Apr-2011 nicm

Add an option (mouse-select-window) which allows the mouse to be used by
clicking on the status line, written by hsim at gmx dot li.


# 1.72 29-Mar-2011 nicm

Change -t on display-message to be target-pane for the #[A-Z]
replacements and add -c as target-client.


Revision tags: OPENBSD_4_9_BASE
# 1.71 26-Jan-2011 nicm

Simplify the way jobs work and drop the persist type, so all jobs are
fire-and-forget.

Status jobs now managed with two trees of output (new and old), rather
than storing the output in the jobs themselves. When the status line is
processed any jobs which don't appear in the new tree are started and
the output from the old tree displayed. When a job finishes it updates
the new tree with its output and that is used for any subsequent
redraws. When the status interval expires, the new tree is moved to the
old so that all jobs are run again.

This fixes the "#(echo %H:%M:%S)" problem which would lead to thousands
of identical persistent jobs and high memory use (this can still be
achieved by adding "sleep 30" but that is much less likely to happen by
accident).


# 1.70 03-Jan-2011 nicm

Handle a # at the end of a replacement string (such as status-left)
correctly. Found by Thomas Adam.


# 1.69 01-Jan-2011 nicm

Move the user-visible parts of all options (names, types, limit, default
values) together into one set of tables in options-table.c. Also clean
up and simplify cmd-set-options.c and move a common print function into
option-table.c.


# 1.68 30-Dec-2010 nicm

Change from a per-session stack of buffers to one global stack which is
much more convenient and also simplifies lot of code. This renders
copy-buffer useless and makes buffer-limit now a server option.

By Tiago Cunha.


# 1.67 30-Dec-2010 nicm

Add a function to create window flags rather than doing the same thing
in two places. From Thomas Adam.


# 1.66 11-Dec-2010 nicm

Oops, these functions return a const char *, so make the local variable
const as well.


# 1.65 11-Dec-2010 nicm

Make the prompt history global for all clients which is much more useful than per-client history.


# 1.64 06-Dec-2010 nicm

Add an option to alert (monitor) for silence (lack of activity) in a
window. From Thomas Adam.


Revision tags: OPENBSD_4_8_BASE
# 1.63 21-Jun-2010 nicm

Having a list of winlinks->alerts for each session is stupid, just store
the alert flags directly in the winlink itself.


# 1.62 14-May-2010 nicm

Colour+attribute options for status line alerts, from Alex Alexander.


# 1.61 31-Mar-2010 nicm

Don't accept keys with modifiers as input. Fixes crash reported by Brian
R Landy.


# 1.60 27-Mar-2010 nicm

Don't leak job command in #().


# 1.59 22-Mar-2010 nicm

Dead functions, lint.


Revision tags: OPENBSD_4_7_BASE
# 1.58 27-Jan-2010 nicm

Calculate offset correctly, fixes incorrect offset and prevents crash when
status-left is empty. From Micah Cowan.


# 1.57 26-Jan-2010 nicm

Actually use the copy made when no newline is found, from martynas@.


# 1.56 14-Dec-2009 nicm

Add server options to completion as well.


# 1.55 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.54 03-Dec-2009 nicm

Eliminate duplicate code and ease the passage for server-wide options by adding
a -w flag to set-option and show-options and making setw and showw aliases to
set -w and show -w.

Note: setw and showw are still there, but now aliases for set -w and show -w.


# 1.53 26-Nov-2009 nicm

Tidy up various bits of the paste code, make the data buffer char * and add
comments.


# 1.52 26-Nov-2009 nicm

Remove a couple of unused arguments where possible, and add /* ARGSUSED */ to
the rest to reduce lint output.


# 1.51 20-Nov-2009 nicm

Display UTF-8 properly in status line messages and prompt. Cursor handling is
still way off though.


# 1.50 20-Nov-2009 nicm

Remove oldest messages from log when limit is hit, not newest.


# 1.49 19-Nov-2009 nicm

Get some brackets in the right place so ## works. Also fix a space in a
comment.


# 1.48 19-Nov-2009 nicm

Change status line drawing to create the window list in a separate screen and
then copy it into the status line screen. This allows UTF-8 in window names and
fixes some problems with #[] in window-status-format.


# 1.47 19-Nov-2009 nicm

Two new options, window-status-format and window-status-current-format, which
allow the format of each window in the status line window list to be controlled
using similar # sequences as status-left/right.

This diff also moves part of the way towards UTF-8 support in window names but
it isn't quite there yet.


# 1.46 19-Nov-2009 nicm

Tidy up by breaking the # replacement code into a separate function, also add a
few comments.


# 1.45 19-Nov-2009 nicm

Don't interpret #() for display-message, it usually doesn't make sense and may
leak commands.


# 1.44 18-Nov-2009 nicm

Add a per-client log of status line messages displayed while that client
exists. A new message-limit session option sets the maximum number of entries
and a command, show-messages, shows the log (bound to ~ by default).

This (and prompt history) might be better as a single global log but until
there are global options it is easier for them to be per client.


# 1.43 17-Nov-2009 nicm

Permit top-bit-set characters to be entered in the status line. They could
already be set from the shell and are just passed through when printing (so
invisible characters or displaying on terminals with different character sets
may cause problems).

Note that entering UTF-8 may not work and in any case currently the status line
cannot display it correctly (outside of status-left/status-right).


# 1.42 04-Nov-2009 nicm

Use timeout events for the identify and message timers.


# 1.41 04-Nov-2009 nicm

Switch jobs over to use a bufferevent.


# 1.40 04-Nov-2009 nicm

Unused (but assigned to) variable, found by lint.


# 1.39 01-Nov-2009 nicm

Add a flag for jobs that shouldn't be freed after they've died and use it for
status jobs, then only kill those jobs when status-left, status-right or
set-titles-string is changed.

Fixes problems with changing options from inside #().


# 1.38 10-Oct-2009 nicm

Rather than running status-left, status-right and window title #() with popen
immediately every redraw, queue them up and run them in the background,
starting each once every status-interval. The actual status line uses the
output from the last run.

This brings several advantages:

- tmux itself may be called from inside #() without causing the server to hang;
- likewise, sleep or similar doesn't cause the server to block;
- commands aren't run excessively often when redrawing;
- commands shared by status-left and status-right, or used multiple times, will
only be run once.

run-shell and if-shell still use system()/popen() but will be changed over to
use this too later.


# 1.37 10-Oct-2009 nicm

Add "grouped sessions" which have independent name, options, current window and
so on but where the linked windows are synchronized (ie creating, killing
windows and so on are mirrored between the sessions). A grouped session may be
created by passing -t to new-session.

Had this around for a while, tested by a couple of people.


# 1.36 23-Sep-2009 nicm

Remove PROMPT_HIDDEN code which is now unused.


# 1.35 23-Sep-2009 nicm

Remove the internal tmux locking and instead detach each client and run the
command specified by a new option "lock-command" (by default "lock -np") in
each client.

This means each terminal has to be unlocked individually but simplifies the
code and allows the system password to be used to unlock.

Note that the set-password command is gone, so it will need to be removed from
configuration files, and the -U command line flag has been removed.

This is the third protocol version change so again it is best to stop the tmux
server before upgrading.


# 1.34 20-Sep-2009 nicm

Regularise some fatal messages.


# 1.33 10-Sep-2009 nicm

Permit options such as status-bg to be configured using the entire 256 colour
palette by setting "colour0" to "colour255".


# 1.32 07-Sep-2009 nicm

Give each paste buffer a size member instead of requiring them to be
zero-terminated.


# 1.31 07-Sep-2009 nicm

Permit embedded colour and attributes in status-left and status-right using new
#[] special characters, for example #[fg=red,bg=blue,blink].


# 1.30 02-Sep-2009 nicm

Add a transpose-chars command in edit mode (C-t in emacs mode only). From Kalle
Olavi Niemitalo.


# 1.29 01-Sep-2009 nicm

Use "Password:" with no space for password prompts and don't display a *s for
the password, like pretty much everything else. From martynas@ with minor
tweaks by me.


# 1.28 31-Aug-2009 nicm

Add a new display-panes command, with two options (display-panes-colour and
display-panes-time), which displays a visual indication of the number of each
pane.


# 1.27 19-Aug-2009 nicm

Extend command-prompt with a -p option which is a comma-separated list of one
or more prompts to present in order.

The responses to the prompt are replaced in the template string: %% are
replaced in order, so the first prompt replaces the first %%, the second
replaces the second, and so on. In addition, %1 up to %9 are replaced with the
responses to the first the ninth prompts

The default template is "%1" so the response to the first prompt is processed
as a command.

Note that this changes the behaviour for %% so if there is only one prompt,
only the first %% will be replaced. Templates such as "neww -n '%%' 'ssh %%'"
should be changed to "neww -n '%1' 'ssh %1'".

From Tiago Cunha.


# 1.26 18-Aug-2009 nicm

Add a "delete line" key when editing in the status line or the search up/down
prompt. C-u with emacs keys, d with vi.


# 1.25 13-Aug-2009 nicm

Switch the prompt code to return an empty string when the user enters no
response and reserve NULL for an explicit cancel. Change all callbacks to treat
them the same so no functional change.

Also add cancel key bindings to emacs mode which were missing.


# 1.24 08-Aug-2009 nicm

Options to set the colours and attributes for status-left/-right. From Thomas
Adam, thanks.


# 1.23 05-Aug-2009 nicm

If colours are not supported by the terminal, try to emulate a coloured
background by setting or clearing the reverse attribute.

This makes a few applications which don't use the reverse attribute themselves
a little happier, and allows the status, message and mode options to have
default attributes and fg/bg options that work as expected when set as reverse.


# 1.22 30-Jul-2009 nicm

Plug some memory leaks.


# 1.21 28-Jul-2009 nicm

Next step towards customisable mode keys: build each default table of keys into
a named tree on start and use that for lookups. Also add command to string
translation tables and modify list-keys to show the the mode key bindings (new
-t argument).


# 1.20 27-Jul-2009 nicm

Change mode key bindings from big switches into a set of tables. Rather than
lumping them all together, split editing keys from those used in choice/more
mode and those for copy/scroll mode.

Tidier and clearer, and the first step towards customisable mode keys.


# 1.19 27-Jul-2009 nicm

Get rid of empty mode_key_free function.


# 1.18 27-Jul-2009 nicm

Add a key to delete to end of line at the prompt (^K in emacs mode, C/D in vi).

From Kalle Olavi Niemitalo.


# 1.17 26-Jul-2009 nicm

Calculate the space available for the prompt buffer and the cursor position
correctly, and make it work when the screen is not wide enough.

Noticed by Kalle Olavi Niemitalo.


# 1.16 21-Jul-2009 nicm

Remove a couple of unused functions and fix a type ("FALLTHOUGH"), found by
lint.


# 1.15 20-Jul-2009 nicm

Add a status-justify option to allow the window list in the status line to be
positioned at the left, centre, or right.


# 1.14 20-Jul-2009 nicm

New options, window-status-current-{fg,bg,attr}, to set the fg, bg and
attributes with which the current window is shown in the status line. From
Johan Friis, thanks.


# 1.13 17-Jul-2009 nicm

- New command display-message (alias display) to display a message in the
status line (bound to "i" and displays the current window and time by
default). The same substitutions are applied as for status-left/right.
- Add support for including the window index (#I), pane index (#P) and window
name (#W) in the message, and status-left or status-right.
- Bump protocol version.

From Tiago Cunha, thanks!


# 1.12 17-Jul-2009 nicm

Memory could be leaked if a second prompt or message appeared while another was
still present, so add a separate prompt free callback and make the _clear
function responsible for calling it if necessary (rather than the individual
prompt callbacks). Also make both messages and prompts clear any existing when
a new is set.

In addition, the screen could be modified while the prompt is there, restore
the redraw-entire-screen behaviour on prompt clear; add a comment as a
reminder.


# 1.11 16-Jul-2009 nicm

Remove some duplicate code that was causing the status line to be redrawn even
when it hadn't changed.


# 1.10 15-Jul-2009 nicm

Make status_message_set a variadic printf-like function. No functional change -
helpful for a couple of things coming soon.


# 1.9 15-Jul-2009 nicm

Having to update NSETOPTION/NSETWINDOWOPTION when adding new options is a bit
annoying and it is only use for iterating, so use a sentinel to mark the end of
each array instead. Different fix for a problem pointed out by Kalle Olavi
Niemitalo.


# 1.8 14-Jul-2009 nicm

For some reason when clearing status/message it was redrawing the entire client
not just the status line. Changing this also revealed the check for the status
line was incorrect when drawing the pane.


# 1.7 14-Jul-2009 nicm

Instead of faking up a status line in status_redraw, use the same code to
redraw it as to draw the entire screen, just skip all lines but the last.

This makes horizontal split redraw properly when the status line is off.


# 1.6 12-Jul-2009 nicm

Add a "back to indentation" key in copy mode to move the cursor to the first
non-whitespace character. ^ with vi and M-m with emacs key bindings. Another
from Kalle Olavi Niemitalo, thanks.


Revision tags: OPENBSD_4_6_BASE
# 1.5 26-Jun-2009 nicm

Status line fixes: don't truncate status-right now the length calculation is
done for UTF-8, limit to the maximum length correctly when printing, and always
print a space even if the left string is longer than the width available.


# 1.4 04-Jun-2009 nicm

If the prompt is hidden or a password is sent with -U, zero it before freeing
it.


# 1.3 03-Jun-2009 nicm

New session option, status-utf8, to control the interpretation of top-bit-set
characters in status-left and status-right (if on, they are treated as UTF-8;
otherwise passed through).


# 1.2 03-Jun-2009 nicm

Add a UTF-8 aware string length function and make UTF-8 in
status-left/status-right work properly. At the moment any top-bit-set
characters are assumed to be UTF-8: a status-utf8 option to configure this will
come shortly.


# 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.230 01-Nov-2021 nicm

Fix a comparison, from Ben Boeckel, and a crash when opening completion
menu, from Anindya Mukherjee.


# 1.229 26-Oct-2021 nicm

Accept some emacs control keys in vi normal mode, from Alexis
Hildebrandt in GitHub issue 2922.


# 1.228 26-Oct-2021 nicm

Do not allow inline styles to replace mode-style for the selected item,
from Alexis Hildebrandt in GitHub issue 2946.


Revision tags: OPENBSD_7_0_BASE
# 1.227 20-Aug-2021 nicm

Remove stray spaces after function names.


# 1.226 12-Aug-2021 nicm

Use COLOUR_DEFAULT not hardcoded 8.


# 1.225 10-Jun-2021 nicm

More accurate vi(1) word navigation in copy mode and on the status line.
This changes the meaning of the word-separators option - setting it to
the empty string is equivalent to the previous behavior. From Will Noble
in GitHub issue 2693.


# 1.224 10-Jun-2021 nicm

Add different command historys for different types of prompts
("command", "search" etc). From Anindya Mukherjee.


# 1.223 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.222 10-Jun-2021 nicm

Include current client in size calculation for new sessions, GitHub
issue 2662.


Revision tags: OPENBSD_6_9_BASE
# 1.221 12-Apr-2021 nicm

Add a flag to disable keys to close a message, GitHub issue 2625.


# 1.220 22-Feb-2021 nicm

Move jump commands to grid reader, make them UTF-8 aware, and tidy up,
from Anindya Mukherjee.


# 1.219 08-Jan-2021 nicm

With incremental search, start empty and only repeat the previous search
if the user tries to search again with an empty prompt. This matches
emacs behaviour more closely.


Revision tags: OPENBSD_6_8_BASE
# 1.218 27-Jul-2020 nicm

Add a -d option to display-message to set delay, from theonekeyg at
gmail dot com in GitHub issue 2322.


# 1.217 11-Jun-2020 nicm

Fix a crash when completing sessions, from Anindya Mukherjee.


# 1.216 26-May-2020 nicm

Remove leftover debug logging and fix comparison.


# 1.215 26-May-2020 nicm

Set up UTF-8 data for ASCII keys correctly.


# 1.214 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.213 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.212 16-May-2020 nicm

Rename KEYC_ESCAPE to KEYC_META.


# 1.211 16-May-2020 nicm

Expand target from client and use it to expand the prompt.


# 1.210 16-May-2020 nicm

Support embedded styles in the display-message message, GitHub issue
2206.


# 1.209 16-May-2020 nicm

Change message log to be per server rather than per client and include
every command that is run.


# 1.208 16-May-2020 nicm

Do not hoke into struct window_pane from the tty code and instead set
everything up in tty_ctx. Provide a way to initialize the tty_ctx from a
callback and use it to let popups draw directly through input_parse in
the same way as panes do, rather than forcing a full redraw on every
change.


# 1.207 16-May-2020 nicm

Use formats for status-style and message-style.


# 1.206 16-May-2020 nicm

Complete partial window indexes properly.


# 1.205 16-May-2020 nicm

Add -W and -T flags to command-prompt to only complete a window and a
target, also complete aliases.


# 1.204 16-May-2020 nicm

Improve command prompt completion:

- Show a menu with completions if there are multiple.

- Don't complete argument stuff (options, layouts) at start of text.

- For -t and -s, if there is no : then complete sessions but if there is
a :, show a menu of all windows in the session rather than trying to
complete the window name which is a bit useless if there are
duplicates.


# 1.203 16-May-2020 nicm

Drop having a separate type for style options and make them all strings,
which allows formats to be expanded. Any styles without a '#{' are still
validated when they are set but any with a '#{' are not. Formats are not
expanded usefully in many cases yet, that will be changed later.

To make this work, a few other changes:

- set-option -a with a style option automatically appends a ",".

- OSC 10 and 11 don't set the window-style option anymore, instead the
fg and bg are stored in the pane struct and act as the defaults that
can be overridden by window-style.

- status-fg and -bg now override status-style instead of trying to keep
them in sync.


Revision tags: OPENBSD_6_7_BASE
# 1.202 12-Mar-2020 nicm

Add C-g to cancel command prompt with vi(1) keys as well as emacs, and q
in command mode.


# 1.201 27-Jan-2020 nicm

Add support for adding a note to a key binding (with bind-key -N) and
use this to add descriptions to the default key bindings. A new -N flag
to list-keys shows key bindings with notes rather than the default
bind-key command used to create them. Change the default ? binding to
use this to show a readable summary of keys.

Also extend command-prompt to return the name of the key pressed and add
a default binding (/) to show the note for the next key pressed

Suggested by Alex Tremblay in GitHub issue 2000.


Revision tags: OPENBSD_6_6_BASE
# 1.200 28-May-2019 nicm

Redraw status line if size changes, GitHub issue 1762. Also fix length
of target buffer when pasting into status line.


# 1.199 23-May-2019 nicm

Fix length calculation for pasting UTF-8 characters in the status line,
GitHub issue 1753.


# 1.198 11-May-2019 nicm

Do not reduce window height by status line height for control mode
clients, from George Nachman.


# 1.197 03-May-2019 nicm

Fix reverse attribute in status line, GitHub issue 1709.


# 1.196 26-Apr-2019 nicm

Merge hooks into options and make each one an array option. This allows
multiple commands to be easily bound to one hook. set-hook and
show-hooks remain but they are now variants of set-option and
show-options. show-options now has a -H flag to show hooks (by default
they are not shown).


# 1.195 25-Apr-2019 nicm

options_array_item_value cannot return NULL.


# 1.194 23-Apr-2019 nicm

Somehow missed these bits in last commit.


# 1.193 23-Apr-2019 nicm

Indicate an array option with a flag rather than a special type so that
in future will not have to be strings.


Revision tags: OPENBSD_6_5_BASE
# 1.192 18-Mar-2019 nicm

Extend the #[] style syntax and use that together with previous format
changes to allow the status line to be entirely configured with a single
option.

Now that it is possible to configure their content, enable the existing
code that lets the status line be multiple lines in height. The status
option can now take a value of 2, 3, 4 or 5 (as well as the previous on
or off) to configure more than one line. The new status-format array
option configures the format of each line, the default just references
the existing status-* options, although some of the more obscure status
options may be eliminated in time.

Additions to the #[] syntax are: "align" to specify alignment (left,
centre, right), "list" for the window list and "range" to configure
ranges of text for the mouse bindings.

The "align" keyword can also be used to specify alignment of entries in
tree mode and the pane status lines.


# 1.191 18-Mar-2019 nicm

Make array options a sparse tree instead of an array of char * and
remove the size limit.


# 1.190 18-Mar-2019 nicm

With force, kill previous job before starting new. Fixes problem
reported by Scott Mcdermott in GitHub issue 1627.


# 1.189 16-Mar-2019 nicm

Use a pointer for the active screen in the status line instead of
copying them around all the time.


# 1.188 16-Mar-2019 nicm

Give status_save_old the client so it can do the reinit too.


# 1.187 16-Mar-2019 nicm

Tidy and rename some bits of status line code.


# 1.186 15-Mar-2019 nicm

Move status line free into its own function.


# 1.185 14-Mar-2019 nicm

Store the time in the format tree rather than passing it around.


# 1.184 12-Mar-2019 nicm

DECRC and DECSC apparently need to preserve origin mode as well, based
on a fix from Marc Reisner.


# 1.183 09-Feb-2019 nicm

Completion of command-alias members.


# 1.182 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.181 29-Aug-2018 nicm

Keep any text killed in the command prompt with C-w and yank it with
C-y, only use the top buffer if no text has previously been killed. This
and previous change promped by discussion with kn@.


# 1.180 29-Aug-2018 nicm

Add C-Left and C-Right as aliases for M-b and M-f.


# 1.179 22-Aug-2018 nicm

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


# 1.178 20-Aug-2018 nicm

Move offset of window list into status struct.


# 1.177 19-Aug-2018 nicm

Add a client redraw-window flag instead of the redraw-all flag and for
all just use the three flags together (window, borders, status).


Revision tags: OPENBSD_6_3_BASE
# 1.176 22-Feb-2018 nicm

Remove an unused variable.


# 1.175 05-Feb-2018 nicm

Add struct status_line to hold status line members of struct client, not
used yet but will be soon. From Thomas Adam.


# 1.174 01-Jan-2018 nicm

Add C-g at command prompt for emacs people, GitHub issue 1213.


# 1.173 27-Dec-2017 nicm

Draw command prompt correctly with status line off.


# 1.172 18-Dec-2017 nicm

Remove unused variable from Thomas Adam.


# 1.171 02-Nov-2017 nicm

Add a "fast" version of screen_write_copy for tree mode that doesn't do
all the checks and selection and marking stuff needed for copy mode.


# 1.170 20-Oct-2017 nicm

Clear status line with spaces again so reverse works, spotted by sthen.


# 1.169 16-Oct-2017 nicm

Infrastructure for drawing status lines of more than one line in height,
still only one is allowed but this lets tmux draw bigger ones.


Revision tags: OPENBSD_6_2_BASE
# 1.168 29-May-2017 nicm

Add a flag to stop the prompt input being expanded.


# 1.167 29-May-2017 nicm

Store a copy of the old status line, will be needed soon for new choose mode.


# 1.166 17-May-2017 nicm

Tidy command prompt callbacks and pass in the client.


# 1.165 03-May-2017 nicm

Add a format for the last search string in copy mode and fix the prompt
so it can work when in -I, suggested by Suraj N Kurapati.


# 1.164 01-May-2017 nicm

In order that people can use formats like #D in #() in the status line
and not have to wait for an update when they change pane, we allow
commands to run more than once a second if the expanded form
changes. Unfortunately this can mean them being run far too often
(pretty much continually) when multiple clients exist, because some
formats (including #D) will always differ between clients.

To avoid this, give each client its own tree of jobs which means that
the same command will be different instances for each client - similar
to how we have the tag to separate commands for different panes.

GitHub issue 889; test case reported by Paul Johnson.


# 1.163 22-Apr-2017 nicm

Memory leak from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.162 09-Feb-2017 nicm

Break the message storage function into its own function, useful for
debugging.


# 1.161 03-Feb-2017 nicm

Cache status line position to reduce option lookups during output.


# 1.160 03-Feb-2017 nicm

Add a window or pane id "tag" to each format tree and use it to separate
jobs, this means that if the same job is used for different windows or
panes (for example in pane-border-format), it will be run separately for
each pane.


# 1.159 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.158 06-Jan-2017 nicm

Incremental search in copy mode (on for emacs keys by default) - much
the same as normal searching but updates the cursor position and marked
search terms as you type. C-r and C-s in the prompt repeat the search,
once finished searching (with Enter), N and n work as before.


# 1.157 05-Jan-2017 nicm

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


# 1.156 07-Dec-2016 nicm

Do not clear the prompt when a message is shown, just leave it around and
return to it when the message is finished.


# 1.155 12-Oct-2016 nicm

Drop the edit mode key tables and just use fixed key bindings for the
command prompt.


# 1.154 12-Oct-2016 nicm

The repeat prompt in both emacs and vi (and the old one in tmux) doesn't
support line editing and instead executes a command as soon as a
non-number key is pressed. Add a -N flag to command-prompt for the same
in copy mode. Reported by Theo Buehler.


# 1.153 11-Oct-2016 nicm

Fundamental change to how copy mode key bindings work:

The vi-copy and emacs-copy mode key tables are gone, and instead copy
mode commands are bound in one of two normal key tables ("copy-mode" or
"copy-mode-vi"). Keys are bound to "send-keys -X copy-mode-command". So:

bind -temacs-copy C-Up scroll-up
bind -temacs-copy -R5 WheelUpPane scroll-up

Becomes:

bind -Tcopy-mode C-Up send -X scroll-up
bind -Tcopy-mode WheelUpPane send -N5 -X scroll-up

This allows the full command parser and command set to be used - for
example, we can use the normal command prompt for searching, jumping,
and so on instead of a custom one:

bind -Tcopy-mode C-r command-prompt -p'search up' "send -X search-backward '%%'"

command-prompt also gets a -1 option to only require on key press, which
is needed for jumping.

The plan is to get rid of mode keys entirely, so more to come eventually.


# 1.152 11-Oct-2016 nicm

Support UTF-8 entry into the command prompt.


# 1.151 10-Oct-2016 nicm

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


# 1.150 12-Sep-2016 nicm

Allow repeat count to be specified in mode key tables with bind-key -R,
and set the default repeat count to 5 for WheelUp and WheelDown in
copy-mode.


Revision tags: OPENBSD_6_0_BASE
# 1.149 06-Jun-2016 nicm

Allow #[] in window-status-separator.


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

I no longer use my SourceForge address so replace it.


# 1.147 01-Jan-2016 nicm

Don't rely on a calculation wrapping when applying message-limit, and
break out of the loop early. From Nicolas Viennot.


# 1.146 11-Dec-2015 nicm

Style nits and line wrapping of function declarations.


# 1.145 11-Dec-2015 nicm

Add cmdq as an argument to format_create and add a format for the
command name (will also be used for more later).


# 1.144 08-Dec-2015 nicm

Remove format_create_flags and just pass flags to format_create.


# 1.143 22-Nov-2015 tim

If display-time is set to 0, show status messages until a key is pressed;
OK nicm@


# 1.142 20-Nov-2015 nicm

Instead of separate tables for different types of options, give each
option a scope type (server, session, window) in one table.


# 1.141 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.140 13-Nov-2015 nicm

Long overdue change to the way we store cells in the grid: now, instead
of storing a full grid_cell with UTF-8 data and everything, store a new
type grid_cell_entry. This can either be the cell itself (for ASCII
cells), or an offset into an extended array (per line) for UTF-8
data.

This avoid a large (8 byte) overhead on non-UTF-8 cells (by far the
majority for most users) without the complexity of the shadow array we
had before. Grid memory without any UTF-8 is about half.

The disadvantage that cells can no longer be modified in place and need
to be copied out of the grid and back but it turned out to be lot less
complicated than I expected.


# 1.139 12-Nov-2015 nicm

Nuke the utf8 and status-utf8 options and make tmux only a UTF-8
terminal. We still support non-UTF-8 terminals outside tmux, but inside
it is always UTF-8 (as when the utf8 and status-utf8 options were on).


# 1.138 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.137 27-Oct-2015 nicm

Move struct options into options.c.


# 1.136 20-Oct-2015 nicm

Use client pointer not file descriptor in logging.


# 1.135 14-Sep-2015 nicm

Make refresh-client force update of jobs, from Sina Siadat.


# 1.134 29-Aug-2015 nicm

Move struct paste_buffer out of tmux.h.


# 1.133 28-Aug-2015 nicm

Run status update on a per-client timer at status-interval.


Revision tags: OPENBSD_5_8_BASE
# 1.132 29-Jul-2015 nicm

status_out and associated data structures are no longer used.


# 1.131 28-Jul-2015 nicm

Tidy up the way terminals are described and move some structs out of tmux.h.


# 1.130 20-Jul-2015 nicm

Add an option (history-file) for a file to save/restore command prompt
history, from Olof-Joachim Frahm.


# 1.129 27-May-2015 nicm

Move the jobs output cache into the formats code so that #() work more
generally (for example, again working in set-titles-string).


# 1.128 06-May-2015 nicm

Remove ARRAY_* from history and expand completion to complete a) layout
names and b) targets beginning with -t or -s.


# 1.127 25-Apr-2015 nicm

Make message log a TAILQ.


# 1.126 24-Apr-2015 nicm

Set working directory for run-shell and if-shell.


# 1.125 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_7_BASE
# 1.124 06-Feb-2015 nicm

Use the same time for both calls to format_expand_time.


# 1.123 06-Feb-2015 nicm

status_replace can now become local to status.c and it no longer needs
the jobsflag argument. While here there is no need to repeat work that
format_defaults already does.


# 1.122 06-Feb-2015 nicm

Add format_expand_time and use it instead of status_replace where
command execution is not needed.


# 1.121 05-Feb-2015 nicm

Wrap all the individual format_* calls in a single format_defaults
functions.


# 1.120 01-Feb-2015 nicm

Remove two unused arguments from status_replace.


# 1.119 20-Jan-2015 sthen

typo in comment ;) ok nicm


# 1.118 05-Nov-2014 nicm

Do not put a space between status-left/status-right and the window list,
instead move the space into the defaults for the options (so status-left
now defaults to "[#S] ". From Balazs Kezes.


# 1.117 20-Oct-2014 nicm

Better format for printf format attributes.


# 1.116 08-Oct-2014 nicm

Add xreallocarray and remove nmemb argument from xrealloc.


# 1.115 02-Oct-2014 nicm

Take account of window-status-separator when checking window position,
based on diff from Balazs Kezes.


Revision tags: OPENBSD_5_6_BASE
# 1.114 24-Apr-2014 nicm

There is no longer a need for a paste_stack struct or for global_buffers
to be global. Move to paste.c.


# 1.113 17-Apr-2014 nicm

Remove the monitor-content option and associated bits and bobs. It's
never worked very well. If there is a big demand for it to return, will
consider better ways to do it.


# 1.112 02-Apr-2014 nicm

Do not replace ## with # in status_replace1 because it'll be done later
by the format code.


# 1.111 31-Mar-2014 nicm

Make message-limit a server option.


Revision tags: OPENBSD_5_5_BASE
# 1.110 14-Feb-2014 nicm

Style nit - no space between function name and bracket.


# 1.109 14-Feb-2014 nicm

Check for NULL session and whatnot in status_replace, from Thomas Adam.


# 1.108 28-Jan-2014 nicm

Allow replacing each of the many sets of separate foo-{fg,bg,attr}
options with a single foo-style option. For example:

set -g status-fg yellow
set -g status-bg red
set -g status-attr blink

Becomes:

set -g status-style fg=yellow,bg=red,blink

The -a flag to set can be used to add to rather than replace a style. So:

set -g status-bg red

Becomes:

set -ag status-style bg=red

Currently this is fully backwards compatible (all *-{fg,bg,attr} options
remain) but the plan is to deprecate them over time.

From Tiago Cunha.


Revision tags: OPENBSD_5_4_BASE
# 1.107 05-Jul-2013 nicm

Whitespace nits, from Ben Boeckel.


# 1.106 05-Jul-2013 nicm

Act like vi(1) when moving words, from Ben Boeckel.


# 1.105 05-Jul-2013 nicm

Implement s, S, C mode switch commands in vi(1) mode, from Ben Boeckel.


# 1.104 31-May-2013 nicm

Demote the old single-character replacement variables (#S and friends)
to aliases of formats. From Tiago Cunha.


# 1.103 25-Mar-2013 nicm

Extend jobs to support writing and use that for copy-pipe instead of
popen, from Chris Johnsen.


# 1.102 22-Mar-2013 nicm

evbuffer_readline returns allocated storage, don't leak it.


# 1.101 22-Mar-2013 nicm

Add copy-pipe mode command to copy selection and also pipe to a command.


# 1.100 22-Mar-2013 nicm

No more lint means no more ARGSUSED.


# 1.99 21-Mar-2013 nicm

Aargh. Spaces -> tabs.


# 1.98 21-Mar-2013 nicm

Do not leak formats in status_replace.


# 1.97 21-Mar-2013 nicm

Add a format client_prefix which is 1 if prefix key has been
pressed, used for example #{?client_prefix,X,Y}. Also a few extra
server_client_status needed.


# 1.96 21-Mar-2013 nicm

Allow formats in status options.


Revision tags: OPENBSD_5_3_BASE
# 1.95 27-Nov-2012 nicm

Add window-status-last-* options, from Boris Faure.


Revision tags: OPENBSD_5_2_BASE
# 1.94 10-Jul-2012 nicm

xfree is not particularly helpful, remove it. From Thomas Adam.


# 1.93 09-Jul-2012 nicm

Move a NULL check inside a function, from Tiago Cunha.


# 1.92 29-Apr-2012 nicm

Use int not u_char for colours from options since they may have bit 8
set to mark them as 256-colour. Reported by Chris Johnson.


# 1.91 23-Apr-2012 nicm

Add window-status-separator option, from Thomas Adam.


# 1.90 17-Mar-2012 nicm

Check event_initialized before event_del if event may not have been set
up; libevent2 complains about this. Reported by Moriyoshi Koizumi.


# 1.89 04-Mar-2012 nicm

Add A and I keys for vi status line editing.


# 1.88 03-Mar-2012 nicm

The wlmouse offset should be part of the client, not the server. From
Ailin Nemui.


Revision tags: OPENBSD_5_1_BASE
# 1.87 29-Jan-2012 nicm

Add an option to move the status line to the top of the screen,
requested by many.


# 1.86 26-Jan-2012 nicm

Terminate strftime buffer properly even if a really long format string
is given, from Tiago Cunha.


# 1.85 26-Jan-2012 nicm

Fix memory leak in error path, from Tiago Cunha.


# 1.84 20-Jan-2012 nicm

Add some trivial additional status line attributes from jwcxz at users
dot sourceforge dot net.


# 1.83 20-Jan-2012 nicm

Add space movement keys for vi mode in the status line from Ben Boeckel.


# 1.82 01-Dec-2011 nicm

Make M-f and M-b work the same at the command prompt as in copy mode,
pointed out by Romain Francoise.


# 1.81 15-Nov-2011 nicm

Add word movement and editing command for command prompt editing, from
Ben Boeckel.


# 1.80 15-Nov-2011 nicm

Make window_pane_index work the same as window_index, from Ben Boeckel.


# 1.79 05-Nov-2011 nicm

Option to change status line (message) background when using vi keys and
in command mode. From Ben Boeckel.


# 1.78 20-Aug-2011 nicm

Fix a couple of memory leaks, from marcel partap.


Revision tags: OPENBSD_5_0_BASE
# 1.77 08-Jul-2011 nicm

Make confirm-before prompt customizable with -p option like
command-prompt. Also move responsibility for calling status_replace into
status_prompt_{set,update} and add #W and #P to the default kill-window
and kill-pane prompts. By Tiago Cunha.


# 1.76 02-Jul-2011 nicm

Allow the initial context on prompts to be set with the new -I option to
command-prompt. From Tiago Cunha.


# 1.75 29-Apr-2011 nicm

Only redraw the status line on command update, not the entire client
(big DOH).


# 1.74 24-Apr-2011 nicm

Provide #h for short hostname (no domain) from Michal Mazurek.


# 1.73 18-Apr-2011 nicm

Add an option (mouse-select-window) which allows the mouse to be used by
clicking on the status line, written by hsim at gmx dot li.


# 1.72 29-Mar-2011 nicm

Change -t on display-message to be target-pane for the #[A-Z]
replacements and add -c as target-client.


Revision tags: OPENBSD_4_9_BASE
# 1.71 26-Jan-2011 nicm

Simplify the way jobs work and drop the persist type, so all jobs are
fire-and-forget.

Status jobs now managed with two trees of output (new and old), rather
than storing the output in the jobs themselves. When the status line is
processed any jobs which don't appear in the new tree are started and
the output from the old tree displayed. When a job finishes it updates
the new tree with its output and that is used for any subsequent
redraws. When the status interval expires, the new tree is moved to the
old so that all jobs are run again.

This fixes the "#(echo %H:%M:%S)" problem which would lead to thousands
of identical persistent jobs and high memory use (this can still be
achieved by adding "sleep 30" but that is much less likely to happen by
accident).


# 1.70 03-Jan-2011 nicm

Handle a # at the end of a replacement string (such as status-left)
correctly. Found by Thomas Adam.


# 1.69 01-Jan-2011 nicm

Move the user-visible parts of all options (names, types, limit, default
values) together into one set of tables in options-table.c. Also clean
up and simplify cmd-set-options.c and move a common print function into
option-table.c.


# 1.68 30-Dec-2010 nicm

Change from a per-session stack of buffers to one global stack which is
much more convenient and also simplifies lot of code. This renders
copy-buffer useless and makes buffer-limit now a server option.

By Tiago Cunha.


# 1.67 30-Dec-2010 nicm

Add a function to create window flags rather than doing the same thing
in two places. From Thomas Adam.


# 1.66 11-Dec-2010 nicm

Oops, these functions return a const char *, so make the local variable
const as well.


# 1.65 11-Dec-2010 nicm

Make the prompt history global for all clients which is much more useful than per-client history.


# 1.64 06-Dec-2010 nicm

Add an option to alert (monitor) for silence (lack of activity) in a
window. From Thomas Adam.


Revision tags: OPENBSD_4_8_BASE
# 1.63 21-Jun-2010 nicm

Having a list of winlinks->alerts for each session is stupid, just store
the alert flags directly in the winlink itself.


# 1.62 14-May-2010 nicm

Colour+attribute options for status line alerts, from Alex Alexander.


# 1.61 31-Mar-2010 nicm

Don't accept keys with modifiers as input. Fixes crash reported by Brian
R Landy.


# 1.60 27-Mar-2010 nicm

Don't leak job command in #().


# 1.59 22-Mar-2010 nicm

Dead functions, lint.


Revision tags: OPENBSD_4_7_BASE
# 1.58 27-Jan-2010 nicm

Calculate offset correctly, fixes incorrect offset and prevents crash when
status-left is empty. From Micah Cowan.


# 1.57 26-Jan-2010 nicm

Actually use the copy made when no newline is found, from martynas@.


# 1.56 14-Dec-2009 nicm

Add server options to completion as well.


# 1.55 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.54 03-Dec-2009 nicm

Eliminate duplicate code and ease the passage for server-wide options by adding
a -w flag to set-option and show-options and making setw and showw aliases to
set -w and show -w.

Note: setw and showw are still there, but now aliases for set -w and show -w.


# 1.53 26-Nov-2009 nicm

Tidy up various bits of the paste code, make the data buffer char * and add
comments.


# 1.52 26-Nov-2009 nicm

Remove a couple of unused arguments where possible, and add /* ARGSUSED */ to
the rest to reduce lint output.


# 1.51 20-Nov-2009 nicm

Display UTF-8 properly in status line messages and prompt. Cursor handling is
still way off though.


# 1.50 20-Nov-2009 nicm

Remove oldest messages from log when limit is hit, not newest.


# 1.49 19-Nov-2009 nicm

Get some brackets in the right place so ## works. Also fix a space in a
comment.


# 1.48 19-Nov-2009 nicm

Change status line drawing to create the window list in a separate screen and
then copy it into the status line screen. This allows UTF-8 in window names and
fixes some problems with #[] in window-status-format.


# 1.47 19-Nov-2009 nicm

Two new options, window-status-format and window-status-current-format, which
allow the format of each window in the status line window list to be controlled
using similar # sequences as status-left/right.

This diff also moves part of the way towards UTF-8 support in window names but
it isn't quite there yet.


# 1.46 19-Nov-2009 nicm

Tidy up by breaking the # replacement code into a separate function, also add a
few comments.


# 1.45 19-Nov-2009 nicm

Don't interpret #() for display-message, it usually doesn't make sense and may
leak commands.


# 1.44 18-Nov-2009 nicm

Add a per-client log of status line messages displayed while that client
exists. A new message-limit session option sets the maximum number of entries
and a command, show-messages, shows the log (bound to ~ by default).

This (and prompt history) might be better as a single global log but until
there are global options it is easier for them to be per client.


# 1.43 17-Nov-2009 nicm

Permit top-bit-set characters to be entered in the status line. They could
already be set from the shell and are just passed through when printing (so
invisible characters or displaying on terminals with different character sets
may cause problems).

Note that entering UTF-8 may not work and in any case currently the status line
cannot display it correctly (outside of status-left/status-right).


# 1.42 04-Nov-2009 nicm

Use timeout events for the identify and message timers.


# 1.41 04-Nov-2009 nicm

Switch jobs over to use a bufferevent.


# 1.40 04-Nov-2009 nicm

Unused (but assigned to) variable, found by lint.


# 1.39 01-Nov-2009 nicm

Add a flag for jobs that shouldn't be freed after they've died and use it for
status jobs, then only kill those jobs when status-left, status-right or
set-titles-string is changed.

Fixes problems with changing options from inside #().


# 1.38 10-Oct-2009 nicm

Rather than running status-left, status-right and window title #() with popen
immediately every redraw, queue them up and run them in the background,
starting each once every status-interval. The actual status line uses the
output from the last run.

This brings several advantages:

- tmux itself may be called from inside #() without causing the server to hang;
- likewise, sleep or similar doesn't cause the server to block;
- commands aren't run excessively often when redrawing;
- commands shared by status-left and status-right, or used multiple times, will
only be run once.

run-shell and if-shell still use system()/popen() but will be changed over to
use this too later.


# 1.37 10-Oct-2009 nicm

Add "grouped sessions" which have independent name, options, current window and
so on but where the linked windows are synchronized (ie creating, killing
windows and so on are mirrored between the sessions). A grouped session may be
created by passing -t to new-session.

Had this around for a while, tested by a couple of people.


# 1.36 23-Sep-2009 nicm

Remove PROMPT_HIDDEN code which is now unused.


# 1.35 23-Sep-2009 nicm

Remove the internal tmux locking and instead detach each client and run the
command specified by a new option "lock-command" (by default "lock -np") in
each client.

This means each terminal has to be unlocked individually but simplifies the
code and allows the system password to be used to unlock.

Note that the set-password command is gone, so it will need to be removed from
configuration files, and the -U command line flag has been removed.

This is the third protocol version change so again it is best to stop the tmux
server before upgrading.


# 1.34 20-Sep-2009 nicm

Regularise some fatal messages.


# 1.33 10-Sep-2009 nicm

Permit options such as status-bg to be configured using the entire 256 colour
palette by setting "colour0" to "colour255".


# 1.32 07-Sep-2009 nicm

Give each paste buffer a size member instead of requiring them to be
zero-terminated.


# 1.31 07-Sep-2009 nicm

Permit embedded colour and attributes in status-left and status-right using new
#[] special characters, for example #[fg=red,bg=blue,blink].


# 1.30 02-Sep-2009 nicm

Add a transpose-chars command in edit mode (C-t in emacs mode only). From Kalle
Olavi Niemitalo.


# 1.29 01-Sep-2009 nicm

Use "Password:" with no space for password prompts and don't display a *s for
the password, like pretty much everything else. From martynas@ with minor
tweaks by me.


# 1.28 31-Aug-2009 nicm

Add a new display-panes command, with two options (display-panes-colour and
display-panes-time), which displays a visual indication of the number of each
pane.


# 1.27 19-Aug-2009 nicm

Extend command-prompt with a -p option which is a comma-separated list of one
or more prompts to present in order.

The responses to the prompt are replaced in the template string: %% are
replaced in order, so the first prompt replaces the first %%, the second
replaces the second, and so on. In addition, %1 up to %9 are replaced with the
responses to the first the ninth prompts

The default template is "%1" so the response to the first prompt is processed
as a command.

Note that this changes the behaviour for %% so if there is only one prompt,
only the first %% will be replaced. Templates such as "neww -n '%%' 'ssh %%'"
should be changed to "neww -n '%1' 'ssh %1'".

From Tiago Cunha.


# 1.26 18-Aug-2009 nicm

Add a "delete line" key when editing in the status line or the search up/down
prompt. C-u with emacs keys, d with vi.


# 1.25 13-Aug-2009 nicm

Switch the prompt code to return an empty string when the user enters no
response and reserve NULL for an explicit cancel. Change all callbacks to treat
them the same so no functional change.

Also add cancel key bindings to emacs mode which were missing.


# 1.24 08-Aug-2009 nicm

Options to set the colours and attributes for status-left/-right. From Thomas
Adam, thanks.


# 1.23 05-Aug-2009 nicm

If colours are not supported by the terminal, try to emulate a coloured
background by setting or clearing the reverse attribute.

This makes a few applications which don't use the reverse attribute themselves
a little happier, and allows the status, message and mode options to have
default attributes and fg/bg options that work as expected when set as reverse.


# 1.22 30-Jul-2009 nicm

Plug some memory leaks.


# 1.21 28-Jul-2009 nicm

Next step towards customisable mode keys: build each default table of keys into
a named tree on start and use that for lookups. Also add command to string
translation tables and modify list-keys to show the the mode key bindings (new
-t argument).


# 1.20 27-Jul-2009 nicm

Change mode key bindings from big switches into a set of tables. Rather than
lumping them all together, split editing keys from those used in choice/more
mode and those for copy/scroll mode.

Tidier and clearer, and the first step towards customisable mode keys.


# 1.19 27-Jul-2009 nicm

Get rid of empty mode_key_free function.


# 1.18 27-Jul-2009 nicm

Add a key to delete to end of line at the prompt (^K in emacs mode, C/D in vi).

From Kalle Olavi Niemitalo.


# 1.17 26-Jul-2009 nicm

Calculate the space available for the prompt buffer and the cursor position
correctly, and make it work when the screen is not wide enough.

Noticed by Kalle Olavi Niemitalo.


# 1.16 21-Jul-2009 nicm

Remove a couple of unused functions and fix a type ("FALLTHOUGH"), found by
lint.


# 1.15 20-Jul-2009 nicm

Add a status-justify option to allow the window list in the status line to be
positioned at the left, centre, or right.


# 1.14 20-Jul-2009 nicm

New options, window-status-current-{fg,bg,attr}, to set the fg, bg and
attributes with which the current window is shown in the status line. From
Johan Friis, thanks.


# 1.13 17-Jul-2009 nicm

- New command display-message (alias display) to display a message in the
status line (bound to "i" and displays the current window and time by
default). The same substitutions are applied as for status-left/right.
- Add support for including the window index (#I), pane index (#P) and window
name (#W) in the message, and status-left or status-right.
- Bump protocol version.

From Tiago Cunha, thanks!


# 1.12 17-Jul-2009 nicm

Memory could be leaked if a second prompt or message appeared while another was
still present, so add a separate prompt free callback and make the _clear
function responsible for calling it if necessary (rather than the individual
prompt callbacks). Also make both messages and prompts clear any existing when
a new is set.

In addition, the screen could be modified while the prompt is there, restore
the redraw-entire-screen behaviour on prompt clear; add a comment as a
reminder.


# 1.11 16-Jul-2009 nicm

Remove some duplicate code that was causing the status line to be redrawn even
when it hadn't changed.


# 1.10 15-Jul-2009 nicm

Make status_message_set a variadic printf-like function. No functional change -
helpful for a couple of things coming soon.


# 1.9 15-Jul-2009 nicm

Having to update NSETOPTION/NSETWINDOWOPTION when adding new options is a bit
annoying and it is only use for iterating, so use a sentinel to mark the end of
each array instead. Different fix for a problem pointed out by Kalle Olavi
Niemitalo.


# 1.8 14-Jul-2009 nicm

For some reason when clearing status/message it was redrawing the entire client
not just the status line. Changing this also revealed the check for the status
line was incorrect when drawing the pane.


# 1.7 14-Jul-2009 nicm

Instead of faking up a status line in status_redraw, use the same code to
redraw it as to draw the entire screen, just skip all lines but the last.

This makes horizontal split redraw properly when the status line is off.


# 1.6 12-Jul-2009 nicm

Add a "back to indentation" key in copy mode to move the cursor to the first
non-whitespace character. ^ with vi and M-m with emacs key bindings. Another
from Kalle Olavi Niemitalo, thanks.


Revision tags: OPENBSD_4_6_BASE
# 1.5 26-Jun-2009 nicm

Status line fixes: don't truncate status-right now the length calculation is
done for UTF-8, limit to the maximum length correctly when printing, and always
print a space even if the left string is longer than the width available.


# 1.4 04-Jun-2009 nicm

If the prompt is hidden or a password is sent with -U, zero it before freeing
it.


# 1.3 03-Jun-2009 nicm

New session option, status-utf8, to control the interpretation of top-bit-set
characters in status-left and status-right (if on, they are treated as UTF-8;
otherwise passed through).


# 1.2 03-Jun-2009 nicm

Add a UTF-8 aware string length function and make UTF-8 in
status-left/status-right work properly. At the moment any top-bit-set
characters are assumed to be UTF-8: a status-utf8 option to configure this will
come shortly.


# 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.229 26-Oct-2021 nicm

Accept some emacs control keys in vi normal mode, from Alexis
Hildebrandt in GitHub issue 2922.


# 1.228 26-Oct-2021 nicm

Do not allow inline styles to replace mode-style for the selected item,
from Alexis Hildebrandt in GitHub issue 2946.


Revision tags: OPENBSD_7_0_BASE
# 1.227 20-Aug-2021 nicm

Remove stray spaces after function names.


# 1.226 12-Aug-2021 nicm

Use COLOUR_DEFAULT not hardcoded 8.


# 1.225 10-Jun-2021 nicm

More accurate vi(1) word navigation in copy mode and on the status line.
This changes the meaning of the word-separators option - setting it to
the empty string is equivalent to the previous behavior. From Will Noble
in GitHub issue 2693.


# 1.224 10-Jun-2021 nicm

Add different command historys for different types of prompts
("command", "search" etc). From Anindya Mukherjee.


# 1.223 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.222 10-Jun-2021 nicm

Include current client in size calculation for new sessions, GitHub
issue 2662.


Revision tags: OPENBSD_6_9_BASE
# 1.221 12-Apr-2021 nicm

Add a flag to disable keys to close a message, GitHub issue 2625.


# 1.220 22-Feb-2021 nicm

Move jump commands to grid reader, make them UTF-8 aware, and tidy up,
from Anindya Mukherjee.


# 1.219 08-Jan-2021 nicm

With incremental search, start empty and only repeat the previous search
if the user tries to search again with an empty prompt. This matches
emacs behaviour more closely.


Revision tags: OPENBSD_6_8_BASE
# 1.218 27-Jul-2020 nicm

Add a -d option to display-message to set delay, from theonekeyg at
gmail dot com in GitHub issue 2322.


# 1.217 11-Jun-2020 nicm

Fix a crash when completing sessions, from Anindya Mukherjee.


# 1.216 26-May-2020 nicm

Remove leftover debug logging and fix comparison.


# 1.215 26-May-2020 nicm

Set up UTF-8 data for ASCII keys correctly.


# 1.214 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.213 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.212 16-May-2020 nicm

Rename KEYC_ESCAPE to KEYC_META.


# 1.211 16-May-2020 nicm

Expand target from client and use it to expand the prompt.


# 1.210 16-May-2020 nicm

Support embedded styles in the display-message message, GitHub issue
2206.


# 1.209 16-May-2020 nicm

Change message log to be per server rather than per client and include
every command that is run.


# 1.208 16-May-2020 nicm

Do not hoke into struct window_pane from the tty code and instead set
everything up in tty_ctx. Provide a way to initialize the tty_ctx from a
callback and use it to let popups draw directly through input_parse in
the same way as panes do, rather than forcing a full redraw on every
change.


# 1.207 16-May-2020 nicm

Use formats for status-style and message-style.


# 1.206 16-May-2020 nicm

Complete partial window indexes properly.


# 1.205 16-May-2020 nicm

Add -W and -T flags to command-prompt to only complete a window and a
target, also complete aliases.


# 1.204 16-May-2020 nicm

Improve command prompt completion:

- Show a menu with completions if there are multiple.

- Don't complete argument stuff (options, layouts) at start of text.

- For -t and -s, if there is no : then complete sessions but if there is
a :, show a menu of all windows in the session rather than trying to
complete the window name which is a bit useless if there are
duplicates.


# 1.203 16-May-2020 nicm

Drop having a separate type for style options and make them all strings,
which allows formats to be expanded. Any styles without a '#{' are still
validated when they are set but any with a '#{' are not. Formats are not
expanded usefully in many cases yet, that will be changed later.

To make this work, a few other changes:

- set-option -a with a style option automatically appends a ",".

- OSC 10 and 11 don't set the window-style option anymore, instead the
fg and bg are stored in the pane struct and act as the defaults that
can be overridden by window-style.

- status-fg and -bg now override status-style instead of trying to keep
them in sync.


Revision tags: OPENBSD_6_7_BASE
# 1.202 12-Mar-2020 nicm

Add C-g to cancel command prompt with vi(1) keys as well as emacs, and q
in command mode.


# 1.201 27-Jan-2020 nicm

Add support for adding a note to a key binding (with bind-key -N) and
use this to add descriptions to the default key bindings. A new -N flag
to list-keys shows key bindings with notes rather than the default
bind-key command used to create them. Change the default ? binding to
use this to show a readable summary of keys.

Also extend command-prompt to return the name of the key pressed and add
a default binding (/) to show the note for the next key pressed

Suggested by Alex Tremblay in GitHub issue 2000.


Revision tags: OPENBSD_6_6_BASE
# 1.200 28-May-2019 nicm

Redraw status line if size changes, GitHub issue 1762. Also fix length
of target buffer when pasting into status line.


# 1.199 23-May-2019 nicm

Fix length calculation for pasting UTF-8 characters in the status line,
GitHub issue 1753.


# 1.198 11-May-2019 nicm

Do not reduce window height by status line height for control mode
clients, from George Nachman.


# 1.197 03-May-2019 nicm

Fix reverse attribute in status line, GitHub issue 1709.


# 1.196 26-Apr-2019 nicm

Merge hooks into options and make each one an array option. This allows
multiple commands to be easily bound to one hook. set-hook and
show-hooks remain but they are now variants of set-option and
show-options. show-options now has a -H flag to show hooks (by default
they are not shown).


# 1.195 25-Apr-2019 nicm

options_array_item_value cannot return NULL.


# 1.194 23-Apr-2019 nicm

Somehow missed these bits in last commit.


# 1.193 23-Apr-2019 nicm

Indicate an array option with a flag rather than a special type so that
in future will not have to be strings.


Revision tags: OPENBSD_6_5_BASE
# 1.192 18-Mar-2019 nicm

Extend the #[] style syntax and use that together with previous format
changes to allow the status line to be entirely configured with a single
option.

Now that it is possible to configure their content, enable the existing
code that lets the status line be multiple lines in height. The status
option can now take a value of 2, 3, 4 or 5 (as well as the previous on
or off) to configure more than one line. The new status-format array
option configures the format of each line, the default just references
the existing status-* options, although some of the more obscure status
options may be eliminated in time.

Additions to the #[] syntax are: "align" to specify alignment (left,
centre, right), "list" for the window list and "range" to configure
ranges of text for the mouse bindings.

The "align" keyword can also be used to specify alignment of entries in
tree mode and the pane status lines.


# 1.191 18-Mar-2019 nicm

Make array options a sparse tree instead of an array of char * and
remove the size limit.


# 1.190 18-Mar-2019 nicm

With force, kill previous job before starting new. Fixes problem
reported by Scott Mcdermott in GitHub issue 1627.


# 1.189 16-Mar-2019 nicm

Use a pointer for the active screen in the status line instead of
copying them around all the time.


# 1.188 16-Mar-2019 nicm

Give status_save_old the client so it can do the reinit too.


# 1.187 16-Mar-2019 nicm

Tidy and rename some bits of status line code.


# 1.186 15-Mar-2019 nicm

Move status line free into its own function.


# 1.185 14-Mar-2019 nicm

Store the time in the format tree rather than passing it around.


# 1.184 12-Mar-2019 nicm

DECRC and DECSC apparently need to preserve origin mode as well, based
on a fix from Marc Reisner.


# 1.183 09-Feb-2019 nicm

Completion of command-alias members.


# 1.182 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.181 29-Aug-2018 nicm

Keep any text killed in the command prompt with C-w and yank it with
C-y, only use the top buffer if no text has previously been killed. This
and previous change promped by discussion with kn@.


# 1.180 29-Aug-2018 nicm

Add C-Left and C-Right as aliases for M-b and M-f.


# 1.179 22-Aug-2018 nicm

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


# 1.178 20-Aug-2018 nicm

Move offset of window list into status struct.


# 1.177 19-Aug-2018 nicm

Add a client redraw-window flag instead of the redraw-all flag and for
all just use the three flags together (window, borders, status).


Revision tags: OPENBSD_6_3_BASE
# 1.176 22-Feb-2018 nicm

Remove an unused variable.


# 1.175 05-Feb-2018 nicm

Add struct status_line to hold status line members of struct client, not
used yet but will be soon. From Thomas Adam.


# 1.174 01-Jan-2018 nicm

Add C-g at command prompt for emacs people, GitHub issue 1213.


# 1.173 27-Dec-2017 nicm

Draw command prompt correctly with status line off.


# 1.172 18-Dec-2017 nicm

Remove unused variable from Thomas Adam.


# 1.171 02-Nov-2017 nicm

Add a "fast" version of screen_write_copy for tree mode that doesn't do
all the checks and selection and marking stuff needed for copy mode.


# 1.170 20-Oct-2017 nicm

Clear status line with spaces again so reverse works, spotted by sthen.


# 1.169 16-Oct-2017 nicm

Infrastructure for drawing status lines of more than one line in height,
still only one is allowed but this lets tmux draw bigger ones.


Revision tags: OPENBSD_6_2_BASE
# 1.168 29-May-2017 nicm

Add a flag to stop the prompt input being expanded.


# 1.167 29-May-2017 nicm

Store a copy of the old status line, will be needed soon for new choose mode.


# 1.166 17-May-2017 nicm

Tidy command prompt callbacks and pass in the client.


# 1.165 03-May-2017 nicm

Add a format for the last search string in copy mode and fix the prompt
so it can work when in -I, suggested by Suraj N Kurapati.


# 1.164 01-May-2017 nicm

In order that people can use formats like #D in #() in the status line
and not have to wait for an update when they change pane, we allow
commands to run more than once a second if the expanded form
changes. Unfortunately this can mean them being run far too often
(pretty much continually) when multiple clients exist, because some
formats (including #D) will always differ between clients.

To avoid this, give each client its own tree of jobs which means that
the same command will be different instances for each client - similar
to how we have the tag to separate commands for different panes.

GitHub issue 889; test case reported by Paul Johnson.


# 1.163 22-Apr-2017 nicm

Memory leak from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.162 09-Feb-2017 nicm

Break the message storage function into its own function, useful for
debugging.


# 1.161 03-Feb-2017 nicm

Cache status line position to reduce option lookups during output.


# 1.160 03-Feb-2017 nicm

Add a window or pane id "tag" to each format tree and use it to separate
jobs, this means that if the same job is used for different windows or
panes (for example in pane-border-format), it will be run separately for
each pane.


# 1.159 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.158 06-Jan-2017 nicm

Incremental search in copy mode (on for emacs keys by default) - much
the same as normal searching but updates the cursor position and marked
search terms as you type. C-r and C-s in the prompt repeat the search,
once finished searching (with Enter), N and n work as before.


# 1.157 05-Jan-2017 nicm

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


# 1.156 07-Dec-2016 nicm

Do not clear the prompt when a message is shown, just leave it around and
return to it when the message is finished.


# 1.155 12-Oct-2016 nicm

Drop the edit mode key tables and just use fixed key bindings for the
command prompt.


# 1.154 12-Oct-2016 nicm

The repeat prompt in both emacs and vi (and the old one in tmux) doesn't
support line editing and instead executes a command as soon as a
non-number key is pressed. Add a -N flag to command-prompt for the same
in copy mode. Reported by Theo Buehler.


# 1.153 11-Oct-2016 nicm

Fundamental change to how copy mode key bindings work:

The vi-copy and emacs-copy mode key tables are gone, and instead copy
mode commands are bound in one of two normal key tables ("copy-mode" or
"copy-mode-vi"). Keys are bound to "send-keys -X copy-mode-command". So:

bind -temacs-copy C-Up scroll-up
bind -temacs-copy -R5 WheelUpPane scroll-up

Becomes:

bind -Tcopy-mode C-Up send -X scroll-up
bind -Tcopy-mode WheelUpPane send -N5 -X scroll-up

This allows the full command parser and command set to be used - for
example, we can use the normal command prompt for searching, jumping,
and so on instead of a custom one:

bind -Tcopy-mode C-r command-prompt -p'search up' "send -X search-backward '%%'"

command-prompt also gets a -1 option to only require on key press, which
is needed for jumping.

The plan is to get rid of mode keys entirely, so more to come eventually.


# 1.152 11-Oct-2016 nicm

Support UTF-8 entry into the command prompt.


# 1.151 10-Oct-2016 nicm

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


# 1.150 12-Sep-2016 nicm

Allow repeat count to be specified in mode key tables with bind-key -R,
and set the default repeat count to 5 for WheelUp and WheelDown in
copy-mode.


Revision tags: OPENBSD_6_0_BASE
# 1.149 06-Jun-2016 nicm

Allow #[] in window-status-separator.


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

I no longer use my SourceForge address so replace it.


# 1.147 01-Jan-2016 nicm

Don't rely on a calculation wrapping when applying message-limit, and
break out of the loop early. From Nicolas Viennot.


# 1.146 11-Dec-2015 nicm

Style nits and line wrapping of function declarations.


# 1.145 11-Dec-2015 nicm

Add cmdq as an argument to format_create and add a format for the
command name (will also be used for more later).


# 1.144 08-Dec-2015 nicm

Remove format_create_flags and just pass flags to format_create.


# 1.143 22-Nov-2015 tim

If display-time is set to 0, show status messages until a key is pressed;
OK nicm@


# 1.142 20-Nov-2015 nicm

Instead of separate tables for different types of options, give each
option a scope type (server, session, window) in one table.


# 1.141 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.140 13-Nov-2015 nicm

Long overdue change to the way we store cells in the grid: now, instead
of storing a full grid_cell with UTF-8 data and everything, store a new
type grid_cell_entry. This can either be the cell itself (for ASCII
cells), or an offset into an extended array (per line) for UTF-8
data.

This avoid a large (8 byte) overhead on non-UTF-8 cells (by far the
majority for most users) without the complexity of the shadow array we
had before. Grid memory without any UTF-8 is about half.

The disadvantage that cells can no longer be modified in place and need
to be copied out of the grid and back but it turned out to be lot less
complicated than I expected.


# 1.139 12-Nov-2015 nicm

Nuke the utf8 and status-utf8 options and make tmux only a UTF-8
terminal. We still support non-UTF-8 terminals outside tmux, but inside
it is always UTF-8 (as when the utf8 and status-utf8 options were on).


# 1.138 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.137 27-Oct-2015 nicm

Move struct options into options.c.


# 1.136 20-Oct-2015 nicm

Use client pointer not file descriptor in logging.


# 1.135 14-Sep-2015 nicm

Make refresh-client force update of jobs, from Sina Siadat.


# 1.134 29-Aug-2015 nicm

Move struct paste_buffer out of tmux.h.


# 1.133 28-Aug-2015 nicm

Run status update on a per-client timer at status-interval.


Revision tags: OPENBSD_5_8_BASE
# 1.132 29-Jul-2015 nicm

status_out and associated data structures are no longer used.


# 1.131 28-Jul-2015 nicm

Tidy up the way terminals are described and move some structs out of tmux.h.


# 1.130 20-Jul-2015 nicm

Add an option (history-file) for a file to save/restore command prompt
history, from Olof-Joachim Frahm.


# 1.129 27-May-2015 nicm

Move the jobs output cache into the formats code so that #() work more
generally (for example, again working in set-titles-string).


# 1.128 06-May-2015 nicm

Remove ARRAY_* from history and expand completion to complete a) layout
names and b) targets beginning with -t or -s.


# 1.127 25-Apr-2015 nicm

Make message log a TAILQ.


# 1.126 24-Apr-2015 nicm

Set working directory for run-shell and if-shell.


# 1.125 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_7_BASE
# 1.124 06-Feb-2015 nicm

Use the same time for both calls to format_expand_time.


# 1.123 06-Feb-2015 nicm

status_replace can now become local to status.c and it no longer needs
the jobsflag argument. While here there is no need to repeat work that
format_defaults already does.


# 1.122 06-Feb-2015 nicm

Add format_expand_time and use it instead of status_replace where
command execution is not needed.


# 1.121 05-Feb-2015 nicm

Wrap all the individual format_* calls in a single format_defaults
functions.


# 1.120 01-Feb-2015 nicm

Remove two unused arguments from status_replace.


# 1.119 20-Jan-2015 sthen

typo in comment ;) ok nicm


# 1.118 05-Nov-2014 nicm

Do not put a space between status-left/status-right and the window list,
instead move the space into the defaults for the options (so status-left
now defaults to "[#S] ". From Balazs Kezes.


# 1.117 20-Oct-2014 nicm

Better format for printf format attributes.


# 1.116 08-Oct-2014 nicm

Add xreallocarray and remove nmemb argument from xrealloc.


# 1.115 02-Oct-2014 nicm

Take account of window-status-separator when checking window position,
based on diff from Balazs Kezes.


Revision tags: OPENBSD_5_6_BASE
# 1.114 24-Apr-2014 nicm

There is no longer a need for a paste_stack struct or for global_buffers
to be global. Move to paste.c.


# 1.113 17-Apr-2014 nicm

Remove the monitor-content option and associated bits and bobs. It's
never worked very well. If there is a big demand for it to return, will
consider better ways to do it.


# 1.112 02-Apr-2014 nicm

Do not replace ## with # in status_replace1 because it'll be done later
by the format code.


# 1.111 31-Mar-2014 nicm

Make message-limit a server option.


Revision tags: OPENBSD_5_5_BASE
# 1.110 14-Feb-2014 nicm

Style nit - no space between function name and bracket.


# 1.109 14-Feb-2014 nicm

Check for NULL session and whatnot in status_replace, from Thomas Adam.


# 1.108 28-Jan-2014 nicm

Allow replacing each of the many sets of separate foo-{fg,bg,attr}
options with a single foo-style option. For example:

set -g status-fg yellow
set -g status-bg red
set -g status-attr blink

Becomes:

set -g status-style fg=yellow,bg=red,blink

The -a flag to set can be used to add to rather than replace a style. So:

set -g status-bg red

Becomes:

set -ag status-style bg=red

Currently this is fully backwards compatible (all *-{fg,bg,attr} options
remain) but the plan is to deprecate them over time.

From Tiago Cunha.


Revision tags: OPENBSD_5_4_BASE
# 1.107 05-Jul-2013 nicm

Whitespace nits, from Ben Boeckel.


# 1.106 05-Jul-2013 nicm

Act like vi(1) when moving words, from Ben Boeckel.


# 1.105 05-Jul-2013 nicm

Implement s, S, C mode switch commands in vi(1) mode, from Ben Boeckel.


# 1.104 31-May-2013 nicm

Demote the old single-character replacement variables (#S and friends)
to aliases of formats. From Tiago Cunha.


# 1.103 25-Mar-2013 nicm

Extend jobs to support writing and use that for copy-pipe instead of
popen, from Chris Johnsen.


# 1.102 22-Mar-2013 nicm

evbuffer_readline returns allocated storage, don't leak it.


# 1.101 22-Mar-2013 nicm

Add copy-pipe mode command to copy selection and also pipe to a command.


# 1.100 22-Mar-2013 nicm

No more lint means no more ARGSUSED.


# 1.99 21-Mar-2013 nicm

Aargh. Spaces -> tabs.


# 1.98 21-Mar-2013 nicm

Do not leak formats in status_replace.


# 1.97 21-Mar-2013 nicm

Add a format client_prefix which is 1 if prefix key has been
pressed, used for example #{?client_prefix,X,Y}. Also a few extra
server_client_status needed.


# 1.96 21-Mar-2013 nicm

Allow formats in status options.


Revision tags: OPENBSD_5_3_BASE
# 1.95 27-Nov-2012 nicm

Add window-status-last-* options, from Boris Faure.


Revision tags: OPENBSD_5_2_BASE
# 1.94 10-Jul-2012 nicm

xfree is not particularly helpful, remove it. From Thomas Adam.


# 1.93 09-Jul-2012 nicm

Move a NULL check inside a function, from Tiago Cunha.


# 1.92 29-Apr-2012 nicm

Use int not u_char for colours from options since they may have bit 8
set to mark them as 256-colour. Reported by Chris Johnson.


# 1.91 23-Apr-2012 nicm

Add window-status-separator option, from Thomas Adam.


# 1.90 17-Mar-2012 nicm

Check event_initialized before event_del if event may not have been set
up; libevent2 complains about this. Reported by Moriyoshi Koizumi.


# 1.89 04-Mar-2012 nicm

Add A and I keys for vi status line editing.


# 1.88 03-Mar-2012 nicm

The wlmouse offset should be part of the client, not the server. From
Ailin Nemui.


Revision tags: OPENBSD_5_1_BASE
# 1.87 29-Jan-2012 nicm

Add an option to move the status line to the top of the screen,
requested by many.


# 1.86 26-Jan-2012 nicm

Terminate strftime buffer properly even if a really long format string
is given, from Tiago Cunha.


# 1.85 26-Jan-2012 nicm

Fix memory leak in error path, from Tiago Cunha.


# 1.84 20-Jan-2012 nicm

Add some trivial additional status line attributes from jwcxz at users
dot sourceforge dot net.


# 1.83 20-Jan-2012 nicm

Add space movement keys for vi mode in the status line from Ben Boeckel.


# 1.82 01-Dec-2011 nicm

Make M-f and M-b work the same at the command prompt as in copy mode,
pointed out by Romain Francoise.


# 1.81 15-Nov-2011 nicm

Add word movement and editing command for command prompt editing, from
Ben Boeckel.


# 1.80 15-Nov-2011 nicm

Make window_pane_index work the same as window_index, from Ben Boeckel.


# 1.79 05-Nov-2011 nicm

Option to change status line (message) background when using vi keys and
in command mode. From Ben Boeckel.


# 1.78 20-Aug-2011 nicm

Fix a couple of memory leaks, from marcel partap.


Revision tags: OPENBSD_5_0_BASE
# 1.77 08-Jul-2011 nicm

Make confirm-before prompt customizable with -p option like
command-prompt. Also move responsibility for calling status_replace into
status_prompt_{set,update} and add #W and #P to the default kill-window
and kill-pane prompts. By Tiago Cunha.


# 1.76 02-Jul-2011 nicm

Allow the initial context on prompts to be set with the new -I option to
command-prompt. From Tiago Cunha.


# 1.75 29-Apr-2011 nicm

Only redraw the status line on command update, not the entire client
(big DOH).


# 1.74 24-Apr-2011 nicm

Provide #h for short hostname (no domain) from Michal Mazurek.


# 1.73 18-Apr-2011 nicm

Add an option (mouse-select-window) which allows the mouse to be used by
clicking on the status line, written by hsim at gmx dot li.


# 1.72 29-Mar-2011 nicm

Change -t on display-message to be target-pane for the #[A-Z]
replacements and add -c as target-client.


Revision tags: OPENBSD_4_9_BASE
# 1.71 26-Jan-2011 nicm

Simplify the way jobs work and drop the persist type, so all jobs are
fire-and-forget.

Status jobs now managed with two trees of output (new and old), rather
than storing the output in the jobs themselves. When the status line is
processed any jobs which don't appear in the new tree are started and
the output from the old tree displayed. When a job finishes it updates
the new tree with its output and that is used for any subsequent
redraws. When the status interval expires, the new tree is moved to the
old so that all jobs are run again.

This fixes the "#(echo %H:%M:%S)" problem which would lead to thousands
of identical persistent jobs and high memory use (this can still be
achieved by adding "sleep 30" but that is much less likely to happen by
accident).


# 1.70 03-Jan-2011 nicm

Handle a # at the end of a replacement string (such as status-left)
correctly. Found by Thomas Adam.


# 1.69 01-Jan-2011 nicm

Move the user-visible parts of all options (names, types, limit, default
values) together into one set of tables in options-table.c. Also clean
up and simplify cmd-set-options.c and move a common print function into
option-table.c.


# 1.68 30-Dec-2010 nicm

Change from a per-session stack of buffers to one global stack which is
much more convenient and also simplifies lot of code. This renders
copy-buffer useless and makes buffer-limit now a server option.

By Tiago Cunha.


# 1.67 30-Dec-2010 nicm

Add a function to create window flags rather than doing the same thing
in two places. From Thomas Adam.


# 1.66 11-Dec-2010 nicm

Oops, these functions return a const char *, so make the local variable
const as well.


# 1.65 11-Dec-2010 nicm

Make the prompt history global for all clients which is much more useful than per-client history.


# 1.64 06-Dec-2010 nicm

Add an option to alert (monitor) for silence (lack of activity) in a
window. From Thomas Adam.


Revision tags: OPENBSD_4_8_BASE
# 1.63 21-Jun-2010 nicm

Having a list of winlinks->alerts for each session is stupid, just store
the alert flags directly in the winlink itself.


# 1.62 14-May-2010 nicm

Colour+attribute options for status line alerts, from Alex Alexander.


# 1.61 31-Mar-2010 nicm

Don't accept keys with modifiers as input. Fixes crash reported by Brian
R Landy.


# 1.60 27-Mar-2010 nicm

Don't leak job command in #().


# 1.59 22-Mar-2010 nicm

Dead functions, lint.


Revision tags: OPENBSD_4_7_BASE
# 1.58 27-Jan-2010 nicm

Calculate offset correctly, fixes incorrect offset and prevents crash when
status-left is empty. From Micah Cowan.


# 1.57 26-Jan-2010 nicm

Actually use the copy made when no newline is found, from martynas@.


# 1.56 14-Dec-2009 nicm

Add server options to completion as well.


# 1.55 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.54 03-Dec-2009 nicm

Eliminate duplicate code and ease the passage for server-wide options by adding
a -w flag to set-option and show-options and making setw and showw aliases to
set -w and show -w.

Note: setw and showw are still there, but now aliases for set -w and show -w.


# 1.53 26-Nov-2009 nicm

Tidy up various bits of the paste code, make the data buffer char * and add
comments.


# 1.52 26-Nov-2009 nicm

Remove a couple of unused arguments where possible, and add /* ARGSUSED */ to
the rest to reduce lint output.


# 1.51 20-Nov-2009 nicm

Display UTF-8 properly in status line messages and prompt. Cursor handling is
still way off though.


# 1.50 20-Nov-2009 nicm

Remove oldest messages from log when limit is hit, not newest.


# 1.49 19-Nov-2009 nicm

Get some brackets in the right place so ## works. Also fix a space in a
comment.


# 1.48 19-Nov-2009 nicm

Change status line drawing to create the window list in a separate screen and
then copy it into the status line screen. This allows UTF-8 in window names and
fixes some problems with #[] in window-status-format.


# 1.47 19-Nov-2009 nicm

Two new options, window-status-format and window-status-current-format, which
allow the format of each window in the status line window list to be controlled
using similar # sequences as status-left/right.

This diff also moves part of the way towards UTF-8 support in window names but
it isn't quite there yet.


# 1.46 19-Nov-2009 nicm

Tidy up by breaking the # replacement code into a separate function, also add a
few comments.


# 1.45 19-Nov-2009 nicm

Don't interpret #() for display-message, it usually doesn't make sense and may
leak commands.


# 1.44 18-Nov-2009 nicm

Add a per-client log of status line messages displayed while that client
exists. A new message-limit session option sets the maximum number of entries
and a command, show-messages, shows the log (bound to ~ by default).

This (and prompt history) might be better as a single global log but until
there are global options it is easier for them to be per client.


# 1.43 17-Nov-2009 nicm

Permit top-bit-set characters to be entered in the status line. They could
already be set from the shell and are just passed through when printing (so
invisible characters or displaying on terminals with different character sets
may cause problems).

Note that entering UTF-8 may not work and in any case currently the status line
cannot display it correctly (outside of status-left/status-right).


# 1.42 04-Nov-2009 nicm

Use timeout events for the identify and message timers.


# 1.41 04-Nov-2009 nicm

Switch jobs over to use a bufferevent.


# 1.40 04-Nov-2009 nicm

Unused (but assigned to) variable, found by lint.


# 1.39 01-Nov-2009 nicm

Add a flag for jobs that shouldn't be freed after they've died and use it for
status jobs, then only kill those jobs when status-left, status-right or
set-titles-string is changed.

Fixes problems with changing options from inside #().


# 1.38 10-Oct-2009 nicm

Rather than running status-left, status-right and window title #() with popen
immediately every redraw, queue them up and run them in the background,
starting each once every status-interval. The actual status line uses the
output from the last run.

This brings several advantages:

- tmux itself may be called from inside #() without causing the server to hang;
- likewise, sleep or similar doesn't cause the server to block;
- commands aren't run excessively often when redrawing;
- commands shared by status-left and status-right, or used multiple times, will
only be run once.

run-shell and if-shell still use system()/popen() but will be changed over to
use this too later.


# 1.37 10-Oct-2009 nicm

Add "grouped sessions" which have independent name, options, current window and
so on but where the linked windows are synchronized (ie creating, killing
windows and so on are mirrored between the sessions). A grouped session may be
created by passing -t to new-session.

Had this around for a while, tested by a couple of people.


# 1.36 23-Sep-2009 nicm

Remove PROMPT_HIDDEN code which is now unused.


# 1.35 23-Sep-2009 nicm

Remove the internal tmux locking and instead detach each client and run the
command specified by a new option "lock-command" (by default "lock -np") in
each client.

This means each terminal has to be unlocked individually but simplifies the
code and allows the system password to be used to unlock.

Note that the set-password command is gone, so it will need to be removed from
configuration files, and the -U command line flag has been removed.

This is the third protocol version change so again it is best to stop the tmux
server before upgrading.


# 1.34 20-Sep-2009 nicm

Regularise some fatal messages.


# 1.33 10-Sep-2009 nicm

Permit options such as status-bg to be configured using the entire 256 colour
palette by setting "colour0" to "colour255".


# 1.32 07-Sep-2009 nicm

Give each paste buffer a size member instead of requiring them to be
zero-terminated.


# 1.31 07-Sep-2009 nicm

Permit embedded colour and attributes in status-left and status-right using new
#[] special characters, for example #[fg=red,bg=blue,blink].


# 1.30 02-Sep-2009 nicm

Add a transpose-chars command in edit mode (C-t in emacs mode only). From Kalle
Olavi Niemitalo.


# 1.29 01-Sep-2009 nicm

Use "Password:" with no space for password prompts and don't display a *s for
the password, like pretty much everything else. From martynas@ with minor
tweaks by me.


# 1.28 31-Aug-2009 nicm

Add a new display-panes command, with two options (display-panes-colour and
display-panes-time), which displays a visual indication of the number of each
pane.


# 1.27 19-Aug-2009 nicm

Extend command-prompt with a -p option which is a comma-separated list of one
or more prompts to present in order.

The responses to the prompt are replaced in the template string: %% are
replaced in order, so the first prompt replaces the first %%, the second
replaces the second, and so on. In addition, %1 up to %9 are replaced with the
responses to the first the ninth prompts

The default template is "%1" so the response to the first prompt is processed
as a command.

Note that this changes the behaviour for %% so if there is only one prompt,
only the first %% will be replaced. Templates such as "neww -n '%%' 'ssh %%'"
should be changed to "neww -n '%1' 'ssh %1'".

From Tiago Cunha.


# 1.26 18-Aug-2009 nicm

Add a "delete line" key when editing in the status line or the search up/down
prompt. C-u with emacs keys, d with vi.


# 1.25 13-Aug-2009 nicm

Switch the prompt code to return an empty string when the user enters no
response and reserve NULL for an explicit cancel. Change all callbacks to treat
them the same so no functional change.

Also add cancel key bindings to emacs mode which were missing.


# 1.24 08-Aug-2009 nicm

Options to set the colours and attributes for status-left/-right. From Thomas
Adam, thanks.


# 1.23 05-Aug-2009 nicm

If colours are not supported by the terminal, try to emulate a coloured
background by setting or clearing the reverse attribute.

This makes a few applications which don't use the reverse attribute themselves
a little happier, and allows the status, message and mode options to have
default attributes and fg/bg options that work as expected when set as reverse.


# 1.22 30-Jul-2009 nicm

Plug some memory leaks.


# 1.21 28-Jul-2009 nicm

Next step towards customisable mode keys: build each default table of keys into
a named tree on start and use that for lookups. Also add command to string
translation tables and modify list-keys to show the the mode key bindings (new
-t argument).


# 1.20 27-Jul-2009 nicm

Change mode key bindings from big switches into a set of tables. Rather than
lumping them all together, split editing keys from those used in choice/more
mode and those for copy/scroll mode.

Tidier and clearer, and the first step towards customisable mode keys.


# 1.19 27-Jul-2009 nicm

Get rid of empty mode_key_free function.


# 1.18 27-Jul-2009 nicm

Add a key to delete to end of line at the prompt (^K in emacs mode, C/D in vi).

From Kalle Olavi Niemitalo.


# 1.17 26-Jul-2009 nicm

Calculate the space available for the prompt buffer and the cursor position
correctly, and make it work when the screen is not wide enough.

Noticed by Kalle Olavi Niemitalo.


# 1.16 21-Jul-2009 nicm

Remove a couple of unused functions and fix a type ("FALLTHOUGH"), found by
lint.


# 1.15 20-Jul-2009 nicm

Add a status-justify option to allow the window list in the status line to be
positioned at the left, centre, or right.


# 1.14 20-Jul-2009 nicm

New options, window-status-current-{fg,bg,attr}, to set the fg, bg and
attributes with which the current window is shown in the status line. From
Johan Friis, thanks.


# 1.13 17-Jul-2009 nicm

- New command display-message (alias display) to display a message in the
status line (bound to "i" and displays the current window and time by
default). The same substitutions are applied as for status-left/right.
- Add support for including the window index (#I), pane index (#P) and window
name (#W) in the message, and status-left or status-right.
- Bump protocol version.

From Tiago Cunha, thanks!


# 1.12 17-Jul-2009 nicm

Memory could be leaked if a second prompt or message appeared while another was
still present, so add a separate prompt free callback and make the _clear
function responsible for calling it if necessary (rather than the individual
prompt callbacks). Also make both messages and prompts clear any existing when
a new is set.

In addition, the screen could be modified while the prompt is there, restore
the redraw-entire-screen behaviour on prompt clear; add a comment as a
reminder.


# 1.11 16-Jul-2009 nicm

Remove some duplicate code that was causing the status line to be redrawn even
when it hadn't changed.


# 1.10 15-Jul-2009 nicm

Make status_message_set a variadic printf-like function. No functional change -
helpful for a couple of things coming soon.


# 1.9 15-Jul-2009 nicm

Having to update NSETOPTION/NSETWINDOWOPTION when adding new options is a bit
annoying and it is only use for iterating, so use a sentinel to mark the end of
each array instead. Different fix for a problem pointed out by Kalle Olavi
Niemitalo.


# 1.8 14-Jul-2009 nicm

For some reason when clearing status/message it was redrawing the entire client
not just the status line. Changing this also revealed the check for the status
line was incorrect when drawing the pane.


# 1.7 14-Jul-2009 nicm

Instead of faking up a status line in status_redraw, use the same code to
redraw it as to draw the entire screen, just skip all lines but the last.

This makes horizontal split redraw properly when the status line is off.


# 1.6 12-Jul-2009 nicm

Add a "back to indentation" key in copy mode to move the cursor to the first
non-whitespace character. ^ with vi and M-m with emacs key bindings. Another
from Kalle Olavi Niemitalo, thanks.


Revision tags: OPENBSD_4_6_BASE
# 1.5 26-Jun-2009 nicm

Status line fixes: don't truncate status-right now the length calculation is
done for UTF-8, limit to the maximum length correctly when printing, and always
print a space even if the left string is longer than the width available.


# 1.4 04-Jun-2009 nicm

If the prompt is hidden or a password is sent with -U, zero it before freeing
it.


# 1.3 03-Jun-2009 nicm

New session option, status-utf8, to control the interpretation of top-bit-set
characters in status-left and status-right (if on, they are treated as UTF-8;
otherwise passed through).


# 1.2 03-Jun-2009 nicm

Add a UTF-8 aware string length function and make UTF-8 in
status-left/status-right work properly. At the moment any top-bit-set
characters are assumed to be UTF-8: a status-utf8 option to configure this will
come shortly.


# 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.227 20-Aug-2021 nicm

Remove stray spaces after function names.


# 1.226 12-Aug-2021 nicm

Use COLOUR_DEFAULT not hardcoded 8.


# 1.225 10-Jun-2021 nicm

More accurate vi(1) word navigation in copy mode and on the status line.
This changes the meaning of the word-separators option - setting it to
the empty string is equivalent to the previous behavior. From Will Noble
in GitHub issue 2693.


# 1.224 10-Jun-2021 nicm

Add different command historys for different types of prompts
("command", "search" etc). From Anindya Mukherjee.


# 1.223 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.222 10-Jun-2021 nicm

Include current client in size calculation for new sessions, GitHub
issue 2662.


Revision tags: OPENBSD_6_9_BASE
# 1.221 12-Apr-2021 nicm

Add a flag to disable keys to close a message, GitHub issue 2625.


# 1.220 22-Feb-2021 nicm

Move jump commands to grid reader, make them UTF-8 aware, and tidy up,
from Anindya Mukherjee.


# 1.219 08-Jan-2021 nicm

With incremental search, start empty and only repeat the previous search
if the user tries to search again with an empty prompt. This matches
emacs behaviour more closely.


Revision tags: OPENBSD_6_8_BASE
# 1.218 27-Jul-2020 nicm

Add a -d option to display-message to set delay, from theonekeyg at
gmail dot com in GitHub issue 2322.


# 1.217 11-Jun-2020 nicm

Fix a crash when completing sessions, from Anindya Mukherjee.


# 1.216 26-May-2020 nicm

Remove leftover debug logging and fix comparison.


# 1.215 26-May-2020 nicm

Set up UTF-8 data for ASCII keys correctly.


# 1.214 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.213 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.212 16-May-2020 nicm

Rename KEYC_ESCAPE to KEYC_META.


# 1.211 16-May-2020 nicm

Expand target from client and use it to expand the prompt.


# 1.210 16-May-2020 nicm

Support embedded styles in the display-message message, GitHub issue
2206.


# 1.209 16-May-2020 nicm

Change message log to be per server rather than per client and include
every command that is run.


# 1.208 16-May-2020 nicm

Do not hoke into struct window_pane from the tty code and instead set
everything up in tty_ctx. Provide a way to initialize the tty_ctx from a
callback and use it to let popups draw directly through input_parse in
the same way as panes do, rather than forcing a full redraw on every
change.


# 1.207 16-May-2020 nicm

Use formats for status-style and message-style.


# 1.206 16-May-2020 nicm

Complete partial window indexes properly.


# 1.205 16-May-2020 nicm

Add -W and -T flags to command-prompt to only complete a window and a
target, also complete aliases.


# 1.204 16-May-2020 nicm

Improve command prompt completion:

- Show a menu with completions if there are multiple.

- Don't complete argument stuff (options, layouts) at start of text.

- For -t and -s, if there is no : then complete sessions but if there is
a :, show a menu of all windows in the session rather than trying to
complete the window name which is a bit useless if there are
duplicates.


# 1.203 16-May-2020 nicm

Drop having a separate type for style options and make them all strings,
which allows formats to be expanded. Any styles without a '#{' are still
validated when they are set but any with a '#{' are not. Formats are not
expanded usefully in many cases yet, that will be changed later.

To make this work, a few other changes:

- set-option -a with a style option automatically appends a ",".

- OSC 10 and 11 don't set the window-style option anymore, instead the
fg and bg are stored in the pane struct and act as the defaults that
can be overridden by window-style.

- status-fg and -bg now override status-style instead of trying to keep
them in sync.


Revision tags: OPENBSD_6_7_BASE
# 1.202 12-Mar-2020 nicm

Add C-g to cancel command prompt with vi(1) keys as well as emacs, and q
in command mode.


# 1.201 27-Jan-2020 nicm

Add support for adding a note to a key binding (with bind-key -N) and
use this to add descriptions to the default key bindings. A new -N flag
to list-keys shows key bindings with notes rather than the default
bind-key command used to create them. Change the default ? binding to
use this to show a readable summary of keys.

Also extend command-prompt to return the name of the key pressed and add
a default binding (/) to show the note for the next key pressed

Suggested by Alex Tremblay in GitHub issue 2000.


Revision tags: OPENBSD_6_6_BASE
# 1.200 28-May-2019 nicm

Redraw status line if size changes, GitHub issue 1762. Also fix length
of target buffer when pasting into status line.


# 1.199 23-May-2019 nicm

Fix length calculation for pasting UTF-8 characters in the status line,
GitHub issue 1753.


# 1.198 11-May-2019 nicm

Do not reduce window height by status line height for control mode
clients, from George Nachman.


# 1.197 03-May-2019 nicm

Fix reverse attribute in status line, GitHub issue 1709.


# 1.196 26-Apr-2019 nicm

Merge hooks into options and make each one an array option. This allows
multiple commands to be easily bound to one hook. set-hook and
show-hooks remain but they are now variants of set-option and
show-options. show-options now has a -H flag to show hooks (by default
they are not shown).


# 1.195 25-Apr-2019 nicm

options_array_item_value cannot return NULL.


# 1.194 23-Apr-2019 nicm

Somehow missed these bits in last commit.


# 1.193 23-Apr-2019 nicm

Indicate an array option with a flag rather than a special type so that
in future will not have to be strings.


Revision tags: OPENBSD_6_5_BASE
# 1.192 18-Mar-2019 nicm

Extend the #[] style syntax and use that together with previous format
changes to allow the status line to be entirely configured with a single
option.

Now that it is possible to configure their content, enable the existing
code that lets the status line be multiple lines in height. The status
option can now take a value of 2, 3, 4 or 5 (as well as the previous on
or off) to configure more than one line. The new status-format array
option configures the format of each line, the default just references
the existing status-* options, although some of the more obscure status
options may be eliminated in time.

Additions to the #[] syntax are: "align" to specify alignment (left,
centre, right), "list" for the window list and "range" to configure
ranges of text for the mouse bindings.

The "align" keyword can also be used to specify alignment of entries in
tree mode and the pane status lines.


# 1.191 18-Mar-2019 nicm

Make array options a sparse tree instead of an array of char * and
remove the size limit.


# 1.190 18-Mar-2019 nicm

With force, kill previous job before starting new. Fixes problem
reported by Scott Mcdermott in GitHub issue 1627.


# 1.189 16-Mar-2019 nicm

Use a pointer for the active screen in the status line instead of
copying them around all the time.


# 1.188 16-Mar-2019 nicm

Give status_save_old the client so it can do the reinit too.


# 1.187 16-Mar-2019 nicm

Tidy and rename some bits of status line code.


# 1.186 15-Mar-2019 nicm

Move status line free into its own function.


# 1.185 14-Mar-2019 nicm

Store the time in the format tree rather than passing it around.


# 1.184 12-Mar-2019 nicm

DECRC and DECSC apparently need to preserve origin mode as well, based
on a fix from Marc Reisner.


# 1.183 09-Feb-2019 nicm

Completion of command-alias members.


# 1.182 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.181 29-Aug-2018 nicm

Keep any text killed in the command prompt with C-w and yank it with
C-y, only use the top buffer if no text has previously been killed. This
and previous change promped by discussion with kn@.


# 1.180 29-Aug-2018 nicm

Add C-Left and C-Right as aliases for M-b and M-f.


# 1.179 22-Aug-2018 nicm

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


# 1.178 20-Aug-2018 nicm

Move offset of window list into status struct.


# 1.177 19-Aug-2018 nicm

Add a client redraw-window flag instead of the redraw-all flag and for
all just use the three flags together (window, borders, status).


Revision tags: OPENBSD_6_3_BASE
# 1.176 22-Feb-2018 nicm

Remove an unused variable.


# 1.175 05-Feb-2018 nicm

Add struct status_line to hold status line members of struct client, not
used yet but will be soon. From Thomas Adam.


# 1.174 01-Jan-2018 nicm

Add C-g at command prompt for emacs people, GitHub issue 1213.


# 1.173 27-Dec-2017 nicm

Draw command prompt correctly with status line off.


# 1.172 18-Dec-2017 nicm

Remove unused variable from Thomas Adam.


# 1.171 02-Nov-2017 nicm

Add a "fast" version of screen_write_copy for tree mode that doesn't do
all the checks and selection and marking stuff needed for copy mode.


# 1.170 20-Oct-2017 nicm

Clear status line with spaces again so reverse works, spotted by sthen.


# 1.169 16-Oct-2017 nicm

Infrastructure for drawing status lines of more than one line in height,
still only one is allowed but this lets tmux draw bigger ones.


Revision tags: OPENBSD_6_2_BASE
# 1.168 29-May-2017 nicm

Add a flag to stop the prompt input being expanded.


# 1.167 29-May-2017 nicm

Store a copy of the old status line, will be needed soon for new choose mode.


# 1.166 17-May-2017 nicm

Tidy command prompt callbacks and pass in the client.


# 1.165 03-May-2017 nicm

Add a format for the last search string in copy mode and fix the prompt
so it can work when in -I, suggested by Suraj N Kurapati.


# 1.164 01-May-2017 nicm

In order that people can use formats like #D in #() in the status line
and not have to wait for an update when they change pane, we allow
commands to run more than once a second if the expanded form
changes. Unfortunately this can mean them being run far too often
(pretty much continually) when multiple clients exist, because some
formats (including #D) will always differ between clients.

To avoid this, give each client its own tree of jobs which means that
the same command will be different instances for each client - similar
to how we have the tag to separate commands for different panes.

GitHub issue 889; test case reported by Paul Johnson.


# 1.163 22-Apr-2017 nicm

Memory leak from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.162 09-Feb-2017 nicm

Break the message storage function into its own function, useful for
debugging.


# 1.161 03-Feb-2017 nicm

Cache status line position to reduce option lookups during output.


# 1.160 03-Feb-2017 nicm

Add a window or pane id "tag" to each format tree and use it to separate
jobs, this means that if the same job is used for different windows or
panes (for example in pane-border-format), it will be run separately for
each pane.


# 1.159 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.158 06-Jan-2017 nicm

Incremental search in copy mode (on for emacs keys by default) - much
the same as normal searching but updates the cursor position and marked
search terms as you type. C-r and C-s in the prompt repeat the search,
once finished searching (with Enter), N and n work as before.


# 1.157 05-Jan-2017 nicm

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


# 1.156 07-Dec-2016 nicm

Do not clear the prompt when a message is shown, just leave it around and
return to it when the message is finished.


# 1.155 12-Oct-2016 nicm

Drop the edit mode key tables and just use fixed key bindings for the
command prompt.


# 1.154 12-Oct-2016 nicm

The repeat prompt in both emacs and vi (and the old one in tmux) doesn't
support line editing and instead executes a command as soon as a
non-number key is pressed. Add a -N flag to command-prompt for the same
in copy mode. Reported by Theo Buehler.


# 1.153 11-Oct-2016 nicm

Fundamental change to how copy mode key bindings work:

The vi-copy and emacs-copy mode key tables are gone, and instead copy
mode commands are bound in one of two normal key tables ("copy-mode" or
"copy-mode-vi"). Keys are bound to "send-keys -X copy-mode-command". So:

bind -temacs-copy C-Up scroll-up
bind -temacs-copy -R5 WheelUpPane scroll-up

Becomes:

bind -Tcopy-mode C-Up send -X scroll-up
bind -Tcopy-mode WheelUpPane send -N5 -X scroll-up

This allows the full command parser and command set to be used - for
example, we can use the normal command prompt for searching, jumping,
and so on instead of a custom one:

bind -Tcopy-mode C-r command-prompt -p'search up' "send -X search-backward '%%'"

command-prompt also gets a -1 option to only require on key press, which
is needed for jumping.

The plan is to get rid of mode keys entirely, so more to come eventually.


# 1.152 11-Oct-2016 nicm

Support UTF-8 entry into the command prompt.


# 1.151 10-Oct-2016 nicm

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


# 1.150 12-Sep-2016 nicm

Allow repeat count to be specified in mode key tables with bind-key -R,
and set the default repeat count to 5 for WheelUp and WheelDown in
copy-mode.


Revision tags: OPENBSD_6_0_BASE
# 1.149 06-Jun-2016 nicm

Allow #[] in window-status-separator.


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

I no longer use my SourceForge address so replace it.


# 1.147 01-Jan-2016 nicm

Don't rely on a calculation wrapping when applying message-limit, and
break out of the loop early. From Nicolas Viennot.


# 1.146 11-Dec-2015 nicm

Style nits and line wrapping of function declarations.


# 1.145 11-Dec-2015 nicm

Add cmdq as an argument to format_create and add a format for the
command name (will also be used for more later).


# 1.144 08-Dec-2015 nicm

Remove format_create_flags and just pass flags to format_create.


# 1.143 22-Nov-2015 tim

If display-time is set to 0, show status messages until a key is pressed;
OK nicm@


# 1.142 20-Nov-2015 nicm

Instead of separate tables for different types of options, give each
option a scope type (server, session, window) in one table.


# 1.141 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.140 13-Nov-2015 nicm

Long overdue change to the way we store cells in the grid: now, instead
of storing a full grid_cell with UTF-8 data and everything, store a new
type grid_cell_entry. This can either be the cell itself (for ASCII
cells), or an offset into an extended array (per line) for UTF-8
data.

This avoid a large (8 byte) overhead on non-UTF-8 cells (by far the
majority for most users) without the complexity of the shadow array we
had before. Grid memory without any UTF-8 is about half.

The disadvantage that cells can no longer be modified in place and need
to be copied out of the grid and back but it turned out to be lot less
complicated than I expected.


# 1.139 12-Nov-2015 nicm

Nuke the utf8 and status-utf8 options and make tmux only a UTF-8
terminal. We still support non-UTF-8 terminals outside tmux, but inside
it is always UTF-8 (as when the utf8 and status-utf8 options were on).


# 1.138 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.137 27-Oct-2015 nicm

Move struct options into options.c.


# 1.136 20-Oct-2015 nicm

Use client pointer not file descriptor in logging.


# 1.135 14-Sep-2015 nicm

Make refresh-client force update of jobs, from Sina Siadat.


# 1.134 29-Aug-2015 nicm

Move struct paste_buffer out of tmux.h.


# 1.133 28-Aug-2015 nicm

Run status update on a per-client timer at status-interval.


Revision tags: OPENBSD_5_8_BASE
# 1.132 29-Jul-2015 nicm

status_out and associated data structures are no longer used.


# 1.131 28-Jul-2015 nicm

Tidy up the way terminals are described and move some structs out of tmux.h.


# 1.130 20-Jul-2015 nicm

Add an option (history-file) for a file to save/restore command prompt
history, from Olof-Joachim Frahm.


# 1.129 27-May-2015 nicm

Move the jobs output cache into the formats code so that #() work more
generally (for example, again working in set-titles-string).


# 1.128 06-May-2015 nicm

Remove ARRAY_* from history and expand completion to complete a) layout
names and b) targets beginning with -t or -s.


# 1.127 25-Apr-2015 nicm

Make message log a TAILQ.


# 1.126 24-Apr-2015 nicm

Set working directory for run-shell and if-shell.


# 1.125 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_7_BASE
# 1.124 06-Feb-2015 nicm

Use the same time for both calls to format_expand_time.


# 1.123 06-Feb-2015 nicm

status_replace can now become local to status.c and it no longer needs
the jobsflag argument. While here there is no need to repeat work that
format_defaults already does.


# 1.122 06-Feb-2015 nicm

Add format_expand_time and use it instead of status_replace where
command execution is not needed.


# 1.121 05-Feb-2015 nicm

Wrap all the individual format_* calls in a single format_defaults
functions.


# 1.120 01-Feb-2015 nicm

Remove two unused arguments from status_replace.


# 1.119 20-Jan-2015 sthen

typo in comment ;) ok nicm


# 1.118 05-Nov-2014 nicm

Do not put a space between status-left/status-right and the window list,
instead move the space into the defaults for the options (so status-left
now defaults to "[#S] ". From Balazs Kezes.


# 1.117 20-Oct-2014 nicm

Better format for printf format attributes.


# 1.116 08-Oct-2014 nicm

Add xreallocarray and remove nmemb argument from xrealloc.


# 1.115 02-Oct-2014 nicm

Take account of window-status-separator when checking window position,
based on diff from Balazs Kezes.


Revision tags: OPENBSD_5_6_BASE
# 1.114 24-Apr-2014 nicm

There is no longer a need for a paste_stack struct or for global_buffers
to be global. Move to paste.c.


# 1.113 17-Apr-2014 nicm

Remove the monitor-content option and associated bits and bobs. It's
never worked very well. If there is a big demand for it to return, will
consider better ways to do it.


# 1.112 02-Apr-2014 nicm

Do not replace ## with # in status_replace1 because it'll be done later
by the format code.


# 1.111 31-Mar-2014 nicm

Make message-limit a server option.


Revision tags: OPENBSD_5_5_BASE
# 1.110 14-Feb-2014 nicm

Style nit - no space between function name and bracket.


# 1.109 14-Feb-2014 nicm

Check for NULL session and whatnot in status_replace, from Thomas Adam.


# 1.108 28-Jan-2014 nicm

Allow replacing each of the many sets of separate foo-{fg,bg,attr}
options with a single foo-style option. For example:

set -g status-fg yellow
set -g status-bg red
set -g status-attr blink

Becomes:

set -g status-style fg=yellow,bg=red,blink

The -a flag to set can be used to add to rather than replace a style. So:

set -g status-bg red

Becomes:

set -ag status-style bg=red

Currently this is fully backwards compatible (all *-{fg,bg,attr} options
remain) but the plan is to deprecate them over time.

From Tiago Cunha.


Revision tags: OPENBSD_5_4_BASE
# 1.107 05-Jul-2013 nicm

Whitespace nits, from Ben Boeckel.


# 1.106 05-Jul-2013 nicm

Act like vi(1) when moving words, from Ben Boeckel.


# 1.105 05-Jul-2013 nicm

Implement s, S, C mode switch commands in vi(1) mode, from Ben Boeckel.


# 1.104 31-May-2013 nicm

Demote the old single-character replacement variables (#S and friends)
to aliases of formats. From Tiago Cunha.


# 1.103 25-Mar-2013 nicm

Extend jobs to support writing and use that for copy-pipe instead of
popen, from Chris Johnsen.


# 1.102 22-Mar-2013 nicm

evbuffer_readline returns allocated storage, don't leak it.


# 1.101 22-Mar-2013 nicm

Add copy-pipe mode command to copy selection and also pipe to a command.


# 1.100 22-Mar-2013 nicm

No more lint means no more ARGSUSED.


# 1.99 21-Mar-2013 nicm

Aargh. Spaces -> tabs.


# 1.98 21-Mar-2013 nicm

Do not leak formats in status_replace.


# 1.97 21-Mar-2013 nicm

Add a format client_prefix which is 1 if prefix key has been
pressed, used for example #{?client_prefix,X,Y}. Also a few extra
server_client_status needed.


# 1.96 21-Mar-2013 nicm

Allow formats in status options.


Revision tags: OPENBSD_5_3_BASE
# 1.95 27-Nov-2012 nicm

Add window-status-last-* options, from Boris Faure.


Revision tags: OPENBSD_5_2_BASE
# 1.94 10-Jul-2012 nicm

xfree is not particularly helpful, remove it. From Thomas Adam.


# 1.93 09-Jul-2012 nicm

Move a NULL check inside a function, from Tiago Cunha.


# 1.92 29-Apr-2012 nicm

Use int not u_char for colours from options since they may have bit 8
set to mark them as 256-colour. Reported by Chris Johnson.


# 1.91 23-Apr-2012 nicm

Add window-status-separator option, from Thomas Adam.


# 1.90 17-Mar-2012 nicm

Check event_initialized before event_del if event may not have been set
up; libevent2 complains about this. Reported by Moriyoshi Koizumi.


# 1.89 04-Mar-2012 nicm

Add A and I keys for vi status line editing.


# 1.88 03-Mar-2012 nicm

The wlmouse offset should be part of the client, not the server. From
Ailin Nemui.


Revision tags: OPENBSD_5_1_BASE
# 1.87 29-Jan-2012 nicm

Add an option to move the status line to the top of the screen,
requested by many.


# 1.86 26-Jan-2012 nicm

Terminate strftime buffer properly even if a really long format string
is given, from Tiago Cunha.


# 1.85 26-Jan-2012 nicm

Fix memory leak in error path, from Tiago Cunha.


# 1.84 20-Jan-2012 nicm

Add some trivial additional status line attributes from jwcxz at users
dot sourceforge dot net.


# 1.83 20-Jan-2012 nicm

Add space movement keys for vi mode in the status line from Ben Boeckel.


# 1.82 01-Dec-2011 nicm

Make M-f and M-b work the same at the command prompt as in copy mode,
pointed out by Romain Francoise.


# 1.81 15-Nov-2011 nicm

Add word movement and editing command for command prompt editing, from
Ben Boeckel.


# 1.80 15-Nov-2011 nicm

Make window_pane_index work the same as window_index, from Ben Boeckel.


# 1.79 05-Nov-2011 nicm

Option to change status line (message) background when using vi keys and
in command mode. From Ben Boeckel.


# 1.78 20-Aug-2011 nicm

Fix a couple of memory leaks, from marcel partap.


Revision tags: OPENBSD_5_0_BASE
# 1.77 08-Jul-2011 nicm

Make confirm-before prompt customizable with -p option like
command-prompt. Also move responsibility for calling status_replace into
status_prompt_{set,update} and add #W and #P to the default kill-window
and kill-pane prompts. By Tiago Cunha.


# 1.76 02-Jul-2011 nicm

Allow the initial context on prompts to be set with the new -I option to
command-prompt. From Tiago Cunha.


# 1.75 29-Apr-2011 nicm

Only redraw the status line on command update, not the entire client
(big DOH).


# 1.74 24-Apr-2011 nicm

Provide #h for short hostname (no domain) from Michal Mazurek.


# 1.73 18-Apr-2011 nicm

Add an option (mouse-select-window) which allows the mouse to be used by
clicking on the status line, written by hsim at gmx dot li.


# 1.72 29-Mar-2011 nicm

Change -t on display-message to be target-pane for the #[A-Z]
replacements and add -c as target-client.


Revision tags: OPENBSD_4_9_BASE
# 1.71 26-Jan-2011 nicm

Simplify the way jobs work and drop the persist type, so all jobs are
fire-and-forget.

Status jobs now managed with two trees of output (new and old), rather
than storing the output in the jobs themselves. When the status line is
processed any jobs which don't appear in the new tree are started and
the output from the old tree displayed. When a job finishes it updates
the new tree with its output and that is used for any subsequent
redraws. When the status interval expires, the new tree is moved to the
old so that all jobs are run again.

This fixes the "#(echo %H:%M:%S)" problem which would lead to thousands
of identical persistent jobs and high memory use (this can still be
achieved by adding "sleep 30" but that is much less likely to happen by
accident).


# 1.70 03-Jan-2011 nicm

Handle a # at the end of a replacement string (such as status-left)
correctly. Found by Thomas Adam.


# 1.69 01-Jan-2011 nicm

Move the user-visible parts of all options (names, types, limit, default
values) together into one set of tables in options-table.c. Also clean
up and simplify cmd-set-options.c and move a common print function into
option-table.c.


# 1.68 30-Dec-2010 nicm

Change from a per-session stack of buffers to one global stack which is
much more convenient and also simplifies lot of code. This renders
copy-buffer useless and makes buffer-limit now a server option.

By Tiago Cunha.


# 1.67 30-Dec-2010 nicm

Add a function to create window flags rather than doing the same thing
in two places. From Thomas Adam.


# 1.66 11-Dec-2010 nicm

Oops, these functions return a const char *, so make the local variable
const as well.


# 1.65 11-Dec-2010 nicm

Make the prompt history global for all clients which is much more useful than per-client history.


# 1.64 06-Dec-2010 nicm

Add an option to alert (monitor) for silence (lack of activity) in a
window. From Thomas Adam.


Revision tags: OPENBSD_4_8_BASE
# 1.63 21-Jun-2010 nicm

Having a list of winlinks->alerts for each session is stupid, just store
the alert flags directly in the winlink itself.


# 1.62 14-May-2010 nicm

Colour+attribute options for status line alerts, from Alex Alexander.


# 1.61 31-Mar-2010 nicm

Don't accept keys with modifiers as input. Fixes crash reported by Brian
R Landy.


# 1.60 27-Mar-2010 nicm

Don't leak job command in #().


# 1.59 22-Mar-2010 nicm

Dead functions, lint.


Revision tags: OPENBSD_4_7_BASE
# 1.58 27-Jan-2010 nicm

Calculate offset correctly, fixes incorrect offset and prevents crash when
status-left is empty. From Micah Cowan.


# 1.57 26-Jan-2010 nicm

Actually use the copy made when no newline is found, from martynas@.


# 1.56 14-Dec-2009 nicm

Add server options to completion as well.


# 1.55 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.54 03-Dec-2009 nicm

Eliminate duplicate code and ease the passage for server-wide options by adding
a -w flag to set-option and show-options and making setw and showw aliases to
set -w and show -w.

Note: setw and showw are still there, but now aliases for set -w and show -w.


# 1.53 26-Nov-2009 nicm

Tidy up various bits of the paste code, make the data buffer char * and add
comments.


# 1.52 26-Nov-2009 nicm

Remove a couple of unused arguments where possible, and add /* ARGSUSED */ to
the rest to reduce lint output.


# 1.51 20-Nov-2009 nicm

Display UTF-8 properly in status line messages and prompt. Cursor handling is
still way off though.


# 1.50 20-Nov-2009 nicm

Remove oldest messages from log when limit is hit, not newest.


# 1.49 19-Nov-2009 nicm

Get some brackets in the right place so ## works. Also fix a space in a
comment.


# 1.48 19-Nov-2009 nicm

Change status line drawing to create the window list in a separate screen and
then copy it into the status line screen. This allows UTF-8 in window names and
fixes some problems with #[] in window-status-format.


# 1.47 19-Nov-2009 nicm

Two new options, window-status-format and window-status-current-format, which
allow the format of each window in the status line window list to be controlled
using similar # sequences as status-left/right.

This diff also moves part of the way towards UTF-8 support in window names but
it isn't quite there yet.


# 1.46 19-Nov-2009 nicm

Tidy up by breaking the # replacement code into a separate function, also add a
few comments.


# 1.45 19-Nov-2009 nicm

Don't interpret #() for display-message, it usually doesn't make sense and may
leak commands.


# 1.44 18-Nov-2009 nicm

Add a per-client log of status line messages displayed while that client
exists. A new message-limit session option sets the maximum number of entries
and a command, show-messages, shows the log (bound to ~ by default).

This (and prompt history) might be better as a single global log but until
there are global options it is easier for them to be per client.


# 1.43 17-Nov-2009 nicm

Permit top-bit-set characters to be entered in the status line. They could
already be set from the shell and are just passed through when printing (so
invisible characters or displaying on terminals with different character sets
may cause problems).

Note that entering UTF-8 may not work and in any case currently the status line
cannot display it correctly (outside of status-left/status-right).


# 1.42 04-Nov-2009 nicm

Use timeout events for the identify and message timers.


# 1.41 04-Nov-2009 nicm

Switch jobs over to use a bufferevent.


# 1.40 04-Nov-2009 nicm

Unused (but assigned to) variable, found by lint.


# 1.39 01-Nov-2009 nicm

Add a flag for jobs that shouldn't be freed after they've died and use it for
status jobs, then only kill those jobs when status-left, status-right or
set-titles-string is changed.

Fixes problems with changing options from inside #().


# 1.38 10-Oct-2009 nicm

Rather than running status-left, status-right and window title #() with popen
immediately every redraw, queue them up and run them in the background,
starting each once every status-interval. The actual status line uses the
output from the last run.

This brings several advantages:

- tmux itself may be called from inside #() without causing the server to hang;
- likewise, sleep or similar doesn't cause the server to block;
- commands aren't run excessively often when redrawing;
- commands shared by status-left and status-right, or used multiple times, will
only be run once.

run-shell and if-shell still use system()/popen() but will be changed over to
use this too later.


# 1.37 10-Oct-2009 nicm

Add "grouped sessions" which have independent name, options, current window and
so on but where the linked windows are synchronized (ie creating, killing
windows and so on are mirrored between the sessions). A grouped session may be
created by passing -t to new-session.

Had this around for a while, tested by a couple of people.


# 1.36 23-Sep-2009 nicm

Remove PROMPT_HIDDEN code which is now unused.


# 1.35 23-Sep-2009 nicm

Remove the internal tmux locking and instead detach each client and run the
command specified by a new option "lock-command" (by default "lock -np") in
each client.

This means each terminal has to be unlocked individually but simplifies the
code and allows the system password to be used to unlock.

Note that the set-password command is gone, so it will need to be removed from
configuration files, and the -U command line flag has been removed.

This is the third protocol version change so again it is best to stop the tmux
server before upgrading.


# 1.34 20-Sep-2009 nicm

Regularise some fatal messages.


# 1.33 10-Sep-2009 nicm

Permit options such as status-bg to be configured using the entire 256 colour
palette by setting "colour0" to "colour255".


# 1.32 07-Sep-2009 nicm

Give each paste buffer a size member instead of requiring them to be
zero-terminated.


# 1.31 07-Sep-2009 nicm

Permit embedded colour and attributes in status-left and status-right using new
#[] special characters, for example #[fg=red,bg=blue,blink].


# 1.30 02-Sep-2009 nicm

Add a transpose-chars command in edit mode (C-t in emacs mode only). From Kalle
Olavi Niemitalo.


# 1.29 01-Sep-2009 nicm

Use "Password:" with no space for password prompts and don't display a *s for
the password, like pretty much everything else. From martynas@ with minor
tweaks by me.


# 1.28 31-Aug-2009 nicm

Add a new display-panes command, with two options (display-panes-colour and
display-panes-time), which displays a visual indication of the number of each
pane.


# 1.27 19-Aug-2009 nicm

Extend command-prompt with a -p option which is a comma-separated list of one
or more prompts to present in order.

The responses to the prompt are replaced in the template string: %% are
replaced in order, so the first prompt replaces the first %%, the second
replaces the second, and so on. In addition, %1 up to %9 are replaced with the
responses to the first the ninth prompts

The default template is "%1" so the response to the first prompt is processed
as a command.

Note that this changes the behaviour for %% so if there is only one prompt,
only the first %% will be replaced. Templates such as "neww -n '%%' 'ssh %%'"
should be changed to "neww -n '%1' 'ssh %1'".

From Tiago Cunha.


# 1.26 18-Aug-2009 nicm

Add a "delete line" key when editing in the status line or the search up/down
prompt. C-u with emacs keys, d with vi.


# 1.25 13-Aug-2009 nicm

Switch the prompt code to return an empty string when the user enters no
response and reserve NULL for an explicit cancel. Change all callbacks to treat
them the same so no functional change.

Also add cancel key bindings to emacs mode which were missing.


# 1.24 08-Aug-2009 nicm

Options to set the colours and attributes for status-left/-right. From Thomas
Adam, thanks.


# 1.23 05-Aug-2009 nicm

If colours are not supported by the terminal, try to emulate a coloured
background by setting or clearing the reverse attribute.

This makes a few applications which don't use the reverse attribute themselves
a little happier, and allows the status, message and mode options to have
default attributes and fg/bg options that work as expected when set as reverse.


# 1.22 30-Jul-2009 nicm

Plug some memory leaks.


# 1.21 28-Jul-2009 nicm

Next step towards customisable mode keys: build each default table of keys into
a named tree on start and use that for lookups. Also add command to string
translation tables and modify list-keys to show the the mode key bindings (new
-t argument).


# 1.20 27-Jul-2009 nicm

Change mode key bindings from big switches into a set of tables. Rather than
lumping them all together, split editing keys from those used in choice/more
mode and those for copy/scroll mode.

Tidier and clearer, and the first step towards customisable mode keys.


# 1.19 27-Jul-2009 nicm

Get rid of empty mode_key_free function.


# 1.18 27-Jul-2009 nicm

Add a key to delete to end of line at the prompt (^K in emacs mode, C/D in vi).

From Kalle Olavi Niemitalo.


# 1.17 26-Jul-2009 nicm

Calculate the space available for the prompt buffer and the cursor position
correctly, and make it work when the screen is not wide enough.

Noticed by Kalle Olavi Niemitalo.


# 1.16 21-Jul-2009 nicm

Remove a couple of unused functions and fix a type ("FALLTHOUGH"), found by
lint.


# 1.15 20-Jul-2009 nicm

Add a status-justify option to allow the window list in the status line to be
positioned at the left, centre, or right.


# 1.14 20-Jul-2009 nicm

New options, window-status-current-{fg,bg,attr}, to set the fg, bg and
attributes with which the current window is shown in the status line. From
Johan Friis, thanks.


# 1.13 17-Jul-2009 nicm

- New command display-message (alias display) to display a message in the
status line (bound to "i" and displays the current window and time by
default). The same substitutions are applied as for status-left/right.
- Add support for including the window index (#I), pane index (#P) and window
name (#W) in the message, and status-left or status-right.
- Bump protocol version.

From Tiago Cunha, thanks!


# 1.12 17-Jul-2009 nicm

Memory could be leaked if a second prompt or message appeared while another was
still present, so add a separate prompt free callback and make the _clear
function responsible for calling it if necessary (rather than the individual
prompt callbacks). Also make both messages and prompts clear any existing when
a new is set.

In addition, the screen could be modified while the prompt is there, restore
the redraw-entire-screen behaviour on prompt clear; add a comment as a
reminder.


# 1.11 16-Jul-2009 nicm

Remove some duplicate code that was causing the status line to be redrawn even
when it hadn't changed.


# 1.10 15-Jul-2009 nicm

Make status_message_set a variadic printf-like function. No functional change -
helpful for a couple of things coming soon.


# 1.9 15-Jul-2009 nicm

Having to update NSETOPTION/NSETWINDOWOPTION when adding new options is a bit
annoying and it is only use for iterating, so use a sentinel to mark the end of
each array instead. Different fix for a problem pointed out by Kalle Olavi
Niemitalo.


# 1.8 14-Jul-2009 nicm

For some reason when clearing status/message it was redrawing the entire client
not just the status line. Changing this also revealed the check for the status
line was incorrect when drawing the pane.


# 1.7 14-Jul-2009 nicm

Instead of faking up a status line in status_redraw, use the same code to
redraw it as to draw the entire screen, just skip all lines but the last.

This makes horizontal split redraw properly when the status line is off.


# 1.6 12-Jul-2009 nicm

Add a "back to indentation" key in copy mode to move the cursor to the first
non-whitespace character. ^ with vi and M-m with emacs key bindings. Another
from Kalle Olavi Niemitalo, thanks.


Revision tags: OPENBSD_4_6_BASE
# 1.5 26-Jun-2009 nicm

Status line fixes: don't truncate status-right now the length calculation is
done for UTF-8, limit to the maximum length correctly when printing, and always
print a space even if the left string is longer than the width available.


# 1.4 04-Jun-2009 nicm

If the prompt is hidden or a password is sent with -U, zero it before freeing
it.


# 1.3 03-Jun-2009 nicm

New session option, status-utf8, to control the interpretation of top-bit-set
characters in status-left and status-right (if on, they are treated as UTF-8;
otherwise passed through).


# 1.2 03-Jun-2009 nicm

Add a UTF-8 aware string length function and make UTF-8 in
status-left/status-right work properly. At the moment any top-bit-set
characters are assumed to be UTF-8: a status-utf8 option to configure this will
come shortly.


# 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.226 12-Aug-2021 nicm

Use COLOUR_DEFAULT not hardcoded 8.


# 1.225 10-Jun-2021 nicm

More accurate vi(1) word navigation in copy mode and on the status line.
This changes the meaning of the word-separators option - setting it to
the empty string is equivalent to the previous behavior. From Will Noble
in GitHub issue 2693.


# 1.224 10-Jun-2021 nicm

Add different command historys for different types of prompts
("command", "search" etc). From Anindya Mukherjee.


# 1.223 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.222 10-Jun-2021 nicm

Include current client in size calculation for new sessions, GitHub
issue 2662.


Revision tags: OPENBSD_6_9_BASE
# 1.221 12-Apr-2021 nicm

Add a flag to disable keys to close a message, GitHub issue 2625.


# 1.220 22-Feb-2021 nicm

Move jump commands to grid reader, make them UTF-8 aware, and tidy up,
from Anindya Mukherjee.


# 1.219 08-Jan-2021 nicm

With incremental search, start empty and only repeat the previous search
if the user tries to search again with an empty prompt. This matches
emacs behaviour more closely.


Revision tags: OPENBSD_6_8_BASE
# 1.218 27-Jul-2020 nicm

Add a -d option to display-message to set delay, from theonekeyg at
gmail dot com in GitHub issue 2322.


# 1.217 11-Jun-2020 nicm

Fix a crash when completing sessions, from Anindya Mukherjee.


# 1.216 26-May-2020 nicm

Remove leftover debug logging and fix comparison.


# 1.215 26-May-2020 nicm

Set up UTF-8 data for ASCII keys correctly.


# 1.214 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.213 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.212 16-May-2020 nicm

Rename KEYC_ESCAPE to KEYC_META.


# 1.211 16-May-2020 nicm

Expand target from client and use it to expand the prompt.


# 1.210 16-May-2020 nicm

Support embedded styles in the display-message message, GitHub issue
2206.


# 1.209 16-May-2020 nicm

Change message log to be per server rather than per client and include
every command that is run.


# 1.208 16-May-2020 nicm

Do not hoke into struct window_pane from the tty code and instead set
everything up in tty_ctx. Provide a way to initialize the tty_ctx from a
callback and use it to let popups draw directly through input_parse in
the same way as panes do, rather than forcing a full redraw on every
change.


# 1.207 16-May-2020 nicm

Use formats for status-style and message-style.


# 1.206 16-May-2020 nicm

Complete partial window indexes properly.


# 1.205 16-May-2020 nicm

Add -W and -T flags to command-prompt to only complete a window and a
target, also complete aliases.


# 1.204 16-May-2020 nicm

Improve command prompt completion:

- Show a menu with completions if there are multiple.

- Don't complete argument stuff (options, layouts) at start of text.

- For -t and -s, if there is no : then complete sessions but if there is
a :, show a menu of all windows in the session rather than trying to
complete the window name which is a bit useless if there are
duplicates.


# 1.203 16-May-2020 nicm

Drop having a separate type for style options and make them all strings,
which allows formats to be expanded. Any styles without a '#{' are still
validated when they are set but any with a '#{' are not. Formats are not
expanded usefully in many cases yet, that will be changed later.

To make this work, a few other changes:

- set-option -a with a style option automatically appends a ",".

- OSC 10 and 11 don't set the window-style option anymore, instead the
fg and bg are stored in the pane struct and act as the defaults that
can be overridden by window-style.

- status-fg and -bg now override status-style instead of trying to keep
them in sync.


Revision tags: OPENBSD_6_7_BASE
# 1.202 12-Mar-2020 nicm

Add C-g to cancel command prompt with vi(1) keys as well as emacs, and q
in command mode.


# 1.201 27-Jan-2020 nicm

Add support for adding a note to a key binding (with bind-key -N) and
use this to add descriptions to the default key bindings. A new -N flag
to list-keys shows key bindings with notes rather than the default
bind-key command used to create them. Change the default ? binding to
use this to show a readable summary of keys.

Also extend command-prompt to return the name of the key pressed and add
a default binding (/) to show the note for the next key pressed

Suggested by Alex Tremblay in GitHub issue 2000.


Revision tags: OPENBSD_6_6_BASE
# 1.200 28-May-2019 nicm

Redraw status line if size changes, GitHub issue 1762. Also fix length
of target buffer when pasting into status line.


# 1.199 23-May-2019 nicm

Fix length calculation for pasting UTF-8 characters in the status line,
GitHub issue 1753.


# 1.198 11-May-2019 nicm

Do not reduce window height by status line height for control mode
clients, from George Nachman.


# 1.197 03-May-2019 nicm

Fix reverse attribute in status line, GitHub issue 1709.


# 1.196 26-Apr-2019 nicm

Merge hooks into options and make each one an array option. This allows
multiple commands to be easily bound to one hook. set-hook and
show-hooks remain but they are now variants of set-option and
show-options. show-options now has a -H flag to show hooks (by default
they are not shown).


# 1.195 25-Apr-2019 nicm

options_array_item_value cannot return NULL.


# 1.194 23-Apr-2019 nicm

Somehow missed these bits in last commit.


# 1.193 23-Apr-2019 nicm

Indicate an array option with a flag rather than a special type so that
in future will not have to be strings.


Revision tags: OPENBSD_6_5_BASE
# 1.192 18-Mar-2019 nicm

Extend the #[] style syntax and use that together with previous format
changes to allow the status line to be entirely configured with a single
option.

Now that it is possible to configure their content, enable the existing
code that lets the status line be multiple lines in height. The status
option can now take a value of 2, 3, 4 or 5 (as well as the previous on
or off) to configure more than one line. The new status-format array
option configures the format of each line, the default just references
the existing status-* options, although some of the more obscure status
options may be eliminated in time.

Additions to the #[] syntax are: "align" to specify alignment (left,
centre, right), "list" for the window list and "range" to configure
ranges of text for the mouse bindings.

The "align" keyword can also be used to specify alignment of entries in
tree mode and the pane status lines.


# 1.191 18-Mar-2019 nicm

Make array options a sparse tree instead of an array of char * and
remove the size limit.


# 1.190 18-Mar-2019 nicm

With force, kill previous job before starting new. Fixes problem
reported by Scott Mcdermott in GitHub issue 1627.


# 1.189 16-Mar-2019 nicm

Use a pointer for the active screen in the status line instead of
copying them around all the time.


# 1.188 16-Mar-2019 nicm

Give status_save_old the client so it can do the reinit too.


# 1.187 16-Mar-2019 nicm

Tidy and rename some bits of status line code.


# 1.186 15-Mar-2019 nicm

Move status line free into its own function.


# 1.185 14-Mar-2019 nicm

Store the time in the format tree rather than passing it around.


# 1.184 12-Mar-2019 nicm

DECRC and DECSC apparently need to preserve origin mode as well, based
on a fix from Marc Reisner.


# 1.183 09-Feb-2019 nicm

Completion of command-alias members.


# 1.182 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.181 29-Aug-2018 nicm

Keep any text killed in the command prompt with C-w and yank it with
C-y, only use the top buffer if no text has previously been killed. This
and previous change promped by discussion with kn@.


# 1.180 29-Aug-2018 nicm

Add C-Left and C-Right as aliases for M-b and M-f.


# 1.179 22-Aug-2018 nicm

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


# 1.178 20-Aug-2018 nicm

Move offset of window list into status struct.


# 1.177 19-Aug-2018 nicm

Add a client redraw-window flag instead of the redraw-all flag and for
all just use the three flags together (window, borders, status).


Revision tags: OPENBSD_6_3_BASE
# 1.176 22-Feb-2018 nicm

Remove an unused variable.


# 1.175 05-Feb-2018 nicm

Add struct status_line to hold status line members of struct client, not
used yet but will be soon. From Thomas Adam.


# 1.174 01-Jan-2018 nicm

Add C-g at command prompt for emacs people, GitHub issue 1213.


# 1.173 27-Dec-2017 nicm

Draw command prompt correctly with status line off.


# 1.172 18-Dec-2017 nicm

Remove unused variable from Thomas Adam.


# 1.171 02-Nov-2017 nicm

Add a "fast" version of screen_write_copy for tree mode that doesn't do
all the checks and selection and marking stuff needed for copy mode.


# 1.170 20-Oct-2017 nicm

Clear status line with spaces again so reverse works, spotted by sthen.


# 1.169 16-Oct-2017 nicm

Infrastructure for drawing status lines of more than one line in height,
still only one is allowed but this lets tmux draw bigger ones.


Revision tags: OPENBSD_6_2_BASE
# 1.168 29-May-2017 nicm

Add a flag to stop the prompt input being expanded.


# 1.167 29-May-2017 nicm

Store a copy of the old status line, will be needed soon for new choose mode.


# 1.166 17-May-2017 nicm

Tidy command prompt callbacks and pass in the client.


# 1.165 03-May-2017 nicm

Add a format for the last search string in copy mode and fix the prompt
so it can work when in -I, suggested by Suraj N Kurapati.


# 1.164 01-May-2017 nicm

In order that people can use formats like #D in #() in the status line
and not have to wait for an update when they change pane, we allow
commands to run more than once a second if the expanded form
changes. Unfortunately this can mean them being run far too often
(pretty much continually) when multiple clients exist, because some
formats (including #D) will always differ between clients.

To avoid this, give each client its own tree of jobs which means that
the same command will be different instances for each client - similar
to how we have the tag to separate commands for different panes.

GitHub issue 889; test case reported by Paul Johnson.


# 1.163 22-Apr-2017 nicm

Memory leak from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.162 09-Feb-2017 nicm

Break the message storage function into its own function, useful for
debugging.


# 1.161 03-Feb-2017 nicm

Cache status line position to reduce option lookups during output.


# 1.160 03-Feb-2017 nicm

Add a window or pane id "tag" to each format tree and use it to separate
jobs, this means that if the same job is used for different windows or
panes (for example in pane-border-format), it will be run separately for
each pane.


# 1.159 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.158 06-Jan-2017 nicm

Incremental search in copy mode (on for emacs keys by default) - much
the same as normal searching but updates the cursor position and marked
search terms as you type. C-r and C-s in the prompt repeat the search,
once finished searching (with Enter), N and n work as before.


# 1.157 05-Jan-2017 nicm

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


# 1.156 07-Dec-2016 nicm

Do not clear the prompt when a message is shown, just leave it around and
return to it when the message is finished.


# 1.155 12-Oct-2016 nicm

Drop the edit mode key tables and just use fixed key bindings for the
command prompt.


# 1.154 12-Oct-2016 nicm

The repeat prompt in both emacs and vi (and the old one in tmux) doesn't
support line editing and instead executes a command as soon as a
non-number key is pressed. Add a -N flag to command-prompt for the same
in copy mode. Reported by Theo Buehler.


# 1.153 11-Oct-2016 nicm

Fundamental change to how copy mode key bindings work:

The vi-copy and emacs-copy mode key tables are gone, and instead copy
mode commands are bound in one of two normal key tables ("copy-mode" or
"copy-mode-vi"). Keys are bound to "send-keys -X copy-mode-command". So:

bind -temacs-copy C-Up scroll-up
bind -temacs-copy -R5 WheelUpPane scroll-up

Becomes:

bind -Tcopy-mode C-Up send -X scroll-up
bind -Tcopy-mode WheelUpPane send -N5 -X scroll-up

This allows the full command parser and command set to be used - for
example, we can use the normal command prompt for searching, jumping,
and so on instead of a custom one:

bind -Tcopy-mode C-r command-prompt -p'search up' "send -X search-backward '%%'"

command-prompt also gets a -1 option to only require on key press, which
is needed for jumping.

The plan is to get rid of mode keys entirely, so more to come eventually.


# 1.152 11-Oct-2016 nicm

Support UTF-8 entry into the command prompt.


# 1.151 10-Oct-2016 nicm

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


# 1.150 12-Sep-2016 nicm

Allow repeat count to be specified in mode key tables with bind-key -R,
and set the default repeat count to 5 for WheelUp and WheelDown in
copy-mode.


Revision tags: OPENBSD_6_0_BASE
# 1.149 06-Jun-2016 nicm

Allow #[] in window-status-separator.


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

I no longer use my SourceForge address so replace it.


# 1.147 01-Jan-2016 nicm

Don't rely on a calculation wrapping when applying message-limit, and
break out of the loop early. From Nicolas Viennot.


# 1.146 11-Dec-2015 nicm

Style nits and line wrapping of function declarations.


# 1.145 11-Dec-2015 nicm

Add cmdq as an argument to format_create and add a format for the
command name (will also be used for more later).


# 1.144 08-Dec-2015 nicm

Remove format_create_flags and just pass flags to format_create.


# 1.143 22-Nov-2015 tim

If display-time is set to 0, show status messages until a key is pressed;
OK nicm@


# 1.142 20-Nov-2015 nicm

Instead of separate tables for different types of options, give each
option a scope type (server, session, window) in one table.


# 1.141 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.140 13-Nov-2015 nicm

Long overdue change to the way we store cells in the grid: now, instead
of storing a full grid_cell with UTF-8 data and everything, store a new
type grid_cell_entry. This can either be the cell itself (for ASCII
cells), or an offset into an extended array (per line) for UTF-8
data.

This avoid a large (8 byte) overhead on non-UTF-8 cells (by far the
majority for most users) without the complexity of the shadow array we
had before. Grid memory without any UTF-8 is about half.

The disadvantage that cells can no longer be modified in place and need
to be copied out of the grid and back but it turned out to be lot less
complicated than I expected.


# 1.139 12-Nov-2015 nicm

Nuke the utf8 and status-utf8 options and make tmux only a UTF-8
terminal. We still support non-UTF-8 terminals outside tmux, but inside
it is always UTF-8 (as when the utf8 and status-utf8 options were on).


# 1.138 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.137 27-Oct-2015 nicm

Move struct options into options.c.


# 1.136 20-Oct-2015 nicm

Use client pointer not file descriptor in logging.


# 1.135 14-Sep-2015 nicm

Make refresh-client force update of jobs, from Sina Siadat.


# 1.134 29-Aug-2015 nicm

Move struct paste_buffer out of tmux.h.


# 1.133 28-Aug-2015 nicm

Run status update on a per-client timer at status-interval.


Revision tags: OPENBSD_5_8_BASE
# 1.132 29-Jul-2015 nicm

status_out and associated data structures are no longer used.


# 1.131 28-Jul-2015 nicm

Tidy up the way terminals are described and move some structs out of tmux.h.


# 1.130 20-Jul-2015 nicm

Add an option (history-file) for a file to save/restore command prompt
history, from Olof-Joachim Frahm.


# 1.129 27-May-2015 nicm

Move the jobs output cache into the formats code so that #() work more
generally (for example, again working in set-titles-string).


# 1.128 06-May-2015 nicm

Remove ARRAY_* from history and expand completion to complete a) layout
names and b) targets beginning with -t or -s.


# 1.127 25-Apr-2015 nicm

Make message log a TAILQ.


# 1.126 24-Apr-2015 nicm

Set working directory for run-shell and if-shell.


# 1.125 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_7_BASE
# 1.124 06-Feb-2015 nicm

Use the same time for both calls to format_expand_time.


# 1.123 06-Feb-2015 nicm

status_replace can now become local to status.c and it no longer needs
the jobsflag argument. While here there is no need to repeat work that
format_defaults already does.


# 1.122 06-Feb-2015 nicm

Add format_expand_time and use it instead of status_replace where
command execution is not needed.


# 1.121 05-Feb-2015 nicm

Wrap all the individual format_* calls in a single format_defaults
functions.


# 1.120 01-Feb-2015 nicm

Remove two unused arguments from status_replace.


# 1.119 20-Jan-2015 sthen

typo in comment ;) ok nicm


# 1.118 05-Nov-2014 nicm

Do not put a space between status-left/status-right and the window list,
instead move the space into the defaults for the options (so status-left
now defaults to "[#S] ". From Balazs Kezes.


# 1.117 20-Oct-2014 nicm

Better format for printf format attributes.


# 1.116 08-Oct-2014 nicm

Add xreallocarray and remove nmemb argument from xrealloc.


# 1.115 02-Oct-2014 nicm

Take account of window-status-separator when checking window position,
based on diff from Balazs Kezes.


Revision tags: OPENBSD_5_6_BASE
# 1.114 24-Apr-2014 nicm

There is no longer a need for a paste_stack struct or for global_buffers
to be global. Move to paste.c.


# 1.113 17-Apr-2014 nicm

Remove the monitor-content option and associated bits and bobs. It's
never worked very well. If there is a big demand for it to return, will
consider better ways to do it.


# 1.112 02-Apr-2014 nicm

Do not replace ## with # in status_replace1 because it'll be done later
by the format code.


# 1.111 31-Mar-2014 nicm

Make message-limit a server option.


Revision tags: OPENBSD_5_5_BASE
# 1.110 14-Feb-2014 nicm

Style nit - no space between function name and bracket.


# 1.109 14-Feb-2014 nicm

Check for NULL session and whatnot in status_replace, from Thomas Adam.


# 1.108 28-Jan-2014 nicm

Allow replacing each of the many sets of separate foo-{fg,bg,attr}
options with a single foo-style option. For example:

set -g status-fg yellow
set -g status-bg red
set -g status-attr blink

Becomes:

set -g status-style fg=yellow,bg=red,blink

The -a flag to set can be used to add to rather than replace a style. So:

set -g status-bg red

Becomes:

set -ag status-style bg=red

Currently this is fully backwards compatible (all *-{fg,bg,attr} options
remain) but the plan is to deprecate them over time.

From Tiago Cunha.


Revision tags: OPENBSD_5_4_BASE
# 1.107 05-Jul-2013 nicm

Whitespace nits, from Ben Boeckel.


# 1.106 05-Jul-2013 nicm

Act like vi(1) when moving words, from Ben Boeckel.


# 1.105 05-Jul-2013 nicm

Implement s, S, C mode switch commands in vi(1) mode, from Ben Boeckel.


# 1.104 31-May-2013 nicm

Demote the old single-character replacement variables (#S and friends)
to aliases of formats. From Tiago Cunha.


# 1.103 25-Mar-2013 nicm

Extend jobs to support writing and use that for copy-pipe instead of
popen, from Chris Johnsen.


# 1.102 22-Mar-2013 nicm

evbuffer_readline returns allocated storage, don't leak it.


# 1.101 22-Mar-2013 nicm

Add copy-pipe mode command to copy selection and also pipe to a command.


# 1.100 22-Mar-2013 nicm

No more lint means no more ARGSUSED.


# 1.99 21-Mar-2013 nicm

Aargh. Spaces -> tabs.


# 1.98 21-Mar-2013 nicm

Do not leak formats in status_replace.


# 1.97 21-Mar-2013 nicm

Add a format client_prefix which is 1 if prefix key has been
pressed, used for example #{?client_prefix,X,Y}. Also a few extra
server_client_status needed.


# 1.96 21-Mar-2013 nicm

Allow formats in status options.


Revision tags: OPENBSD_5_3_BASE
# 1.95 27-Nov-2012 nicm

Add window-status-last-* options, from Boris Faure.


Revision tags: OPENBSD_5_2_BASE
# 1.94 10-Jul-2012 nicm

xfree is not particularly helpful, remove it. From Thomas Adam.


# 1.93 09-Jul-2012 nicm

Move a NULL check inside a function, from Tiago Cunha.


# 1.92 29-Apr-2012 nicm

Use int not u_char for colours from options since they may have bit 8
set to mark them as 256-colour. Reported by Chris Johnson.


# 1.91 23-Apr-2012 nicm

Add window-status-separator option, from Thomas Adam.


# 1.90 17-Mar-2012 nicm

Check event_initialized before event_del if event may not have been set
up; libevent2 complains about this. Reported by Moriyoshi Koizumi.


# 1.89 04-Mar-2012 nicm

Add A and I keys for vi status line editing.


# 1.88 03-Mar-2012 nicm

The wlmouse offset should be part of the client, not the server. From
Ailin Nemui.


Revision tags: OPENBSD_5_1_BASE
# 1.87 29-Jan-2012 nicm

Add an option to move the status line to the top of the screen,
requested by many.


# 1.86 26-Jan-2012 nicm

Terminate strftime buffer properly even if a really long format string
is given, from Tiago Cunha.


# 1.85 26-Jan-2012 nicm

Fix memory leak in error path, from Tiago Cunha.


# 1.84 20-Jan-2012 nicm

Add some trivial additional status line attributes from jwcxz at users
dot sourceforge dot net.


# 1.83 20-Jan-2012 nicm

Add space movement keys for vi mode in the status line from Ben Boeckel.


# 1.82 01-Dec-2011 nicm

Make M-f and M-b work the same at the command prompt as in copy mode,
pointed out by Romain Francoise.


# 1.81 15-Nov-2011 nicm

Add word movement and editing command for command prompt editing, from
Ben Boeckel.


# 1.80 15-Nov-2011 nicm

Make window_pane_index work the same as window_index, from Ben Boeckel.


# 1.79 05-Nov-2011 nicm

Option to change status line (message) background when using vi keys and
in command mode. From Ben Boeckel.


# 1.78 20-Aug-2011 nicm

Fix a couple of memory leaks, from marcel partap.


Revision tags: OPENBSD_5_0_BASE
# 1.77 08-Jul-2011 nicm

Make confirm-before prompt customizable with -p option like
command-prompt. Also move responsibility for calling status_replace into
status_prompt_{set,update} and add #W and #P to the default kill-window
and kill-pane prompts. By Tiago Cunha.


# 1.76 02-Jul-2011 nicm

Allow the initial context on prompts to be set with the new -I option to
command-prompt. From Tiago Cunha.


# 1.75 29-Apr-2011 nicm

Only redraw the status line on command update, not the entire client
(big DOH).


# 1.74 24-Apr-2011 nicm

Provide #h for short hostname (no domain) from Michal Mazurek.


# 1.73 18-Apr-2011 nicm

Add an option (mouse-select-window) which allows the mouse to be used by
clicking on the status line, written by hsim at gmx dot li.


# 1.72 29-Mar-2011 nicm

Change -t on display-message to be target-pane for the #[A-Z]
replacements and add -c as target-client.


Revision tags: OPENBSD_4_9_BASE
# 1.71 26-Jan-2011 nicm

Simplify the way jobs work and drop the persist type, so all jobs are
fire-and-forget.

Status jobs now managed with two trees of output (new and old), rather
than storing the output in the jobs themselves. When the status line is
processed any jobs which don't appear in the new tree are started and
the output from the old tree displayed. When a job finishes it updates
the new tree with its output and that is used for any subsequent
redraws. When the status interval expires, the new tree is moved to the
old so that all jobs are run again.

This fixes the "#(echo %H:%M:%S)" problem which would lead to thousands
of identical persistent jobs and high memory use (this can still be
achieved by adding "sleep 30" but that is much less likely to happen by
accident).


# 1.70 03-Jan-2011 nicm

Handle a # at the end of a replacement string (such as status-left)
correctly. Found by Thomas Adam.


# 1.69 01-Jan-2011 nicm

Move the user-visible parts of all options (names, types, limit, default
values) together into one set of tables in options-table.c. Also clean
up and simplify cmd-set-options.c and move a common print function into
option-table.c.


# 1.68 30-Dec-2010 nicm

Change from a per-session stack of buffers to one global stack which is
much more convenient and also simplifies lot of code. This renders
copy-buffer useless and makes buffer-limit now a server option.

By Tiago Cunha.


# 1.67 30-Dec-2010 nicm

Add a function to create window flags rather than doing the same thing
in two places. From Thomas Adam.


# 1.66 11-Dec-2010 nicm

Oops, these functions return a const char *, so make the local variable
const as well.


# 1.65 11-Dec-2010 nicm

Make the prompt history global for all clients which is much more useful than per-client history.


# 1.64 06-Dec-2010 nicm

Add an option to alert (monitor) for silence (lack of activity) in a
window. From Thomas Adam.


Revision tags: OPENBSD_4_8_BASE
# 1.63 21-Jun-2010 nicm

Having a list of winlinks->alerts for each session is stupid, just store
the alert flags directly in the winlink itself.


# 1.62 14-May-2010 nicm

Colour+attribute options for status line alerts, from Alex Alexander.


# 1.61 31-Mar-2010 nicm

Don't accept keys with modifiers as input. Fixes crash reported by Brian
R Landy.


# 1.60 27-Mar-2010 nicm

Don't leak job command in #().


# 1.59 22-Mar-2010 nicm

Dead functions, lint.


Revision tags: OPENBSD_4_7_BASE
# 1.58 27-Jan-2010 nicm

Calculate offset correctly, fixes incorrect offset and prevents crash when
status-left is empty. From Micah Cowan.


# 1.57 26-Jan-2010 nicm

Actually use the copy made when no newline is found, from martynas@.


# 1.56 14-Dec-2009 nicm

Add server options to completion as well.


# 1.55 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.54 03-Dec-2009 nicm

Eliminate duplicate code and ease the passage for server-wide options by adding
a -w flag to set-option and show-options and making setw and showw aliases to
set -w and show -w.

Note: setw and showw are still there, but now aliases for set -w and show -w.


# 1.53 26-Nov-2009 nicm

Tidy up various bits of the paste code, make the data buffer char * and add
comments.


# 1.52 26-Nov-2009 nicm

Remove a couple of unused arguments where possible, and add /* ARGSUSED */ to
the rest to reduce lint output.


# 1.51 20-Nov-2009 nicm

Display UTF-8 properly in status line messages and prompt. Cursor handling is
still way off though.


# 1.50 20-Nov-2009 nicm

Remove oldest messages from log when limit is hit, not newest.


# 1.49 19-Nov-2009 nicm

Get some brackets in the right place so ## works. Also fix a space in a
comment.


# 1.48 19-Nov-2009 nicm

Change status line drawing to create the window list in a separate screen and
then copy it into the status line screen. This allows UTF-8 in window names and
fixes some problems with #[] in window-status-format.


# 1.47 19-Nov-2009 nicm

Two new options, window-status-format and window-status-current-format, which
allow the format of each window in the status line window list to be controlled
using similar # sequences as status-left/right.

This diff also moves part of the way towards UTF-8 support in window names but
it isn't quite there yet.


# 1.46 19-Nov-2009 nicm

Tidy up by breaking the # replacement code into a separate function, also add a
few comments.


# 1.45 19-Nov-2009 nicm

Don't interpret #() for display-message, it usually doesn't make sense and may
leak commands.


# 1.44 18-Nov-2009 nicm

Add a per-client log of status line messages displayed while that client
exists. A new message-limit session option sets the maximum number of entries
and a command, show-messages, shows the log (bound to ~ by default).

This (and prompt history) might be better as a single global log but until
there are global options it is easier for them to be per client.


# 1.43 17-Nov-2009 nicm

Permit top-bit-set characters to be entered in the status line. They could
already be set from the shell and are just passed through when printing (so
invisible characters or displaying on terminals with different character sets
may cause problems).

Note that entering UTF-8 may not work and in any case currently the status line
cannot display it correctly (outside of status-left/status-right).


# 1.42 04-Nov-2009 nicm

Use timeout events for the identify and message timers.


# 1.41 04-Nov-2009 nicm

Switch jobs over to use a bufferevent.


# 1.40 04-Nov-2009 nicm

Unused (but assigned to) variable, found by lint.


# 1.39 01-Nov-2009 nicm

Add a flag for jobs that shouldn't be freed after they've died and use it for
status jobs, then only kill those jobs when status-left, status-right or
set-titles-string is changed.

Fixes problems with changing options from inside #().


# 1.38 10-Oct-2009 nicm

Rather than running status-left, status-right and window title #() with popen
immediately every redraw, queue them up and run them in the background,
starting each once every status-interval. The actual status line uses the
output from the last run.

This brings several advantages:

- tmux itself may be called from inside #() without causing the server to hang;
- likewise, sleep or similar doesn't cause the server to block;
- commands aren't run excessively often when redrawing;
- commands shared by status-left and status-right, or used multiple times, will
only be run once.

run-shell and if-shell still use system()/popen() but will be changed over to
use this too later.


# 1.37 10-Oct-2009 nicm

Add "grouped sessions" which have independent name, options, current window and
so on but where the linked windows are synchronized (ie creating, killing
windows and so on are mirrored between the sessions). A grouped session may be
created by passing -t to new-session.

Had this around for a while, tested by a couple of people.


# 1.36 23-Sep-2009 nicm

Remove PROMPT_HIDDEN code which is now unused.


# 1.35 23-Sep-2009 nicm

Remove the internal tmux locking and instead detach each client and run the
command specified by a new option "lock-command" (by default "lock -np") in
each client.

This means each terminal has to be unlocked individually but simplifies the
code and allows the system password to be used to unlock.

Note that the set-password command is gone, so it will need to be removed from
configuration files, and the -U command line flag has been removed.

This is the third protocol version change so again it is best to stop the tmux
server before upgrading.


# 1.34 20-Sep-2009 nicm

Regularise some fatal messages.


# 1.33 10-Sep-2009 nicm

Permit options such as status-bg to be configured using the entire 256 colour
palette by setting "colour0" to "colour255".


# 1.32 07-Sep-2009 nicm

Give each paste buffer a size member instead of requiring them to be
zero-terminated.


# 1.31 07-Sep-2009 nicm

Permit embedded colour and attributes in status-left and status-right using new
#[] special characters, for example #[fg=red,bg=blue,blink].


# 1.30 02-Sep-2009 nicm

Add a transpose-chars command in edit mode (C-t in emacs mode only). From Kalle
Olavi Niemitalo.


# 1.29 01-Sep-2009 nicm

Use "Password:" with no space for password prompts and don't display a *s for
the password, like pretty much everything else. From martynas@ with minor
tweaks by me.


# 1.28 31-Aug-2009 nicm

Add a new display-panes command, with two options (display-panes-colour and
display-panes-time), which displays a visual indication of the number of each
pane.


# 1.27 19-Aug-2009 nicm

Extend command-prompt with a -p option which is a comma-separated list of one
or more prompts to present in order.

The responses to the prompt are replaced in the template string: %% are
replaced in order, so the first prompt replaces the first %%, the second
replaces the second, and so on. In addition, %1 up to %9 are replaced with the
responses to the first the ninth prompts

The default template is "%1" so the response to the first prompt is processed
as a command.

Note that this changes the behaviour for %% so if there is only one prompt,
only the first %% will be replaced. Templates such as "neww -n '%%' 'ssh %%'"
should be changed to "neww -n '%1' 'ssh %1'".

From Tiago Cunha.


# 1.26 18-Aug-2009 nicm

Add a "delete line" key when editing in the status line or the search up/down
prompt. C-u with emacs keys, d with vi.


# 1.25 13-Aug-2009 nicm

Switch the prompt code to return an empty string when the user enters no
response and reserve NULL for an explicit cancel. Change all callbacks to treat
them the same so no functional change.

Also add cancel key bindings to emacs mode which were missing.


# 1.24 08-Aug-2009 nicm

Options to set the colours and attributes for status-left/-right. From Thomas
Adam, thanks.


# 1.23 05-Aug-2009 nicm

If colours are not supported by the terminal, try to emulate a coloured
background by setting or clearing the reverse attribute.

This makes a few applications which don't use the reverse attribute themselves
a little happier, and allows the status, message and mode options to have
default attributes and fg/bg options that work as expected when set as reverse.


# 1.22 30-Jul-2009 nicm

Plug some memory leaks.


# 1.21 28-Jul-2009 nicm

Next step towards customisable mode keys: build each default table of keys into
a named tree on start and use that for lookups. Also add command to string
translation tables and modify list-keys to show the the mode key bindings (new
-t argument).


# 1.20 27-Jul-2009 nicm

Change mode key bindings from big switches into a set of tables. Rather than
lumping them all together, split editing keys from those used in choice/more
mode and those for copy/scroll mode.

Tidier and clearer, and the first step towards customisable mode keys.


# 1.19 27-Jul-2009 nicm

Get rid of empty mode_key_free function.


# 1.18 27-Jul-2009 nicm

Add a key to delete to end of line at the prompt (^K in emacs mode, C/D in vi).

From Kalle Olavi Niemitalo.


# 1.17 26-Jul-2009 nicm

Calculate the space available for the prompt buffer and the cursor position
correctly, and make it work when the screen is not wide enough.

Noticed by Kalle Olavi Niemitalo.


# 1.16 21-Jul-2009 nicm

Remove a couple of unused functions and fix a type ("FALLTHOUGH"), found by
lint.


# 1.15 20-Jul-2009 nicm

Add a status-justify option to allow the window list in the status line to be
positioned at the left, centre, or right.


# 1.14 20-Jul-2009 nicm

New options, window-status-current-{fg,bg,attr}, to set the fg, bg and
attributes with which the current window is shown in the status line. From
Johan Friis, thanks.


# 1.13 17-Jul-2009 nicm

- New command display-message (alias display) to display a message in the
status line (bound to "i" and displays the current window and time by
default). The same substitutions are applied as for status-left/right.
- Add support for including the window index (#I), pane index (#P) and window
name (#W) in the message, and status-left or status-right.
- Bump protocol version.

From Tiago Cunha, thanks!


# 1.12 17-Jul-2009 nicm

Memory could be leaked if a second prompt or message appeared while another was
still present, so add a separate prompt free callback and make the _clear
function responsible for calling it if necessary (rather than the individual
prompt callbacks). Also make both messages and prompts clear any existing when
a new is set.

In addition, the screen could be modified while the prompt is there, restore
the redraw-entire-screen behaviour on prompt clear; add a comment as a
reminder.


# 1.11 16-Jul-2009 nicm

Remove some duplicate code that was causing the status line to be redrawn even
when it hadn't changed.


# 1.10 15-Jul-2009 nicm

Make status_message_set a variadic printf-like function. No functional change -
helpful for a couple of things coming soon.


# 1.9 15-Jul-2009 nicm

Having to update NSETOPTION/NSETWINDOWOPTION when adding new options is a bit
annoying and it is only use for iterating, so use a sentinel to mark the end of
each array instead. Different fix for a problem pointed out by Kalle Olavi
Niemitalo.


# 1.8 14-Jul-2009 nicm

For some reason when clearing status/message it was redrawing the entire client
not just the status line. Changing this also revealed the check for the status
line was incorrect when drawing the pane.


# 1.7 14-Jul-2009 nicm

Instead of faking up a status line in status_redraw, use the same code to
redraw it as to draw the entire screen, just skip all lines but the last.

This makes horizontal split redraw properly when the status line is off.


# 1.6 12-Jul-2009 nicm

Add a "back to indentation" key in copy mode to move the cursor to the first
non-whitespace character. ^ with vi and M-m with emacs key bindings. Another
from Kalle Olavi Niemitalo, thanks.


Revision tags: OPENBSD_4_6_BASE
# 1.5 26-Jun-2009 nicm

Status line fixes: don't truncate status-right now the length calculation is
done for UTF-8, limit to the maximum length correctly when printing, and always
print a space even if the left string is longer than the width available.


# 1.4 04-Jun-2009 nicm

If the prompt is hidden or a password is sent with -U, zero it before freeing
it.


# 1.3 03-Jun-2009 nicm

New session option, status-utf8, to control the interpretation of top-bit-set
characters in status-left and status-right (if on, they are treated as UTF-8;
otherwise passed through).


# 1.2 03-Jun-2009 nicm

Add a UTF-8 aware string length function and make UTF-8 in
status-left/status-right work properly. At the moment any top-bit-set
characters are assumed to be UTF-8: a status-utf8 option to configure this will
come shortly.


# 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.225 10-Jun-2021 nicm

More accurate vi(1) word navigation in copy mode and on the status line.
This changes the meaning of the word-separators option - setting it to
the empty string is equivalent to the previous behavior. From Will Noble
in GitHub issue 2693.


# 1.224 10-Jun-2021 nicm

Add different command historys for different types of prompts
("command", "search" etc). From Anindya Mukherjee.


# 1.223 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.222 10-Jun-2021 nicm

Include current client in size calculation for new sessions, GitHub
issue 2662.


Revision tags: OPENBSD_6_9_BASE
# 1.221 12-Apr-2021 nicm

Add a flag to disable keys to close a message, GitHub issue 2625.


# 1.220 22-Feb-2021 nicm

Move jump commands to grid reader, make them UTF-8 aware, and tidy up,
from Anindya Mukherjee.


# 1.219 08-Jan-2021 nicm

With incremental search, start empty and only repeat the previous search
if the user tries to search again with an empty prompt. This matches
emacs behaviour more closely.


Revision tags: OPENBSD_6_8_BASE
# 1.218 27-Jul-2020 nicm

Add a -d option to display-message to set delay, from theonekeyg at
gmail dot com in GitHub issue 2322.


# 1.217 11-Jun-2020 nicm

Fix a crash when completing sessions, from Anindya Mukherjee.


# 1.216 26-May-2020 nicm

Remove leftover debug logging and fix comparison.


# 1.215 26-May-2020 nicm

Set up UTF-8 data for ASCII keys correctly.


# 1.214 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.213 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.212 16-May-2020 nicm

Rename KEYC_ESCAPE to KEYC_META.


# 1.211 16-May-2020 nicm

Expand target from client and use it to expand the prompt.


# 1.210 16-May-2020 nicm

Support embedded styles in the display-message message, GitHub issue
2206.


# 1.209 16-May-2020 nicm

Change message log to be per server rather than per client and include
every command that is run.


# 1.208 16-May-2020 nicm

Do not hoke into struct window_pane from the tty code and instead set
everything up in tty_ctx. Provide a way to initialize the tty_ctx from a
callback and use it to let popups draw directly through input_parse in
the same way as panes do, rather than forcing a full redraw on every
change.


# 1.207 16-May-2020 nicm

Use formats for status-style and message-style.


# 1.206 16-May-2020 nicm

Complete partial window indexes properly.


# 1.205 16-May-2020 nicm

Add -W and -T flags to command-prompt to only complete a window and a
target, also complete aliases.


# 1.204 16-May-2020 nicm

Improve command prompt completion:

- Show a menu with completions if there are multiple.

- Don't complete argument stuff (options, layouts) at start of text.

- For -t and -s, if there is no : then complete sessions but if there is
a :, show a menu of all windows in the session rather than trying to
complete the window name which is a bit useless if there are
duplicates.


# 1.203 16-May-2020 nicm

Drop having a separate type for style options and make them all strings,
which allows formats to be expanded. Any styles without a '#{' are still
validated when they are set but any with a '#{' are not. Formats are not
expanded usefully in many cases yet, that will be changed later.

To make this work, a few other changes:

- set-option -a with a style option automatically appends a ",".

- OSC 10 and 11 don't set the window-style option anymore, instead the
fg and bg are stored in the pane struct and act as the defaults that
can be overridden by window-style.

- status-fg and -bg now override status-style instead of trying to keep
them in sync.


Revision tags: OPENBSD_6_7_BASE
# 1.202 12-Mar-2020 nicm

Add C-g to cancel command prompt with vi(1) keys as well as emacs, and q
in command mode.


# 1.201 27-Jan-2020 nicm

Add support for adding a note to a key binding (with bind-key -N) and
use this to add descriptions to the default key bindings. A new -N flag
to list-keys shows key bindings with notes rather than the default
bind-key command used to create them. Change the default ? binding to
use this to show a readable summary of keys.

Also extend command-prompt to return the name of the key pressed and add
a default binding (/) to show the note for the next key pressed

Suggested by Alex Tremblay in GitHub issue 2000.


Revision tags: OPENBSD_6_6_BASE
# 1.200 28-May-2019 nicm

Redraw status line if size changes, GitHub issue 1762. Also fix length
of target buffer when pasting into status line.


# 1.199 23-May-2019 nicm

Fix length calculation for pasting UTF-8 characters in the status line,
GitHub issue 1753.


# 1.198 11-May-2019 nicm

Do not reduce window height by status line height for control mode
clients, from George Nachman.


# 1.197 03-May-2019 nicm

Fix reverse attribute in status line, GitHub issue 1709.


# 1.196 26-Apr-2019 nicm

Merge hooks into options and make each one an array option. This allows
multiple commands to be easily bound to one hook. set-hook and
show-hooks remain but they are now variants of set-option and
show-options. show-options now has a -H flag to show hooks (by default
they are not shown).


# 1.195 25-Apr-2019 nicm

options_array_item_value cannot return NULL.


# 1.194 23-Apr-2019 nicm

Somehow missed these bits in last commit.


# 1.193 23-Apr-2019 nicm

Indicate an array option with a flag rather than a special type so that
in future will not have to be strings.


Revision tags: OPENBSD_6_5_BASE
# 1.192 18-Mar-2019 nicm

Extend the #[] style syntax and use that together with previous format
changes to allow the status line to be entirely configured with a single
option.

Now that it is possible to configure their content, enable the existing
code that lets the status line be multiple lines in height. The status
option can now take a value of 2, 3, 4 or 5 (as well as the previous on
or off) to configure more than one line. The new status-format array
option configures the format of each line, the default just references
the existing status-* options, although some of the more obscure status
options may be eliminated in time.

Additions to the #[] syntax are: "align" to specify alignment (left,
centre, right), "list" for the window list and "range" to configure
ranges of text for the mouse bindings.

The "align" keyword can also be used to specify alignment of entries in
tree mode and the pane status lines.


# 1.191 18-Mar-2019 nicm

Make array options a sparse tree instead of an array of char * and
remove the size limit.


# 1.190 18-Mar-2019 nicm

With force, kill previous job before starting new. Fixes problem
reported by Scott Mcdermott in GitHub issue 1627.


# 1.189 16-Mar-2019 nicm

Use a pointer for the active screen in the status line instead of
copying them around all the time.


# 1.188 16-Mar-2019 nicm

Give status_save_old the client so it can do the reinit too.


# 1.187 16-Mar-2019 nicm

Tidy and rename some bits of status line code.


# 1.186 15-Mar-2019 nicm

Move status line free into its own function.


# 1.185 14-Mar-2019 nicm

Store the time in the format tree rather than passing it around.


# 1.184 12-Mar-2019 nicm

DECRC and DECSC apparently need to preserve origin mode as well, based
on a fix from Marc Reisner.


# 1.183 09-Feb-2019 nicm

Completion of command-alias members.


# 1.182 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.181 29-Aug-2018 nicm

Keep any text killed in the command prompt with C-w and yank it with
C-y, only use the top buffer if no text has previously been killed. This
and previous change promped by discussion with kn@.


# 1.180 29-Aug-2018 nicm

Add C-Left and C-Right as aliases for M-b and M-f.


# 1.179 22-Aug-2018 nicm

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


# 1.178 20-Aug-2018 nicm

Move offset of window list into status struct.


# 1.177 19-Aug-2018 nicm

Add a client redraw-window flag instead of the redraw-all flag and for
all just use the three flags together (window, borders, status).


Revision tags: OPENBSD_6_3_BASE
# 1.176 22-Feb-2018 nicm

Remove an unused variable.


# 1.175 05-Feb-2018 nicm

Add struct status_line to hold status line members of struct client, not
used yet but will be soon. From Thomas Adam.


# 1.174 01-Jan-2018 nicm

Add C-g at command prompt for emacs people, GitHub issue 1213.


# 1.173 27-Dec-2017 nicm

Draw command prompt correctly with status line off.


# 1.172 18-Dec-2017 nicm

Remove unused variable from Thomas Adam.


# 1.171 02-Nov-2017 nicm

Add a "fast" version of screen_write_copy for tree mode that doesn't do
all the checks and selection and marking stuff needed for copy mode.


# 1.170 20-Oct-2017 nicm

Clear status line with spaces again so reverse works, spotted by sthen.


# 1.169 16-Oct-2017 nicm

Infrastructure for drawing status lines of more than one line in height,
still only one is allowed but this lets tmux draw bigger ones.


Revision tags: OPENBSD_6_2_BASE
# 1.168 29-May-2017 nicm

Add a flag to stop the prompt input being expanded.


# 1.167 29-May-2017 nicm

Store a copy of the old status line, will be needed soon for new choose mode.


# 1.166 17-May-2017 nicm

Tidy command prompt callbacks and pass in the client.


# 1.165 03-May-2017 nicm

Add a format for the last search string in copy mode and fix the prompt
so it can work when in -I, suggested by Suraj N Kurapati.


# 1.164 01-May-2017 nicm

In order that people can use formats like #D in #() in the status line
and not have to wait for an update when they change pane, we allow
commands to run more than once a second if the expanded form
changes. Unfortunately this can mean them being run far too often
(pretty much continually) when multiple clients exist, because some
formats (including #D) will always differ between clients.

To avoid this, give each client its own tree of jobs which means that
the same command will be different instances for each client - similar
to how we have the tag to separate commands for different panes.

GitHub issue 889; test case reported by Paul Johnson.


# 1.163 22-Apr-2017 nicm

Memory leak from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.162 09-Feb-2017 nicm

Break the message storage function into its own function, useful for
debugging.


# 1.161 03-Feb-2017 nicm

Cache status line position to reduce option lookups during output.


# 1.160 03-Feb-2017 nicm

Add a window or pane id "tag" to each format tree and use it to separate
jobs, this means that if the same job is used for different windows or
panes (for example in pane-border-format), it will be run separately for
each pane.


# 1.159 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.158 06-Jan-2017 nicm

Incremental search in copy mode (on for emacs keys by default) - much
the same as normal searching but updates the cursor position and marked
search terms as you type. C-r and C-s in the prompt repeat the search,
once finished searching (with Enter), N and n work as before.


# 1.157 05-Jan-2017 nicm

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


# 1.156 07-Dec-2016 nicm

Do not clear the prompt when a message is shown, just leave it around and
return to it when the message is finished.


# 1.155 12-Oct-2016 nicm

Drop the edit mode key tables and just use fixed key bindings for the
command prompt.


# 1.154 12-Oct-2016 nicm

The repeat prompt in both emacs and vi (and the old one in tmux) doesn't
support line editing and instead executes a command as soon as a
non-number key is pressed. Add a -N flag to command-prompt for the same
in copy mode. Reported by Theo Buehler.


# 1.153 11-Oct-2016 nicm

Fundamental change to how copy mode key bindings work:

The vi-copy and emacs-copy mode key tables are gone, and instead copy
mode commands are bound in one of two normal key tables ("copy-mode" or
"copy-mode-vi"). Keys are bound to "send-keys -X copy-mode-command". So:

bind -temacs-copy C-Up scroll-up
bind -temacs-copy -R5 WheelUpPane scroll-up

Becomes:

bind -Tcopy-mode C-Up send -X scroll-up
bind -Tcopy-mode WheelUpPane send -N5 -X scroll-up

This allows the full command parser and command set to be used - for
example, we can use the normal command prompt for searching, jumping,
and so on instead of a custom one:

bind -Tcopy-mode C-r command-prompt -p'search up' "send -X search-backward '%%'"

command-prompt also gets a -1 option to only require on key press, which
is needed for jumping.

The plan is to get rid of mode keys entirely, so more to come eventually.


# 1.152 11-Oct-2016 nicm

Support UTF-8 entry into the command prompt.


# 1.151 10-Oct-2016 nicm

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


# 1.150 12-Sep-2016 nicm

Allow repeat count to be specified in mode key tables with bind-key -R,
and set the default repeat count to 5 for WheelUp and WheelDown in
copy-mode.


Revision tags: OPENBSD_6_0_BASE
# 1.149 06-Jun-2016 nicm

Allow #[] in window-status-separator.


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

I no longer use my SourceForge address so replace it.


# 1.147 01-Jan-2016 nicm

Don't rely on a calculation wrapping when applying message-limit, and
break out of the loop early. From Nicolas Viennot.


# 1.146 11-Dec-2015 nicm

Style nits and line wrapping of function declarations.


# 1.145 11-Dec-2015 nicm

Add cmdq as an argument to format_create and add a format for the
command name (will also be used for more later).


# 1.144 08-Dec-2015 nicm

Remove format_create_flags and just pass flags to format_create.


# 1.143 22-Nov-2015 tim

If display-time is set to 0, show status messages until a key is pressed;
OK nicm@


# 1.142 20-Nov-2015 nicm

Instead of separate tables for different types of options, give each
option a scope type (server, session, window) in one table.


# 1.141 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.140 13-Nov-2015 nicm

Long overdue change to the way we store cells in the grid: now, instead
of storing a full grid_cell with UTF-8 data and everything, store a new
type grid_cell_entry. This can either be the cell itself (for ASCII
cells), or an offset into an extended array (per line) for UTF-8
data.

This avoid a large (8 byte) overhead on non-UTF-8 cells (by far the
majority for most users) without the complexity of the shadow array we
had before. Grid memory without any UTF-8 is about half.

The disadvantage that cells can no longer be modified in place and need
to be copied out of the grid and back but it turned out to be lot less
complicated than I expected.


# 1.139 12-Nov-2015 nicm

Nuke the utf8 and status-utf8 options and make tmux only a UTF-8
terminal. We still support non-UTF-8 terminals outside tmux, but inside
it is always UTF-8 (as when the utf8 and status-utf8 options were on).


# 1.138 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.137 27-Oct-2015 nicm

Move struct options into options.c.


# 1.136 20-Oct-2015 nicm

Use client pointer not file descriptor in logging.


# 1.135 14-Sep-2015 nicm

Make refresh-client force update of jobs, from Sina Siadat.


# 1.134 29-Aug-2015 nicm

Move struct paste_buffer out of tmux.h.


# 1.133 28-Aug-2015 nicm

Run status update on a per-client timer at status-interval.


Revision tags: OPENBSD_5_8_BASE
# 1.132 29-Jul-2015 nicm

status_out and associated data structures are no longer used.


# 1.131 28-Jul-2015 nicm

Tidy up the way terminals are described and move some structs out of tmux.h.


# 1.130 20-Jul-2015 nicm

Add an option (history-file) for a file to save/restore command prompt
history, from Olof-Joachim Frahm.


# 1.129 27-May-2015 nicm

Move the jobs output cache into the formats code so that #() work more
generally (for example, again working in set-titles-string).


# 1.128 06-May-2015 nicm

Remove ARRAY_* from history and expand completion to complete a) layout
names and b) targets beginning with -t or -s.


# 1.127 25-Apr-2015 nicm

Make message log a TAILQ.


# 1.126 24-Apr-2015 nicm

Set working directory for run-shell and if-shell.


# 1.125 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_7_BASE
# 1.124 06-Feb-2015 nicm

Use the same time for both calls to format_expand_time.


# 1.123 06-Feb-2015 nicm

status_replace can now become local to status.c and it no longer needs
the jobsflag argument. While here there is no need to repeat work that
format_defaults already does.


# 1.122 06-Feb-2015 nicm

Add format_expand_time and use it instead of status_replace where
command execution is not needed.


# 1.121 05-Feb-2015 nicm

Wrap all the individual format_* calls in a single format_defaults
functions.


# 1.120 01-Feb-2015 nicm

Remove two unused arguments from status_replace.


# 1.119 20-Jan-2015 sthen

typo in comment ;) ok nicm


# 1.118 05-Nov-2014 nicm

Do not put a space between status-left/status-right and the window list,
instead move the space into the defaults for the options (so status-left
now defaults to "[#S] ". From Balazs Kezes.


# 1.117 20-Oct-2014 nicm

Better format for printf format attributes.


# 1.116 08-Oct-2014 nicm

Add xreallocarray and remove nmemb argument from xrealloc.


# 1.115 02-Oct-2014 nicm

Take account of window-status-separator when checking window position,
based on diff from Balazs Kezes.


Revision tags: OPENBSD_5_6_BASE
# 1.114 24-Apr-2014 nicm

There is no longer a need for a paste_stack struct or for global_buffers
to be global. Move to paste.c.


# 1.113 17-Apr-2014 nicm

Remove the monitor-content option and associated bits and bobs. It's
never worked very well. If there is a big demand for it to return, will
consider better ways to do it.


# 1.112 02-Apr-2014 nicm

Do not replace ## with # in status_replace1 because it'll be done later
by the format code.


# 1.111 31-Mar-2014 nicm

Make message-limit a server option.


Revision tags: OPENBSD_5_5_BASE
# 1.110 14-Feb-2014 nicm

Style nit - no space between function name and bracket.


# 1.109 14-Feb-2014 nicm

Check for NULL session and whatnot in status_replace, from Thomas Adam.


# 1.108 28-Jan-2014 nicm

Allow replacing each of the many sets of separate foo-{fg,bg,attr}
options with a single foo-style option. For example:

set -g status-fg yellow
set -g status-bg red
set -g status-attr blink

Becomes:

set -g status-style fg=yellow,bg=red,blink

The -a flag to set can be used to add to rather than replace a style. So:

set -g status-bg red

Becomes:

set -ag status-style bg=red

Currently this is fully backwards compatible (all *-{fg,bg,attr} options
remain) but the plan is to deprecate them over time.

From Tiago Cunha.


Revision tags: OPENBSD_5_4_BASE
# 1.107 05-Jul-2013 nicm

Whitespace nits, from Ben Boeckel.


# 1.106 05-Jul-2013 nicm

Act like vi(1) when moving words, from Ben Boeckel.


# 1.105 05-Jul-2013 nicm

Implement s, S, C mode switch commands in vi(1) mode, from Ben Boeckel.


# 1.104 31-May-2013 nicm

Demote the old single-character replacement variables (#S and friends)
to aliases of formats. From Tiago Cunha.


# 1.103 25-Mar-2013 nicm

Extend jobs to support writing and use that for copy-pipe instead of
popen, from Chris Johnsen.


# 1.102 22-Mar-2013 nicm

evbuffer_readline returns allocated storage, don't leak it.


# 1.101 22-Mar-2013 nicm

Add copy-pipe mode command to copy selection and also pipe to a command.


# 1.100 22-Mar-2013 nicm

No more lint means no more ARGSUSED.


# 1.99 21-Mar-2013 nicm

Aargh. Spaces -> tabs.


# 1.98 21-Mar-2013 nicm

Do not leak formats in status_replace.


# 1.97 21-Mar-2013 nicm

Add a format client_prefix which is 1 if prefix key has been
pressed, used for example #{?client_prefix,X,Y}. Also a few extra
server_client_status needed.


# 1.96 21-Mar-2013 nicm

Allow formats in status options.


Revision tags: OPENBSD_5_3_BASE
# 1.95 27-Nov-2012 nicm

Add window-status-last-* options, from Boris Faure.


Revision tags: OPENBSD_5_2_BASE
# 1.94 10-Jul-2012 nicm

xfree is not particularly helpful, remove it. From Thomas Adam.


# 1.93 09-Jul-2012 nicm

Move a NULL check inside a function, from Tiago Cunha.


# 1.92 29-Apr-2012 nicm

Use int not u_char for colours from options since they may have bit 8
set to mark them as 256-colour. Reported by Chris Johnson.


# 1.91 23-Apr-2012 nicm

Add window-status-separator option, from Thomas Adam.


# 1.90 17-Mar-2012 nicm

Check event_initialized before event_del if event may not have been set
up; libevent2 complains about this. Reported by Moriyoshi Koizumi.


# 1.89 04-Mar-2012 nicm

Add A and I keys for vi status line editing.


# 1.88 03-Mar-2012 nicm

The wlmouse offset should be part of the client, not the server. From
Ailin Nemui.


Revision tags: OPENBSD_5_1_BASE
# 1.87 29-Jan-2012 nicm

Add an option to move the status line to the top of the screen,
requested by many.


# 1.86 26-Jan-2012 nicm

Terminate strftime buffer properly even if a really long format string
is given, from Tiago Cunha.


# 1.85 26-Jan-2012 nicm

Fix memory leak in error path, from Tiago Cunha.


# 1.84 20-Jan-2012 nicm

Add some trivial additional status line attributes from jwcxz at users
dot sourceforge dot net.


# 1.83 20-Jan-2012 nicm

Add space movement keys for vi mode in the status line from Ben Boeckel.


# 1.82 01-Dec-2011 nicm

Make M-f and M-b work the same at the command prompt as in copy mode,
pointed out by Romain Francoise.


# 1.81 15-Nov-2011 nicm

Add word movement and editing command for command prompt editing, from
Ben Boeckel.


# 1.80 15-Nov-2011 nicm

Make window_pane_index work the same as window_index, from Ben Boeckel.


# 1.79 05-Nov-2011 nicm

Option to change status line (message) background when using vi keys and
in command mode. From Ben Boeckel.


# 1.78 20-Aug-2011 nicm

Fix a couple of memory leaks, from marcel partap.


Revision tags: OPENBSD_5_0_BASE
# 1.77 08-Jul-2011 nicm

Make confirm-before prompt customizable with -p option like
command-prompt. Also move responsibility for calling status_replace into
status_prompt_{set,update} and add #W and #P to the default kill-window
and kill-pane prompts. By Tiago Cunha.


# 1.76 02-Jul-2011 nicm

Allow the initial context on prompts to be set with the new -I option to
command-prompt. From Tiago Cunha.


# 1.75 29-Apr-2011 nicm

Only redraw the status line on command update, not the entire client
(big DOH).


# 1.74 24-Apr-2011 nicm

Provide #h for short hostname (no domain) from Michal Mazurek.


# 1.73 18-Apr-2011 nicm

Add an option (mouse-select-window) which allows the mouse to be used by
clicking on the status line, written by hsim at gmx dot li.


# 1.72 29-Mar-2011 nicm

Change -t on display-message to be target-pane for the #[A-Z]
replacements and add -c as target-client.


Revision tags: OPENBSD_4_9_BASE
# 1.71 26-Jan-2011 nicm

Simplify the way jobs work and drop the persist type, so all jobs are
fire-and-forget.

Status jobs now managed with two trees of output (new and old), rather
than storing the output in the jobs themselves. When the status line is
processed any jobs which don't appear in the new tree are started and
the output from the old tree displayed. When a job finishes it updates
the new tree with its output and that is used for any subsequent
redraws. When the status interval expires, the new tree is moved to the
old so that all jobs are run again.

This fixes the "#(echo %H:%M:%S)" problem which would lead to thousands
of identical persistent jobs and high memory use (this can still be
achieved by adding "sleep 30" but that is much less likely to happen by
accident).


# 1.70 03-Jan-2011 nicm

Handle a # at the end of a replacement string (such as status-left)
correctly. Found by Thomas Adam.


# 1.69 01-Jan-2011 nicm

Move the user-visible parts of all options (names, types, limit, default
values) together into one set of tables in options-table.c. Also clean
up and simplify cmd-set-options.c and move a common print function into
option-table.c.


# 1.68 30-Dec-2010 nicm

Change from a per-session stack of buffers to one global stack which is
much more convenient and also simplifies lot of code. This renders
copy-buffer useless and makes buffer-limit now a server option.

By Tiago Cunha.


# 1.67 30-Dec-2010 nicm

Add a function to create window flags rather than doing the same thing
in two places. From Thomas Adam.


# 1.66 11-Dec-2010 nicm

Oops, these functions return a const char *, so make the local variable
const as well.


# 1.65 11-Dec-2010 nicm

Make the prompt history global for all clients which is much more useful than per-client history.


# 1.64 06-Dec-2010 nicm

Add an option to alert (monitor) for silence (lack of activity) in a
window. From Thomas Adam.


Revision tags: OPENBSD_4_8_BASE
# 1.63 21-Jun-2010 nicm

Having a list of winlinks->alerts for each session is stupid, just store
the alert flags directly in the winlink itself.


# 1.62 14-May-2010 nicm

Colour+attribute options for status line alerts, from Alex Alexander.


# 1.61 31-Mar-2010 nicm

Don't accept keys with modifiers as input. Fixes crash reported by Brian
R Landy.


# 1.60 27-Mar-2010 nicm

Don't leak job command in #().


# 1.59 22-Mar-2010 nicm

Dead functions, lint.


Revision tags: OPENBSD_4_7_BASE
# 1.58 27-Jan-2010 nicm

Calculate offset correctly, fixes incorrect offset and prevents crash when
status-left is empty. From Micah Cowan.


# 1.57 26-Jan-2010 nicm

Actually use the copy made when no newline is found, from martynas@.


# 1.56 14-Dec-2009 nicm

Add server options to completion as well.


# 1.55 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.54 03-Dec-2009 nicm

Eliminate duplicate code and ease the passage for server-wide options by adding
a -w flag to set-option and show-options and making setw and showw aliases to
set -w and show -w.

Note: setw and showw are still there, but now aliases for set -w and show -w.


# 1.53 26-Nov-2009 nicm

Tidy up various bits of the paste code, make the data buffer char * and add
comments.


# 1.52 26-Nov-2009 nicm

Remove a couple of unused arguments where possible, and add /* ARGSUSED */ to
the rest to reduce lint output.


# 1.51 20-Nov-2009 nicm

Display UTF-8 properly in status line messages and prompt. Cursor handling is
still way off though.


# 1.50 20-Nov-2009 nicm

Remove oldest messages from log when limit is hit, not newest.


# 1.49 19-Nov-2009 nicm

Get some brackets in the right place so ## works. Also fix a space in a
comment.


# 1.48 19-Nov-2009 nicm

Change status line drawing to create the window list in a separate screen and
then copy it into the status line screen. This allows UTF-8 in window names and
fixes some problems with #[] in window-status-format.


# 1.47 19-Nov-2009 nicm

Two new options, window-status-format and window-status-current-format, which
allow the format of each window in the status line window list to be controlled
using similar # sequences as status-left/right.

This diff also moves part of the way towards UTF-8 support in window names but
it isn't quite there yet.


# 1.46 19-Nov-2009 nicm

Tidy up by breaking the # replacement code into a separate function, also add a
few comments.


# 1.45 19-Nov-2009 nicm

Don't interpret #() for display-message, it usually doesn't make sense and may
leak commands.


# 1.44 18-Nov-2009 nicm

Add a per-client log of status line messages displayed while that client
exists. A new message-limit session option sets the maximum number of entries
and a command, show-messages, shows the log (bound to ~ by default).

This (and prompt history) might be better as a single global log but until
there are global options it is easier for them to be per client.


# 1.43 17-Nov-2009 nicm

Permit top-bit-set characters to be entered in the status line. They could
already be set from the shell and are just passed through when printing (so
invisible characters or displaying on terminals with different character sets
may cause problems).

Note that entering UTF-8 may not work and in any case currently the status line
cannot display it correctly (outside of status-left/status-right).


# 1.42 04-Nov-2009 nicm

Use timeout events for the identify and message timers.


# 1.41 04-Nov-2009 nicm

Switch jobs over to use a bufferevent.


# 1.40 04-Nov-2009 nicm

Unused (but assigned to) variable, found by lint.


# 1.39 01-Nov-2009 nicm

Add a flag for jobs that shouldn't be freed after they've died and use it for
status jobs, then only kill those jobs when status-left, status-right or
set-titles-string is changed.

Fixes problems with changing options from inside #().


# 1.38 10-Oct-2009 nicm

Rather than running status-left, status-right and window title #() with popen
immediately every redraw, queue them up and run them in the background,
starting each once every status-interval. The actual status line uses the
output from the last run.

This brings several advantages:

- tmux itself may be called from inside #() without causing the server to hang;
- likewise, sleep or similar doesn't cause the server to block;
- commands aren't run excessively often when redrawing;
- commands shared by status-left and status-right, or used multiple times, will
only be run once.

run-shell and if-shell still use system()/popen() but will be changed over to
use this too later.


# 1.37 10-Oct-2009 nicm

Add "grouped sessions" which have independent name, options, current window and
so on but where the linked windows are synchronized (ie creating, killing
windows and so on are mirrored between the sessions). A grouped session may be
created by passing -t to new-session.

Had this around for a while, tested by a couple of people.


# 1.36 23-Sep-2009 nicm

Remove PROMPT_HIDDEN code which is now unused.


# 1.35 23-Sep-2009 nicm

Remove the internal tmux locking and instead detach each client and run the
command specified by a new option "lock-command" (by default "lock -np") in
each client.

This means each terminal has to be unlocked individually but simplifies the
code and allows the system password to be used to unlock.

Note that the set-password command is gone, so it will need to be removed from
configuration files, and the -U command line flag has been removed.

This is the third protocol version change so again it is best to stop the tmux
server before upgrading.


# 1.34 20-Sep-2009 nicm

Regularise some fatal messages.


# 1.33 10-Sep-2009 nicm

Permit options such as status-bg to be configured using the entire 256 colour
palette by setting "colour0" to "colour255".


# 1.32 07-Sep-2009 nicm

Give each paste buffer a size member instead of requiring them to be
zero-terminated.


# 1.31 07-Sep-2009 nicm

Permit embedded colour and attributes in status-left and status-right using new
#[] special characters, for example #[fg=red,bg=blue,blink].


# 1.30 02-Sep-2009 nicm

Add a transpose-chars command in edit mode (C-t in emacs mode only). From Kalle
Olavi Niemitalo.


# 1.29 01-Sep-2009 nicm

Use "Password:" with no space for password prompts and don't display a *s for
the password, like pretty much everything else. From martynas@ with minor
tweaks by me.


# 1.28 31-Aug-2009 nicm

Add a new display-panes command, with two options (display-panes-colour and
display-panes-time), which displays a visual indication of the number of each
pane.


# 1.27 19-Aug-2009 nicm

Extend command-prompt with a -p option which is a comma-separated list of one
or more prompts to present in order.

The responses to the prompt are replaced in the template string: %% are
replaced in order, so the first prompt replaces the first %%, the second
replaces the second, and so on. In addition, %1 up to %9 are replaced with the
responses to the first the ninth prompts

The default template is "%1" so the response to the first prompt is processed
as a command.

Note that this changes the behaviour for %% so if there is only one prompt,
only the first %% will be replaced. Templates such as "neww -n '%%' 'ssh %%'"
should be changed to "neww -n '%1' 'ssh %1'".

From Tiago Cunha.


# 1.26 18-Aug-2009 nicm

Add a "delete line" key when editing in the status line or the search up/down
prompt. C-u with emacs keys, d with vi.


# 1.25 13-Aug-2009 nicm

Switch the prompt code to return an empty string when the user enters no
response and reserve NULL for an explicit cancel. Change all callbacks to treat
them the same so no functional change.

Also add cancel key bindings to emacs mode which were missing.


# 1.24 08-Aug-2009 nicm

Options to set the colours and attributes for status-left/-right. From Thomas
Adam, thanks.


# 1.23 05-Aug-2009 nicm

If colours are not supported by the terminal, try to emulate a coloured
background by setting or clearing the reverse attribute.

This makes a few applications which don't use the reverse attribute themselves
a little happier, and allows the status, message and mode options to have
default attributes and fg/bg options that work as expected when set as reverse.


# 1.22 30-Jul-2009 nicm

Plug some memory leaks.


# 1.21 28-Jul-2009 nicm

Next step towards customisable mode keys: build each default table of keys into
a named tree on start and use that for lookups. Also add command to string
translation tables and modify list-keys to show the the mode key bindings (new
-t argument).


# 1.20 27-Jul-2009 nicm

Change mode key bindings from big switches into a set of tables. Rather than
lumping them all together, split editing keys from those used in choice/more
mode and those for copy/scroll mode.

Tidier and clearer, and the first step towards customisable mode keys.


# 1.19 27-Jul-2009 nicm

Get rid of empty mode_key_free function.


# 1.18 27-Jul-2009 nicm

Add a key to delete to end of line at the prompt (^K in emacs mode, C/D in vi).

From Kalle Olavi Niemitalo.


# 1.17 26-Jul-2009 nicm

Calculate the space available for the prompt buffer and the cursor position
correctly, and make it work when the screen is not wide enough.

Noticed by Kalle Olavi Niemitalo.


# 1.16 21-Jul-2009 nicm

Remove a couple of unused functions and fix a type ("FALLTHOUGH"), found by
lint.


# 1.15 20-Jul-2009 nicm

Add a status-justify option to allow the window list in the status line to be
positioned at the left, centre, or right.


# 1.14 20-Jul-2009 nicm

New options, window-status-current-{fg,bg,attr}, to set the fg, bg and
attributes with which the current window is shown in the status line. From
Johan Friis, thanks.


# 1.13 17-Jul-2009 nicm

- New command display-message (alias display) to display a message in the
status line (bound to "i" and displays the current window and time by
default). The same substitutions are applied as for status-left/right.
- Add support for including the window index (#I), pane index (#P) and window
name (#W) in the message, and status-left or status-right.
- Bump protocol version.

From Tiago Cunha, thanks!


# 1.12 17-Jul-2009 nicm

Memory could be leaked if a second prompt or message appeared while another was
still present, so add a separate prompt free callback and make the _clear
function responsible for calling it if necessary (rather than the individual
prompt callbacks). Also make both messages and prompts clear any existing when
a new is set.

In addition, the screen could be modified while the prompt is there, restore
the redraw-entire-screen behaviour on prompt clear; add a comment as a
reminder.


# 1.11 16-Jul-2009 nicm

Remove some duplicate code that was causing the status line to be redrawn even
when it hadn't changed.


# 1.10 15-Jul-2009 nicm

Make status_message_set a variadic printf-like function. No functional change -
helpful for a couple of things coming soon.


# 1.9 15-Jul-2009 nicm

Having to update NSETOPTION/NSETWINDOWOPTION when adding new options is a bit
annoying and it is only use for iterating, so use a sentinel to mark the end of
each array instead. Different fix for a problem pointed out by Kalle Olavi
Niemitalo.


# 1.8 14-Jul-2009 nicm

For some reason when clearing status/message it was redrawing the entire client
not just the status line. Changing this also revealed the check for the status
line was incorrect when drawing the pane.


# 1.7 14-Jul-2009 nicm

Instead of faking up a status line in status_redraw, use the same code to
redraw it as to draw the entire screen, just skip all lines but the last.

This makes horizontal split redraw properly when the status line is off.


# 1.6 12-Jul-2009 nicm

Add a "back to indentation" key in copy mode to move the cursor to the first
non-whitespace character. ^ with vi and M-m with emacs key bindings. Another
from Kalle Olavi Niemitalo, thanks.


Revision tags: OPENBSD_4_6_BASE
# 1.5 26-Jun-2009 nicm

Status line fixes: don't truncate status-right now the length calculation is
done for UTF-8, limit to the maximum length correctly when printing, and always
print a space even if the left string is longer than the width available.


# 1.4 04-Jun-2009 nicm

If the prompt is hidden or a password is sent with -U, zero it before freeing
it.


# 1.3 03-Jun-2009 nicm

New session option, status-utf8, to control the interpretation of top-bit-set
characters in status-left and status-right (if on, they are treated as UTF-8;
otherwise passed through).


# 1.2 03-Jun-2009 nicm

Add a UTF-8 aware string length function and make UTF-8 in
status-left/status-right work properly. At the moment any top-bit-set
characters are assumed to be UTF-8: a status-utf8 option to configure this will
come shortly.


# 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.221 12-Apr-2021 nicm

Add a flag to disable keys to close a message, GitHub issue 2625.


# 1.220 22-Feb-2021 nicm

Move jump commands to grid reader, make them UTF-8 aware, and tidy up,
from Anindya Mukherjee.


# 1.219 08-Jan-2021 nicm

With incremental search, start empty and only repeat the previous search
if the user tries to search again with an empty prompt. This matches
emacs behaviour more closely.


Revision tags: OPENBSD_6_8_BASE
# 1.218 27-Jul-2020 nicm

Add a -d option to display-message to set delay, from theonekeyg at
gmail dot com in GitHub issue 2322.


# 1.217 11-Jun-2020 nicm

Fix a crash when completing sessions, from Anindya Mukherjee.


# 1.216 26-May-2020 nicm

Remove leftover debug logging and fix comparison.


# 1.215 26-May-2020 nicm

Set up UTF-8 data for ASCII keys correctly.


# 1.214 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.213 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.212 16-May-2020 nicm

Rename KEYC_ESCAPE to KEYC_META.


# 1.211 16-May-2020 nicm

Expand target from client and use it to expand the prompt.


# 1.210 16-May-2020 nicm

Support embedded styles in the display-message message, GitHub issue
2206.


# 1.209 16-May-2020 nicm

Change message log to be per server rather than per client and include
every command that is run.


# 1.208 16-May-2020 nicm

Do not hoke into struct window_pane from the tty code and instead set
everything up in tty_ctx. Provide a way to initialize the tty_ctx from a
callback and use it to let popups draw directly through input_parse in
the same way as panes do, rather than forcing a full redraw on every
change.


# 1.207 16-May-2020 nicm

Use formats for status-style and message-style.


# 1.206 16-May-2020 nicm

Complete partial window indexes properly.


# 1.205 16-May-2020 nicm

Add -W and -T flags to command-prompt to only complete a window and a
target, also complete aliases.


# 1.204 16-May-2020 nicm

Improve command prompt completion:

- Show a menu with completions if there are multiple.

- Don't complete argument stuff (options, layouts) at start of text.

- For -t and -s, if there is no : then complete sessions but if there is
a :, show a menu of all windows in the session rather than trying to
complete the window name which is a bit useless if there are
duplicates.


# 1.203 16-May-2020 nicm

Drop having a separate type for style options and make them all strings,
which allows formats to be expanded. Any styles without a '#{' are still
validated when they are set but any with a '#{' are not. Formats are not
expanded usefully in many cases yet, that will be changed later.

To make this work, a few other changes:

- set-option -a with a style option automatically appends a ",".

- OSC 10 and 11 don't set the window-style option anymore, instead the
fg and bg are stored in the pane struct and act as the defaults that
can be overridden by window-style.

- status-fg and -bg now override status-style instead of trying to keep
them in sync.


Revision tags: OPENBSD_6_7_BASE
# 1.202 12-Mar-2020 nicm

Add C-g to cancel command prompt with vi(1) keys as well as emacs, and q
in command mode.


# 1.201 27-Jan-2020 nicm

Add support for adding a note to a key binding (with bind-key -N) and
use this to add descriptions to the default key bindings. A new -N flag
to list-keys shows key bindings with notes rather than the default
bind-key command used to create them. Change the default ? binding to
use this to show a readable summary of keys.

Also extend command-prompt to return the name of the key pressed and add
a default binding (/) to show the note for the next key pressed

Suggested by Alex Tremblay in GitHub issue 2000.


Revision tags: OPENBSD_6_6_BASE
# 1.200 28-May-2019 nicm

Redraw status line if size changes, GitHub issue 1762. Also fix length
of target buffer when pasting into status line.


# 1.199 23-May-2019 nicm

Fix length calculation for pasting UTF-8 characters in the status line,
GitHub issue 1753.


# 1.198 11-May-2019 nicm

Do not reduce window height by status line height for control mode
clients, from George Nachman.


# 1.197 03-May-2019 nicm

Fix reverse attribute in status line, GitHub issue 1709.


# 1.196 26-Apr-2019 nicm

Merge hooks into options and make each one an array option. This allows
multiple commands to be easily bound to one hook. set-hook and
show-hooks remain but they are now variants of set-option and
show-options. show-options now has a -H flag to show hooks (by default
they are not shown).


# 1.195 25-Apr-2019 nicm

options_array_item_value cannot return NULL.


# 1.194 23-Apr-2019 nicm

Somehow missed these bits in last commit.


# 1.193 23-Apr-2019 nicm

Indicate an array option with a flag rather than a special type so that
in future will not have to be strings.


Revision tags: OPENBSD_6_5_BASE
# 1.192 18-Mar-2019 nicm

Extend the #[] style syntax and use that together with previous format
changes to allow the status line to be entirely configured with a single
option.

Now that it is possible to configure their content, enable the existing
code that lets the status line be multiple lines in height. The status
option can now take a value of 2, 3, 4 or 5 (as well as the previous on
or off) to configure more than one line. The new status-format array
option configures the format of each line, the default just references
the existing status-* options, although some of the more obscure status
options may be eliminated in time.

Additions to the #[] syntax are: "align" to specify alignment (left,
centre, right), "list" for the window list and "range" to configure
ranges of text for the mouse bindings.

The "align" keyword can also be used to specify alignment of entries in
tree mode and the pane status lines.


# 1.191 18-Mar-2019 nicm

Make array options a sparse tree instead of an array of char * and
remove the size limit.


# 1.190 18-Mar-2019 nicm

With force, kill previous job before starting new. Fixes problem
reported by Scott Mcdermott in GitHub issue 1627.


# 1.189 16-Mar-2019 nicm

Use a pointer for the active screen in the status line instead of
copying them around all the time.


# 1.188 16-Mar-2019 nicm

Give status_save_old the client so it can do the reinit too.


# 1.187 16-Mar-2019 nicm

Tidy and rename some bits of status line code.


# 1.186 15-Mar-2019 nicm

Move status line free into its own function.


# 1.185 14-Mar-2019 nicm

Store the time in the format tree rather than passing it around.


# 1.184 12-Mar-2019 nicm

DECRC and DECSC apparently need to preserve origin mode as well, based
on a fix from Marc Reisner.


# 1.183 09-Feb-2019 nicm

Completion of command-alias members.


# 1.182 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.181 29-Aug-2018 nicm

Keep any text killed in the command prompt with C-w and yank it with
C-y, only use the top buffer if no text has previously been killed. This
and previous change promped by discussion with kn@.


# 1.180 29-Aug-2018 nicm

Add C-Left and C-Right as aliases for M-b and M-f.


# 1.179 22-Aug-2018 nicm

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


# 1.178 20-Aug-2018 nicm

Move offset of window list into status struct.


# 1.177 19-Aug-2018 nicm

Add a client redraw-window flag instead of the redraw-all flag and for
all just use the three flags together (window, borders, status).


Revision tags: OPENBSD_6_3_BASE
# 1.176 22-Feb-2018 nicm

Remove an unused variable.


# 1.175 05-Feb-2018 nicm

Add struct status_line to hold status line members of struct client, not
used yet but will be soon. From Thomas Adam.


# 1.174 01-Jan-2018 nicm

Add C-g at command prompt for emacs people, GitHub issue 1213.


# 1.173 27-Dec-2017 nicm

Draw command prompt correctly with status line off.


# 1.172 18-Dec-2017 nicm

Remove unused variable from Thomas Adam.


# 1.171 02-Nov-2017 nicm

Add a "fast" version of screen_write_copy for tree mode that doesn't do
all the checks and selection and marking stuff needed for copy mode.


# 1.170 20-Oct-2017 nicm

Clear status line with spaces again so reverse works, spotted by sthen.


# 1.169 16-Oct-2017 nicm

Infrastructure for drawing status lines of more than one line in height,
still only one is allowed but this lets tmux draw bigger ones.


Revision tags: OPENBSD_6_2_BASE
# 1.168 29-May-2017 nicm

Add a flag to stop the prompt input being expanded.


# 1.167 29-May-2017 nicm

Store a copy of the old status line, will be needed soon for new choose mode.


# 1.166 17-May-2017 nicm

Tidy command prompt callbacks and pass in the client.


# 1.165 03-May-2017 nicm

Add a format for the last search string in copy mode and fix the prompt
so it can work when in -I, suggested by Suraj N Kurapati.


# 1.164 01-May-2017 nicm

In order that people can use formats like #D in #() in the status line
and not have to wait for an update when they change pane, we allow
commands to run more than once a second if the expanded form
changes. Unfortunately this can mean them being run far too often
(pretty much continually) when multiple clients exist, because some
formats (including #D) will always differ between clients.

To avoid this, give each client its own tree of jobs which means that
the same command will be different instances for each client - similar
to how we have the tag to separate commands for different panes.

GitHub issue 889; test case reported by Paul Johnson.


# 1.163 22-Apr-2017 nicm

Memory leak from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.162 09-Feb-2017 nicm

Break the message storage function into its own function, useful for
debugging.


# 1.161 03-Feb-2017 nicm

Cache status line position to reduce option lookups during output.


# 1.160 03-Feb-2017 nicm

Add a window or pane id "tag" to each format tree and use it to separate
jobs, this means that if the same job is used for different windows or
panes (for example in pane-border-format), it will be run separately for
each pane.


# 1.159 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.158 06-Jan-2017 nicm

Incremental search in copy mode (on for emacs keys by default) - much
the same as normal searching but updates the cursor position and marked
search terms as you type. C-r and C-s in the prompt repeat the search,
once finished searching (with Enter), N and n work as before.


# 1.157 05-Jan-2017 nicm

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


# 1.156 07-Dec-2016 nicm

Do not clear the prompt when a message is shown, just leave it around and
return to it when the message is finished.


# 1.155 12-Oct-2016 nicm

Drop the edit mode key tables and just use fixed key bindings for the
command prompt.


# 1.154 12-Oct-2016 nicm

The repeat prompt in both emacs and vi (and the old one in tmux) doesn't
support line editing and instead executes a command as soon as a
non-number key is pressed. Add a -N flag to command-prompt for the same
in copy mode. Reported by Theo Buehler.


# 1.153 11-Oct-2016 nicm

Fundamental change to how copy mode key bindings work:

The vi-copy and emacs-copy mode key tables are gone, and instead copy
mode commands are bound in one of two normal key tables ("copy-mode" or
"copy-mode-vi"). Keys are bound to "send-keys -X copy-mode-command". So:

bind -temacs-copy C-Up scroll-up
bind -temacs-copy -R5 WheelUpPane scroll-up

Becomes:

bind -Tcopy-mode C-Up send -X scroll-up
bind -Tcopy-mode WheelUpPane send -N5 -X scroll-up

This allows the full command parser and command set to be used - for
example, we can use the normal command prompt for searching, jumping,
and so on instead of a custom one:

bind -Tcopy-mode C-r command-prompt -p'search up' "send -X search-backward '%%'"

command-prompt also gets a -1 option to only require on key press, which
is needed for jumping.

The plan is to get rid of mode keys entirely, so more to come eventually.


# 1.152 11-Oct-2016 nicm

Support UTF-8 entry into the command prompt.


# 1.151 10-Oct-2016 nicm

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


# 1.150 12-Sep-2016 nicm

Allow repeat count to be specified in mode key tables with bind-key -R,
and set the default repeat count to 5 for WheelUp and WheelDown in
copy-mode.


Revision tags: OPENBSD_6_0_BASE
# 1.149 06-Jun-2016 nicm

Allow #[] in window-status-separator.


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

I no longer use my SourceForge address so replace it.


# 1.147 01-Jan-2016 nicm

Don't rely on a calculation wrapping when applying message-limit, and
break out of the loop early. From Nicolas Viennot.


# 1.146 11-Dec-2015 nicm

Style nits and line wrapping of function declarations.


# 1.145 11-Dec-2015 nicm

Add cmdq as an argument to format_create and add a format for the
command name (will also be used for more later).


# 1.144 08-Dec-2015 nicm

Remove format_create_flags and just pass flags to format_create.


# 1.143 22-Nov-2015 tim

If display-time is set to 0, show status messages until a key is pressed;
OK nicm@


# 1.142 20-Nov-2015 nicm

Instead of separate tables for different types of options, give each
option a scope type (server, session, window) in one table.


# 1.141 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.140 13-Nov-2015 nicm

Long overdue change to the way we store cells in the grid: now, instead
of storing a full grid_cell with UTF-8 data and everything, store a new
type grid_cell_entry. This can either be the cell itself (for ASCII
cells), or an offset into an extended array (per line) for UTF-8
data.

This avoid a large (8 byte) overhead on non-UTF-8 cells (by far the
majority for most users) without the complexity of the shadow array we
had before. Grid memory without any UTF-8 is about half.

The disadvantage that cells can no longer be modified in place and need
to be copied out of the grid and back but it turned out to be lot less
complicated than I expected.


# 1.139 12-Nov-2015 nicm

Nuke the utf8 and status-utf8 options and make tmux only a UTF-8
terminal. We still support non-UTF-8 terminals outside tmux, but inside
it is always UTF-8 (as when the utf8 and status-utf8 options were on).


# 1.138 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.137 27-Oct-2015 nicm

Move struct options into options.c.


# 1.136 20-Oct-2015 nicm

Use client pointer not file descriptor in logging.


# 1.135 14-Sep-2015 nicm

Make refresh-client force update of jobs, from Sina Siadat.


# 1.134 29-Aug-2015 nicm

Move struct paste_buffer out of tmux.h.


# 1.133 28-Aug-2015 nicm

Run status update on a per-client timer at status-interval.


Revision tags: OPENBSD_5_8_BASE
# 1.132 29-Jul-2015 nicm

status_out and associated data structures are no longer used.


# 1.131 28-Jul-2015 nicm

Tidy up the way terminals are described and move some structs out of tmux.h.


# 1.130 20-Jul-2015 nicm

Add an option (history-file) for a file to save/restore command prompt
history, from Olof-Joachim Frahm.


# 1.129 27-May-2015 nicm

Move the jobs output cache into the formats code so that #() work more
generally (for example, again working in set-titles-string).


# 1.128 06-May-2015 nicm

Remove ARRAY_* from history and expand completion to complete a) layout
names and b) targets beginning with -t or -s.


# 1.127 25-Apr-2015 nicm

Make message log a TAILQ.


# 1.126 24-Apr-2015 nicm

Set working directory for run-shell and if-shell.


# 1.125 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_7_BASE
# 1.124 06-Feb-2015 nicm

Use the same time for both calls to format_expand_time.


# 1.123 06-Feb-2015 nicm

status_replace can now become local to status.c and it no longer needs
the jobsflag argument. While here there is no need to repeat work that
format_defaults already does.


# 1.122 06-Feb-2015 nicm

Add format_expand_time and use it instead of status_replace where
command execution is not needed.


# 1.121 05-Feb-2015 nicm

Wrap all the individual format_* calls in a single format_defaults
functions.


# 1.120 01-Feb-2015 nicm

Remove two unused arguments from status_replace.


# 1.119 20-Jan-2015 sthen

typo in comment ;) ok nicm


# 1.118 05-Nov-2014 nicm

Do not put a space between status-left/status-right and the window list,
instead move the space into the defaults for the options (so status-left
now defaults to "[#S] ". From Balazs Kezes.


# 1.117 20-Oct-2014 nicm

Better format for printf format attributes.


# 1.116 08-Oct-2014 nicm

Add xreallocarray and remove nmemb argument from xrealloc.


# 1.115 02-Oct-2014 nicm

Take account of window-status-separator when checking window position,
based on diff from Balazs Kezes.


Revision tags: OPENBSD_5_6_BASE
# 1.114 24-Apr-2014 nicm

There is no longer a need for a paste_stack struct or for global_buffers
to be global. Move to paste.c.


# 1.113 17-Apr-2014 nicm

Remove the monitor-content option and associated bits and bobs. It's
never worked very well. If there is a big demand for it to return, will
consider better ways to do it.


# 1.112 02-Apr-2014 nicm

Do not replace ## with # in status_replace1 because it'll be done later
by the format code.


# 1.111 31-Mar-2014 nicm

Make message-limit a server option.


Revision tags: OPENBSD_5_5_BASE
# 1.110 14-Feb-2014 nicm

Style nit - no space between function name and bracket.


# 1.109 14-Feb-2014 nicm

Check for NULL session and whatnot in status_replace, from Thomas Adam.


# 1.108 28-Jan-2014 nicm

Allow replacing each of the many sets of separate foo-{fg,bg,attr}
options with a single foo-style option. For example:

set -g status-fg yellow
set -g status-bg red
set -g status-attr blink

Becomes:

set -g status-style fg=yellow,bg=red,blink

The -a flag to set can be used to add to rather than replace a style. So:

set -g status-bg red

Becomes:

set -ag status-style bg=red

Currently this is fully backwards compatible (all *-{fg,bg,attr} options
remain) but the plan is to deprecate them over time.

From Tiago Cunha.


Revision tags: OPENBSD_5_4_BASE
# 1.107 05-Jul-2013 nicm

Whitespace nits, from Ben Boeckel.


# 1.106 05-Jul-2013 nicm

Act like vi(1) when moving words, from Ben Boeckel.


# 1.105 05-Jul-2013 nicm

Implement s, S, C mode switch commands in vi(1) mode, from Ben Boeckel.


# 1.104 31-May-2013 nicm

Demote the old single-character replacement variables (#S and friends)
to aliases of formats. From Tiago Cunha.


# 1.103 25-Mar-2013 nicm

Extend jobs to support writing and use that for copy-pipe instead of
popen, from Chris Johnsen.


# 1.102 22-Mar-2013 nicm

evbuffer_readline returns allocated storage, don't leak it.


# 1.101 22-Mar-2013 nicm

Add copy-pipe mode command to copy selection and also pipe to a command.


# 1.100 22-Mar-2013 nicm

No more lint means no more ARGSUSED.


# 1.99 21-Mar-2013 nicm

Aargh. Spaces -> tabs.


# 1.98 21-Mar-2013 nicm

Do not leak formats in status_replace.


# 1.97 21-Mar-2013 nicm

Add a format client_prefix which is 1 if prefix key has been
pressed, used for example #{?client_prefix,X,Y}. Also a few extra
server_client_status needed.


# 1.96 21-Mar-2013 nicm

Allow formats in status options.


Revision tags: OPENBSD_5_3_BASE
# 1.95 27-Nov-2012 nicm

Add window-status-last-* options, from Boris Faure.


Revision tags: OPENBSD_5_2_BASE
# 1.94 10-Jul-2012 nicm

xfree is not particularly helpful, remove it. From Thomas Adam.


# 1.93 09-Jul-2012 nicm

Move a NULL check inside a function, from Tiago Cunha.


# 1.92 29-Apr-2012 nicm

Use int not u_char for colours from options since they may have bit 8
set to mark them as 256-colour. Reported by Chris Johnson.


# 1.91 23-Apr-2012 nicm

Add window-status-separator option, from Thomas Adam.


# 1.90 17-Mar-2012 nicm

Check event_initialized before event_del if event may not have been set
up; libevent2 complains about this. Reported by Moriyoshi Koizumi.


# 1.89 04-Mar-2012 nicm

Add A and I keys for vi status line editing.


# 1.88 03-Mar-2012 nicm

The wlmouse offset should be part of the client, not the server. From
Ailin Nemui.


Revision tags: OPENBSD_5_1_BASE
# 1.87 29-Jan-2012 nicm

Add an option to move the status line to the top of the screen,
requested by many.


# 1.86 26-Jan-2012 nicm

Terminate strftime buffer properly even if a really long format string
is given, from Tiago Cunha.


# 1.85 26-Jan-2012 nicm

Fix memory leak in error path, from Tiago Cunha.


# 1.84 20-Jan-2012 nicm

Add some trivial additional status line attributes from jwcxz at users
dot sourceforge dot net.


# 1.83 20-Jan-2012 nicm

Add space movement keys for vi mode in the status line from Ben Boeckel.


# 1.82 01-Dec-2011 nicm

Make M-f and M-b work the same at the command prompt as in copy mode,
pointed out by Romain Francoise.


# 1.81 15-Nov-2011 nicm

Add word movement and editing command for command prompt editing, from
Ben Boeckel.


# 1.80 15-Nov-2011 nicm

Make window_pane_index work the same as window_index, from Ben Boeckel.


# 1.79 05-Nov-2011 nicm

Option to change status line (message) background when using vi keys and
in command mode. From Ben Boeckel.


# 1.78 20-Aug-2011 nicm

Fix a couple of memory leaks, from marcel partap.


Revision tags: OPENBSD_5_0_BASE
# 1.77 08-Jul-2011 nicm

Make confirm-before prompt customizable with -p option like
command-prompt. Also move responsibility for calling status_replace into
status_prompt_{set,update} and add #W and #P to the default kill-window
and kill-pane prompts. By Tiago Cunha.


# 1.76 02-Jul-2011 nicm

Allow the initial context on prompts to be set with the new -I option to
command-prompt. From Tiago Cunha.


# 1.75 29-Apr-2011 nicm

Only redraw the status line on command update, not the entire client
(big DOH).


# 1.74 24-Apr-2011 nicm

Provide #h for short hostname (no domain) from Michal Mazurek.


# 1.73 18-Apr-2011 nicm

Add an option (mouse-select-window) which allows the mouse to be used by
clicking on the status line, written by hsim at gmx dot li.


# 1.72 29-Mar-2011 nicm

Change -t on display-message to be target-pane for the #[A-Z]
replacements and add -c as target-client.


Revision tags: OPENBSD_4_9_BASE
# 1.71 26-Jan-2011 nicm

Simplify the way jobs work and drop the persist type, so all jobs are
fire-and-forget.

Status jobs now managed with two trees of output (new and old), rather
than storing the output in the jobs themselves. When the status line is
processed any jobs which don't appear in the new tree are started and
the output from the old tree displayed. When a job finishes it updates
the new tree with its output and that is used for any subsequent
redraws. When the status interval expires, the new tree is moved to the
old so that all jobs are run again.

This fixes the "#(echo %H:%M:%S)" problem which would lead to thousands
of identical persistent jobs and high memory use (this can still be
achieved by adding "sleep 30" but that is much less likely to happen by
accident).


# 1.70 03-Jan-2011 nicm

Handle a # at the end of a replacement string (such as status-left)
correctly. Found by Thomas Adam.


# 1.69 01-Jan-2011 nicm

Move the user-visible parts of all options (names, types, limit, default
values) together into one set of tables in options-table.c. Also clean
up and simplify cmd-set-options.c and move a common print function into
option-table.c.


# 1.68 30-Dec-2010 nicm

Change from a per-session stack of buffers to one global stack which is
much more convenient and also simplifies lot of code. This renders
copy-buffer useless and makes buffer-limit now a server option.

By Tiago Cunha.


# 1.67 30-Dec-2010 nicm

Add a function to create window flags rather than doing the same thing
in two places. From Thomas Adam.


# 1.66 11-Dec-2010 nicm

Oops, these functions return a const char *, so make the local variable
const as well.


# 1.65 11-Dec-2010 nicm

Make the prompt history global for all clients which is much more useful than per-client history.


# 1.64 06-Dec-2010 nicm

Add an option to alert (monitor) for silence (lack of activity) in a
window. From Thomas Adam.


Revision tags: OPENBSD_4_8_BASE
# 1.63 21-Jun-2010 nicm

Having a list of winlinks->alerts for each session is stupid, just store
the alert flags directly in the winlink itself.


# 1.62 14-May-2010 nicm

Colour+attribute options for status line alerts, from Alex Alexander.


# 1.61 31-Mar-2010 nicm

Don't accept keys with modifiers as input. Fixes crash reported by Brian
R Landy.


# 1.60 27-Mar-2010 nicm

Don't leak job command in #().


# 1.59 22-Mar-2010 nicm

Dead functions, lint.


Revision tags: OPENBSD_4_7_BASE
# 1.58 27-Jan-2010 nicm

Calculate offset correctly, fixes incorrect offset and prevents crash when
status-left is empty. From Micah Cowan.


# 1.57 26-Jan-2010 nicm

Actually use the copy made when no newline is found, from martynas@.


# 1.56 14-Dec-2009 nicm

Add server options to completion as well.


# 1.55 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.54 03-Dec-2009 nicm

Eliminate duplicate code and ease the passage for server-wide options by adding
a -w flag to set-option and show-options and making setw and showw aliases to
set -w and show -w.

Note: setw and showw are still there, but now aliases for set -w and show -w.


# 1.53 26-Nov-2009 nicm

Tidy up various bits of the paste code, make the data buffer char * and add
comments.


# 1.52 26-Nov-2009 nicm

Remove a couple of unused arguments where possible, and add /* ARGSUSED */ to
the rest to reduce lint output.


# 1.51 20-Nov-2009 nicm

Display UTF-8 properly in status line messages and prompt. Cursor handling is
still way off though.


# 1.50 20-Nov-2009 nicm

Remove oldest messages from log when limit is hit, not newest.


# 1.49 19-Nov-2009 nicm

Get some brackets in the right place so ## works. Also fix a space in a
comment.


# 1.48 19-Nov-2009 nicm

Change status line drawing to create the window list in a separate screen and
then copy it into the status line screen. This allows UTF-8 in window names and
fixes some problems with #[] in window-status-format.


# 1.47 19-Nov-2009 nicm

Two new options, window-status-format and window-status-current-format, which
allow the format of each window in the status line window list to be controlled
using similar # sequences as status-left/right.

This diff also moves part of the way towards UTF-8 support in window names but
it isn't quite there yet.


# 1.46 19-Nov-2009 nicm

Tidy up by breaking the # replacement code into a separate function, also add a
few comments.


# 1.45 19-Nov-2009 nicm

Don't interpret #() for display-message, it usually doesn't make sense and may
leak commands.


# 1.44 18-Nov-2009 nicm

Add a per-client log of status line messages displayed while that client
exists. A new message-limit session option sets the maximum number of entries
and a command, show-messages, shows the log (bound to ~ by default).

This (and prompt history) might be better as a single global log but until
there are global options it is easier for them to be per client.


# 1.43 17-Nov-2009 nicm

Permit top-bit-set characters to be entered in the status line. They could
already be set from the shell and are just passed through when printing (so
invisible characters or displaying on terminals with different character sets
may cause problems).

Note that entering UTF-8 may not work and in any case currently the status line
cannot display it correctly (outside of status-left/status-right).


# 1.42 04-Nov-2009 nicm

Use timeout events for the identify and message timers.


# 1.41 04-Nov-2009 nicm

Switch jobs over to use a bufferevent.


# 1.40 04-Nov-2009 nicm

Unused (but assigned to) variable, found by lint.


# 1.39 01-Nov-2009 nicm

Add a flag for jobs that shouldn't be freed after they've died and use it for
status jobs, then only kill those jobs when status-left, status-right or
set-titles-string is changed.

Fixes problems with changing options from inside #().


# 1.38 10-Oct-2009 nicm

Rather than running status-left, status-right and window title #() with popen
immediately every redraw, queue them up and run them in the background,
starting each once every status-interval. The actual status line uses the
output from the last run.

This brings several advantages:

- tmux itself may be called from inside #() without causing the server to hang;
- likewise, sleep or similar doesn't cause the server to block;
- commands aren't run excessively often when redrawing;
- commands shared by status-left and status-right, or used multiple times, will
only be run once.

run-shell and if-shell still use system()/popen() but will be changed over to
use this too later.


# 1.37 10-Oct-2009 nicm

Add "grouped sessions" which have independent name, options, current window and
so on but where the linked windows are synchronized (ie creating, killing
windows and so on are mirrored between the sessions). A grouped session may be
created by passing -t to new-session.

Had this around for a while, tested by a couple of people.


# 1.36 23-Sep-2009 nicm

Remove PROMPT_HIDDEN code which is now unused.


# 1.35 23-Sep-2009 nicm

Remove the internal tmux locking and instead detach each client and run the
command specified by a new option "lock-command" (by default "lock -np") in
each client.

This means each terminal has to be unlocked individually but simplifies the
code and allows the system password to be used to unlock.

Note that the set-password command is gone, so it will need to be removed from
configuration files, and the -U command line flag has been removed.

This is the third protocol version change so again it is best to stop the tmux
server before upgrading.


# 1.34 20-Sep-2009 nicm

Regularise some fatal messages.


# 1.33 10-Sep-2009 nicm

Permit options such as status-bg to be configured using the entire 256 colour
palette by setting "colour0" to "colour255".


# 1.32 07-Sep-2009 nicm

Give each paste buffer a size member instead of requiring them to be
zero-terminated.


# 1.31 07-Sep-2009 nicm

Permit embedded colour and attributes in status-left and status-right using new
#[] special characters, for example #[fg=red,bg=blue,blink].


# 1.30 02-Sep-2009 nicm

Add a transpose-chars command in edit mode (C-t in emacs mode only). From Kalle
Olavi Niemitalo.


# 1.29 01-Sep-2009 nicm

Use "Password:" with no space for password prompts and don't display a *s for
the password, like pretty much everything else. From martynas@ with minor
tweaks by me.


# 1.28 31-Aug-2009 nicm

Add a new display-panes command, with two options (display-panes-colour and
display-panes-time), which displays a visual indication of the number of each
pane.


# 1.27 19-Aug-2009 nicm

Extend command-prompt with a -p option which is a comma-separated list of one
or more prompts to present in order.

The responses to the prompt are replaced in the template string: %% are
replaced in order, so the first prompt replaces the first %%, the second
replaces the second, and so on. In addition, %1 up to %9 are replaced with the
responses to the first the ninth prompts

The default template is "%1" so the response to the first prompt is processed
as a command.

Note that this changes the behaviour for %% so if there is only one prompt,
only the first %% will be replaced. Templates such as "neww -n '%%' 'ssh %%'"
should be changed to "neww -n '%1' 'ssh %1'".

From Tiago Cunha.


# 1.26 18-Aug-2009 nicm

Add a "delete line" key when editing in the status line or the search up/down
prompt. C-u with emacs keys, d with vi.


# 1.25 13-Aug-2009 nicm

Switch the prompt code to return an empty string when the user enters no
response and reserve NULL for an explicit cancel. Change all callbacks to treat
them the same so no functional change.

Also add cancel key bindings to emacs mode which were missing.


# 1.24 08-Aug-2009 nicm

Options to set the colours and attributes for status-left/-right. From Thomas
Adam, thanks.


# 1.23 05-Aug-2009 nicm

If colours are not supported by the terminal, try to emulate a coloured
background by setting or clearing the reverse attribute.

This makes a few applications which don't use the reverse attribute themselves
a little happier, and allows the status, message and mode options to have
default attributes and fg/bg options that work as expected when set as reverse.


# 1.22 30-Jul-2009 nicm

Plug some memory leaks.


# 1.21 28-Jul-2009 nicm

Next step towards customisable mode keys: build each default table of keys into
a named tree on start and use that for lookups. Also add command to string
translation tables and modify list-keys to show the the mode key bindings (new
-t argument).


# 1.20 27-Jul-2009 nicm

Change mode key bindings from big switches into a set of tables. Rather than
lumping them all together, split editing keys from those used in choice/more
mode and those for copy/scroll mode.

Tidier and clearer, and the first step towards customisable mode keys.


# 1.19 27-Jul-2009 nicm

Get rid of empty mode_key_free function.


# 1.18 27-Jul-2009 nicm

Add a key to delete to end of line at the prompt (^K in emacs mode, C/D in vi).

From Kalle Olavi Niemitalo.


# 1.17 26-Jul-2009 nicm

Calculate the space available for the prompt buffer and the cursor position
correctly, and make it work when the screen is not wide enough.

Noticed by Kalle Olavi Niemitalo.


# 1.16 21-Jul-2009 nicm

Remove a couple of unused functions and fix a type ("FALLTHOUGH"), found by
lint.


# 1.15 20-Jul-2009 nicm

Add a status-justify option to allow the window list in the status line to be
positioned at the left, centre, or right.


# 1.14 20-Jul-2009 nicm

New options, window-status-current-{fg,bg,attr}, to set the fg, bg and
attributes with which the current window is shown in the status line. From
Johan Friis, thanks.


# 1.13 17-Jul-2009 nicm

- New command display-message (alias display) to display a message in the
status line (bound to "i" and displays the current window and time by
default). The same substitutions are applied as for status-left/right.
- Add support for including the window index (#I), pane index (#P) and window
name (#W) in the message, and status-left or status-right.
- Bump protocol version.

From Tiago Cunha, thanks!


# 1.12 17-Jul-2009 nicm

Memory could be leaked if a second prompt or message appeared while another was
still present, so add a separate prompt free callback and make the _clear
function responsible for calling it if necessary (rather than the individual
prompt callbacks). Also make both messages and prompts clear any existing when
a new is set.

In addition, the screen could be modified while the prompt is there, restore
the redraw-entire-screen behaviour on prompt clear; add a comment as a
reminder.


# 1.11 16-Jul-2009 nicm

Remove some duplicate code that was causing the status line to be redrawn even
when it hadn't changed.


# 1.10 15-Jul-2009 nicm

Make status_message_set a variadic printf-like function. No functional change -
helpful for a couple of things coming soon.


# 1.9 15-Jul-2009 nicm

Having to update NSETOPTION/NSETWINDOWOPTION when adding new options is a bit
annoying and it is only use for iterating, so use a sentinel to mark the end of
each array instead. Different fix for a problem pointed out by Kalle Olavi
Niemitalo.


# 1.8 14-Jul-2009 nicm

For some reason when clearing status/message it was redrawing the entire client
not just the status line. Changing this also revealed the check for the status
line was incorrect when drawing the pane.


# 1.7 14-Jul-2009 nicm

Instead of faking up a status line in status_redraw, use the same code to
redraw it as to draw the entire screen, just skip all lines but the last.

This makes horizontal split redraw properly when the status line is off.


# 1.6 12-Jul-2009 nicm

Add a "back to indentation" key in copy mode to move the cursor to the first
non-whitespace character. ^ with vi and M-m with emacs key bindings. Another
from Kalle Olavi Niemitalo, thanks.


Revision tags: OPENBSD_4_6_BASE
# 1.5 26-Jun-2009 nicm

Status line fixes: don't truncate status-right now the length calculation is
done for UTF-8, limit to the maximum length correctly when printing, and always
print a space even if the left string is longer than the width available.


# 1.4 04-Jun-2009 nicm

If the prompt is hidden or a password is sent with -U, zero it before freeing
it.


# 1.3 03-Jun-2009 nicm

New session option, status-utf8, to control the interpretation of top-bit-set
characters in status-left and status-right (if on, they are treated as UTF-8;
otherwise passed through).


# 1.2 03-Jun-2009 nicm

Add a UTF-8 aware string length function and make UTF-8 in
status-left/status-right work properly. At the moment any top-bit-set
characters are assumed to be UTF-8: a status-utf8 option to configure this will
come shortly.


# 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.220 22-Feb-2021 nicm

Move jump commands to grid reader, make them UTF-8 aware, and tidy up,
from Anindya Mukherjee.


# 1.219 08-Jan-2021 nicm

With incremental search, start empty and only repeat the previous search
if the user tries to search again with an empty prompt. This matches
emacs behaviour more closely.


Revision tags: OPENBSD_6_8_BASE
# 1.218 27-Jul-2020 nicm

Add a -d option to display-message to set delay, from theonekeyg at
gmail dot com in GitHub issue 2322.


# 1.217 11-Jun-2020 nicm

Fix a crash when completing sessions, from Anindya Mukherjee.


# 1.216 26-May-2020 nicm

Remove leftover debug logging and fix comparison.


# 1.215 26-May-2020 nicm

Set up UTF-8 data for ASCII keys correctly.


# 1.214 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.213 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.212 16-May-2020 nicm

Rename KEYC_ESCAPE to KEYC_META.


# 1.211 16-May-2020 nicm

Expand target from client and use it to expand the prompt.


# 1.210 16-May-2020 nicm

Support embedded styles in the display-message message, GitHub issue
2206.


# 1.209 16-May-2020 nicm

Change message log to be per server rather than per client and include
every command that is run.


# 1.208 16-May-2020 nicm

Do not hoke into struct window_pane from the tty code and instead set
everything up in tty_ctx. Provide a way to initialize the tty_ctx from a
callback and use it to let popups draw directly through input_parse in
the same way as panes do, rather than forcing a full redraw on every
change.


# 1.207 16-May-2020 nicm

Use formats for status-style and message-style.


# 1.206 16-May-2020 nicm

Complete partial window indexes properly.


# 1.205 16-May-2020 nicm

Add -W and -T flags to command-prompt to only complete a window and a
target, also complete aliases.


# 1.204 16-May-2020 nicm

Improve command prompt completion:

- Show a menu with completions if there are multiple.

- Don't complete argument stuff (options, layouts) at start of text.

- For -t and -s, if there is no : then complete sessions but if there is
a :, show a menu of all windows in the session rather than trying to
complete the window name which is a bit useless if there are
duplicates.


# 1.203 16-May-2020 nicm

Drop having a separate type for style options and make them all strings,
which allows formats to be expanded. Any styles without a '#{' are still
validated when they are set but any with a '#{' are not. Formats are not
expanded usefully in many cases yet, that will be changed later.

To make this work, a few other changes:

- set-option -a with a style option automatically appends a ",".

- OSC 10 and 11 don't set the window-style option anymore, instead the
fg and bg are stored in the pane struct and act as the defaults that
can be overridden by window-style.

- status-fg and -bg now override status-style instead of trying to keep
them in sync.


Revision tags: OPENBSD_6_7_BASE
# 1.202 12-Mar-2020 nicm

Add C-g to cancel command prompt with vi(1) keys as well as emacs, and q
in command mode.


# 1.201 27-Jan-2020 nicm

Add support for adding a note to a key binding (with bind-key -N) and
use this to add descriptions to the default key bindings. A new -N flag
to list-keys shows key bindings with notes rather than the default
bind-key command used to create them. Change the default ? binding to
use this to show a readable summary of keys.

Also extend command-prompt to return the name of the key pressed and add
a default binding (/) to show the note for the next key pressed

Suggested by Alex Tremblay in GitHub issue 2000.


Revision tags: OPENBSD_6_6_BASE
# 1.200 28-May-2019 nicm

Redraw status line if size changes, GitHub issue 1762. Also fix length
of target buffer when pasting into status line.


# 1.199 23-May-2019 nicm

Fix length calculation for pasting UTF-8 characters in the status line,
GitHub issue 1753.


# 1.198 11-May-2019 nicm

Do not reduce window height by status line height for control mode
clients, from George Nachman.


# 1.197 03-May-2019 nicm

Fix reverse attribute in status line, GitHub issue 1709.


# 1.196 26-Apr-2019 nicm

Merge hooks into options and make each one an array option. This allows
multiple commands to be easily bound to one hook. set-hook and
show-hooks remain but they are now variants of set-option and
show-options. show-options now has a -H flag to show hooks (by default
they are not shown).


# 1.195 25-Apr-2019 nicm

options_array_item_value cannot return NULL.


# 1.194 23-Apr-2019 nicm

Somehow missed these bits in last commit.


# 1.193 23-Apr-2019 nicm

Indicate an array option with a flag rather than a special type so that
in future will not have to be strings.


Revision tags: OPENBSD_6_5_BASE
# 1.192 18-Mar-2019 nicm

Extend the #[] style syntax and use that together with previous format
changes to allow the status line to be entirely configured with a single
option.

Now that it is possible to configure their content, enable the existing
code that lets the status line be multiple lines in height. The status
option can now take a value of 2, 3, 4 or 5 (as well as the previous on
or off) to configure more than one line. The new status-format array
option configures the format of each line, the default just references
the existing status-* options, although some of the more obscure status
options may be eliminated in time.

Additions to the #[] syntax are: "align" to specify alignment (left,
centre, right), "list" for the window list and "range" to configure
ranges of text for the mouse bindings.

The "align" keyword can also be used to specify alignment of entries in
tree mode and the pane status lines.


# 1.191 18-Mar-2019 nicm

Make array options a sparse tree instead of an array of char * and
remove the size limit.


# 1.190 18-Mar-2019 nicm

With force, kill previous job before starting new. Fixes problem
reported by Scott Mcdermott in GitHub issue 1627.


# 1.189 16-Mar-2019 nicm

Use a pointer for the active screen in the status line instead of
copying them around all the time.


# 1.188 16-Mar-2019 nicm

Give status_save_old the client so it can do the reinit too.


# 1.187 16-Mar-2019 nicm

Tidy and rename some bits of status line code.


# 1.186 15-Mar-2019 nicm

Move status line free into its own function.


# 1.185 14-Mar-2019 nicm

Store the time in the format tree rather than passing it around.


# 1.184 12-Mar-2019 nicm

DECRC and DECSC apparently need to preserve origin mode as well, based
on a fix from Marc Reisner.


# 1.183 09-Feb-2019 nicm

Completion of command-alias members.


# 1.182 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.181 29-Aug-2018 nicm

Keep any text killed in the command prompt with C-w and yank it with
C-y, only use the top buffer if no text has previously been killed. This
and previous change promped by discussion with kn@.


# 1.180 29-Aug-2018 nicm

Add C-Left and C-Right as aliases for M-b and M-f.


# 1.179 22-Aug-2018 nicm

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


# 1.178 20-Aug-2018 nicm

Move offset of window list into status struct.


# 1.177 19-Aug-2018 nicm

Add a client redraw-window flag instead of the redraw-all flag and for
all just use the three flags together (window, borders, status).


Revision tags: OPENBSD_6_3_BASE
# 1.176 22-Feb-2018 nicm

Remove an unused variable.


# 1.175 05-Feb-2018 nicm

Add struct status_line to hold status line members of struct client, not
used yet but will be soon. From Thomas Adam.


# 1.174 01-Jan-2018 nicm

Add C-g at command prompt for emacs people, GitHub issue 1213.


# 1.173 27-Dec-2017 nicm

Draw command prompt correctly with status line off.


# 1.172 18-Dec-2017 nicm

Remove unused variable from Thomas Adam.


# 1.171 02-Nov-2017 nicm

Add a "fast" version of screen_write_copy for tree mode that doesn't do
all the checks and selection and marking stuff needed for copy mode.


# 1.170 20-Oct-2017 nicm

Clear status line with spaces again so reverse works, spotted by sthen.


# 1.169 16-Oct-2017 nicm

Infrastructure for drawing status lines of more than one line in height,
still only one is allowed but this lets tmux draw bigger ones.


Revision tags: OPENBSD_6_2_BASE
# 1.168 29-May-2017 nicm

Add a flag to stop the prompt input being expanded.


# 1.167 29-May-2017 nicm

Store a copy of the old status line, will be needed soon for new choose mode.


# 1.166 17-May-2017 nicm

Tidy command prompt callbacks and pass in the client.


# 1.165 03-May-2017 nicm

Add a format for the last search string in copy mode and fix the prompt
so it can work when in -I, suggested by Suraj N Kurapati.


# 1.164 01-May-2017 nicm

In order that people can use formats like #D in #() in the status line
and not have to wait for an update when they change pane, we allow
commands to run more than once a second if the expanded form
changes. Unfortunately this can mean them being run far too often
(pretty much continually) when multiple clients exist, because some
formats (including #D) will always differ between clients.

To avoid this, give each client its own tree of jobs which means that
the same command will be different instances for each client - similar
to how we have the tag to separate commands for different panes.

GitHub issue 889; test case reported by Paul Johnson.


# 1.163 22-Apr-2017 nicm

Memory leak from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.162 09-Feb-2017 nicm

Break the message storage function into its own function, useful for
debugging.


# 1.161 03-Feb-2017 nicm

Cache status line position to reduce option lookups during output.


# 1.160 03-Feb-2017 nicm

Add a window or pane id "tag" to each format tree and use it to separate
jobs, this means that if the same job is used for different windows or
panes (for example in pane-border-format), it will be run separately for
each pane.


# 1.159 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.158 06-Jan-2017 nicm

Incremental search in copy mode (on for emacs keys by default) - much
the same as normal searching but updates the cursor position and marked
search terms as you type. C-r and C-s in the prompt repeat the search,
once finished searching (with Enter), N and n work as before.


# 1.157 05-Jan-2017 nicm

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


# 1.156 07-Dec-2016 nicm

Do not clear the prompt when a message is shown, just leave it around and
return to it when the message is finished.


# 1.155 12-Oct-2016 nicm

Drop the edit mode key tables and just use fixed key bindings for the
command prompt.


# 1.154 12-Oct-2016 nicm

The repeat prompt in both emacs and vi (and the old one in tmux) doesn't
support line editing and instead executes a command as soon as a
non-number key is pressed. Add a -N flag to command-prompt for the same
in copy mode. Reported by Theo Buehler.


# 1.153 11-Oct-2016 nicm

Fundamental change to how copy mode key bindings work:

The vi-copy and emacs-copy mode key tables are gone, and instead copy
mode commands are bound in one of two normal key tables ("copy-mode" or
"copy-mode-vi"). Keys are bound to "send-keys -X copy-mode-command". So:

bind -temacs-copy C-Up scroll-up
bind -temacs-copy -R5 WheelUpPane scroll-up

Becomes:

bind -Tcopy-mode C-Up send -X scroll-up
bind -Tcopy-mode WheelUpPane send -N5 -X scroll-up

This allows the full command parser and command set to be used - for
example, we can use the normal command prompt for searching, jumping,
and so on instead of a custom one:

bind -Tcopy-mode C-r command-prompt -p'search up' "send -X search-backward '%%'"

command-prompt also gets a -1 option to only require on key press, which
is needed for jumping.

The plan is to get rid of mode keys entirely, so more to come eventually.


# 1.152 11-Oct-2016 nicm

Support UTF-8 entry into the command prompt.


# 1.151 10-Oct-2016 nicm

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


# 1.150 12-Sep-2016 nicm

Allow repeat count to be specified in mode key tables with bind-key -R,
and set the default repeat count to 5 for WheelUp and WheelDown in
copy-mode.


Revision tags: OPENBSD_6_0_BASE
# 1.149 06-Jun-2016 nicm

Allow #[] in window-status-separator.


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

I no longer use my SourceForge address so replace it.


# 1.147 01-Jan-2016 nicm

Don't rely on a calculation wrapping when applying message-limit, and
break out of the loop early. From Nicolas Viennot.


# 1.146 11-Dec-2015 nicm

Style nits and line wrapping of function declarations.


# 1.145 11-Dec-2015 nicm

Add cmdq as an argument to format_create and add a format for the
command name (will also be used for more later).


# 1.144 08-Dec-2015 nicm

Remove format_create_flags and just pass flags to format_create.


# 1.143 22-Nov-2015 tim

If display-time is set to 0, show status messages until a key is pressed;
OK nicm@


# 1.142 20-Nov-2015 nicm

Instead of separate tables for different types of options, give each
option a scope type (server, session, window) in one table.


# 1.141 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.140 13-Nov-2015 nicm

Long overdue change to the way we store cells in the grid: now, instead
of storing a full grid_cell with UTF-8 data and everything, store a new
type grid_cell_entry. This can either be the cell itself (for ASCII
cells), or an offset into an extended array (per line) for UTF-8
data.

This avoid a large (8 byte) overhead on non-UTF-8 cells (by far the
majority for most users) without the complexity of the shadow array we
had before. Grid memory without any UTF-8 is about half.

The disadvantage that cells can no longer be modified in place and need
to be copied out of the grid and back but it turned out to be lot less
complicated than I expected.


# 1.139 12-Nov-2015 nicm

Nuke the utf8 and status-utf8 options and make tmux only a UTF-8
terminal. We still support non-UTF-8 terminals outside tmux, but inside
it is always UTF-8 (as when the utf8 and status-utf8 options were on).


# 1.138 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.137 27-Oct-2015 nicm

Move struct options into options.c.


# 1.136 20-Oct-2015 nicm

Use client pointer not file descriptor in logging.


# 1.135 14-Sep-2015 nicm

Make refresh-client force update of jobs, from Sina Siadat.


# 1.134 29-Aug-2015 nicm

Move struct paste_buffer out of tmux.h.


# 1.133 28-Aug-2015 nicm

Run status update on a per-client timer at status-interval.


Revision tags: OPENBSD_5_8_BASE
# 1.132 29-Jul-2015 nicm

status_out and associated data structures are no longer used.


# 1.131 28-Jul-2015 nicm

Tidy up the way terminals are described and move some structs out of tmux.h.


# 1.130 20-Jul-2015 nicm

Add an option (history-file) for a file to save/restore command prompt
history, from Olof-Joachim Frahm.


# 1.129 27-May-2015 nicm

Move the jobs output cache into the formats code so that #() work more
generally (for example, again working in set-titles-string).


# 1.128 06-May-2015 nicm

Remove ARRAY_* from history and expand completion to complete a) layout
names and b) targets beginning with -t or -s.


# 1.127 25-Apr-2015 nicm

Make message log a TAILQ.


# 1.126 24-Apr-2015 nicm

Set working directory for run-shell and if-shell.


# 1.125 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_7_BASE
# 1.124 06-Feb-2015 nicm

Use the same time for both calls to format_expand_time.


# 1.123 06-Feb-2015 nicm

status_replace can now become local to status.c and it no longer needs
the jobsflag argument. While here there is no need to repeat work that
format_defaults already does.


# 1.122 06-Feb-2015 nicm

Add format_expand_time and use it instead of status_replace where
command execution is not needed.


# 1.121 05-Feb-2015 nicm

Wrap all the individual format_* calls in a single format_defaults
functions.


# 1.120 01-Feb-2015 nicm

Remove two unused arguments from status_replace.


# 1.119 20-Jan-2015 sthen

typo in comment ;) ok nicm


# 1.118 05-Nov-2014 nicm

Do not put a space between status-left/status-right and the window list,
instead move the space into the defaults for the options (so status-left
now defaults to "[#S] ". From Balazs Kezes.


# 1.117 20-Oct-2014 nicm

Better format for printf format attributes.


# 1.116 08-Oct-2014 nicm

Add xreallocarray and remove nmemb argument from xrealloc.


# 1.115 02-Oct-2014 nicm

Take account of window-status-separator when checking window position,
based on diff from Balazs Kezes.


Revision tags: OPENBSD_5_6_BASE
# 1.114 24-Apr-2014 nicm

There is no longer a need for a paste_stack struct or for global_buffers
to be global. Move to paste.c.


# 1.113 17-Apr-2014 nicm

Remove the monitor-content option and associated bits and bobs. It's
never worked very well. If there is a big demand for it to return, will
consider better ways to do it.


# 1.112 02-Apr-2014 nicm

Do not replace ## with # in status_replace1 because it'll be done later
by the format code.


# 1.111 31-Mar-2014 nicm

Make message-limit a server option.


Revision tags: OPENBSD_5_5_BASE
# 1.110 14-Feb-2014 nicm

Style nit - no space between function name and bracket.


# 1.109 14-Feb-2014 nicm

Check for NULL session and whatnot in status_replace, from Thomas Adam.


# 1.108 28-Jan-2014 nicm

Allow replacing each of the many sets of separate foo-{fg,bg,attr}
options with a single foo-style option. For example:

set -g status-fg yellow
set -g status-bg red
set -g status-attr blink

Becomes:

set -g status-style fg=yellow,bg=red,blink

The -a flag to set can be used to add to rather than replace a style. So:

set -g status-bg red

Becomes:

set -ag status-style bg=red

Currently this is fully backwards compatible (all *-{fg,bg,attr} options
remain) but the plan is to deprecate them over time.

From Tiago Cunha.


Revision tags: OPENBSD_5_4_BASE
# 1.107 05-Jul-2013 nicm

Whitespace nits, from Ben Boeckel.


# 1.106 05-Jul-2013 nicm

Act like vi(1) when moving words, from Ben Boeckel.


# 1.105 05-Jul-2013 nicm

Implement s, S, C mode switch commands in vi(1) mode, from Ben Boeckel.


# 1.104 31-May-2013 nicm

Demote the old single-character replacement variables (#S and friends)
to aliases of formats. From Tiago Cunha.


# 1.103 25-Mar-2013 nicm

Extend jobs to support writing and use that for copy-pipe instead of
popen, from Chris Johnsen.


# 1.102 22-Mar-2013 nicm

evbuffer_readline returns allocated storage, don't leak it.


# 1.101 22-Mar-2013 nicm

Add copy-pipe mode command to copy selection and also pipe to a command.


# 1.100 22-Mar-2013 nicm

No more lint means no more ARGSUSED.


# 1.99 21-Mar-2013 nicm

Aargh. Spaces -> tabs.


# 1.98 21-Mar-2013 nicm

Do not leak formats in status_replace.


# 1.97 21-Mar-2013 nicm

Add a format client_prefix which is 1 if prefix key has been
pressed, used for example #{?client_prefix,X,Y}. Also a few extra
server_client_status needed.


# 1.96 21-Mar-2013 nicm

Allow formats in status options.


Revision tags: OPENBSD_5_3_BASE
# 1.95 27-Nov-2012 nicm

Add window-status-last-* options, from Boris Faure.


Revision tags: OPENBSD_5_2_BASE
# 1.94 10-Jul-2012 nicm

xfree is not particularly helpful, remove it. From Thomas Adam.


# 1.93 09-Jul-2012 nicm

Move a NULL check inside a function, from Tiago Cunha.


# 1.92 29-Apr-2012 nicm

Use int not u_char for colours from options since they may have bit 8
set to mark them as 256-colour. Reported by Chris Johnson.


# 1.91 23-Apr-2012 nicm

Add window-status-separator option, from Thomas Adam.


# 1.90 17-Mar-2012 nicm

Check event_initialized before event_del if event may not have been set
up; libevent2 complains about this. Reported by Moriyoshi Koizumi.


# 1.89 04-Mar-2012 nicm

Add A and I keys for vi status line editing.


# 1.88 03-Mar-2012 nicm

The wlmouse offset should be part of the client, not the server. From
Ailin Nemui.


Revision tags: OPENBSD_5_1_BASE
# 1.87 29-Jan-2012 nicm

Add an option to move the status line to the top of the screen,
requested by many.


# 1.86 26-Jan-2012 nicm

Terminate strftime buffer properly even if a really long format string
is given, from Tiago Cunha.


# 1.85 26-Jan-2012 nicm

Fix memory leak in error path, from Tiago Cunha.


# 1.84 20-Jan-2012 nicm

Add some trivial additional status line attributes from jwcxz at users
dot sourceforge dot net.


# 1.83 20-Jan-2012 nicm

Add space movement keys for vi mode in the status line from Ben Boeckel.


# 1.82 01-Dec-2011 nicm

Make M-f and M-b work the same at the command prompt as in copy mode,
pointed out by Romain Francoise.


# 1.81 15-Nov-2011 nicm

Add word movement and editing command for command prompt editing, from
Ben Boeckel.


# 1.80 15-Nov-2011 nicm

Make window_pane_index work the same as window_index, from Ben Boeckel.


# 1.79 05-Nov-2011 nicm

Option to change status line (message) background when using vi keys and
in command mode. From Ben Boeckel.


# 1.78 20-Aug-2011 nicm

Fix a couple of memory leaks, from marcel partap.


Revision tags: OPENBSD_5_0_BASE
# 1.77 08-Jul-2011 nicm

Make confirm-before prompt customizable with -p option like
command-prompt. Also move responsibility for calling status_replace into
status_prompt_{set,update} and add #W and #P to the default kill-window
and kill-pane prompts. By Tiago Cunha.


# 1.76 02-Jul-2011 nicm

Allow the initial context on prompts to be set with the new -I option to
command-prompt. From Tiago Cunha.


# 1.75 29-Apr-2011 nicm

Only redraw the status line on command update, not the entire client
(big DOH).


# 1.74 24-Apr-2011 nicm

Provide #h for short hostname (no domain) from Michal Mazurek.


# 1.73 18-Apr-2011 nicm

Add an option (mouse-select-window) which allows the mouse to be used by
clicking on the status line, written by hsim at gmx dot li.


# 1.72 29-Mar-2011 nicm

Change -t on display-message to be target-pane for the #[A-Z]
replacements and add -c as target-client.


Revision tags: OPENBSD_4_9_BASE
# 1.71 26-Jan-2011 nicm

Simplify the way jobs work and drop the persist type, so all jobs are
fire-and-forget.

Status jobs now managed with two trees of output (new and old), rather
than storing the output in the jobs themselves. When the status line is
processed any jobs which don't appear in the new tree are started and
the output from the old tree displayed. When a job finishes it updates
the new tree with its output and that is used for any subsequent
redraws. When the status interval expires, the new tree is moved to the
old so that all jobs are run again.

This fixes the "#(echo %H:%M:%S)" problem which would lead to thousands
of identical persistent jobs and high memory use (this can still be
achieved by adding "sleep 30" but that is much less likely to happen by
accident).


# 1.70 03-Jan-2011 nicm

Handle a # at the end of a replacement string (such as status-left)
correctly. Found by Thomas Adam.


# 1.69 01-Jan-2011 nicm

Move the user-visible parts of all options (names, types, limit, default
values) together into one set of tables in options-table.c. Also clean
up and simplify cmd-set-options.c and move a common print function into
option-table.c.


# 1.68 30-Dec-2010 nicm

Change from a per-session stack of buffers to one global stack which is
much more convenient and also simplifies lot of code. This renders
copy-buffer useless and makes buffer-limit now a server option.

By Tiago Cunha.


# 1.67 30-Dec-2010 nicm

Add a function to create window flags rather than doing the same thing
in two places. From Thomas Adam.


# 1.66 11-Dec-2010 nicm

Oops, these functions return a const char *, so make the local variable
const as well.


# 1.65 11-Dec-2010 nicm

Make the prompt history global for all clients which is much more useful than per-client history.


# 1.64 06-Dec-2010 nicm

Add an option to alert (monitor) for silence (lack of activity) in a
window. From Thomas Adam.


Revision tags: OPENBSD_4_8_BASE
# 1.63 21-Jun-2010 nicm

Having a list of winlinks->alerts for each session is stupid, just store
the alert flags directly in the winlink itself.


# 1.62 14-May-2010 nicm

Colour+attribute options for status line alerts, from Alex Alexander.


# 1.61 31-Mar-2010 nicm

Don't accept keys with modifiers as input. Fixes crash reported by Brian
R Landy.


# 1.60 27-Mar-2010 nicm

Don't leak job command in #().


# 1.59 22-Mar-2010 nicm

Dead functions, lint.


Revision tags: OPENBSD_4_7_BASE
# 1.58 27-Jan-2010 nicm

Calculate offset correctly, fixes incorrect offset and prevents crash when
status-left is empty. From Micah Cowan.


# 1.57 26-Jan-2010 nicm

Actually use the copy made when no newline is found, from martynas@.


# 1.56 14-Dec-2009 nicm

Add server options to completion as well.


# 1.55 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.54 03-Dec-2009 nicm

Eliminate duplicate code and ease the passage for server-wide options by adding
a -w flag to set-option and show-options and making setw and showw aliases to
set -w and show -w.

Note: setw and showw are still there, but now aliases for set -w and show -w.


# 1.53 26-Nov-2009 nicm

Tidy up various bits of the paste code, make the data buffer char * and add
comments.


# 1.52 26-Nov-2009 nicm

Remove a couple of unused arguments where possible, and add /* ARGSUSED */ to
the rest to reduce lint output.


# 1.51 20-Nov-2009 nicm

Display UTF-8 properly in status line messages and prompt. Cursor handling is
still way off though.


# 1.50 20-Nov-2009 nicm

Remove oldest messages from log when limit is hit, not newest.


# 1.49 19-Nov-2009 nicm

Get some brackets in the right place so ## works. Also fix a space in a
comment.


# 1.48 19-Nov-2009 nicm

Change status line drawing to create the window list in a separate screen and
then copy it into the status line screen. This allows UTF-8 in window names and
fixes some problems with #[] in window-status-format.


# 1.47 19-Nov-2009 nicm

Two new options, window-status-format and window-status-current-format, which
allow the format of each window in the status line window list to be controlled
using similar # sequences as status-left/right.

This diff also moves part of the way towards UTF-8 support in window names but
it isn't quite there yet.


# 1.46 19-Nov-2009 nicm

Tidy up by breaking the # replacement code into a separate function, also add a
few comments.


# 1.45 19-Nov-2009 nicm

Don't interpret #() for display-message, it usually doesn't make sense and may
leak commands.


# 1.44 18-Nov-2009 nicm

Add a per-client log of status line messages displayed while that client
exists. A new message-limit session option sets the maximum number of entries
and a command, show-messages, shows the log (bound to ~ by default).

This (and prompt history) might be better as a single global log but until
there are global options it is easier for them to be per client.


# 1.43 17-Nov-2009 nicm

Permit top-bit-set characters to be entered in the status line. They could
already be set from the shell and are just passed through when printing (so
invisible characters or displaying on terminals with different character sets
may cause problems).

Note that entering UTF-8 may not work and in any case currently the status line
cannot display it correctly (outside of status-left/status-right).


# 1.42 04-Nov-2009 nicm

Use timeout events for the identify and message timers.


# 1.41 04-Nov-2009 nicm

Switch jobs over to use a bufferevent.


# 1.40 04-Nov-2009 nicm

Unused (but assigned to) variable, found by lint.


# 1.39 01-Nov-2009 nicm

Add a flag for jobs that shouldn't be freed after they've died and use it for
status jobs, then only kill those jobs when status-left, status-right or
set-titles-string is changed.

Fixes problems with changing options from inside #().


# 1.38 10-Oct-2009 nicm

Rather than running status-left, status-right and window title #() with popen
immediately every redraw, queue them up and run them in the background,
starting each once every status-interval. The actual status line uses the
output from the last run.

This brings several advantages:

- tmux itself may be called from inside #() without causing the server to hang;
- likewise, sleep or similar doesn't cause the server to block;
- commands aren't run excessively often when redrawing;
- commands shared by status-left and status-right, or used multiple times, will
only be run once.

run-shell and if-shell still use system()/popen() but will be changed over to
use this too later.


# 1.37 10-Oct-2009 nicm

Add "grouped sessions" which have independent name, options, current window and
so on but where the linked windows are synchronized (ie creating, killing
windows and so on are mirrored between the sessions). A grouped session may be
created by passing -t to new-session.

Had this around for a while, tested by a couple of people.


# 1.36 23-Sep-2009 nicm

Remove PROMPT_HIDDEN code which is now unused.


# 1.35 23-Sep-2009 nicm

Remove the internal tmux locking and instead detach each client and run the
command specified by a new option "lock-command" (by default "lock -np") in
each client.

This means each terminal has to be unlocked individually but simplifies the
code and allows the system password to be used to unlock.

Note that the set-password command is gone, so it will need to be removed from
configuration files, and the -U command line flag has been removed.

This is the third protocol version change so again it is best to stop the tmux
server before upgrading.


# 1.34 20-Sep-2009 nicm

Regularise some fatal messages.


# 1.33 10-Sep-2009 nicm

Permit options such as status-bg to be configured using the entire 256 colour
palette by setting "colour0" to "colour255".


# 1.32 07-Sep-2009 nicm

Give each paste buffer a size member instead of requiring them to be
zero-terminated.


# 1.31 07-Sep-2009 nicm

Permit embedded colour and attributes in status-left and status-right using new
#[] special characters, for example #[fg=red,bg=blue,blink].


# 1.30 02-Sep-2009 nicm

Add a transpose-chars command in edit mode (C-t in emacs mode only). From Kalle
Olavi Niemitalo.


# 1.29 01-Sep-2009 nicm

Use "Password:" with no space for password prompts and don't display a *s for
the password, like pretty much everything else. From martynas@ with minor
tweaks by me.


# 1.28 31-Aug-2009 nicm

Add a new display-panes command, with two options (display-panes-colour and
display-panes-time), which displays a visual indication of the number of each
pane.


# 1.27 19-Aug-2009 nicm

Extend command-prompt with a -p option which is a comma-separated list of one
or more prompts to present in order.

The responses to the prompt are replaced in the template string: %% are
replaced in order, so the first prompt replaces the first %%, the second
replaces the second, and so on. In addition, %1 up to %9 are replaced with the
responses to the first the ninth prompts

The default template is "%1" so the response to the first prompt is processed
as a command.

Note that this changes the behaviour for %% so if there is only one prompt,
only the first %% will be replaced. Templates such as "neww -n '%%' 'ssh %%'"
should be changed to "neww -n '%1' 'ssh %1'".

From Tiago Cunha.


# 1.26 18-Aug-2009 nicm

Add a "delete line" key when editing in the status line or the search up/down
prompt. C-u with emacs keys, d with vi.


# 1.25 13-Aug-2009 nicm

Switch the prompt code to return an empty string when the user enters no
response and reserve NULL for an explicit cancel. Change all callbacks to treat
them the same so no functional change.

Also add cancel key bindings to emacs mode which were missing.


# 1.24 08-Aug-2009 nicm

Options to set the colours and attributes for status-left/-right. From Thomas
Adam, thanks.


# 1.23 05-Aug-2009 nicm

If colours are not supported by the terminal, try to emulate a coloured
background by setting or clearing the reverse attribute.

This makes a few applications which don't use the reverse attribute themselves
a little happier, and allows the status, message and mode options to have
default attributes and fg/bg options that work as expected when set as reverse.


# 1.22 30-Jul-2009 nicm

Plug some memory leaks.


# 1.21 28-Jul-2009 nicm

Next step towards customisable mode keys: build each default table of keys into
a named tree on start and use that for lookups. Also add command to string
translation tables and modify list-keys to show the the mode key bindings (new
-t argument).


# 1.20 27-Jul-2009 nicm

Change mode key bindings from big switches into a set of tables. Rather than
lumping them all together, split editing keys from those used in choice/more
mode and those for copy/scroll mode.

Tidier and clearer, and the first step towards customisable mode keys.


# 1.19 27-Jul-2009 nicm

Get rid of empty mode_key_free function.


# 1.18 27-Jul-2009 nicm

Add a key to delete to end of line at the prompt (^K in emacs mode, C/D in vi).

From Kalle Olavi Niemitalo.


# 1.17 26-Jul-2009 nicm

Calculate the space available for the prompt buffer and the cursor position
correctly, and make it work when the screen is not wide enough.

Noticed by Kalle Olavi Niemitalo.


# 1.16 21-Jul-2009 nicm

Remove a couple of unused functions and fix a type ("FALLTHOUGH"), found by
lint.


# 1.15 20-Jul-2009 nicm

Add a status-justify option to allow the window list in the status line to be
positioned at the left, centre, or right.


# 1.14 20-Jul-2009 nicm

New options, window-status-current-{fg,bg,attr}, to set the fg, bg and
attributes with which the current window is shown in the status line. From
Johan Friis, thanks.


# 1.13 17-Jul-2009 nicm

- New command display-message (alias display) to display a message in the
status line (bound to "i" and displays the current window and time by
default). The same substitutions are applied as for status-left/right.
- Add support for including the window index (#I), pane index (#P) and window
name (#W) in the message, and status-left or status-right.
- Bump protocol version.

From Tiago Cunha, thanks!


# 1.12 17-Jul-2009 nicm

Memory could be leaked if a second prompt or message appeared while another was
still present, so add a separate prompt free callback and make the _clear
function responsible for calling it if necessary (rather than the individual
prompt callbacks). Also make both messages and prompts clear any existing when
a new is set.

In addition, the screen could be modified while the prompt is there, restore
the redraw-entire-screen behaviour on prompt clear; add a comment as a
reminder.


# 1.11 16-Jul-2009 nicm

Remove some duplicate code that was causing the status line to be redrawn even
when it hadn't changed.


# 1.10 15-Jul-2009 nicm

Make status_message_set a variadic printf-like function. No functional change -
helpful for a couple of things coming soon.


# 1.9 15-Jul-2009 nicm

Having to update NSETOPTION/NSETWINDOWOPTION when adding new options is a bit
annoying and it is only use for iterating, so use a sentinel to mark the end of
each array instead. Different fix for a problem pointed out by Kalle Olavi
Niemitalo.


# 1.8 14-Jul-2009 nicm

For some reason when clearing status/message it was redrawing the entire client
not just the status line. Changing this also revealed the check for the status
line was incorrect when drawing the pane.


# 1.7 14-Jul-2009 nicm

Instead of faking up a status line in status_redraw, use the same code to
redraw it as to draw the entire screen, just skip all lines but the last.

This makes horizontal split redraw properly when the status line is off.


# 1.6 12-Jul-2009 nicm

Add a "back to indentation" key in copy mode to move the cursor to the first
non-whitespace character. ^ with vi and M-m with emacs key bindings. Another
from Kalle Olavi Niemitalo, thanks.


Revision tags: OPENBSD_4_6_BASE
# 1.5 26-Jun-2009 nicm

Status line fixes: don't truncate status-right now the length calculation is
done for UTF-8, limit to the maximum length correctly when printing, and always
print a space even if the left string is longer than the width available.


# 1.4 04-Jun-2009 nicm

If the prompt is hidden or a password is sent with -U, zero it before freeing
it.


# 1.3 03-Jun-2009 nicm

New session option, status-utf8, to control the interpretation of top-bit-set
characters in status-left and status-right (if on, they are treated as UTF-8;
otherwise passed through).


# 1.2 03-Jun-2009 nicm

Add a UTF-8 aware string length function and make UTF-8 in
status-left/status-right work properly. At the moment any top-bit-set
characters are assumed to be UTF-8: a status-utf8 option to configure this will
come shortly.


# 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.219 08-Jan-2021 nicm

With incremental search, start empty and only repeat the previous search
if the user tries to search again with an empty prompt. This matches
emacs behaviour more closely.


Revision tags: OPENBSD_6_8_BASE
# 1.218 27-Jul-2020 nicm

Add a -d option to display-message to set delay, from theonekeyg at
gmail dot com in GitHub issue 2322.


# 1.217 11-Jun-2020 nicm

Fix a crash when completing sessions, from Anindya Mukherjee.


# 1.216 26-May-2020 nicm

Remove leftover debug logging and fix comparison.


# 1.215 26-May-2020 nicm

Set up UTF-8 data for ASCII keys correctly.


# 1.214 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.213 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.212 16-May-2020 nicm

Rename KEYC_ESCAPE to KEYC_META.


# 1.211 16-May-2020 nicm

Expand target from client and use it to expand the prompt.


# 1.210 16-May-2020 nicm

Support embedded styles in the display-message message, GitHub issue
2206.


# 1.209 16-May-2020 nicm

Change message log to be per server rather than per client and include
every command that is run.


# 1.208 16-May-2020 nicm

Do not hoke into struct window_pane from the tty code and instead set
everything up in tty_ctx. Provide a way to initialize the tty_ctx from a
callback and use it to let popups draw directly through input_parse in
the same way as panes do, rather than forcing a full redraw on every
change.


# 1.207 16-May-2020 nicm

Use formats for status-style and message-style.


# 1.206 16-May-2020 nicm

Complete partial window indexes properly.


# 1.205 16-May-2020 nicm

Add -W and -T flags to command-prompt to only complete a window and a
target, also complete aliases.


# 1.204 16-May-2020 nicm

Improve command prompt completion:

- Show a menu with completions if there are multiple.

- Don't complete argument stuff (options, layouts) at start of text.

- For -t and -s, if there is no : then complete sessions but if there is
a :, show a menu of all windows in the session rather than trying to
complete the window name which is a bit useless if there are
duplicates.


# 1.203 16-May-2020 nicm

Drop having a separate type for style options and make them all strings,
which allows formats to be expanded. Any styles without a '#{' are still
validated when they are set but any with a '#{' are not. Formats are not
expanded usefully in many cases yet, that will be changed later.

To make this work, a few other changes:

- set-option -a with a style option automatically appends a ",".

- OSC 10 and 11 don't set the window-style option anymore, instead the
fg and bg are stored in the pane struct and act as the defaults that
can be overridden by window-style.

- status-fg and -bg now override status-style instead of trying to keep
them in sync.


Revision tags: OPENBSD_6_7_BASE
# 1.202 12-Mar-2020 nicm

Add C-g to cancel command prompt with vi(1) keys as well as emacs, and q
in command mode.


# 1.201 27-Jan-2020 nicm

Add support for adding a note to a key binding (with bind-key -N) and
use this to add descriptions to the default key bindings. A new -N flag
to list-keys shows key bindings with notes rather than the default
bind-key command used to create them. Change the default ? binding to
use this to show a readable summary of keys.

Also extend command-prompt to return the name of the key pressed and add
a default binding (/) to show the note for the next key pressed

Suggested by Alex Tremblay in GitHub issue 2000.


Revision tags: OPENBSD_6_6_BASE
# 1.200 28-May-2019 nicm

Redraw status line if size changes, GitHub issue 1762. Also fix length
of target buffer when pasting into status line.


# 1.199 23-May-2019 nicm

Fix length calculation for pasting UTF-8 characters in the status line,
GitHub issue 1753.


# 1.198 11-May-2019 nicm

Do not reduce window height by status line height for control mode
clients, from George Nachman.


# 1.197 03-May-2019 nicm

Fix reverse attribute in status line, GitHub issue 1709.


# 1.196 26-Apr-2019 nicm

Merge hooks into options and make each one an array option. This allows
multiple commands to be easily bound to one hook. set-hook and
show-hooks remain but they are now variants of set-option and
show-options. show-options now has a -H flag to show hooks (by default
they are not shown).


# 1.195 25-Apr-2019 nicm

options_array_item_value cannot return NULL.


# 1.194 23-Apr-2019 nicm

Somehow missed these bits in last commit.


# 1.193 23-Apr-2019 nicm

Indicate an array option with a flag rather than a special type so that
in future will not have to be strings.


Revision tags: OPENBSD_6_5_BASE
# 1.192 18-Mar-2019 nicm

Extend the #[] style syntax and use that together with previous format
changes to allow the status line to be entirely configured with a single
option.

Now that it is possible to configure their content, enable the existing
code that lets the status line be multiple lines in height. The status
option can now take a value of 2, 3, 4 or 5 (as well as the previous on
or off) to configure more than one line. The new status-format array
option configures the format of each line, the default just references
the existing status-* options, although some of the more obscure status
options may be eliminated in time.

Additions to the #[] syntax are: "align" to specify alignment (left,
centre, right), "list" for the window list and "range" to configure
ranges of text for the mouse bindings.

The "align" keyword can also be used to specify alignment of entries in
tree mode and the pane status lines.


# 1.191 18-Mar-2019 nicm

Make array options a sparse tree instead of an array of char * and
remove the size limit.


# 1.190 18-Mar-2019 nicm

With force, kill previous job before starting new. Fixes problem
reported by Scott Mcdermott in GitHub issue 1627.


# 1.189 16-Mar-2019 nicm

Use a pointer for the active screen in the status line instead of
copying them around all the time.


# 1.188 16-Mar-2019 nicm

Give status_save_old the client so it can do the reinit too.


# 1.187 16-Mar-2019 nicm

Tidy and rename some bits of status line code.


# 1.186 15-Mar-2019 nicm

Move status line free into its own function.


# 1.185 14-Mar-2019 nicm

Store the time in the format tree rather than passing it around.


# 1.184 12-Mar-2019 nicm

DECRC and DECSC apparently need to preserve origin mode as well, based
on a fix from Marc Reisner.


# 1.183 09-Feb-2019 nicm

Completion of command-alias members.


# 1.182 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.181 29-Aug-2018 nicm

Keep any text killed in the command prompt with C-w and yank it with
C-y, only use the top buffer if no text has previously been killed. This
and previous change promped by discussion with kn@.


# 1.180 29-Aug-2018 nicm

Add C-Left and C-Right as aliases for M-b and M-f.


# 1.179 22-Aug-2018 nicm

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


# 1.178 20-Aug-2018 nicm

Move offset of window list into status struct.


# 1.177 19-Aug-2018 nicm

Add a client redraw-window flag instead of the redraw-all flag and for
all just use the three flags together (window, borders, status).


Revision tags: OPENBSD_6_3_BASE
# 1.176 22-Feb-2018 nicm

Remove an unused variable.


# 1.175 05-Feb-2018 nicm

Add struct status_line to hold status line members of struct client, not
used yet but will be soon. From Thomas Adam.


# 1.174 01-Jan-2018 nicm

Add C-g at command prompt for emacs people, GitHub issue 1213.


# 1.173 27-Dec-2017 nicm

Draw command prompt correctly with status line off.


# 1.172 18-Dec-2017 nicm

Remove unused variable from Thomas Adam.


# 1.171 02-Nov-2017 nicm

Add a "fast" version of screen_write_copy for tree mode that doesn't do
all the checks and selection and marking stuff needed for copy mode.


# 1.170 20-Oct-2017 nicm

Clear status line with spaces again so reverse works, spotted by sthen.


# 1.169 16-Oct-2017 nicm

Infrastructure for drawing status lines of more than one line in height,
still only one is allowed but this lets tmux draw bigger ones.


Revision tags: OPENBSD_6_2_BASE
# 1.168 29-May-2017 nicm

Add a flag to stop the prompt input being expanded.


# 1.167 29-May-2017 nicm

Store a copy of the old status line, will be needed soon for new choose mode.


# 1.166 17-May-2017 nicm

Tidy command prompt callbacks and pass in the client.


# 1.165 03-May-2017 nicm

Add a format for the last search string in copy mode and fix the prompt
so it can work when in -I, suggested by Suraj N Kurapati.


# 1.164 01-May-2017 nicm

In order that people can use formats like #D in #() in the status line
and not have to wait for an update when they change pane, we allow
commands to run more than once a second if the expanded form
changes. Unfortunately this can mean them being run far too often
(pretty much continually) when multiple clients exist, because some
formats (including #D) will always differ between clients.

To avoid this, give each client its own tree of jobs which means that
the same command will be different instances for each client - similar
to how we have the tag to separate commands for different panes.

GitHub issue 889; test case reported by Paul Johnson.


# 1.163 22-Apr-2017 nicm

Memory leak from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.162 09-Feb-2017 nicm

Break the message storage function into its own function, useful for
debugging.


# 1.161 03-Feb-2017 nicm

Cache status line position to reduce option lookups during output.


# 1.160 03-Feb-2017 nicm

Add a window or pane id "tag" to each format tree and use it to separate
jobs, this means that if the same job is used for different windows or
panes (for example in pane-border-format), it will be run separately for
each pane.


# 1.159 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.158 06-Jan-2017 nicm

Incremental search in copy mode (on for emacs keys by default) - much
the same as normal searching but updates the cursor position and marked
search terms as you type. C-r and C-s in the prompt repeat the search,
once finished searching (with Enter), N and n work as before.


# 1.157 05-Jan-2017 nicm

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


# 1.156 07-Dec-2016 nicm

Do not clear the prompt when a message is shown, just leave it around and
return to it when the message is finished.


# 1.155 12-Oct-2016 nicm

Drop the edit mode key tables and just use fixed key bindings for the
command prompt.


# 1.154 12-Oct-2016 nicm

The repeat prompt in both emacs and vi (and the old one in tmux) doesn't
support line editing and instead executes a command as soon as a
non-number key is pressed. Add a -N flag to command-prompt for the same
in copy mode. Reported by Theo Buehler.


# 1.153 11-Oct-2016 nicm

Fundamental change to how copy mode key bindings work:

The vi-copy and emacs-copy mode key tables are gone, and instead copy
mode commands are bound in one of two normal key tables ("copy-mode" or
"copy-mode-vi"). Keys are bound to "send-keys -X copy-mode-command". So:

bind -temacs-copy C-Up scroll-up
bind -temacs-copy -R5 WheelUpPane scroll-up

Becomes:

bind -Tcopy-mode C-Up send -X scroll-up
bind -Tcopy-mode WheelUpPane send -N5 -X scroll-up

This allows the full command parser and command set to be used - for
example, we can use the normal command prompt for searching, jumping,
and so on instead of a custom one:

bind -Tcopy-mode C-r command-prompt -p'search up' "send -X search-backward '%%'"

command-prompt also gets a -1 option to only require on key press, which
is needed for jumping.

The plan is to get rid of mode keys entirely, so more to come eventually.


# 1.152 11-Oct-2016 nicm

Support UTF-8 entry into the command prompt.


# 1.151 10-Oct-2016 nicm

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


# 1.150 12-Sep-2016 nicm

Allow repeat count to be specified in mode key tables with bind-key -R,
and set the default repeat count to 5 for WheelUp and WheelDown in
copy-mode.


Revision tags: OPENBSD_6_0_BASE
# 1.149 06-Jun-2016 nicm

Allow #[] in window-status-separator.


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

I no longer use my SourceForge address so replace it.


# 1.147 01-Jan-2016 nicm

Don't rely on a calculation wrapping when applying message-limit, and
break out of the loop early. From Nicolas Viennot.


# 1.146 11-Dec-2015 nicm

Style nits and line wrapping of function declarations.


# 1.145 11-Dec-2015 nicm

Add cmdq as an argument to format_create and add a format for the
command name (will also be used for more later).


# 1.144 08-Dec-2015 nicm

Remove format_create_flags and just pass flags to format_create.


# 1.143 22-Nov-2015 tim

If display-time is set to 0, show status messages until a key is pressed;
OK nicm@


# 1.142 20-Nov-2015 nicm

Instead of separate tables for different types of options, give each
option a scope type (server, session, window) in one table.


# 1.141 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.140 13-Nov-2015 nicm

Long overdue change to the way we store cells in the grid: now, instead
of storing a full grid_cell with UTF-8 data and everything, store a new
type grid_cell_entry. This can either be the cell itself (for ASCII
cells), or an offset into an extended array (per line) for UTF-8
data.

This avoid a large (8 byte) overhead on non-UTF-8 cells (by far the
majority for most users) without the complexity of the shadow array we
had before. Grid memory without any UTF-8 is about half.

The disadvantage that cells can no longer be modified in place and need
to be copied out of the grid and back but it turned out to be lot less
complicated than I expected.


# 1.139 12-Nov-2015 nicm

Nuke the utf8 and status-utf8 options and make tmux only a UTF-8
terminal. We still support non-UTF-8 terminals outside tmux, but inside
it is always UTF-8 (as when the utf8 and status-utf8 options were on).


# 1.138 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.137 27-Oct-2015 nicm

Move struct options into options.c.


# 1.136 20-Oct-2015 nicm

Use client pointer not file descriptor in logging.


# 1.135 14-Sep-2015 nicm

Make refresh-client force update of jobs, from Sina Siadat.


# 1.134 29-Aug-2015 nicm

Move struct paste_buffer out of tmux.h.


# 1.133 28-Aug-2015 nicm

Run status update on a per-client timer at status-interval.


Revision tags: OPENBSD_5_8_BASE
# 1.132 29-Jul-2015 nicm

status_out and associated data structures are no longer used.


# 1.131 28-Jul-2015 nicm

Tidy up the way terminals are described and move some structs out of tmux.h.


# 1.130 20-Jul-2015 nicm

Add an option (history-file) for a file to save/restore command prompt
history, from Olof-Joachim Frahm.


# 1.129 27-May-2015 nicm

Move the jobs output cache into the formats code so that #() work more
generally (for example, again working in set-titles-string).


# 1.128 06-May-2015 nicm

Remove ARRAY_* from history and expand completion to complete a) layout
names and b) targets beginning with -t or -s.


# 1.127 25-Apr-2015 nicm

Make message log a TAILQ.


# 1.126 24-Apr-2015 nicm

Set working directory for run-shell and if-shell.


# 1.125 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_7_BASE
# 1.124 06-Feb-2015 nicm

Use the same time for both calls to format_expand_time.


# 1.123 06-Feb-2015 nicm

status_replace can now become local to status.c and it no longer needs
the jobsflag argument. While here there is no need to repeat work that
format_defaults already does.


# 1.122 06-Feb-2015 nicm

Add format_expand_time and use it instead of status_replace where
command execution is not needed.


# 1.121 05-Feb-2015 nicm

Wrap all the individual format_* calls in a single format_defaults
functions.


# 1.120 01-Feb-2015 nicm

Remove two unused arguments from status_replace.


# 1.119 20-Jan-2015 sthen

typo in comment ;) ok nicm


# 1.118 05-Nov-2014 nicm

Do not put a space between status-left/status-right and the window list,
instead move the space into the defaults for the options (so status-left
now defaults to "[#S] ". From Balazs Kezes.


# 1.117 20-Oct-2014 nicm

Better format for printf format attributes.


# 1.116 08-Oct-2014 nicm

Add xreallocarray and remove nmemb argument from xrealloc.


# 1.115 02-Oct-2014 nicm

Take account of window-status-separator when checking window position,
based on diff from Balazs Kezes.


Revision tags: OPENBSD_5_6_BASE
# 1.114 24-Apr-2014 nicm

There is no longer a need for a paste_stack struct or for global_buffers
to be global. Move to paste.c.


# 1.113 17-Apr-2014 nicm

Remove the monitor-content option and associated bits and bobs. It's
never worked very well. If there is a big demand for it to return, will
consider better ways to do it.


# 1.112 02-Apr-2014 nicm

Do not replace ## with # in status_replace1 because it'll be done later
by the format code.


# 1.111 31-Mar-2014 nicm

Make message-limit a server option.


Revision tags: OPENBSD_5_5_BASE
# 1.110 14-Feb-2014 nicm

Style nit - no space between function name and bracket.


# 1.109 14-Feb-2014 nicm

Check for NULL session and whatnot in status_replace, from Thomas Adam.


# 1.108 28-Jan-2014 nicm

Allow replacing each of the many sets of separate foo-{fg,bg,attr}
options with a single foo-style option. For example:

set -g status-fg yellow
set -g status-bg red
set -g status-attr blink

Becomes:

set -g status-style fg=yellow,bg=red,blink

The -a flag to set can be used to add to rather than replace a style. So:

set -g status-bg red

Becomes:

set -ag status-style bg=red

Currently this is fully backwards compatible (all *-{fg,bg,attr} options
remain) but the plan is to deprecate them over time.

From Tiago Cunha.


Revision tags: OPENBSD_5_4_BASE
# 1.107 05-Jul-2013 nicm

Whitespace nits, from Ben Boeckel.


# 1.106 05-Jul-2013 nicm

Act like vi(1) when moving words, from Ben Boeckel.


# 1.105 05-Jul-2013 nicm

Implement s, S, C mode switch commands in vi(1) mode, from Ben Boeckel.


# 1.104 31-May-2013 nicm

Demote the old single-character replacement variables (#S and friends)
to aliases of formats. From Tiago Cunha.


# 1.103 25-Mar-2013 nicm

Extend jobs to support writing and use that for copy-pipe instead of
popen, from Chris Johnsen.


# 1.102 22-Mar-2013 nicm

evbuffer_readline returns allocated storage, don't leak it.


# 1.101 22-Mar-2013 nicm

Add copy-pipe mode command to copy selection and also pipe to a command.


# 1.100 22-Mar-2013 nicm

No more lint means no more ARGSUSED.


# 1.99 21-Mar-2013 nicm

Aargh. Spaces -> tabs.


# 1.98 21-Mar-2013 nicm

Do not leak formats in status_replace.


# 1.97 21-Mar-2013 nicm

Add a format client_prefix which is 1 if prefix key has been
pressed, used for example #{?client_prefix,X,Y}. Also a few extra
server_client_status needed.


# 1.96 21-Mar-2013 nicm

Allow formats in status options.


Revision tags: OPENBSD_5_3_BASE
# 1.95 27-Nov-2012 nicm

Add window-status-last-* options, from Boris Faure.


Revision tags: OPENBSD_5_2_BASE
# 1.94 10-Jul-2012 nicm

xfree is not particularly helpful, remove it. From Thomas Adam.


# 1.93 09-Jul-2012 nicm

Move a NULL check inside a function, from Tiago Cunha.


# 1.92 29-Apr-2012 nicm

Use int not u_char for colours from options since they may have bit 8
set to mark them as 256-colour. Reported by Chris Johnson.


# 1.91 23-Apr-2012 nicm

Add window-status-separator option, from Thomas Adam.


# 1.90 17-Mar-2012 nicm

Check event_initialized before event_del if event may not have been set
up; libevent2 complains about this. Reported by Moriyoshi Koizumi.


# 1.89 04-Mar-2012 nicm

Add A and I keys for vi status line editing.


# 1.88 03-Mar-2012 nicm

The wlmouse offset should be part of the client, not the server. From
Ailin Nemui.


Revision tags: OPENBSD_5_1_BASE
# 1.87 29-Jan-2012 nicm

Add an option to move the status line to the top of the screen,
requested by many.


# 1.86 26-Jan-2012 nicm

Terminate strftime buffer properly even if a really long format string
is given, from Tiago Cunha.


# 1.85 26-Jan-2012 nicm

Fix memory leak in error path, from Tiago Cunha.


# 1.84 20-Jan-2012 nicm

Add some trivial additional status line attributes from jwcxz at users
dot sourceforge dot net.


# 1.83 20-Jan-2012 nicm

Add space movement keys for vi mode in the status line from Ben Boeckel.


# 1.82 01-Dec-2011 nicm

Make M-f and M-b work the same at the command prompt as in copy mode,
pointed out by Romain Francoise.


# 1.81 15-Nov-2011 nicm

Add word movement and editing command for command prompt editing, from
Ben Boeckel.


# 1.80 15-Nov-2011 nicm

Make window_pane_index work the same as window_index, from Ben Boeckel.


# 1.79 05-Nov-2011 nicm

Option to change status line (message) background when using vi keys and
in command mode. From Ben Boeckel.


# 1.78 20-Aug-2011 nicm

Fix a couple of memory leaks, from marcel partap.


Revision tags: OPENBSD_5_0_BASE
# 1.77 08-Jul-2011 nicm

Make confirm-before prompt customizable with -p option like
command-prompt. Also move responsibility for calling status_replace into
status_prompt_{set,update} and add #W and #P to the default kill-window
and kill-pane prompts. By Tiago Cunha.


# 1.76 02-Jul-2011 nicm

Allow the initial context on prompts to be set with the new -I option to
command-prompt. From Tiago Cunha.


# 1.75 29-Apr-2011 nicm

Only redraw the status line on command update, not the entire client
(big DOH).


# 1.74 24-Apr-2011 nicm

Provide #h for short hostname (no domain) from Michal Mazurek.


# 1.73 18-Apr-2011 nicm

Add an option (mouse-select-window) which allows the mouse to be used by
clicking on the status line, written by hsim at gmx dot li.


# 1.72 29-Mar-2011 nicm

Change -t on display-message to be target-pane for the #[A-Z]
replacements and add -c as target-client.


Revision tags: OPENBSD_4_9_BASE
# 1.71 26-Jan-2011 nicm

Simplify the way jobs work and drop the persist type, so all jobs are
fire-and-forget.

Status jobs now managed with two trees of output (new and old), rather
than storing the output in the jobs themselves. When the status line is
processed any jobs which don't appear in the new tree are started and
the output from the old tree displayed. When a job finishes it updates
the new tree with its output and that is used for any subsequent
redraws. When the status interval expires, the new tree is moved to the
old so that all jobs are run again.

This fixes the "#(echo %H:%M:%S)" problem which would lead to thousands
of identical persistent jobs and high memory use (this can still be
achieved by adding "sleep 30" but that is much less likely to happen by
accident).


# 1.70 03-Jan-2011 nicm

Handle a # at the end of a replacement string (such as status-left)
correctly. Found by Thomas Adam.


# 1.69 01-Jan-2011 nicm

Move the user-visible parts of all options (names, types, limit, default
values) together into one set of tables in options-table.c. Also clean
up and simplify cmd-set-options.c and move a common print function into
option-table.c.


# 1.68 30-Dec-2010 nicm

Change from a per-session stack of buffers to one global stack which is
much more convenient and also simplifies lot of code. This renders
copy-buffer useless and makes buffer-limit now a server option.

By Tiago Cunha.


# 1.67 30-Dec-2010 nicm

Add a function to create window flags rather than doing the same thing
in two places. From Thomas Adam.


# 1.66 11-Dec-2010 nicm

Oops, these functions return a const char *, so make the local variable
const as well.


# 1.65 11-Dec-2010 nicm

Make the prompt history global for all clients which is much more useful than per-client history.


# 1.64 06-Dec-2010 nicm

Add an option to alert (monitor) for silence (lack of activity) in a
window. From Thomas Adam.


Revision tags: OPENBSD_4_8_BASE
# 1.63 21-Jun-2010 nicm

Having a list of winlinks->alerts for each session is stupid, just store
the alert flags directly in the winlink itself.


# 1.62 14-May-2010 nicm

Colour+attribute options for status line alerts, from Alex Alexander.


# 1.61 31-Mar-2010 nicm

Don't accept keys with modifiers as input. Fixes crash reported by Brian
R Landy.


# 1.60 27-Mar-2010 nicm

Don't leak job command in #().


# 1.59 22-Mar-2010 nicm

Dead functions, lint.


Revision tags: OPENBSD_4_7_BASE
# 1.58 27-Jan-2010 nicm

Calculate offset correctly, fixes incorrect offset and prevents crash when
status-left is empty. From Micah Cowan.


# 1.57 26-Jan-2010 nicm

Actually use the copy made when no newline is found, from martynas@.


# 1.56 14-Dec-2009 nicm

Add server options to completion as well.


# 1.55 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.54 03-Dec-2009 nicm

Eliminate duplicate code and ease the passage for server-wide options by adding
a -w flag to set-option and show-options and making setw and showw aliases to
set -w and show -w.

Note: setw and showw are still there, but now aliases for set -w and show -w.


# 1.53 26-Nov-2009 nicm

Tidy up various bits of the paste code, make the data buffer char * and add
comments.


# 1.52 26-Nov-2009 nicm

Remove a couple of unused arguments where possible, and add /* ARGSUSED */ to
the rest to reduce lint output.


# 1.51 20-Nov-2009 nicm

Display UTF-8 properly in status line messages and prompt. Cursor handling is
still way off though.


# 1.50 20-Nov-2009 nicm

Remove oldest messages from log when limit is hit, not newest.


# 1.49 19-Nov-2009 nicm

Get some brackets in the right place so ## works. Also fix a space in a
comment.


# 1.48 19-Nov-2009 nicm

Change status line drawing to create the window list in a separate screen and
then copy it into the status line screen. This allows UTF-8 in window names and
fixes some problems with #[] in window-status-format.


# 1.47 19-Nov-2009 nicm

Two new options, window-status-format and window-status-current-format, which
allow the format of each window in the status line window list to be controlled
using similar # sequences as status-left/right.

This diff also moves part of the way towards UTF-8 support in window names but
it isn't quite there yet.


# 1.46 19-Nov-2009 nicm

Tidy up by breaking the # replacement code into a separate function, also add a
few comments.


# 1.45 19-Nov-2009 nicm

Don't interpret #() for display-message, it usually doesn't make sense and may
leak commands.


# 1.44 18-Nov-2009 nicm

Add a per-client log of status line messages displayed while that client
exists. A new message-limit session option sets the maximum number of entries
and a command, show-messages, shows the log (bound to ~ by default).

This (and prompt history) might be better as a single global log but until
there are global options it is easier for them to be per client.


# 1.43 17-Nov-2009 nicm

Permit top-bit-set characters to be entered in the status line. They could
already be set from the shell and are just passed through when printing (so
invisible characters or displaying on terminals with different character sets
may cause problems).

Note that entering UTF-8 may not work and in any case currently the status line
cannot display it correctly (outside of status-left/status-right).


# 1.42 04-Nov-2009 nicm

Use timeout events for the identify and message timers.


# 1.41 04-Nov-2009 nicm

Switch jobs over to use a bufferevent.


# 1.40 04-Nov-2009 nicm

Unused (but assigned to) variable, found by lint.


# 1.39 01-Nov-2009 nicm

Add a flag for jobs that shouldn't be freed after they've died and use it for
status jobs, then only kill those jobs when status-left, status-right or
set-titles-string is changed.

Fixes problems with changing options from inside #().


# 1.38 10-Oct-2009 nicm

Rather than running status-left, status-right and window title #() with popen
immediately every redraw, queue them up and run them in the background,
starting each once every status-interval. The actual status line uses the
output from the last run.

This brings several advantages:

- tmux itself may be called from inside #() without causing the server to hang;
- likewise, sleep or similar doesn't cause the server to block;
- commands aren't run excessively often when redrawing;
- commands shared by status-left and status-right, or used multiple times, will
only be run once.

run-shell and if-shell still use system()/popen() but will be changed over to
use this too later.


# 1.37 10-Oct-2009 nicm

Add "grouped sessions" which have independent name, options, current window and
so on but where the linked windows are synchronized (ie creating, killing
windows and so on are mirrored between the sessions). A grouped session may be
created by passing -t to new-session.

Had this around for a while, tested by a couple of people.


# 1.36 23-Sep-2009 nicm

Remove PROMPT_HIDDEN code which is now unused.


# 1.35 23-Sep-2009 nicm

Remove the internal tmux locking and instead detach each client and run the
command specified by a new option "lock-command" (by default "lock -np") in
each client.

This means each terminal has to be unlocked individually but simplifies the
code and allows the system password to be used to unlock.

Note that the set-password command is gone, so it will need to be removed from
configuration files, and the -U command line flag has been removed.

This is the third protocol version change so again it is best to stop the tmux
server before upgrading.


# 1.34 20-Sep-2009 nicm

Regularise some fatal messages.


# 1.33 10-Sep-2009 nicm

Permit options such as status-bg to be configured using the entire 256 colour
palette by setting "colour0" to "colour255".


# 1.32 07-Sep-2009 nicm

Give each paste buffer a size member instead of requiring them to be
zero-terminated.


# 1.31 07-Sep-2009 nicm

Permit embedded colour and attributes in status-left and status-right using new
#[] special characters, for example #[fg=red,bg=blue,blink].


# 1.30 02-Sep-2009 nicm

Add a transpose-chars command in edit mode (C-t in emacs mode only). From Kalle
Olavi Niemitalo.


# 1.29 01-Sep-2009 nicm

Use "Password:" with no space for password prompts and don't display a *s for
the password, like pretty much everything else. From martynas@ with minor
tweaks by me.


# 1.28 31-Aug-2009 nicm

Add a new display-panes command, with two options (display-panes-colour and
display-panes-time), which displays a visual indication of the number of each
pane.


# 1.27 19-Aug-2009 nicm

Extend command-prompt with a -p option which is a comma-separated list of one
or more prompts to present in order.

The responses to the prompt are replaced in the template string: %% are
replaced in order, so the first prompt replaces the first %%, the second
replaces the second, and so on. In addition, %1 up to %9 are replaced with the
responses to the first the ninth prompts

The default template is "%1" so the response to the first prompt is processed
as a command.

Note that this changes the behaviour for %% so if there is only one prompt,
only the first %% will be replaced. Templates such as "neww -n '%%' 'ssh %%'"
should be changed to "neww -n '%1' 'ssh %1'".

From Tiago Cunha.


# 1.26 18-Aug-2009 nicm

Add a "delete line" key when editing in the status line or the search up/down
prompt. C-u with emacs keys, d with vi.


# 1.25 13-Aug-2009 nicm

Switch the prompt code to return an empty string when the user enters no
response and reserve NULL for an explicit cancel. Change all callbacks to treat
them the same so no functional change.

Also add cancel key bindings to emacs mode which were missing.


# 1.24 08-Aug-2009 nicm

Options to set the colours and attributes for status-left/-right. From Thomas
Adam, thanks.


# 1.23 05-Aug-2009 nicm

If colours are not supported by the terminal, try to emulate a coloured
background by setting or clearing the reverse attribute.

This makes a few applications which don't use the reverse attribute themselves
a little happier, and allows the status, message and mode options to have
default attributes and fg/bg options that work as expected when set as reverse.


# 1.22 30-Jul-2009 nicm

Plug some memory leaks.


# 1.21 28-Jul-2009 nicm

Next step towards customisable mode keys: build each default table of keys into
a named tree on start and use that for lookups. Also add command to string
translation tables and modify list-keys to show the the mode key bindings (new
-t argument).


# 1.20 27-Jul-2009 nicm

Change mode key bindings from big switches into a set of tables. Rather than
lumping them all together, split editing keys from those used in choice/more
mode and those for copy/scroll mode.

Tidier and clearer, and the first step towards customisable mode keys.


# 1.19 27-Jul-2009 nicm

Get rid of empty mode_key_free function.


# 1.18 27-Jul-2009 nicm

Add a key to delete to end of line at the prompt (^K in emacs mode, C/D in vi).

From Kalle Olavi Niemitalo.


# 1.17 26-Jul-2009 nicm

Calculate the space available for the prompt buffer and the cursor position
correctly, and make it work when the screen is not wide enough.

Noticed by Kalle Olavi Niemitalo.


# 1.16 21-Jul-2009 nicm

Remove a couple of unused functions and fix a type ("FALLTHOUGH"), found by
lint.


# 1.15 20-Jul-2009 nicm

Add a status-justify option to allow the window list in the status line to be
positioned at the left, centre, or right.


# 1.14 20-Jul-2009 nicm

New options, window-status-current-{fg,bg,attr}, to set the fg, bg and
attributes with which the current window is shown in the status line. From
Johan Friis, thanks.


# 1.13 17-Jul-2009 nicm

- New command display-message (alias display) to display a message in the
status line (bound to "i" and displays the current window and time by
default). The same substitutions are applied as for status-left/right.
- Add support for including the window index (#I), pane index (#P) and window
name (#W) in the message, and status-left or status-right.
- Bump protocol version.

From Tiago Cunha, thanks!


# 1.12 17-Jul-2009 nicm

Memory could be leaked if a second prompt or message appeared while another was
still present, so add a separate prompt free callback and make the _clear
function responsible for calling it if necessary (rather than the individual
prompt callbacks). Also make both messages and prompts clear any existing when
a new is set.

In addition, the screen could be modified while the prompt is there, restore
the redraw-entire-screen behaviour on prompt clear; add a comment as a
reminder.


# 1.11 16-Jul-2009 nicm

Remove some duplicate code that was causing the status line to be redrawn even
when it hadn't changed.


# 1.10 15-Jul-2009 nicm

Make status_message_set a variadic printf-like function. No functional change -
helpful for a couple of things coming soon.


# 1.9 15-Jul-2009 nicm

Having to update NSETOPTION/NSETWINDOWOPTION when adding new options is a bit
annoying and it is only use for iterating, so use a sentinel to mark the end of
each array instead. Different fix for a problem pointed out by Kalle Olavi
Niemitalo.


# 1.8 14-Jul-2009 nicm

For some reason when clearing status/message it was redrawing the entire client
not just the status line. Changing this also revealed the check for the status
line was incorrect when drawing the pane.


# 1.7 14-Jul-2009 nicm

Instead of faking up a status line in status_redraw, use the same code to
redraw it as to draw the entire screen, just skip all lines but the last.

This makes horizontal split redraw properly when the status line is off.


# 1.6 12-Jul-2009 nicm

Add a "back to indentation" key in copy mode to move the cursor to the first
non-whitespace character. ^ with vi and M-m with emacs key bindings. Another
from Kalle Olavi Niemitalo, thanks.


Revision tags: OPENBSD_4_6_BASE
# 1.5 26-Jun-2009 nicm

Status line fixes: don't truncate status-right now the length calculation is
done for UTF-8, limit to the maximum length correctly when printing, and always
print a space even if the left string is longer than the width available.


# 1.4 04-Jun-2009 nicm

If the prompt is hidden or a password is sent with -U, zero it before freeing
it.


# 1.3 03-Jun-2009 nicm

New session option, status-utf8, to control the interpretation of top-bit-set
characters in status-left and status-right (if on, they are treated as UTF-8;
otherwise passed through).


# 1.2 03-Jun-2009 nicm

Add a UTF-8 aware string length function and make UTF-8 in
status-left/status-right work properly. At the moment any top-bit-set
characters are assumed to be UTF-8: a status-utf8 option to configure this will
come shortly.


# 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.218 27-Jul-2020 nicm

Add a -d option to display-message to set delay, from theonekeyg at
gmail dot com in GitHub issue 2322.


# 1.217 11-Jun-2020 nicm

Fix a crash when completing sessions, from Anindya Mukherjee.


# 1.216 26-May-2020 nicm

Remove leftover debug logging and fix comparison.


# 1.215 26-May-2020 nicm

Set up UTF-8 data for ASCII keys correctly.


# 1.214 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.213 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.212 16-May-2020 nicm

Rename KEYC_ESCAPE to KEYC_META.


# 1.211 16-May-2020 nicm

Expand target from client and use it to expand the prompt.


# 1.210 16-May-2020 nicm

Support embedded styles in the display-message message, GitHub issue
2206.


# 1.209 16-May-2020 nicm

Change message log to be per server rather than per client and include
every command that is run.


# 1.208 16-May-2020 nicm

Do not hoke into struct window_pane from the tty code and instead set
everything up in tty_ctx. Provide a way to initialize the tty_ctx from a
callback and use it to let popups draw directly through input_parse in
the same way as panes do, rather than forcing a full redraw on every
change.


# 1.207 16-May-2020 nicm

Use formats for status-style and message-style.


# 1.206 16-May-2020 nicm

Complete partial window indexes properly.


# 1.205 16-May-2020 nicm

Add -W and -T flags to command-prompt to only complete a window and a
target, also complete aliases.


# 1.204 16-May-2020 nicm

Improve command prompt completion:

- Show a menu with completions if there are multiple.

- Don't complete argument stuff (options, layouts) at start of text.

- For -t and -s, if there is no : then complete sessions but if there is
a :, show a menu of all windows in the session rather than trying to
complete the window name which is a bit useless if there are
duplicates.


# 1.203 16-May-2020 nicm

Drop having a separate type for style options and make them all strings,
which allows formats to be expanded. Any styles without a '#{' are still
validated when they are set but any with a '#{' are not. Formats are not
expanded usefully in many cases yet, that will be changed later.

To make this work, a few other changes:

- set-option -a with a style option automatically appends a ",".

- OSC 10 and 11 don't set the window-style option anymore, instead the
fg and bg are stored in the pane struct and act as the defaults that
can be overridden by window-style.

- status-fg and -bg now override status-style instead of trying to keep
them in sync.


Revision tags: OPENBSD_6_7_BASE
# 1.202 12-Mar-2020 nicm

Add C-g to cancel command prompt with vi(1) keys as well as emacs, and q
in command mode.


# 1.201 27-Jan-2020 nicm

Add support for adding a note to a key binding (with bind-key -N) and
use this to add descriptions to the default key bindings. A new -N flag
to list-keys shows key bindings with notes rather than the default
bind-key command used to create them. Change the default ? binding to
use this to show a readable summary of keys.

Also extend command-prompt to return the name of the key pressed and add
a default binding (/) to show the note for the next key pressed

Suggested by Alex Tremblay in GitHub issue 2000.


Revision tags: OPENBSD_6_6_BASE
# 1.200 28-May-2019 nicm

Redraw status line if size changes, GitHub issue 1762. Also fix length
of target buffer when pasting into status line.


# 1.199 23-May-2019 nicm

Fix length calculation for pasting UTF-8 characters in the status line,
GitHub issue 1753.


# 1.198 11-May-2019 nicm

Do not reduce window height by status line height for control mode
clients, from George Nachman.


# 1.197 03-May-2019 nicm

Fix reverse attribute in status line, GitHub issue 1709.


# 1.196 26-Apr-2019 nicm

Merge hooks into options and make each one an array option. This allows
multiple commands to be easily bound to one hook. set-hook and
show-hooks remain but they are now variants of set-option and
show-options. show-options now has a -H flag to show hooks (by default
they are not shown).


# 1.195 25-Apr-2019 nicm

options_array_item_value cannot return NULL.


# 1.194 23-Apr-2019 nicm

Somehow missed these bits in last commit.


# 1.193 23-Apr-2019 nicm

Indicate an array option with a flag rather than a special type so that
in future will not have to be strings.


Revision tags: OPENBSD_6_5_BASE
# 1.192 18-Mar-2019 nicm

Extend the #[] style syntax and use that together with previous format
changes to allow the status line to be entirely configured with a single
option.

Now that it is possible to configure their content, enable the existing
code that lets the status line be multiple lines in height. The status
option can now take a value of 2, 3, 4 or 5 (as well as the previous on
or off) to configure more than one line. The new status-format array
option configures the format of each line, the default just references
the existing status-* options, although some of the more obscure status
options may be eliminated in time.

Additions to the #[] syntax are: "align" to specify alignment (left,
centre, right), "list" for the window list and "range" to configure
ranges of text for the mouse bindings.

The "align" keyword can also be used to specify alignment of entries in
tree mode and the pane status lines.


# 1.191 18-Mar-2019 nicm

Make array options a sparse tree instead of an array of char * and
remove the size limit.


# 1.190 18-Mar-2019 nicm

With force, kill previous job before starting new. Fixes problem
reported by Scott Mcdermott in GitHub issue 1627.


# 1.189 16-Mar-2019 nicm

Use a pointer for the active screen in the status line instead of
copying them around all the time.


# 1.188 16-Mar-2019 nicm

Give status_save_old the client so it can do the reinit too.


# 1.187 16-Mar-2019 nicm

Tidy and rename some bits of status line code.


# 1.186 15-Mar-2019 nicm

Move status line free into its own function.


# 1.185 14-Mar-2019 nicm

Store the time in the format tree rather than passing it around.


# 1.184 12-Mar-2019 nicm

DECRC and DECSC apparently need to preserve origin mode as well, based
on a fix from Marc Reisner.


# 1.183 09-Feb-2019 nicm

Completion of command-alias members.


# 1.182 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.181 29-Aug-2018 nicm

Keep any text killed in the command prompt with C-w and yank it with
C-y, only use the top buffer if no text has previously been killed. This
and previous change promped by discussion with kn@.


# 1.180 29-Aug-2018 nicm

Add C-Left and C-Right as aliases for M-b and M-f.


# 1.179 22-Aug-2018 nicm

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


# 1.178 20-Aug-2018 nicm

Move offset of window list into status struct.


# 1.177 19-Aug-2018 nicm

Add a client redraw-window flag instead of the redraw-all flag and for
all just use the three flags together (window, borders, status).


Revision tags: OPENBSD_6_3_BASE
# 1.176 22-Feb-2018 nicm

Remove an unused variable.


# 1.175 05-Feb-2018 nicm

Add struct status_line to hold status line members of struct client, not
used yet but will be soon. From Thomas Adam.


# 1.174 01-Jan-2018 nicm

Add C-g at command prompt for emacs people, GitHub issue 1213.


# 1.173 27-Dec-2017 nicm

Draw command prompt correctly with status line off.


# 1.172 18-Dec-2017 nicm

Remove unused variable from Thomas Adam.


# 1.171 02-Nov-2017 nicm

Add a "fast" version of screen_write_copy for tree mode that doesn't do
all the checks and selection and marking stuff needed for copy mode.


# 1.170 20-Oct-2017 nicm

Clear status line with spaces again so reverse works, spotted by sthen.


# 1.169 16-Oct-2017 nicm

Infrastructure for drawing status lines of more than one line in height,
still only one is allowed but this lets tmux draw bigger ones.


Revision tags: OPENBSD_6_2_BASE
# 1.168 29-May-2017 nicm

Add a flag to stop the prompt input being expanded.


# 1.167 29-May-2017 nicm

Store a copy of the old status line, will be needed soon for new choose mode.


# 1.166 17-May-2017 nicm

Tidy command prompt callbacks and pass in the client.


# 1.165 03-May-2017 nicm

Add a format for the last search string in copy mode and fix the prompt
so it can work when in -I, suggested by Suraj N Kurapati.


# 1.164 01-May-2017 nicm

In order that people can use formats like #D in #() in the status line
and not have to wait for an update when they change pane, we allow
commands to run more than once a second if the expanded form
changes. Unfortunately this can mean them being run far too often
(pretty much continually) when multiple clients exist, because some
formats (including #D) will always differ between clients.

To avoid this, give each client its own tree of jobs which means that
the same command will be different instances for each client - similar
to how we have the tag to separate commands for different panes.

GitHub issue 889; test case reported by Paul Johnson.


# 1.163 22-Apr-2017 nicm

Memory leak from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.162 09-Feb-2017 nicm

Break the message storage function into its own function, useful for
debugging.


# 1.161 03-Feb-2017 nicm

Cache status line position to reduce option lookups during output.


# 1.160 03-Feb-2017 nicm

Add a window or pane id "tag" to each format tree and use it to separate
jobs, this means that if the same job is used for different windows or
panes (for example in pane-border-format), it will be run separately for
each pane.


# 1.159 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.158 06-Jan-2017 nicm

Incremental search in copy mode (on for emacs keys by default) - much
the same as normal searching but updates the cursor position and marked
search terms as you type. C-r and C-s in the prompt repeat the search,
once finished searching (with Enter), N and n work as before.


# 1.157 05-Jan-2017 nicm

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


# 1.156 07-Dec-2016 nicm

Do not clear the prompt when a message is shown, just leave it around and
return to it when the message is finished.


# 1.155 12-Oct-2016 nicm

Drop the edit mode key tables and just use fixed key bindings for the
command prompt.


# 1.154 12-Oct-2016 nicm

The repeat prompt in both emacs and vi (and the old one in tmux) doesn't
support line editing and instead executes a command as soon as a
non-number key is pressed. Add a -N flag to command-prompt for the same
in copy mode. Reported by Theo Buehler.


# 1.153 11-Oct-2016 nicm

Fundamental change to how copy mode key bindings work:

The vi-copy and emacs-copy mode key tables are gone, and instead copy
mode commands are bound in one of two normal key tables ("copy-mode" or
"copy-mode-vi"). Keys are bound to "send-keys -X copy-mode-command". So:

bind -temacs-copy C-Up scroll-up
bind -temacs-copy -R5 WheelUpPane scroll-up

Becomes:

bind -Tcopy-mode C-Up send -X scroll-up
bind -Tcopy-mode WheelUpPane send -N5 -X scroll-up

This allows the full command parser and command set to be used - for
example, we can use the normal command prompt for searching, jumping,
and so on instead of a custom one:

bind -Tcopy-mode C-r command-prompt -p'search up' "send -X search-backward '%%'"

command-prompt also gets a -1 option to only require on key press, which
is needed for jumping.

The plan is to get rid of mode keys entirely, so more to come eventually.


# 1.152 11-Oct-2016 nicm

Support UTF-8 entry into the command prompt.


# 1.151 10-Oct-2016 nicm

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


# 1.150 12-Sep-2016 nicm

Allow repeat count to be specified in mode key tables with bind-key -R,
and set the default repeat count to 5 for WheelUp and WheelDown in
copy-mode.


Revision tags: OPENBSD_6_0_BASE
# 1.149 06-Jun-2016 nicm

Allow #[] in window-status-separator.


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

I no longer use my SourceForge address so replace it.


# 1.147 01-Jan-2016 nicm

Don't rely on a calculation wrapping when applying message-limit, and
break out of the loop early. From Nicolas Viennot.


# 1.146 11-Dec-2015 nicm

Style nits and line wrapping of function declarations.


# 1.145 11-Dec-2015 nicm

Add cmdq as an argument to format_create and add a format for the
command name (will also be used for more later).


# 1.144 08-Dec-2015 nicm

Remove format_create_flags and just pass flags to format_create.


# 1.143 22-Nov-2015 tim

If display-time is set to 0, show status messages until a key is pressed;
OK nicm@


# 1.142 20-Nov-2015 nicm

Instead of separate tables for different types of options, give each
option a scope type (server, session, window) in one table.


# 1.141 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.140 13-Nov-2015 nicm

Long overdue change to the way we store cells in the grid: now, instead
of storing a full grid_cell with UTF-8 data and everything, store a new
type grid_cell_entry. This can either be the cell itself (for ASCII
cells), or an offset into an extended array (per line) for UTF-8
data.

This avoid a large (8 byte) overhead on non-UTF-8 cells (by far the
majority for most users) without the complexity of the shadow array we
had before. Grid memory without any UTF-8 is about half.

The disadvantage that cells can no longer be modified in place and need
to be copied out of the grid and back but it turned out to be lot less
complicated than I expected.


# 1.139 12-Nov-2015 nicm

Nuke the utf8 and status-utf8 options and make tmux only a UTF-8
terminal. We still support non-UTF-8 terminals outside tmux, but inside
it is always UTF-8 (as when the utf8 and status-utf8 options were on).


# 1.138 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.137 27-Oct-2015 nicm

Move struct options into options.c.


# 1.136 20-Oct-2015 nicm

Use client pointer not file descriptor in logging.


# 1.135 14-Sep-2015 nicm

Make refresh-client force update of jobs, from Sina Siadat.


# 1.134 29-Aug-2015 nicm

Move struct paste_buffer out of tmux.h.


# 1.133 28-Aug-2015 nicm

Run status update on a per-client timer at status-interval.


Revision tags: OPENBSD_5_8_BASE
# 1.132 29-Jul-2015 nicm

status_out and associated data structures are no longer used.


# 1.131 28-Jul-2015 nicm

Tidy up the way terminals are described and move some structs out of tmux.h.


# 1.130 20-Jul-2015 nicm

Add an option (history-file) for a file to save/restore command prompt
history, from Olof-Joachim Frahm.


# 1.129 27-May-2015 nicm

Move the jobs output cache into the formats code so that #() work more
generally (for example, again working in set-titles-string).


# 1.128 06-May-2015 nicm

Remove ARRAY_* from history and expand completion to complete a) layout
names and b) targets beginning with -t or -s.


# 1.127 25-Apr-2015 nicm

Make message log a TAILQ.


# 1.126 24-Apr-2015 nicm

Set working directory for run-shell and if-shell.


# 1.125 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_7_BASE
# 1.124 06-Feb-2015 nicm

Use the same time for both calls to format_expand_time.


# 1.123 06-Feb-2015 nicm

status_replace can now become local to status.c and it no longer needs
the jobsflag argument. While here there is no need to repeat work that
format_defaults already does.


# 1.122 06-Feb-2015 nicm

Add format_expand_time and use it instead of status_replace where
command execution is not needed.


# 1.121 05-Feb-2015 nicm

Wrap all the individual format_* calls in a single format_defaults
functions.


# 1.120 01-Feb-2015 nicm

Remove two unused arguments from status_replace.


# 1.119 20-Jan-2015 sthen

typo in comment ;) ok nicm


# 1.118 05-Nov-2014 nicm

Do not put a space between status-left/status-right and the window list,
instead move the space into the defaults for the options (so status-left
now defaults to "[#S] ". From Balazs Kezes.


# 1.117 20-Oct-2014 nicm

Better format for printf format attributes.


# 1.116 08-Oct-2014 nicm

Add xreallocarray and remove nmemb argument from xrealloc.


# 1.115 02-Oct-2014 nicm

Take account of window-status-separator when checking window position,
based on diff from Balazs Kezes.


Revision tags: OPENBSD_5_6_BASE
# 1.114 24-Apr-2014 nicm

There is no longer a need for a paste_stack struct or for global_buffers
to be global. Move to paste.c.


# 1.113 17-Apr-2014 nicm

Remove the monitor-content option and associated bits and bobs. It's
never worked very well. If there is a big demand for it to return, will
consider better ways to do it.


# 1.112 02-Apr-2014 nicm

Do not replace ## with # in status_replace1 because it'll be done later
by the format code.


# 1.111 31-Mar-2014 nicm

Make message-limit a server option.


Revision tags: OPENBSD_5_5_BASE
# 1.110 14-Feb-2014 nicm

Style nit - no space between function name and bracket.


# 1.109 14-Feb-2014 nicm

Check for NULL session and whatnot in status_replace, from Thomas Adam.


# 1.108 28-Jan-2014 nicm

Allow replacing each of the many sets of separate foo-{fg,bg,attr}
options with a single foo-style option. For example:

set -g status-fg yellow
set -g status-bg red
set -g status-attr blink

Becomes:

set -g status-style fg=yellow,bg=red,blink

The -a flag to set can be used to add to rather than replace a style. So:

set -g status-bg red

Becomes:

set -ag status-style bg=red

Currently this is fully backwards compatible (all *-{fg,bg,attr} options
remain) but the plan is to deprecate them over time.

From Tiago Cunha.


Revision tags: OPENBSD_5_4_BASE
# 1.107 05-Jul-2013 nicm

Whitespace nits, from Ben Boeckel.


# 1.106 05-Jul-2013 nicm

Act like vi(1) when moving words, from Ben Boeckel.


# 1.105 05-Jul-2013 nicm

Implement s, S, C mode switch commands in vi(1) mode, from Ben Boeckel.


# 1.104 31-May-2013 nicm

Demote the old single-character replacement variables (#S and friends)
to aliases of formats. From Tiago Cunha.


# 1.103 25-Mar-2013 nicm

Extend jobs to support writing and use that for copy-pipe instead of
popen, from Chris Johnsen.


# 1.102 22-Mar-2013 nicm

evbuffer_readline returns allocated storage, don't leak it.


# 1.101 22-Mar-2013 nicm

Add copy-pipe mode command to copy selection and also pipe to a command.


# 1.100 22-Mar-2013 nicm

No more lint means no more ARGSUSED.


# 1.99 21-Mar-2013 nicm

Aargh. Spaces -> tabs.


# 1.98 21-Mar-2013 nicm

Do not leak formats in status_replace.


# 1.97 21-Mar-2013 nicm

Add a format client_prefix which is 1 if prefix key has been
pressed, used for example #{?client_prefix,X,Y}. Also a few extra
server_client_status needed.


# 1.96 21-Mar-2013 nicm

Allow formats in status options.


Revision tags: OPENBSD_5_3_BASE
# 1.95 27-Nov-2012 nicm

Add window-status-last-* options, from Boris Faure.


Revision tags: OPENBSD_5_2_BASE
# 1.94 10-Jul-2012 nicm

xfree is not particularly helpful, remove it. From Thomas Adam.


# 1.93 09-Jul-2012 nicm

Move a NULL check inside a function, from Tiago Cunha.


# 1.92 29-Apr-2012 nicm

Use int not u_char for colours from options since they may have bit 8
set to mark them as 256-colour. Reported by Chris Johnson.


# 1.91 23-Apr-2012 nicm

Add window-status-separator option, from Thomas Adam.


# 1.90 17-Mar-2012 nicm

Check event_initialized before event_del if event may not have been set
up; libevent2 complains about this. Reported by Moriyoshi Koizumi.


# 1.89 04-Mar-2012 nicm

Add A and I keys for vi status line editing.


# 1.88 03-Mar-2012 nicm

The wlmouse offset should be part of the client, not the server. From
Ailin Nemui.


Revision tags: OPENBSD_5_1_BASE
# 1.87 29-Jan-2012 nicm

Add an option to move the status line to the top of the screen,
requested by many.


# 1.86 26-Jan-2012 nicm

Terminate strftime buffer properly even if a really long format string
is given, from Tiago Cunha.


# 1.85 26-Jan-2012 nicm

Fix memory leak in error path, from Tiago Cunha.


# 1.84 20-Jan-2012 nicm

Add some trivial additional status line attributes from jwcxz at users
dot sourceforge dot net.


# 1.83 20-Jan-2012 nicm

Add space movement keys for vi mode in the status line from Ben Boeckel.


# 1.82 01-Dec-2011 nicm

Make M-f and M-b work the same at the command prompt as in copy mode,
pointed out by Romain Francoise.


# 1.81 15-Nov-2011 nicm

Add word movement and editing command for command prompt editing, from
Ben Boeckel.


# 1.80 15-Nov-2011 nicm

Make window_pane_index work the same as window_index, from Ben Boeckel.


# 1.79 05-Nov-2011 nicm

Option to change status line (message) background when using vi keys and
in command mode. From Ben Boeckel.


# 1.78 20-Aug-2011 nicm

Fix a couple of memory leaks, from marcel partap.


Revision tags: OPENBSD_5_0_BASE
# 1.77 08-Jul-2011 nicm

Make confirm-before prompt customizable with -p option like
command-prompt. Also move responsibility for calling status_replace into
status_prompt_{set,update} and add #W and #P to the default kill-window
and kill-pane prompts. By Tiago Cunha.


# 1.76 02-Jul-2011 nicm

Allow the initial context on prompts to be set with the new -I option to
command-prompt. From Tiago Cunha.


# 1.75 29-Apr-2011 nicm

Only redraw the status line on command update, not the entire client
(big DOH).


# 1.74 24-Apr-2011 nicm

Provide #h for short hostname (no domain) from Michal Mazurek.


# 1.73 18-Apr-2011 nicm

Add an option (mouse-select-window) which allows the mouse to be used by
clicking on the status line, written by hsim at gmx dot li.


# 1.72 29-Mar-2011 nicm

Change -t on display-message to be target-pane for the #[A-Z]
replacements and add -c as target-client.


Revision tags: OPENBSD_4_9_BASE
# 1.71 26-Jan-2011 nicm

Simplify the way jobs work and drop the persist type, so all jobs are
fire-and-forget.

Status jobs now managed with two trees of output (new and old), rather
than storing the output in the jobs themselves. When the status line is
processed any jobs which don't appear in the new tree are started and
the output from the old tree displayed. When a job finishes it updates
the new tree with its output and that is used for any subsequent
redraws. When the status interval expires, the new tree is moved to the
old so that all jobs are run again.

This fixes the "#(echo %H:%M:%S)" problem which would lead to thousands
of identical persistent jobs and high memory use (this can still be
achieved by adding "sleep 30" but that is much less likely to happen by
accident).


# 1.70 03-Jan-2011 nicm

Handle a # at the end of a replacement string (such as status-left)
correctly. Found by Thomas Adam.


# 1.69 01-Jan-2011 nicm

Move the user-visible parts of all options (names, types, limit, default
values) together into one set of tables in options-table.c. Also clean
up and simplify cmd-set-options.c and move a common print function into
option-table.c.


# 1.68 30-Dec-2010 nicm

Change from a per-session stack of buffers to one global stack which is
much more convenient and also simplifies lot of code. This renders
copy-buffer useless and makes buffer-limit now a server option.

By Tiago Cunha.


# 1.67 30-Dec-2010 nicm

Add a function to create window flags rather than doing the same thing
in two places. From Thomas Adam.


# 1.66 11-Dec-2010 nicm

Oops, these functions return a const char *, so make the local variable
const as well.


# 1.65 11-Dec-2010 nicm

Make the prompt history global for all clients which is much more useful than per-client history.


# 1.64 06-Dec-2010 nicm

Add an option to alert (monitor) for silence (lack of activity) in a
window. From Thomas Adam.


Revision tags: OPENBSD_4_8_BASE
# 1.63 21-Jun-2010 nicm

Having a list of winlinks->alerts for each session is stupid, just store
the alert flags directly in the winlink itself.


# 1.62 14-May-2010 nicm

Colour+attribute options for status line alerts, from Alex Alexander.


# 1.61 31-Mar-2010 nicm

Don't accept keys with modifiers as input. Fixes crash reported by Brian
R Landy.


# 1.60 27-Mar-2010 nicm

Don't leak job command in #().


# 1.59 22-Mar-2010 nicm

Dead functions, lint.


Revision tags: OPENBSD_4_7_BASE
# 1.58 27-Jan-2010 nicm

Calculate offset correctly, fixes incorrect offset and prevents crash when
status-left is empty. From Micah Cowan.


# 1.57 26-Jan-2010 nicm

Actually use the copy made when no newline is found, from martynas@.


# 1.56 14-Dec-2009 nicm

Add server options to completion as well.


# 1.55 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.54 03-Dec-2009 nicm

Eliminate duplicate code and ease the passage for server-wide options by adding
a -w flag to set-option and show-options and making setw and showw aliases to
set -w and show -w.

Note: setw and showw are still there, but now aliases for set -w and show -w.


# 1.53 26-Nov-2009 nicm

Tidy up various bits of the paste code, make the data buffer char * and add
comments.


# 1.52 26-Nov-2009 nicm

Remove a couple of unused arguments where possible, and add /* ARGSUSED */ to
the rest to reduce lint output.


# 1.51 20-Nov-2009 nicm

Display UTF-8 properly in status line messages and prompt. Cursor handling is
still way off though.


# 1.50 20-Nov-2009 nicm

Remove oldest messages from log when limit is hit, not newest.


# 1.49 19-Nov-2009 nicm

Get some brackets in the right place so ## works. Also fix a space in a
comment.


# 1.48 19-Nov-2009 nicm

Change status line drawing to create the window list in a separate screen and
then copy it into the status line screen. This allows UTF-8 in window names and
fixes some problems with #[] in window-status-format.


# 1.47 19-Nov-2009 nicm

Two new options, window-status-format and window-status-current-format, which
allow the format of each window in the status line window list to be controlled
using similar # sequences as status-left/right.

This diff also moves part of the way towards UTF-8 support in window names but
it isn't quite there yet.


# 1.46 19-Nov-2009 nicm

Tidy up by breaking the # replacement code into a separate function, also add a
few comments.


# 1.45 19-Nov-2009 nicm

Don't interpret #() for display-message, it usually doesn't make sense and may
leak commands.


# 1.44 18-Nov-2009 nicm

Add a per-client log of status line messages displayed while that client
exists. A new message-limit session option sets the maximum number of entries
and a command, show-messages, shows the log (bound to ~ by default).

This (and prompt history) might be better as a single global log but until
there are global options it is easier for them to be per client.


# 1.43 17-Nov-2009 nicm

Permit top-bit-set characters to be entered in the status line. They could
already be set from the shell and are just passed through when printing (so
invisible characters or displaying on terminals with different character sets
may cause problems).

Note that entering UTF-8 may not work and in any case currently the status line
cannot display it correctly (outside of status-left/status-right).


# 1.42 04-Nov-2009 nicm

Use timeout events for the identify and message timers.


# 1.41 04-Nov-2009 nicm

Switch jobs over to use a bufferevent.


# 1.40 04-Nov-2009 nicm

Unused (but assigned to) variable, found by lint.


# 1.39 01-Nov-2009 nicm

Add a flag for jobs that shouldn't be freed after they've died and use it for
status jobs, then only kill those jobs when status-left, status-right or
set-titles-string is changed.

Fixes problems with changing options from inside #().


# 1.38 10-Oct-2009 nicm

Rather than running status-left, status-right and window title #() with popen
immediately every redraw, queue them up and run them in the background,
starting each once every status-interval. The actual status line uses the
output from the last run.

This brings several advantages:

- tmux itself may be called from inside #() without causing the server to hang;
- likewise, sleep or similar doesn't cause the server to block;
- commands aren't run excessively often when redrawing;
- commands shared by status-left and status-right, or used multiple times, will
only be run once.

run-shell and if-shell still use system()/popen() but will be changed over to
use this too later.


# 1.37 10-Oct-2009 nicm

Add "grouped sessions" which have independent name, options, current window and
so on but where the linked windows are synchronized (ie creating, killing
windows and so on are mirrored between the sessions). A grouped session may be
created by passing -t to new-session.

Had this around for a while, tested by a couple of people.


# 1.36 23-Sep-2009 nicm

Remove PROMPT_HIDDEN code which is now unused.


# 1.35 23-Sep-2009 nicm

Remove the internal tmux locking and instead detach each client and run the
command specified by a new option "lock-command" (by default "lock -np") in
each client.

This means each terminal has to be unlocked individually but simplifies the
code and allows the system password to be used to unlock.

Note that the set-password command is gone, so it will need to be removed from
configuration files, and the -U command line flag has been removed.

This is the third protocol version change so again it is best to stop the tmux
server before upgrading.


# 1.34 20-Sep-2009 nicm

Regularise some fatal messages.


# 1.33 10-Sep-2009 nicm

Permit options such as status-bg to be configured using the entire 256 colour
palette by setting "colour0" to "colour255".


# 1.32 07-Sep-2009 nicm

Give each paste buffer a size member instead of requiring them to be
zero-terminated.


# 1.31 07-Sep-2009 nicm

Permit embedded colour and attributes in status-left and status-right using new
#[] special characters, for example #[fg=red,bg=blue,blink].


# 1.30 02-Sep-2009 nicm

Add a transpose-chars command in edit mode (C-t in emacs mode only). From Kalle
Olavi Niemitalo.


# 1.29 01-Sep-2009 nicm

Use "Password:" with no space for password prompts and don't display a *s for
the password, like pretty much everything else. From martynas@ with minor
tweaks by me.


# 1.28 31-Aug-2009 nicm

Add a new display-panes command, with two options (display-panes-colour and
display-panes-time), which displays a visual indication of the number of each
pane.


# 1.27 19-Aug-2009 nicm

Extend command-prompt with a -p option which is a comma-separated list of one
or more prompts to present in order.

The responses to the prompt are replaced in the template string: %% are
replaced in order, so the first prompt replaces the first %%, the second
replaces the second, and so on. In addition, %1 up to %9 are replaced with the
responses to the first the ninth prompts

The default template is "%1" so the response to the first prompt is processed
as a command.

Note that this changes the behaviour for %% so if there is only one prompt,
only the first %% will be replaced. Templates such as "neww -n '%%' 'ssh %%'"
should be changed to "neww -n '%1' 'ssh %1'".

From Tiago Cunha.


# 1.26 18-Aug-2009 nicm

Add a "delete line" key when editing in the status line or the search up/down
prompt. C-u with emacs keys, d with vi.


# 1.25 13-Aug-2009 nicm

Switch the prompt code to return an empty string when the user enters no
response and reserve NULL for an explicit cancel. Change all callbacks to treat
them the same so no functional change.

Also add cancel key bindings to emacs mode which were missing.


# 1.24 08-Aug-2009 nicm

Options to set the colours and attributes for status-left/-right. From Thomas
Adam, thanks.


# 1.23 05-Aug-2009 nicm

If colours are not supported by the terminal, try to emulate a coloured
background by setting or clearing the reverse attribute.

This makes a few applications which don't use the reverse attribute themselves
a little happier, and allows the status, message and mode options to have
default attributes and fg/bg options that work as expected when set as reverse.


# 1.22 30-Jul-2009 nicm

Plug some memory leaks.


# 1.21 28-Jul-2009 nicm

Next step towards customisable mode keys: build each default table of keys into
a named tree on start and use that for lookups. Also add command to string
translation tables and modify list-keys to show the the mode key bindings (new
-t argument).


# 1.20 27-Jul-2009 nicm

Change mode key bindings from big switches into a set of tables. Rather than
lumping them all together, split editing keys from those used in choice/more
mode and those for copy/scroll mode.

Tidier and clearer, and the first step towards customisable mode keys.


# 1.19 27-Jul-2009 nicm

Get rid of empty mode_key_free function.


# 1.18 27-Jul-2009 nicm

Add a key to delete to end of line at the prompt (^K in emacs mode, C/D in vi).

From Kalle Olavi Niemitalo.


# 1.17 26-Jul-2009 nicm

Calculate the space available for the prompt buffer and the cursor position
correctly, and make it work when the screen is not wide enough.

Noticed by Kalle Olavi Niemitalo.


# 1.16 21-Jul-2009 nicm

Remove a couple of unused functions and fix a type ("FALLTHOUGH"), found by
lint.


# 1.15 20-Jul-2009 nicm

Add a status-justify option to allow the window list in the status line to be
positioned at the left, centre, or right.


# 1.14 20-Jul-2009 nicm

New options, window-status-current-{fg,bg,attr}, to set the fg, bg and
attributes with which the current window is shown in the status line. From
Johan Friis, thanks.


# 1.13 17-Jul-2009 nicm

- New command display-message (alias display) to display a message in the
status line (bound to "i" and displays the current window and time by
default). The same substitutions are applied as for status-left/right.
- Add support for including the window index (#I), pane index (#P) and window
name (#W) in the message, and status-left or status-right.
- Bump protocol version.

From Tiago Cunha, thanks!


# 1.12 17-Jul-2009 nicm

Memory could be leaked if a second prompt or message appeared while another was
still present, so add a separate prompt free callback and make the _clear
function responsible for calling it if necessary (rather than the individual
prompt callbacks). Also make both messages and prompts clear any existing when
a new is set.

In addition, the screen could be modified while the prompt is there, restore
the redraw-entire-screen behaviour on prompt clear; add a comment as a
reminder.


# 1.11 16-Jul-2009 nicm

Remove some duplicate code that was causing the status line to be redrawn even
when it hadn't changed.


# 1.10 15-Jul-2009 nicm

Make status_message_set a variadic printf-like function. No functional change -
helpful for a couple of things coming soon.


# 1.9 15-Jul-2009 nicm

Having to update NSETOPTION/NSETWINDOWOPTION when adding new options is a bit
annoying and it is only use for iterating, so use a sentinel to mark the end of
each array instead. Different fix for a problem pointed out by Kalle Olavi
Niemitalo.


# 1.8 14-Jul-2009 nicm

For some reason when clearing status/message it was redrawing the entire client
not just the status line. Changing this also revealed the check for the status
line was incorrect when drawing the pane.


# 1.7 14-Jul-2009 nicm

Instead of faking up a status line in status_redraw, use the same code to
redraw it as to draw the entire screen, just skip all lines but the last.

This makes horizontal split redraw properly when the status line is off.


# 1.6 12-Jul-2009 nicm

Add a "back to indentation" key in copy mode to move the cursor to the first
non-whitespace character. ^ with vi and M-m with emacs key bindings. Another
from Kalle Olavi Niemitalo, thanks.


Revision tags: OPENBSD_4_6_BASE
# 1.5 26-Jun-2009 nicm

Status line fixes: don't truncate status-right now the length calculation is
done for UTF-8, limit to the maximum length correctly when printing, and always
print a space even if the left string is longer than the width available.


# 1.4 04-Jun-2009 nicm

If the prompt is hidden or a password is sent with -U, zero it before freeing
it.


# 1.3 03-Jun-2009 nicm

New session option, status-utf8, to control the interpretation of top-bit-set
characters in status-left and status-right (if on, they are treated as UTF-8;
otherwise passed through).


# 1.2 03-Jun-2009 nicm

Add a UTF-8 aware string length function and make UTF-8 in
status-left/status-right work properly. At the moment any top-bit-set
characters are assumed to be UTF-8: a status-utf8 option to configure this will
come shortly.


# 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.217 11-Jun-2020 nicm

Fix a crash when completing sessions, from Anindya Mukherjee.


# 1.216 26-May-2020 nicm

Remove leftover debug logging and fix comparison.


# 1.215 26-May-2020 nicm

Set up UTF-8 data for ASCII keys correctly.


# 1.214 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.213 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.212 16-May-2020 nicm

Rename KEYC_ESCAPE to KEYC_META.


# 1.211 16-May-2020 nicm

Expand target from client and use it to expand the prompt.


# 1.210 16-May-2020 nicm

Support embedded styles in the display-message message, GitHub issue
2206.


# 1.209 16-May-2020 nicm

Change message log to be per server rather than per client and include
every command that is run.


# 1.208 16-May-2020 nicm

Do not hoke into struct window_pane from the tty code and instead set
everything up in tty_ctx. Provide a way to initialize the tty_ctx from a
callback and use it to let popups draw directly through input_parse in
the same way as panes do, rather than forcing a full redraw on every
change.


# 1.207 16-May-2020 nicm

Use formats for status-style and message-style.


# 1.206 16-May-2020 nicm

Complete partial window indexes properly.


# 1.205 16-May-2020 nicm

Add -W and -T flags to command-prompt to only complete a window and a
target, also complete aliases.


# 1.204 16-May-2020 nicm

Improve command prompt completion:

- Show a menu with completions if there are multiple.

- Don't complete argument stuff (options, layouts) at start of text.

- For -t and -s, if there is no : then complete sessions but if there is
a :, show a menu of all windows in the session rather than trying to
complete the window name which is a bit useless if there are
duplicates.


# 1.203 16-May-2020 nicm

Drop having a separate type for style options and make them all strings,
which allows formats to be expanded. Any styles without a '#{' are still
validated when they are set but any with a '#{' are not. Formats are not
expanded usefully in many cases yet, that will be changed later.

To make this work, a few other changes:

- set-option -a with a style option automatically appends a ",".

- OSC 10 and 11 don't set the window-style option anymore, instead the
fg and bg are stored in the pane struct and act as the defaults that
can be overridden by window-style.

- status-fg and -bg now override status-style instead of trying to keep
them in sync.


Revision tags: OPENBSD_6_7_BASE
# 1.202 12-Mar-2020 nicm

Add C-g to cancel command prompt with vi(1) keys as well as emacs, and q
in command mode.


# 1.201 27-Jan-2020 nicm

Add support for adding a note to a key binding (with bind-key -N) and
use this to add descriptions to the default key bindings. A new -N flag
to list-keys shows key bindings with notes rather than the default
bind-key command used to create them. Change the default ? binding to
use this to show a readable summary of keys.

Also extend command-prompt to return the name of the key pressed and add
a default binding (/) to show the note for the next key pressed

Suggested by Alex Tremblay in GitHub issue 2000.


Revision tags: OPENBSD_6_6_BASE
# 1.200 28-May-2019 nicm

Redraw status line if size changes, GitHub issue 1762. Also fix length
of target buffer when pasting into status line.


# 1.199 23-May-2019 nicm

Fix length calculation for pasting UTF-8 characters in the status line,
GitHub issue 1753.


# 1.198 11-May-2019 nicm

Do not reduce window height by status line height for control mode
clients, from George Nachman.


# 1.197 03-May-2019 nicm

Fix reverse attribute in status line, GitHub issue 1709.


# 1.196 26-Apr-2019 nicm

Merge hooks into options and make each one an array option. This allows
multiple commands to be easily bound to one hook. set-hook and
show-hooks remain but they are now variants of set-option and
show-options. show-options now has a -H flag to show hooks (by default
they are not shown).


# 1.195 25-Apr-2019 nicm

options_array_item_value cannot return NULL.


# 1.194 23-Apr-2019 nicm

Somehow missed these bits in last commit.


# 1.193 23-Apr-2019 nicm

Indicate an array option with a flag rather than a special type so that
in future will not have to be strings.


Revision tags: OPENBSD_6_5_BASE
# 1.192 18-Mar-2019 nicm

Extend the #[] style syntax and use that together with previous format
changes to allow the status line to be entirely configured with a single
option.

Now that it is possible to configure their content, enable the existing
code that lets the status line be multiple lines in height. The status
option can now take a value of 2, 3, 4 or 5 (as well as the previous on
or off) to configure more than one line. The new status-format array
option configures the format of each line, the default just references
the existing status-* options, although some of the more obscure status
options may be eliminated in time.

Additions to the #[] syntax are: "align" to specify alignment (left,
centre, right), "list" for the window list and "range" to configure
ranges of text for the mouse bindings.

The "align" keyword can also be used to specify alignment of entries in
tree mode and the pane status lines.


# 1.191 18-Mar-2019 nicm

Make array options a sparse tree instead of an array of char * and
remove the size limit.


# 1.190 18-Mar-2019 nicm

With force, kill previous job before starting new. Fixes problem
reported by Scott Mcdermott in GitHub issue 1627.


# 1.189 16-Mar-2019 nicm

Use a pointer for the active screen in the status line instead of
copying them around all the time.


# 1.188 16-Mar-2019 nicm

Give status_save_old the client so it can do the reinit too.


# 1.187 16-Mar-2019 nicm

Tidy and rename some bits of status line code.


# 1.186 15-Mar-2019 nicm

Move status line free into its own function.


# 1.185 14-Mar-2019 nicm

Store the time in the format tree rather than passing it around.


# 1.184 12-Mar-2019 nicm

DECRC and DECSC apparently need to preserve origin mode as well, based
on a fix from Marc Reisner.


# 1.183 09-Feb-2019 nicm

Completion of command-alias members.


# 1.182 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.181 29-Aug-2018 nicm

Keep any text killed in the command prompt with C-w and yank it with
C-y, only use the top buffer if no text has previously been killed. This
and previous change promped by discussion with kn@.


# 1.180 29-Aug-2018 nicm

Add C-Left and C-Right as aliases for M-b and M-f.


# 1.179 22-Aug-2018 nicm

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


# 1.178 20-Aug-2018 nicm

Move offset of window list into status struct.


# 1.177 19-Aug-2018 nicm

Add a client redraw-window flag instead of the redraw-all flag and for
all just use the three flags together (window, borders, status).


Revision tags: OPENBSD_6_3_BASE
# 1.176 22-Feb-2018 nicm

Remove an unused variable.


# 1.175 05-Feb-2018 nicm

Add struct status_line to hold status line members of struct client, not
used yet but will be soon. From Thomas Adam.


# 1.174 01-Jan-2018 nicm

Add C-g at command prompt for emacs people, GitHub issue 1213.


# 1.173 27-Dec-2017 nicm

Draw command prompt correctly with status line off.


# 1.172 18-Dec-2017 nicm

Remove unused variable from Thomas Adam.


# 1.171 02-Nov-2017 nicm

Add a "fast" version of screen_write_copy for tree mode that doesn't do
all the checks and selection and marking stuff needed for copy mode.


# 1.170 20-Oct-2017 nicm

Clear status line with spaces again so reverse works, spotted by sthen.


# 1.169 16-Oct-2017 nicm

Infrastructure for drawing status lines of more than one line in height,
still only one is allowed but this lets tmux draw bigger ones.


Revision tags: OPENBSD_6_2_BASE
# 1.168 29-May-2017 nicm

Add a flag to stop the prompt input being expanded.


# 1.167 29-May-2017 nicm

Store a copy of the old status line, will be needed soon for new choose mode.


# 1.166 17-May-2017 nicm

Tidy command prompt callbacks and pass in the client.


# 1.165 03-May-2017 nicm

Add a format for the last search string in copy mode and fix the prompt
so it can work when in -I, suggested by Suraj N Kurapati.


# 1.164 01-May-2017 nicm

In order that people can use formats like #D in #() in the status line
and not have to wait for an update when they change pane, we allow
commands to run more than once a second if the expanded form
changes. Unfortunately this can mean them being run far too often
(pretty much continually) when multiple clients exist, because some
formats (including #D) will always differ between clients.

To avoid this, give each client its own tree of jobs which means that
the same command will be different instances for each client - similar
to how we have the tag to separate commands for different panes.

GitHub issue 889; test case reported by Paul Johnson.


# 1.163 22-Apr-2017 nicm

Memory leak from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.162 09-Feb-2017 nicm

Break the message storage function into its own function, useful for
debugging.


# 1.161 03-Feb-2017 nicm

Cache status line position to reduce option lookups during output.


# 1.160 03-Feb-2017 nicm

Add a window or pane id "tag" to each format tree and use it to separate
jobs, this means that if the same job is used for different windows or
panes (for example in pane-border-format), it will be run separately for
each pane.


# 1.159 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.158 06-Jan-2017 nicm

Incremental search in copy mode (on for emacs keys by default) - much
the same as normal searching but updates the cursor position and marked
search terms as you type. C-r and C-s in the prompt repeat the search,
once finished searching (with Enter), N and n work as before.


# 1.157 05-Jan-2017 nicm

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


# 1.156 07-Dec-2016 nicm

Do not clear the prompt when a message is shown, just leave it around and
return to it when the message is finished.


# 1.155 12-Oct-2016 nicm

Drop the edit mode key tables and just use fixed key bindings for the
command prompt.


# 1.154 12-Oct-2016 nicm

The repeat prompt in both emacs and vi (and the old one in tmux) doesn't
support line editing and instead executes a command as soon as a
non-number key is pressed. Add a -N flag to command-prompt for the same
in copy mode. Reported by Theo Buehler.


# 1.153 11-Oct-2016 nicm

Fundamental change to how copy mode key bindings work:

The vi-copy and emacs-copy mode key tables are gone, and instead copy
mode commands are bound in one of two normal key tables ("copy-mode" or
"copy-mode-vi"). Keys are bound to "send-keys -X copy-mode-command". So:

bind -temacs-copy C-Up scroll-up
bind -temacs-copy -R5 WheelUpPane scroll-up

Becomes:

bind -Tcopy-mode C-Up send -X scroll-up
bind -Tcopy-mode WheelUpPane send -N5 -X scroll-up

This allows the full command parser and command set to be used - for
example, we can use the normal command prompt for searching, jumping,
and so on instead of a custom one:

bind -Tcopy-mode C-r command-prompt -p'search up' "send -X search-backward '%%'"

command-prompt also gets a -1 option to only require on key press, which
is needed for jumping.

The plan is to get rid of mode keys entirely, so more to come eventually.


# 1.152 11-Oct-2016 nicm

Support UTF-8 entry into the command prompt.


# 1.151 10-Oct-2016 nicm

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


# 1.150 12-Sep-2016 nicm

Allow repeat count to be specified in mode key tables with bind-key -R,
and set the default repeat count to 5 for WheelUp and WheelDown in
copy-mode.


Revision tags: OPENBSD_6_0_BASE
# 1.149 06-Jun-2016 nicm

Allow #[] in window-status-separator.


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

I no longer use my SourceForge address so replace it.


# 1.147 01-Jan-2016 nicm

Don't rely on a calculation wrapping when applying message-limit, and
break out of the loop early. From Nicolas Viennot.


# 1.146 11-Dec-2015 nicm

Style nits and line wrapping of function declarations.


# 1.145 11-Dec-2015 nicm

Add cmdq as an argument to format_create and add a format for the
command name (will also be used for more later).


# 1.144 08-Dec-2015 nicm

Remove format_create_flags and just pass flags to format_create.


# 1.143 22-Nov-2015 tim

If display-time is set to 0, show status messages until a key is pressed;
OK nicm@


# 1.142 20-Nov-2015 nicm

Instead of separate tables for different types of options, give each
option a scope type (server, session, window) in one table.


# 1.141 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.140 13-Nov-2015 nicm

Long overdue change to the way we store cells in the grid: now, instead
of storing a full grid_cell with UTF-8 data and everything, store a new
type grid_cell_entry. This can either be the cell itself (for ASCII
cells), or an offset into an extended array (per line) for UTF-8
data.

This avoid a large (8 byte) overhead on non-UTF-8 cells (by far the
majority for most users) without the complexity of the shadow array we
had before. Grid memory without any UTF-8 is about half.

The disadvantage that cells can no longer be modified in place and need
to be copied out of the grid and back but it turned out to be lot less
complicated than I expected.


# 1.139 12-Nov-2015 nicm

Nuke the utf8 and status-utf8 options and make tmux only a UTF-8
terminal. We still support non-UTF-8 terminals outside tmux, but inside
it is always UTF-8 (as when the utf8 and status-utf8 options were on).


# 1.138 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.137 27-Oct-2015 nicm

Move struct options into options.c.


# 1.136 20-Oct-2015 nicm

Use client pointer not file descriptor in logging.


# 1.135 14-Sep-2015 nicm

Make refresh-client force update of jobs, from Sina Siadat.


# 1.134 29-Aug-2015 nicm

Move struct paste_buffer out of tmux.h.


# 1.133 28-Aug-2015 nicm

Run status update on a per-client timer at status-interval.


Revision tags: OPENBSD_5_8_BASE
# 1.132 29-Jul-2015 nicm

status_out and associated data structures are no longer used.


# 1.131 28-Jul-2015 nicm

Tidy up the way terminals are described and move some structs out of tmux.h.


# 1.130 20-Jul-2015 nicm

Add an option (history-file) for a file to save/restore command prompt
history, from Olof-Joachim Frahm.


# 1.129 27-May-2015 nicm

Move the jobs output cache into the formats code so that #() work more
generally (for example, again working in set-titles-string).


# 1.128 06-May-2015 nicm

Remove ARRAY_* from history and expand completion to complete a) layout
names and b) targets beginning with -t or -s.


# 1.127 25-Apr-2015 nicm

Make message log a TAILQ.


# 1.126 24-Apr-2015 nicm

Set working directory for run-shell and if-shell.


# 1.125 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_7_BASE
# 1.124 06-Feb-2015 nicm

Use the same time for both calls to format_expand_time.


# 1.123 06-Feb-2015 nicm

status_replace can now become local to status.c and it no longer needs
the jobsflag argument. While here there is no need to repeat work that
format_defaults already does.


# 1.122 06-Feb-2015 nicm

Add format_expand_time and use it instead of status_replace where
command execution is not needed.


# 1.121 05-Feb-2015 nicm

Wrap all the individual format_* calls in a single format_defaults
functions.


# 1.120 01-Feb-2015 nicm

Remove two unused arguments from status_replace.


# 1.119 20-Jan-2015 sthen

typo in comment ;) ok nicm


# 1.118 05-Nov-2014 nicm

Do not put a space between status-left/status-right and the window list,
instead move the space into the defaults for the options (so status-left
now defaults to "[#S] ". From Balazs Kezes.


# 1.117 20-Oct-2014 nicm

Better format for printf format attributes.


# 1.116 08-Oct-2014 nicm

Add xreallocarray and remove nmemb argument from xrealloc.


# 1.115 02-Oct-2014 nicm

Take account of window-status-separator when checking window position,
based on diff from Balazs Kezes.


Revision tags: OPENBSD_5_6_BASE
# 1.114 24-Apr-2014 nicm

There is no longer a need for a paste_stack struct or for global_buffers
to be global. Move to paste.c.


# 1.113 17-Apr-2014 nicm

Remove the monitor-content option and associated bits and bobs. It's
never worked very well. If there is a big demand for it to return, will
consider better ways to do it.


# 1.112 02-Apr-2014 nicm

Do not replace ## with # in status_replace1 because it'll be done later
by the format code.


# 1.111 31-Mar-2014 nicm

Make message-limit a server option.


Revision tags: OPENBSD_5_5_BASE
# 1.110 14-Feb-2014 nicm

Style nit - no space between function name and bracket.


# 1.109 14-Feb-2014 nicm

Check for NULL session and whatnot in status_replace, from Thomas Adam.


# 1.108 28-Jan-2014 nicm

Allow replacing each of the many sets of separate foo-{fg,bg,attr}
options with a single foo-style option. For example:

set -g status-fg yellow
set -g status-bg red
set -g status-attr blink

Becomes:

set -g status-style fg=yellow,bg=red,blink

The -a flag to set can be used to add to rather than replace a style. So:

set -g status-bg red

Becomes:

set -ag status-style bg=red

Currently this is fully backwards compatible (all *-{fg,bg,attr} options
remain) but the plan is to deprecate them over time.

From Tiago Cunha.


Revision tags: OPENBSD_5_4_BASE
# 1.107 05-Jul-2013 nicm

Whitespace nits, from Ben Boeckel.


# 1.106 05-Jul-2013 nicm

Act like vi(1) when moving words, from Ben Boeckel.


# 1.105 05-Jul-2013 nicm

Implement s, S, C mode switch commands in vi(1) mode, from Ben Boeckel.


# 1.104 31-May-2013 nicm

Demote the old single-character replacement variables (#S and friends)
to aliases of formats. From Tiago Cunha.


# 1.103 25-Mar-2013 nicm

Extend jobs to support writing and use that for copy-pipe instead of
popen, from Chris Johnsen.


# 1.102 22-Mar-2013 nicm

evbuffer_readline returns allocated storage, don't leak it.


# 1.101 22-Mar-2013 nicm

Add copy-pipe mode command to copy selection and also pipe to a command.


# 1.100 22-Mar-2013 nicm

No more lint means no more ARGSUSED.


# 1.99 21-Mar-2013 nicm

Aargh. Spaces -> tabs.


# 1.98 21-Mar-2013 nicm

Do not leak formats in status_replace.


# 1.97 21-Mar-2013 nicm

Add a format client_prefix which is 1 if prefix key has been
pressed, used for example #{?client_prefix,X,Y}. Also a few extra
server_client_status needed.


# 1.96 21-Mar-2013 nicm

Allow formats in status options.


Revision tags: OPENBSD_5_3_BASE
# 1.95 27-Nov-2012 nicm

Add window-status-last-* options, from Boris Faure.


Revision tags: OPENBSD_5_2_BASE
# 1.94 10-Jul-2012 nicm

xfree is not particularly helpful, remove it. From Thomas Adam.


# 1.93 09-Jul-2012 nicm

Move a NULL check inside a function, from Tiago Cunha.


# 1.92 29-Apr-2012 nicm

Use int not u_char for colours from options since they may have bit 8
set to mark them as 256-colour. Reported by Chris Johnson.


# 1.91 23-Apr-2012 nicm

Add window-status-separator option, from Thomas Adam.


# 1.90 17-Mar-2012 nicm

Check event_initialized before event_del if event may not have been set
up; libevent2 complains about this. Reported by Moriyoshi Koizumi.


# 1.89 04-Mar-2012 nicm

Add A and I keys for vi status line editing.


# 1.88 03-Mar-2012 nicm

The wlmouse offset should be part of the client, not the server. From
Ailin Nemui.


Revision tags: OPENBSD_5_1_BASE
# 1.87 29-Jan-2012 nicm

Add an option to move the status line to the top of the screen,
requested by many.


# 1.86 26-Jan-2012 nicm

Terminate strftime buffer properly even if a really long format string
is given, from Tiago Cunha.


# 1.85 26-Jan-2012 nicm

Fix memory leak in error path, from Tiago Cunha.


# 1.84 20-Jan-2012 nicm

Add some trivial additional status line attributes from jwcxz at users
dot sourceforge dot net.


# 1.83 20-Jan-2012 nicm

Add space movement keys for vi mode in the status line from Ben Boeckel.


# 1.82 01-Dec-2011 nicm

Make M-f and M-b work the same at the command prompt as in copy mode,
pointed out by Romain Francoise.


# 1.81 15-Nov-2011 nicm

Add word movement and editing command for command prompt editing, from
Ben Boeckel.


# 1.80 15-Nov-2011 nicm

Make window_pane_index work the same as window_index, from Ben Boeckel.


# 1.79 05-Nov-2011 nicm

Option to change status line (message) background when using vi keys and
in command mode. From Ben Boeckel.


# 1.78 20-Aug-2011 nicm

Fix a couple of memory leaks, from marcel partap.


Revision tags: OPENBSD_5_0_BASE
# 1.77 08-Jul-2011 nicm

Make confirm-before prompt customizable with -p option like
command-prompt. Also move responsibility for calling status_replace into
status_prompt_{set,update} and add #W and #P to the default kill-window
and kill-pane prompts. By Tiago Cunha.


# 1.76 02-Jul-2011 nicm

Allow the initial context on prompts to be set with the new -I option to
command-prompt. From Tiago Cunha.


# 1.75 29-Apr-2011 nicm

Only redraw the status line on command update, not the entire client
(big DOH).


# 1.74 24-Apr-2011 nicm

Provide #h for short hostname (no domain) from Michal Mazurek.


# 1.73 18-Apr-2011 nicm

Add an option (mouse-select-window) which allows the mouse to be used by
clicking on the status line, written by hsim at gmx dot li.


# 1.72 29-Mar-2011 nicm

Change -t on display-message to be target-pane for the #[A-Z]
replacements and add -c as target-client.


Revision tags: OPENBSD_4_9_BASE
# 1.71 26-Jan-2011 nicm

Simplify the way jobs work and drop the persist type, so all jobs are
fire-and-forget.

Status jobs now managed with two trees of output (new and old), rather
than storing the output in the jobs themselves. When the status line is
processed any jobs which don't appear in the new tree are started and
the output from the old tree displayed. When a job finishes it updates
the new tree with its output and that is used for any subsequent
redraws. When the status interval expires, the new tree is moved to the
old so that all jobs are run again.

This fixes the "#(echo %H:%M:%S)" problem which would lead to thousands
of identical persistent jobs and high memory use (this can still be
achieved by adding "sleep 30" but that is much less likely to happen by
accident).


# 1.70 03-Jan-2011 nicm

Handle a # at the end of a replacement string (such as status-left)
correctly. Found by Thomas Adam.


# 1.69 01-Jan-2011 nicm

Move the user-visible parts of all options (names, types, limit, default
values) together into one set of tables in options-table.c. Also clean
up and simplify cmd-set-options.c and move a common print function into
option-table.c.


# 1.68 30-Dec-2010 nicm

Change from a per-session stack of buffers to one global stack which is
much more convenient and also simplifies lot of code. This renders
copy-buffer useless and makes buffer-limit now a server option.

By Tiago Cunha.


# 1.67 30-Dec-2010 nicm

Add a function to create window flags rather than doing the same thing
in two places. From Thomas Adam.


# 1.66 11-Dec-2010 nicm

Oops, these functions return a const char *, so make the local variable
const as well.


# 1.65 11-Dec-2010 nicm

Make the prompt history global for all clients which is much more useful than per-client history.


# 1.64 06-Dec-2010 nicm

Add an option to alert (monitor) for silence (lack of activity) in a
window. From Thomas Adam.


Revision tags: OPENBSD_4_8_BASE
# 1.63 21-Jun-2010 nicm

Having a list of winlinks->alerts for each session is stupid, just store
the alert flags directly in the winlink itself.


# 1.62 14-May-2010 nicm

Colour+attribute options for status line alerts, from Alex Alexander.


# 1.61 31-Mar-2010 nicm

Don't accept keys with modifiers as input. Fixes crash reported by Brian
R Landy.


# 1.60 27-Mar-2010 nicm

Don't leak job command in #().


# 1.59 22-Mar-2010 nicm

Dead functions, lint.


Revision tags: OPENBSD_4_7_BASE
# 1.58 27-Jan-2010 nicm

Calculate offset correctly, fixes incorrect offset and prevents crash when
status-left is empty. From Micah Cowan.


# 1.57 26-Jan-2010 nicm

Actually use the copy made when no newline is found, from martynas@.


# 1.56 14-Dec-2009 nicm

Add server options to completion as well.


# 1.55 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.54 03-Dec-2009 nicm

Eliminate duplicate code and ease the passage for server-wide options by adding
a -w flag to set-option and show-options and making setw and showw aliases to
set -w and show -w.

Note: setw and showw are still there, but now aliases for set -w and show -w.


# 1.53 26-Nov-2009 nicm

Tidy up various bits of the paste code, make the data buffer char * and add
comments.


# 1.52 26-Nov-2009 nicm

Remove a couple of unused arguments where possible, and add /* ARGSUSED */ to
the rest to reduce lint output.


# 1.51 20-Nov-2009 nicm

Display UTF-8 properly in status line messages and prompt. Cursor handling is
still way off though.


# 1.50 20-Nov-2009 nicm

Remove oldest messages from log when limit is hit, not newest.


# 1.49 19-Nov-2009 nicm

Get some brackets in the right place so ## works. Also fix a space in a
comment.


# 1.48 19-Nov-2009 nicm

Change status line drawing to create the window list in a separate screen and
then copy it into the status line screen. This allows UTF-8 in window names and
fixes some problems with #[] in window-status-format.


# 1.47 19-Nov-2009 nicm

Two new options, window-status-format and window-status-current-format, which
allow the format of each window in the status line window list to be controlled
using similar # sequences as status-left/right.

This diff also moves part of the way towards UTF-8 support in window names but
it isn't quite there yet.


# 1.46 19-Nov-2009 nicm

Tidy up by breaking the # replacement code into a separate function, also add a
few comments.


# 1.45 19-Nov-2009 nicm

Don't interpret #() for display-message, it usually doesn't make sense and may
leak commands.


# 1.44 18-Nov-2009 nicm

Add a per-client log of status line messages displayed while that client
exists. A new message-limit session option sets the maximum number of entries
and a command, show-messages, shows the log (bound to ~ by default).

This (and prompt history) might be better as a single global log but until
there are global options it is easier for them to be per client.


# 1.43 17-Nov-2009 nicm

Permit top-bit-set characters to be entered in the status line. They could
already be set from the shell and are just passed through when printing (so
invisible characters or displaying on terminals with different character sets
may cause problems).

Note that entering UTF-8 may not work and in any case currently the status line
cannot display it correctly (outside of status-left/status-right).


# 1.42 04-Nov-2009 nicm

Use timeout events for the identify and message timers.


# 1.41 04-Nov-2009 nicm

Switch jobs over to use a bufferevent.


# 1.40 04-Nov-2009 nicm

Unused (but assigned to) variable, found by lint.


# 1.39 01-Nov-2009 nicm

Add a flag for jobs that shouldn't be freed after they've died and use it for
status jobs, then only kill those jobs when status-left, status-right or
set-titles-string is changed.

Fixes problems with changing options from inside #().


# 1.38 10-Oct-2009 nicm

Rather than running status-left, status-right and window title #() with popen
immediately every redraw, queue them up and run them in the background,
starting each once every status-interval. The actual status line uses the
output from the last run.

This brings several advantages:

- tmux itself may be called from inside #() without causing the server to hang;
- likewise, sleep or similar doesn't cause the server to block;
- commands aren't run excessively often when redrawing;
- commands shared by status-left and status-right, or used multiple times, will
only be run once.

run-shell and if-shell still use system()/popen() but will be changed over to
use this too later.


# 1.37 10-Oct-2009 nicm

Add "grouped sessions" which have independent name, options, current window and
so on but where the linked windows are synchronized (ie creating, killing
windows and so on are mirrored between the sessions). A grouped session may be
created by passing -t to new-session.

Had this around for a while, tested by a couple of people.


# 1.36 23-Sep-2009 nicm

Remove PROMPT_HIDDEN code which is now unused.


# 1.35 23-Sep-2009 nicm

Remove the internal tmux locking and instead detach each client and run the
command specified by a new option "lock-command" (by default "lock -np") in
each client.

This means each terminal has to be unlocked individually but simplifies the
code and allows the system password to be used to unlock.

Note that the set-password command is gone, so it will need to be removed from
configuration files, and the -U command line flag has been removed.

This is the third protocol version change so again it is best to stop the tmux
server before upgrading.


# 1.34 20-Sep-2009 nicm

Regularise some fatal messages.


# 1.33 10-Sep-2009 nicm

Permit options such as status-bg to be configured using the entire 256 colour
palette by setting "colour0" to "colour255".


# 1.32 07-Sep-2009 nicm

Give each paste buffer a size member instead of requiring them to be
zero-terminated.


# 1.31 07-Sep-2009 nicm

Permit embedded colour and attributes in status-left and status-right using new
#[] special characters, for example #[fg=red,bg=blue,blink].


# 1.30 02-Sep-2009 nicm

Add a transpose-chars command in edit mode (C-t in emacs mode only). From Kalle
Olavi Niemitalo.


# 1.29 01-Sep-2009 nicm

Use "Password:" with no space for password prompts and don't display a *s for
the password, like pretty much everything else. From martynas@ with minor
tweaks by me.


# 1.28 31-Aug-2009 nicm

Add a new display-panes command, with two options (display-panes-colour and
display-panes-time), which displays a visual indication of the number of each
pane.


# 1.27 19-Aug-2009 nicm

Extend command-prompt with a -p option which is a comma-separated list of one
or more prompts to present in order.

The responses to the prompt are replaced in the template string: %% are
replaced in order, so the first prompt replaces the first %%, the second
replaces the second, and so on. In addition, %1 up to %9 are replaced with the
responses to the first the ninth prompts

The default template is "%1" so the response to the first prompt is processed
as a command.

Note that this changes the behaviour for %% so if there is only one prompt,
only the first %% will be replaced. Templates such as "neww -n '%%' 'ssh %%'"
should be changed to "neww -n '%1' 'ssh %1'".

From Tiago Cunha.


# 1.26 18-Aug-2009 nicm

Add a "delete line" key when editing in the status line or the search up/down
prompt. C-u with emacs keys, d with vi.


# 1.25 13-Aug-2009 nicm

Switch the prompt code to return an empty string when the user enters no
response and reserve NULL for an explicit cancel. Change all callbacks to treat
them the same so no functional change.

Also add cancel key bindings to emacs mode which were missing.


# 1.24 08-Aug-2009 nicm

Options to set the colours and attributes for status-left/-right. From Thomas
Adam, thanks.


# 1.23 05-Aug-2009 nicm

If colours are not supported by the terminal, try to emulate a coloured
background by setting or clearing the reverse attribute.

This makes a few applications which don't use the reverse attribute themselves
a little happier, and allows the status, message and mode options to have
default attributes and fg/bg options that work as expected when set as reverse.


# 1.22 30-Jul-2009 nicm

Plug some memory leaks.


# 1.21 28-Jul-2009 nicm

Next step towards customisable mode keys: build each default table of keys into
a named tree on start and use that for lookups. Also add command to string
translation tables and modify list-keys to show the the mode key bindings (new
-t argument).


# 1.20 27-Jul-2009 nicm

Change mode key bindings from big switches into a set of tables. Rather than
lumping them all together, split editing keys from those used in choice/more
mode and those for copy/scroll mode.

Tidier and clearer, and the first step towards customisable mode keys.


# 1.19 27-Jul-2009 nicm

Get rid of empty mode_key_free function.


# 1.18 27-Jul-2009 nicm

Add a key to delete to end of line at the prompt (^K in emacs mode, C/D in vi).

From Kalle Olavi Niemitalo.


# 1.17 26-Jul-2009 nicm

Calculate the space available for the prompt buffer and the cursor position
correctly, and make it work when the screen is not wide enough.

Noticed by Kalle Olavi Niemitalo.


# 1.16 21-Jul-2009 nicm

Remove a couple of unused functions and fix a type ("FALLTHOUGH"), found by
lint.


# 1.15 20-Jul-2009 nicm

Add a status-justify option to allow the window list in the status line to be
positioned at the left, centre, or right.


# 1.14 20-Jul-2009 nicm

New options, window-status-current-{fg,bg,attr}, to set the fg, bg and
attributes with which the current window is shown in the status line. From
Johan Friis, thanks.


# 1.13 17-Jul-2009 nicm

- New command display-message (alias display) to display a message in the
status line (bound to "i" and displays the current window and time by
default). The same substitutions are applied as for status-left/right.
- Add support for including the window index (#I), pane index (#P) and window
name (#W) in the message, and status-left or status-right.
- Bump protocol version.

From Tiago Cunha, thanks!


# 1.12 17-Jul-2009 nicm

Memory could be leaked if a second prompt or message appeared while another was
still present, so add a separate prompt free callback and make the _clear
function responsible for calling it if necessary (rather than the individual
prompt callbacks). Also make both messages and prompts clear any existing when
a new is set.

In addition, the screen could be modified while the prompt is there, restore
the redraw-entire-screen behaviour on prompt clear; add a comment as a
reminder.


# 1.11 16-Jul-2009 nicm

Remove some duplicate code that was causing the status line to be redrawn even
when it hadn't changed.


# 1.10 15-Jul-2009 nicm

Make status_message_set a variadic printf-like function. No functional change -
helpful for a couple of things coming soon.


# 1.9 15-Jul-2009 nicm

Having to update NSETOPTION/NSETWINDOWOPTION when adding new options is a bit
annoying and it is only use for iterating, so use a sentinel to mark the end of
each array instead. Different fix for a problem pointed out by Kalle Olavi
Niemitalo.


# 1.8 14-Jul-2009 nicm

For some reason when clearing status/message it was redrawing the entire client
not just the status line. Changing this also revealed the check for the status
line was incorrect when drawing the pane.


# 1.7 14-Jul-2009 nicm

Instead of faking up a status line in status_redraw, use the same code to
redraw it as to draw the entire screen, just skip all lines but the last.

This makes horizontal split redraw properly when the status line is off.


# 1.6 12-Jul-2009 nicm

Add a "back to indentation" key in copy mode to move the cursor to the first
non-whitespace character. ^ with vi and M-m with emacs key bindings. Another
from Kalle Olavi Niemitalo, thanks.


Revision tags: OPENBSD_4_6_BASE
# 1.5 26-Jun-2009 nicm

Status line fixes: don't truncate status-right now the length calculation is
done for UTF-8, limit to the maximum length correctly when printing, and always
print a space even if the left string is longer than the width available.


# 1.4 04-Jun-2009 nicm

If the prompt is hidden or a password is sent with -U, zero it before freeing
it.


# 1.3 03-Jun-2009 nicm

New session option, status-utf8, to control the interpretation of top-bit-set
characters in status-left and status-right (if on, they are treated as UTF-8;
otherwise passed through).


# 1.2 03-Jun-2009 nicm

Add a UTF-8 aware string length function and make UTF-8 in
status-left/status-right work properly. At the moment any top-bit-set
characters are assumed to be UTF-8: a status-utf8 option to configure this will
come shortly.


# 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.216 26-May-2020 nicm

Remove leftover debug logging and fix comparison.


# 1.215 26-May-2020 nicm

Set up UTF-8 data for ASCII keys correctly.


# 1.214 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.213 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.212 16-May-2020 nicm

Rename KEYC_ESCAPE to KEYC_META.


# 1.211 16-May-2020 nicm

Expand target from client and use it to expand the prompt.


# 1.210 16-May-2020 nicm

Support embedded styles in the display-message message, GitHub issue
2206.


# 1.209 16-May-2020 nicm

Change message log to be per server rather than per client and include
every command that is run.


# 1.208 16-May-2020 nicm

Do not hoke into struct window_pane from the tty code and instead set
everything up in tty_ctx. Provide a way to initialize the tty_ctx from a
callback and use it to let popups draw directly through input_parse in
the same way as panes do, rather than forcing a full redraw on every
change.


# 1.207 16-May-2020 nicm

Use formats for status-style and message-style.


# 1.206 16-May-2020 nicm

Complete partial window indexes properly.


# 1.205 16-May-2020 nicm

Add -W and -T flags to command-prompt to only complete a window and a
target, also complete aliases.


# 1.204 16-May-2020 nicm

Improve command prompt completion:

- Show a menu with completions if there are multiple.

- Don't complete argument stuff (options, layouts) at start of text.

- For -t and -s, if there is no : then complete sessions but if there is
a :, show a menu of all windows in the session rather than trying to
complete the window name which is a bit useless if there are
duplicates.


# 1.203 16-May-2020 nicm

Drop having a separate type for style options and make them all strings,
which allows formats to be expanded. Any styles without a '#{' are still
validated when they are set but any with a '#{' are not. Formats are not
expanded usefully in many cases yet, that will be changed later.

To make this work, a few other changes:

- set-option -a with a style option automatically appends a ",".

- OSC 10 and 11 don't set the window-style option anymore, instead the
fg and bg are stored in the pane struct and act as the defaults that
can be overridden by window-style.

- status-fg and -bg now override status-style instead of trying to keep
them in sync.


Revision tags: OPENBSD_6_7_BASE
# 1.202 12-Mar-2020 nicm

Add C-g to cancel command prompt with vi(1) keys as well as emacs, and q
in command mode.


# 1.201 27-Jan-2020 nicm

Add support for adding a note to a key binding (with bind-key -N) and
use this to add descriptions to the default key bindings. A new -N flag
to list-keys shows key bindings with notes rather than the default
bind-key command used to create them. Change the default ? binding to
use this to show a readable summary of keys.

Also extend command-prompt to return the name of the key pressed and add
a default binding (/) to show the note for the next key pressed

Suggested by Alex Tremblay in GitHub issue 2000.


Revision tags: OPENBSD_6_6_BASE
# 1.200 28-May-2019 nicm

Redraw status line if size changes, GitHub issue 1762. Also fix length
of target buffer when pasting into status line.


# 1.199 23-May-2019 nicm

Fix length calculation for pasting UTF-8 characters in the status line,
GitHub issue 1753.


# 1.198 11-May-2019 nicm

Do not reduce window height by status line height for control mode
clients, from George Nachman.


# 1.197 03-May-2019 nicm

Fix reverse attribute in status line, GitHub issue 1709.


# 1.196 26-Apr-2019 nicm

Merge hooks into options and make each one an array option. This allows
multiple commands to be easily bound to one hook. set-hook and
show-hooks remain but they are now variants of set-option and
show-options. show-options now has a -H flag to show hooks (by default
they are not shown).


# 1.195 25-Apr-2019 nicm

options_array_item_value cannot return NULL.


# 1.194 23-Apr-2019 nicm

Somehow missed these bits in last commit.


# 1.193 23-Apr-2019 nicm

Indicate an array option with a flag rather than a special type so that
in future will not have to be strings.


Revision tags: OPENBSD_6_5_BASE
# 1.192 18-Mar-2019 nicm

Extend the #[] style syntax and use that together with previous format
changes to allow the status line to be entirely configured with a single
option.

Now that it is possible to configure their content, enable the existing
code that lets the status line be multiple lines in height. The status
option can now take a value of 2, 3, 4 or 5 (as well as the previous on
or off) to configure more than one line. The new status-format array
option configures the format of each line, the default just references
the existing status-* options, although some of the more obscure status
options may be eliminated in time.

Additions to the #[] syntax are: "align" to specify alignment (left,
centre, right), "list" for the window list and "range" to configure
ranges of text for the mouse bindings.

The "align" keyword can also be used to specify alignment of entries in
tree mode and the pane status lines.


# 1.191 18-Mar-2019 nicm

Make array options a sparse tree instead of an array of char * and
remove the size limit.


# 1.190 18-Mar-2019 nicm

With force, kill previous job before starting new. Fixes problem
reported by Scott Mcdermott in GitHub issue 1627.


# 1.189 16-Mar-2019 nicm

Use a pointer for the active screen in the status line instead of
copying them around all the time.


# 1.188 16-Mar-2019 nicm

Give status_save_old the client so it can do the reinit too.


# 1.187 16-Mar-2019 nicm

Tidy and rename some bits of status line code.


# 1.186 15-Mar-2019 nicm

Move status line free into its own function.


# 1.185 14-Mar-2019 nicm

Store the time in the format tree rather than passing it around.


# 1.184 12-Mar-2019 nicm

DECRC and DECSC apparently need to preserve origin mode as well, based
on a fix from Marc Reisner.


# 1.183 09-Feb-2019 nicm

Completion of command-alias members.


# 1.182 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.181 29-Aug-2018 nicm

Keep any text killed in the command prompt with C-w and yank it with
C-y, only use the top buffer if no text has previously been killed. This
and previous change promped by discussion with kn@.


# 1.180 29-Aug-2018 nicm

Add C-Left and C-Right as aliases for M-b and M-f.


# 1.179 22-Aug-2018 nicm

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


# 1.178 20-Aug-2018 nicm

Move offset of window list into status struct.


# 1.177 19-Aug-2018 nicm

Add a client redraw-window flag instead of the redraw-all flag and for
all just use the three flags together (window, borders, status).


Revision tags: OPENBSD_6_3_BASE
# 1.176 22-Feb-2018 nicm

Remove an unused variable.


# 1.175 05-Feb-2018 nicm

Add struct status_line to hold status line members of struct client, not
used yet but will be soon. From Thomas Adam.


# 1.174 01-Jan-2018 nicm

Add C-g at command prompt for emacs people, GitHub issue 1213.


# 1.173 27-Dec-2017 nicm

Draw command prompt correctly with status line off.


# 1.172 18-Dec-2017 nicm

Remove unused variable from Thomas Adam.


# 1.171 02-Nov-2017 nicm

Add a "fast" version of screen_write_copy for tree mode that doesn't do
all the checks and selection and marking stuff needed for copy mode.


# 1.170 20-Oct-2017 nicm

Clear status line with spaces again so reverse works, spotted by sthen.


# 1.169 16-Oct-2017 nicm

Infrastructure for drawing status lines of more than one line in height,
still only one is allowed but this lets tmux draw bigger ones.


Revision tags: OPENBSD_6_2_BASE
# 1.168 29-May-2017 nicm

Add a flag to stop the prompt input being expanded.


# 1.167 29-May-2017 nicm

Store a copy of the old status line, will be needed soon for new choose mode.


# 1.166 17-May-2017 nicm

Tidy command prompt callbacks and pass in the client.


# 1.165 03-May-2017 nicm

Add a format for the last search string in copy mode and fix the prompt
so it can work when in -I, suggested by Suraj N Kurapati.


# 1.164 01-May-2017 nicm

In order that people can use formats like #D in #() in the status line
and not have to wait for an update when they change pane, we allow
commands to run more than once a second if the expanded form
changes. Unfortunately this can mean them being run far too often
(pretty much continually) when multiple clients exist, because some
formats (including #D) will always differ between clients.

To avoid this, give each client its own tree of jobs which means that
the same command will be different instances for each client - similar
to how we have the tag to separate commands for different panes.

GitHub issue 889; test case reported by Paul Johnson.


# 1.163 22-Apr-2017 nicm

Memory leak from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.162 09-Feb-2017 nicm

Break the message storage function into its own function, useful for
debugging.


# 1.161 03-Feb-2017 nicm

Cache status line position to reduce option lookups during output.


# 1.160 03-Feb-2017 nicm

Add a window or pane id "tag" to each format tree and use it to separate
jobs, this means that if the same job is used for different windows or
panes (for example in pane-border-format), it will be run separately for
each pane.


# 1.159 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.158 06-Jan-2017 nicm

Incremental search in copy mode (on for emacs keys by default) - much
the same as normal searching but updates the cursor position and marked
search terms as you type. C-r and C-s in the prompt repeat the search,
once finished searching (with Enter), N and n work as before.


# 1.157 05-Jan-2017 nicm

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


# 1.156 07-Dec-2016 nicm

Do not clear the prompt when a message is shown, just leave it around and
return to it when the message is finished.


# 1.155 12-Oct-2016 nicm

Drop the edit mode key tables and just use fixed key bindings for the
command prompt.


# 1.154 12-Oct-2016 nicm

The repeat prompt in both emacs and vi (and the old one in tmux) doesn't
support line editing and instead executes a command as soon as a
non-number key is pressed. Add a -N flag to command-prompt for the same
in copy mode. Reported by Theo Buehler.


# 1.153 11-Oct-2016 nicm

Fundamental change to how copy mode key bindings work:

The vi-copy and emacs-copy mode key tables are gone, and instead copy
mode commands are bound in one of two normal key tables ("copy-mode" or
"copy-mode-vi"). Keys are bound to "send-keys -X copy-mode-command". So:

bind -temacs-copy C-Up scroll-up
bind -temacs-copy -R5 WheelUpPane scroll-up

Becomes:

bind -Tcopy-mode C-Up send -X scroll-up
bind -Tcopy-mode WheelUpPane send -N5 -X scroll-up

This allows the full command parser and command set to be used - for
example, we can use the normal command prompt for searching, jumping,
and so on instead of a custom one:

bind -Tcopy-mode C-r command-prompt -p'search up' "send -X search-backward '%%'"

command-prompt also gets a -1 option to only require on key press, which
is needed for jumping.

The plan is to get rid of mode keys entirely, so more to come eventually.


# 1.152 11-Oct-2016 nicm

Support UTF-8 entry into the command prompt.


# 1.151 10-Oct-2016 nicm

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


# 1.150 12-Sep-2016 nicm

Allow repeat count to be specified in mode key tables with bind-key -R,
and set the default repeat count to 5 for WheelUp and WheelDown in
copy-mode.


Revision tags: OPENBSD_6_0_BASE
# 1.149 06-Jun-2016 nicm

Allow #[] in window-status-separator.


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

I no longer use my SourceForge address so replace it.


# 1.147 01-Jan-2016 nicm

Don't rely on a calculation wrapping when applying message-limit, and
break out of the loop early. From Nicolas Viennot.


# 1.146 11-Dec-2015 nicm

Style nits and line wrapping of function declarations.


# 1.145 11-Dec-2015 nicm

Add cmdq as an argument to format_create and add a format for the
command name (will also be used for more later).


# 1.144 08-Dec-2015 nicm

Remove format_create_flags and just pass flags to format_create.


# 1.143 22-Nov-2015 tim

If display-time is set to 0, show status messages until a key is pressed;
OK nicm@


# 1.142 20-Nov-2015 nicm

Instead of separate tables for different types of options, give each
option a scope type (server, session, window) in one table.


# 1.141 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.140 13-Nov-2015 nicm

Long overdue change to the way we store cells in the grid: now, instead
of storing a full grid_cell with UTF-8 data and everything, store a new
type grid_cell_entry. This can either be the cell itself (for ASCII
cells), or an offset into an extended array (per line) for UTF-8
data.

This avoid a large (8 byte) overhead on non-UTF-8 cells (by far the
majority for most users) without the complexity of the shadow array we
had before. Grid memory without any UTF-8 is about half.

The disadvantage that cells can no longer be modified in place and need
to be copied out of the grid and back but it turned out to be lot less
complicated than I expected.


# 1.139 12-Nov-2015 nicm

Nuke the utf8 and status-utf8 options and make tmux only a UTF-8
terminal. We still support non-UTF-8 terminals outside tmux, but inside
it is always UTF-8 (as when the utf8 and status-utf8 options were on).


# 1.138 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.137 27-Oct-2015 nicm

Move struct options into options.c.


# 1.136 20-Oct-2015 nicm

Use client pointer not file descriptor in logging.


# 1.135 14-Sep-2015 nicm

Make refresh-client force update of jobs, from Sina Siadat.


# 1.134 29-Aug-2015 nicm

Move struct paste_buffer out of tmux.h.


# 1.133 28-Aug-2015 nicm

Run status update on a per-client timer at status-interval.


Revision tags: OPENBSD_5_8_BASE
# 1.132 29-Jul-2015 nicm

status_out and associated data structures are no longer used.


# 1.131 28-Jul-2015 nicm

Tidy up the way terminals are described and move some structs out of tmux.h.


# 1.130 20-Jul-2015 nicm

Add an option (history-file) for a file to save/restore command prompt
history, from Olof-Joachim Frahm.


# 1.129 27-May-2015 nicm

Move the jobs output cache into the formats code so that #() work more
generally (for example, again working in set-titles-string).


# 1.128 06-May-2015 nicm

Remove ARRAY_* from history and expand completion to complete a) layout
names and b) targets beginning with -t or -s.


# 1.127 25-Apr-2015 nicm

Make message log a TAILQ.


# 1.126 24-Apr-2015 nicm

Set working directory for run-shell and if-shell.


# 1.125 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_7_BASE
# 1.124 06-Feb-2015 nicm

Use the same time for both calls to format_expand_time.


# 1.123 06-Feb-2015 nicm

status_replace can now become local to status.c and it no longer needs
the jobsflag argument. While here there is no need to repeat work that
format_defaults already does.


# 1.122 06-Feb-2015 nicm

Add format_expand_time and use it instead of status_replace where
command execution is not needed.


# 1.121 05-Feb-2015 nicm

Wrap all the individual format_* calls in a single format_defaults
functions.


# 1.120 01-Feb-2015 nicm

Remove two unused arguments from status_replace.


# 1.119 20-Jan-2015 sthen

typo in comment ;) ok nicm


# 1.118 05-Nov-2014 nicm

Do not put a space between status-left/status-right and the window list,
instead move the space into the defaults for the options (so status-left
now defaults to "[#S] ". From Balazs Kezes.


# 1.117 20-Oct-2014 nicm

Better format for printf format attributes.


# 1.116 08-Oct-2014 nicm

Add xreallocarray and remove nmemb argument from xrealloc.


# 1.115 02-Oct-2014 nicm

Take account of window-status-separator when checking window position,
based on diff from Balazs Kezes.


Revision tags: OPENBSD_5_6_BASE
# 1.114 24-Apr-2014 nicm

There is no longer a need for a paste_stack struct or for global_buffers
to be global. Move to paste.c.


# 1.113 17-Apr-2014 nicm

Remove the monitor-content option and associated bits and bobs. It's
never worked very well. If there is a big demand for it to return, will
consider better ways to do it.


# 1.112 02-Apr-2014 nicm

Do not replace ## with # in status_replace1 because it'll be done later
by the format code.


# 1.111 31-Mar-2014 nicm

Make message-limit a server option.


Revision tags: OPENBSD_5_5_BASE
# 1.110 14-Feb-2014 nicm

Style nit - no space between function name and bracket.


# 1.109 14-Feb-2014 nicm

Check for NULL session and whatnot in status_replace, from Thomas Adam.


# 1.108 28-Jan-2014 nicm

Allow replacing each of the many sets of separate foo-{fg,bg,attr}
options with a single foo-style option. For example:

set -g status-fg yellow
set -g status-bg red
set -g status-attr blink

Becomes:

set -g status-style fg=yellow,bg=red,blink

The -a flag to set can be used to add to rather than replace a style. So:

set -g status-bg red

Becomes:

set -ag status-style bg=red

Currently this is fully backwards compatible (all *-{fg,bg,attr} options
remain) but the plan is to deprecate them over time.

From Tiago Cunha.


Revision tags: OPENBSD_5_4_BASE
# 1.107 05-Jul-2013 nicm

Whitespace nits, from Ben Boeckel.


# 1.106 05-Jul-2013 nicm

Act like vi(1) when moving words, from Ben Boeckel.


# 1.105 05-Jul-2013 nicm

Implement s, S, C mode switch commands in vi(1) mode, from Ben Boeckel.


# 1.104 31-May-2013 nicm

Demote the old single-character replacement variables (#S and friends)
to aliases of formats. From Tiago Cunha.


# 1.103 25-Mar-2013 nicm

Extend jobs to support writing and use that for copy-pipe instead of
popen, from Chris Johnsen.


# 1.102 22-Mar-2013 nicm

evbuffer_readline returns allocated storage, don't leak it.


# 1.101 22-Mar-2013 nicm

Add copy-pipe mode command to copy selection and also pipe to a command.


# 1.100 22-Mar-2013 nicm

No more lint means no more ARGSUSED.


# 1.99 21-Mar-2013 nicm

Aargh. Spaces -> tabs.


# 1.98 21-Mar-2013 nicm

Do not leak formats in status_replace.


# 1.97 21-Mar-2013 nicm

Add a format client_prefix which is 1 if prefix key has been
pressed, used for example #{?client_prefix,X,Y}. Also a few extra
server_client_status needed.


# 1.96 21-Mar-2013 nicm

Allow formats in status options.


Revision tags: OPENBSD_5_3_BASE
# 1.95 27-Nov-2012 nicm

Add window-status-last-* options, from Boris Faure.


Revision tags: OPENBSD_5_2_BASE
# 1.94 10-Jul-2012 nicm

xfree is not particularly helpful, remove it. From Thomas Adam.


# 1.93 09-Jul-2012 nicm

Move a NULL check inside a function, from Tiago Cunha.


# 1.92 29-Apr-2012 nicm

Use int not u_char for colours from options since they may have bit 8
set to mark them as 256-colour. Reported by Chris Johnson.


# 1.91 23-Apr-2012 nicm

Add window-status-separator option, from Thomas Adam.


# 1.90 17-Mar-2012 nicm

Check event_initialized before event_del if event may not have been set
up; libevent2 complains about this. Reported by Moriyoshi Koizumi.


# 1.89 04-Mar-2012 nicm

Add A and I keys for vi status line editing.


# 1.88 03-Mar-2012 nicm

The wlmouse offset should be part of the client, not the server. From
Ailin Nemui.


Revision tags: OPENBSD_5_1_BASE
# 1.87 29-Jan-2012 nicm

Add an option to move the status line to the top of the screen,
requested by many.


# 1.86 26-Jan-2012 nicm

Terminate strftime buffer properly even if a really long format string
is given, from Tiago Cunha.


# 1.85 26-Jan-2012 nicm

Fix memory leak in error path, from Tiago Cunha.


# 1.84 20-Jan-2012 nicm

Add some trivial additional status line attributes from jwcxz at users
dot sourceforge dot net.


# 1.83 20-Jan-2012 nicm

Add space movement keys for vi mode in the status line from Ben Boeckel.


# 1.82 01-Dec-2011 nicm

Make M-f and M-b work the same at the command prompt as in copy mode,
pointed out by Romain Francoise.


# 1.81 15-Nov-2011 nicm

Add word movement and editing command for command prompt editing, from
Ben Boeckel.


# 1.80 15-Nov-2011 nicm

Make window_pane_index work the same as window_index, from Ben Boeckel.


# 1.79 05-Nov-2011 nicm

Option to change status line (message) background when using vi keys and
in command mode. From Ben Boeckel.


# 1.78 20-Aug-2011 nicm

Fix a couple of memory leaks, from marcel partap.


Revision tags: OPENBSD_5_0_BASE
# 1.77 08-Jul-2011 nicm

Make confirm-before prompt customizable with -p option like
command-prompt. Also move responsibility for calling status_replace into
status_prompt_{set,update} and add #W and #P to the default kill-window
and kill-pane prompts. By Tiago Cunha.


# 1.76 02-Jul-2011 nicm

Allow the initial context on prompts to be set with the new -I option to
command-prompt. From Tiago Cunha.


# 1.75 29-Apr-2011 nicm

Only redraw the status line on command update, not the entire client
(big DOH).


# 1.74 24-Apr-2011 nicm

Provide #h for short hostname (no domain) from Michal Mazurek.


# 1.73 18-Apr-2011 nicm

Add an option (mouse-select-window) which allows the mouse to be used by
clicking on the status line, written by hsim at gmx dot li.


# 1.72 29-Mar-2011 nicm

Change -t on display-message to be target-pane for the #[A-Z]
replacements and add -c as target-client.


Revision tags: OPENBSD_4_9_BASE
# 1.71 26-Jan-2011 nicm

Simplify the way jobs work and drop the persist type, so all jobs are
fire-and-forget.

Status jobs now managed with two trees of output (new and old), rather
than storing the output in the jobs themselves. When the status line is
processed any jobs which don't appear in the new tree are started and
the output from the old tree displayed. When a job finishes it updates
the new tree with its output and that is used for any subsequent
redraws. When the status interval expires, the new tree is moved to the
old so that all jobs are run again.

This fixes the "#(echo %H:%M:%S)" problem which would lead to thousands
of identical persistent jobs and high memory use (this can still be
achieved by adding "sleep 30" but that is much less likely to happen by
accident).


# 1.70 03-Jan-2011 nicm

Handle a # at the end of a replacement string (such as status-left)
correctly. Found by Thomas Adam.


# 1.69 01-Jan-2011 nicm

Move the user-visible parts of all options (names, types, limit, default
values) together into one set of tables in options-table.c. Also clean
up and simplify cmd-set-options.c and move a common print function into
option-table.c.


# 1.68 30-Dec-2010 nicm

Change from a per-session stack of buffers to one global stack which is
much more convenient and also simplifies lot of code. This renders
copy-buffer useless and makes buffer-limit now a server option.

By Tiago Cunha.


# 1.67 30-Dec-2010 nicm

Add a function to create window flags rather than doing the same thing
in two places. From Thomas Adam.


# 1.66 11-Dec-2010 nicm

Oops, these functions return a const char *, so make the local variable
const as well.


# 1.65 11-Dec-2010 nicm

Make the prompt history global for all clients which is much more useful than per-client history.


# 1.64 06-Dec-2010 nicm

Add an option to alert (monitor) for silence (lack of activity) in a
window. From Thomas Adam.


Revision tags: OPENBSD_4_8_BASE
# 1.63 21-Jun-2010 nicm

Having a list of winlinks->alerts for each session is stupid, just store
the alert flags directly in the winlink itself.


# 1.62 14-May-2010 nicm

Colour+attribute options for status line alerts, from Alex Alexander.


# 1.61 31-Mar-2010 nicm

Don't accept keys with modifiers as input. Fixes crash reported by Brian
R Landy.


# 1.60 27-Mar-2010 nicm

Don't leak job command in #().


# 1.59 22-Mar-2010 nicm

Dead functions, lint.


Revision tags: OPENBSD_4_7_BASE
# 1.58 27-Jan-2010 nicm

Calculate offset correctly, fixes incorrect offset and prevents crash when
status-left is empty. From Micah Cowan.


# 1.57 26-Jan-2010 nicm

Actually use the copy made when no newline is found, from martynas@.


# 1.56 14-Dec-2009 nicm

Add server options to completion as well.


# 1.55 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.54 03-Dec-2009 nicm

Eliminate duplicate code and ease the passage for server-wide options by adding
a -w flag to set-option and show-options and making setw and showw aliases to
set -w and show -w.

Note: setw and showw are still there, but now aliases for set -w and show -w.


# 1.53 26-Nov-2009 nicm

Tidy up various bits of the paste code, make the data buffer char * and add
comments.


# 1.52 26-Nov-2009 nicm

Remove a couple of unused arguments where possible, and add /* ARGSUSED */ to
the rest to reduce lint output.


# 1.51 20-Nov-2009 nicm

Display UTF-8 properly in status line messages and prompt. Cursor handling is
still way off though.


# 1.50 20-Nov-2009 nicm

Remove oldest messages from log when limit is hit, not newest.


# 1.49 19-Nov-2009 nicm

Get some brackets in the right place so ## works. Also fix a space in a
comment.


# 1.48 19-Nov-2009 nicm

Change status line drawing to create the window list in a separate screen and
then copy it into the status line screen. This allows UTF-8 in window names and
fixes some problems with #[] in window-status-format.


# 1.47 19-Nov-2009 nicm

Two new options, window-status-format and window-status-current-format, which
allow the format of each window in the status line window list to be controlled
using similar # sequences as status-left/right.

This diff also moves part of the way towards UTF-8 support in window names but
it isn't quite there yet.


# 1.46 19-Nov-2009 nicm

Tidy up by breaking the # replacement code into a separate function, also add a
few comments.


# 1.45 19-Nov-2009 nicm

Don't interpret #() for display-message, it usually doesn't make sense and may
leak commands.


# 1.44 18-Nov-2009 nicm

Add a per-client log of status line messages displayed while that client
exists. A new message-limit session option sets the maximum number of entries
and a command, show-messages, shows the log (bound to ~ by default).

This (and prompt history) might be better as a single global log but until
there are global options it is easier for them to be per client.


# 1.43 17-Nov-2009 nicm

Permit top-bit-set characters to be entered in the status line. They could
already be set from the shell and are just passed through when printing (so
invisible characters or displaying on terminals with different character sets
may cause problems).

Note that entering UTF-8 may not work and in any case currently the status line
cannot display it correctly (outside of status-left/status-right).


# 1.42 04-Nov-2009 nicm

Use timeout events for the identify and message timers.


# 1.41 04-Nov-2009 nicm

Switch jobs over to use a bufferevent.


# 1.40 04-Nov-2009 nicm

Unused (but assigned to) variable, found by lint.


# 1.39 01-Nov-2009 nicm

Add a flag for jobs that shouldn't be freed after they've died and use it for
status jobs, then only kill those jobs when status-left, status-right or
set-titles-string is changed.

Fixes problems with changing options from inside #().


# 1.38 10-Oct-2009 nicm

Rather than running status-left, status-right and window title #() with popen
immediately every redraw, queue them up and run them in the background,
starting each once every status-interval. The actual status line uses the
output from the last run.

This brings several advantages:

- tmux itself may be called from inside #() without causing the server to hang;
- likewise, sleep or similar doesn't cause the server to block;
- commands aren't run excessively often when redrawing;
- commands shared by status-left and status-right, or used multiple times, will
only be run once.

run-shell and if-shell still use system()/popen() but will be changed over to
use this too later.


# 1.37 10-Oct-2009 nicm

Add "grouped sessions" which have independent name, options, current window and
so on but where the linked windows are synchronized (ie creating, killing
windows and so on are mirrored between the sessions). A grouped session may be
created by passing -t to new-session.

Had this around for a while, tested by a couple of people.


# 1.36 23-Sep-2009 nicm

Remove PROMPT_HIDDEN code which is now unused.


# 1.35 23-Sep-2009 nicm

Remove the internal tmux locking and instead detach each client and run the
command specified by a new option "lock-command" (by default "lock -np") in
each client.

This means each terminal has to be unlocked individually but simplifies the
code and allows the system password to be used to unlock.

Note that the set-password command is gone, so it will need to be removed from
configuration files, and the -U command line flag has been removed.

This is the third protocol version change so again it is best to stop the tmux
server before upgrading.


# 1.34 20-Sep-2009 nicm

Regularise some fatal messages.


# 1.33 10-Sep-2009 nicm

Permit options such as status-bg to be configured using the entire 256 colour
palette by setting "colour0" to "colour255".


# 1.32 07-Sep-2009 nicm

Give each paste buffer a size member instead of requiring them to be
zero-terminated.


# 1.31 07-Sep-2009 nicm

Permit embedded colour and attributes in status-left and status-right using new
#[] special characters, for example #[fg=red,bg=blue,blink].


# 1.30 02-Sep-2009 nicm

Add a transpose-chars command in edit mode (C-t in emacs mode only). From Kalle
Olavi Niemitalo.


# 1.29 01-Sep-2009 nicm

Use "Password:" with no space for password prompts and don't display a *s for
the password, like pretty much everything else. From martynas@ with minor
tweaks by me.


# 1.28 31-Aug-2009 nicm

Add a new display-panes command, with two options (display-panes-colour and
display-panes-time), which displays a visual indication of the number of each
pane.


# 1.27 19-Aug-2009 nicm

Extend command-prompt with a -p option which is a comma-separated list of one
or more prompts to present in order.

The responses to the prompt are replaced in the template string: %% are
replaced in order, so the first prompt replaces the first %%, the second
replaces the second, and so on. In addition, %1 up to %9 are replaced with the
responses to the first the ninth prompts

The default template is "%1" so the response to the first prompt is processed
as a command.

Note that this changes the behaviour for %% so if there is only one prompt,
only the first %% will be replaced. Templates such as "neww -n '%%' 'ssh %%'"
should be changed to "neww -n '%1' 'ssh %1'".

From Tiago Cunha.


# 1.26 18-Aug-2009 nicm

Add a "delete line" key when editing in the status line or the search up/down
prompt. C-u with emacs keys, d with vi.


# 1.25 13-Aug-2009 nicm

Switch the prompt code to return an empty string when the user enters no
response and reserve NULL for an explicit cancel. Change all callbacks to treat
them the same so no functional change.

Also add cancel key bindings to emacs mode which were missing.


# 1.24 08-Aug-2009 nicm

Options to set the colours and attributes for status-left/-right. From Thomas
Adam, thanks.


# 1.23 05-Aug-2009 nicm

If colours are not supported by the terminal, try to emulate a coloured
background by setting or clearing the reverse attribute.

This makes a few applications which don't use the reverse attribute themselves
a little happier, and allows the status, message and mode options to have
default attributes and fg/bg options that work as expected when set as reverse.


# 1.22 30-Jul-2009 nicm

Plug some memory leaks.


# 1.21 28-Jul-2009 nicm

Next step towards customisable mode keys: build each default table of keys into
a named tree on start and use that for lookups. Also add command to string
translation tables and modify list-keys to show the the mode key bindings (new
-t argument).


# 1.20 27-Jul-2009 nicm

Change mode key bindings from big switches into a set of tables. Rather than
lumping them all together, split editing keys from those used in choice/more
mode and those for copy/scroll mode.

Tidier and clearer, and the first step towards customisable mode keys.


# 1.19 27-Jul-2009 nicm

Get rid of empty mode_key_free function.


# 1.18 27-Jul-2009 nicm

Add a key to delete to end of line at the prompt (^K in emacs mode, C/D in vi).

From Kalle Olavi Niemitalo.


# 1.17 26-Jul-2009 nicm

Calculate the space available for the prompt buffer and the cursor position
correctly, and make it work when the screen is not wide enough.

Noticed by Kalle Olavi Niemitalo.


# 1.16 21-Jul-2009 nicm

Remove a couple of unused functions and fix a type ("FALLTHOUGH"), found by
lint.


# 1.15 20-Jul-2009 nicm

Add a status-justify option to allow the window list in the status line to be
positioned at the left, centre, or right.


# 1.14 20-Jul-2009 nicm

New options, window-status-current-{fg,bg,attr}, to set the fg, bg and
attributes with which the current window is shown in the status line. From
Johan Friis, thanks.


# 1.13 17-Jul-2009 nicm

- New command display-message (alias display) to display a message in the
status line (bound to "i" and displays the current window and time by
default). The same substitutions are applied as for status-left/right.
- Add support for including the window index (#I), pane index (#P) and window
name (#W) in the message, and status-left or status-right.
- Bump protocol version.

From Tiago Cunha, thanks!


# 1.12 17-Jul-2009 nicm

Memory could be leaked if a second prompt or message appeared while another was
still present, so add a separate prompt free callback and make the _clear
function responsible for calling it if necessary (rather than the individual
prompt callbacks). Also make both messages and prompts clear any existing when
a new is set.

In addition, the screen could be modified while the prompt is there, restore
the redraw-entire-screen behaviour on prompt clear; add a comment as a
reminder.


# 1.11 16-Jul-2009 nicm

Remove some duplicate code that was causing the status line to be redrawn even
when it hadn't changed.


# 1.10 15-Jul-2009 nicm

Make status_message_set a variadic printf-like function. No functional change -
helpful for a couple of things coming soon.


# 1.9 15-Jul-2009 nicm

Having to update NSETOPTION/NSETWINDOWOPTION when adding new options is a bit
annoying and it is only use for iterating, so use a sentinel to mark the end of
each array instead. Different fix for a problem pointed out by Kalle Olavi
Niemitalo.


# 1.8 14-Jul-2009 nicm

For some reason when clearing status/message it was redrawing the entire client
not just the status line. Changing this also revealed the check for the status
line was incorrect when drawing the pane.


# 1.7 14-Jul-2009 nicm

Instead of faking up a status line in status_redraw, use the same code to
redraw it as to draw the entire screen, just skip all lines but the last.

This makes horizontal split redraw properly when the status line is off.


# 1.6 12-Jul-2009 nicm

Add a "back to indentation" key in copy mode to move the cursor to the first
non-whitespace character. ^ with vi and M-m with emacs key bindings. Another
from Kalle Olavi Niemitalo, thanks.


Revision tags: OPENBSD_4_6_BASE
# 1.5 26-Jun-2009 nicm

Status line fixes: don't truncate status-right now the length calculation is
done for UTF-8, limit to the maximum length correctly when printing, and always
print a space even if the left string is longer than the width available.


# 1.4 04-Jun-2009 nicm

If the prompt is hidden or a password is sent with -U, zero it before freeing
it.


# 1.3 03-Jun-2009 nicm

New session option, status-utf8, to control the interpretation of top-bit-set
characters in status-left and status-right (if on, they are treated as UTF-8;
otherwise passed through).


# 1.2 03-Jun-2009 nicm

Add a UTF-8 aware string length function and make UTF-8 in
status-left/status-right work properly. At the moment any top-bit-set
characters are assumed to be UTF-8: a status-utf8 option to configure this will
come shortly.


# 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.213 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.212 16-May-2020 nicm

Rename KEYC_ESCAPE to KEYC_META.


# 1.211 16-May-2020 nicm

Expand target from client and use it to expand the prompt.


# 1.210 16-May-2020 nicm

Support embedded styles in the display-message message, GitHub issue
2206.


# 1.209 16-May-2020 nicm

Change message log to be per server rather than per client and include
every command that is run.


# 1.208 16-May-2020 nicm

Do not hoke into struct window_pane from the tty code and instead set
everything up in tty_ctx. Provide a way to initialize the tty_ctx from a
callback and use it to let popups draw directly through input_parse in
the same way as panes do, rather than forcing a full redraw on every
change.


# 1.207 16-May-2020 nicm

Use formats for status-style and message-style.


# 1.206 16-May-2020 nicm

Complete partial window indexes properly.


# 1.205 16-May-2020 nicm

Add -W and -T flags to command-prompt to only complete a window and a
target, also complete aliases.


# 1.204 16-May-2020 nicm

Improve command prompt completion:

- Show a menu with completions if there are multiple.

- Don't complete argument stuff (options, layouts) at start of text.

- For -t and -s, if there is no : then complete sessions but if there is
a :, show a menu of all windows in the session rather than trying to
complete the window name which is a bit useless if there are
duplicates.


# 1.203 16-May-2020 nicm

Drop having a separate type for style options and make them all strings,
which allows formats to be expanded. Any styles without a '#{' are still
validated when they are set but any with a '#{' are not. Formats are not
expanded usefully in many cases yet, that will be changed later.

To make this work, a few other changes:

- set-option -a with a style option automatically appends a ",".

- OSC 10 and 11 don't set the window-style option anymore, instead the
fg and bg are stored in the pane struct and act as the defaults that
can be overridden by window-style.

- status-fg and -bg now override status-style instead of trying to keep
them in sync.


Revision tags: OPENBSD_6_7_BASE
# 1.202 12-Mar-2020 nicm

Add C-g to cancel command prompt with vi(1) keys as well as emacs, and q
in command mode.


# 1.201 27-Jan-2020 nicm

Add support for adding a note to a key binding (with bind-key -N) and
use this to add descriptions to the default key bindings. A new -N flag
to list-keys shows key bindings with notes rather than the default
bind-key command used to create them. Change the default ? binding to
use this to show a readable summary of keys.

Also extend command-prompt to return the name of the key pressed and add
a default binding (/) to show the note for the next key pressed

Suggested by Alex Tremblay in GitHub issue 2000.


Revision tags: OPENBSD_6_6_BASE
# 1.200 28-May-2019 nicm

Redraw status line if size changes, GitHub issue 1762. Also fix length
of target buffer when pasting into status line.


# 1.199 23-May-2019 nicm

Fix length calculation for pasting UTF-8 characters in the status line,
GitHub issue 1753.


# 1.198 11-May-2019 nicm

Do not reduce window height by status line height for control mode
clients, from George Nachman.


# 1.197 03-May-2019 nicm

Fix reverse attribute in status line, GitHub issue 1709.


# 1.196 26-Apr-2019 nicm

Merge hooks into options and make each one an array option. This allows
multiple commands to be easily bound to one hook. set-hook and
show-hooks remain but they are now variants of set-option and
show-options. show-options now has a -H flag to show hooks (by default
they are not shown).


# 1.195 25-Apr-2019 nicm

options_array_item_value cannot return NULL.


# 1.194 23-Apr-2019 nicm

Somehow missed these bits in last commit.


# 1.193 23-Apr-2019 nicm

Indicate an array option with a flag rather than a special type so that
in future will not have to be strings.


Revision tags: OPENBSD_6_5_BASE
# 1.192 18-Mar-2019 nicm

Extend the #[] style syntax and use that together with previous format
changes to allow the status line to be entirely configured with a single
option.

Now that it is possible to configure their content, enable the existing
code that lets the status line be multiple lines in height. The status
option can now take a value of 2, 3, 4 or 5 (as well as the previous on
or off) to configure more than one line. The new status-format array
option configures the format of each line, the default just references
the existing status-* options, although some of the more obscure status
options may be eliminated in time.

Additions to the #[] syntax are: "align" to specify alignment (left,
centre, right), "list" for the window list and "range" to configure
ranges of text for the mouse bindings.

The "align" keyword can also be used to specify alignment of entries in
tree mode and the pane status lines.


# 1.191 18-Mar-2019 nicm

Make array options a sparse tree instead of an array of char * and
remove the size limit.


# 1.190 18-Mar-2019 nicm

With force, kill previous job before starting new. Fixes problem
reported by Scott Mcdermott in GitHub issue 1627.


# 1.189 16-Mar-2019 nicm

Use a pointer for the active screen in the status line instead of
copying them around all the time.


# 1.188 16-Mar-2019 nicm

Give status_save_old the client so it can do the reinit too.


# 1.187 16-Mar-2019 nicm

Tidy and rename some bits of status line code.


# 1.186 15-Mar-2019 nicm

Move status line free into its own function.


# 1.185 14-Mar-2019 nicm

Store the time in the format tree rather than passing it around.


# 1.184 12-Mar-2019 nicm

DECRC and DECSC apparently need to preserve origin mode as well, based
on a fix from Marc Reisner.


# 1.183 09-Feb-2019 nicm

Completion of command-alias members.


# 1.182 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.181 29-Aug-2018 nicm

Keep any text killed in the command prompt with C-w and yank it with
C-y, only use the top buffer if no text has previously been killed. This
and previous change promped by discussion with kn@.


# 1.180 29-Aug-2018 nicm

Add C-Left and C-Right as aliases for M-b and M-f.


# 1.179 22-Aug-2018 nicm

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


# 1.178 20-Aug-2018 nicm

Move offset of window list into status struct.


# 1.177 19-Aug-2018 nicm

Add a client redraw-window flag instead of the redraw-all flag and for
all just use the three flags together (window, borders, status).


Revision tags: OPENBSD_6_3_BASE
# 1.176 22-Feb-2018 nicm

Remove an unused variable.


# 1.175 05-Feb-2018 nicm

Add struct status_line to hold status line members of struct client, not
used yet but will be soon. From Thomas Adam.


# 1.174 01-Jan-2018 nicm

Add C-g at command prompt for emacs people, GitHub issue 1213.


# 1.173 27-Dec-2017 nicm

Draw command prompt correctly with status line off.


# 1.172 18-Dec-2017 nicm

Remove unused variable from Thomas Adam.


# 1.171 02-Nov-2017 nicm

Add a "fast" version of screen_write_copy for tree mode that doesn't do
all the checks and selection and marking stuff needed for copy mode.


# 1.170 20-Oct-2017 nicm

Clear status line with spaces again so reverse works, spotted by sthen.


# 1.169 16-Oct-2017 nicm

Infrastructure for drawing status lines of more than one line in height,
still only one is allowed but this lets tmux draw bigger ones.


Revision tags: OPENBSD_6_2_BASE
# 1.168 29-May-2017 nicm

Add a flag to stop the prompt input being expanded.


# 1.167 29-May-2017 nicm

Store a copy of the old status line, will be needed soon for new choose mode.


# 1.166 17-May-2017 nicm

Tidy command prompt callbacks and pass in the client.


# 1.165 03-May-2017 nicm

Add a format for the last search string in copy mode and fix the prompt
so it can work when in -I, suggested by Suraj N Kurapati.


# 1.164 01-May-2017 nicm

In order that people can use formats like #D in #() in the status line
and not have to wait for an update when they change pane, we allow
commands to run more than once a second if the expanded form
changes. Unfortunately this can mean them being run far too often
(pretty much continually) when multiple clients exist, because some
formats (including #D) will always differ between clients.

To avoid this, give each client its own tree of jobs which means that
the same command will be different instances for each client - similar
to how we have the tag to separate commands for different panes.

GitHub issue 889; test case reported by Paul Johnson.


# 1.163 22-Apr-2017 nicm

Memory leak from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.162 09-Feb-2017 nicm

Break the message storage function into its own function, useful for
debugging.


# 1.161 03-Feb-2017 nicm

Cache status line position to reduce option lookups during output.


# 1.160 03-Feb-2017 nicm

Add a window or pane id "tag" to each format tree and use it to separate
jobs, this means that if the same job is used for different windows or
panes (for example in pane-border-format), it will be run separately for
each pane.


# 1.159 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.158 06-Jan-2017 nicm

Incremental search in copy mode (on for emacs keys by default) - much
the same as normal searching but updates the cursor position and marked
search terms as you type. C-r and C-s in the prompt repeat the search,
once finished searching (with Enter), N and n work as before.


# 1.157 05-Jan-2017 nicm

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


# 1.156 07-Dec-2016 nicm

Do not clear the prompt when a message is shown, just leave it around and
return to it when the message is finished.


# 1.155 12-Oct-2016 nicm

Drop the edit mode key tables and just use fixed key bindings for the
command prompt.


# 1.154 12-Oct-2016 nicm

The repeat prompt in both emacs and vi (and the old one in tmux) doesn't
support line editing and instead executes a command as soon as a
non-number key is pressed. Add a -N flag to command-prompt for the same
in copy mode. Reported by Theo Buehler.


# 1.153 11-Oct-2016 nicm

Fundamental change to how copy mode key bindings work:

The vi-copy and emacs-copy mode key tables are gone, and instead copy
mode commands are bound in one of two normal key tables ("copy-mode" or
"copy-mode-vi"). Keys are bound to "send-keys -X copy-mode-command". So:

bind -temacs-copy C-Up scroll-up
bind -temacs-copy -R5 WheelUpPane scroll-up

Becomes:

bind -Tcopy-mode C-Up send -X scroll-up
bind -Tcopy-mode WheelUpPane send -N5 -X scroll-up

This allows the full command parser and command set to be used - for
example, we can use the normal command prompt for searching, jumping,
and so on instead of a custom one:

bind -Tcopy-mode C-r command-prompt -p'search up' "send -X search-backward '%%'"

command-prompt also gets a -1 option to only require on key press, which
is needed for jumping.

The plan is to get rid of mode keys entirely, so more to come eventually.


# 1.152 11-Oct-2016 nicm

Support UTF-8 entry into the command prompt.


# 1.151 10-Oct-2016 nicm

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


# 1.150 12-Sep-2016 nicm

Allow repeat count to be specified in mode key tables with bind-key -R,
and set the default repeat count to 5 for WheelUp and WheelDown in
copy-mode.


Revision tags: OPENBSD_6_0_BASE
# 1.149 06-Jun-2016 nicm

Allow #[] in window-status-separator.


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

I no longer use my SourceForge address so replace it.


# 1.147 01-Jan-2016 nicm

Don't rely on a calculation wrapping when applying message-limit, and
break out of the loop early. From Nicolas Viennot.


# 1.146 11-Dec-2015 nicm

Style nits and line wrapping of function declarations.


# 1.145 11-Dec-2015 nicm

Add cmdq as an argument to format_create and add a format for the
command name (will also be used for more later).


# 1.144 08-Dec-2015 nicm

Remove format_create_flags and just pass flags to format_create.


# 1.143 22-Nov-2015 tim

If display-time is set to 0, show status messages until a key is pressed;
OK nicm@


# 1.142 20-Nov-2015 nicm

Instead of separate tables for different types of options, give each
option a scope type (server, session, window) in one table.


# 1.141 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.140 13-Nov-2015 nicm

Long overdue change to the way we store cells in the grid: now, instead
of storing a full grid_cell with UTF-8 data and everything, store a new
type grid_cell_entry. This can either be the cell itself (for ASCII
cells), or an offset into an extended array (per line) for UTF-8
data.

This avoid a large (8 byte) overhead on non-UTF-8 cells (by far the
majority for most users) without the complexity of the shadow array we
had before. Grid memory without any UTF-8 is about half.

The disadvantage that cells can no longer be modified in place and need
to be copied out of the grid and back but it turned out to be lot less
complicated than I expected.


# 1.139 12-Nov-2015 nicm

Nuke the utf8 and status-utf8 options and make tmux only a UTF-8
terminal. We still support non-UTF-8 terminals outside tmux, but inside
it is always UTF-8 (as when the utf8 and status-utf8 options were on).


# 1.138 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.137 27-Oct-2015 nicm

Move struct options into options.c.


# 1.136 20-Oct-2015 nicm

Use client pointer not file descriptor in logging.


# 1.135 14-Sep-2015 nicm

Make refresh-client force update of jobs, from Sina Siadat.


# 1.134 29-Aug-2015 nicm

Move struct paste_buffer out of tmux.h.


# 1.133 28-Aug-2015 nicm

Run status update on a per-client timer at status-interval.


Revision tags: OPENBSD_5_8_BASE
# 1.132 29-Jul-2015 nicm

status_out and associated data structures are no longer used.


# 1.131 28-Jul-2015 nicm

Tidy up the way terminals are described and move some structs out of tmux.h.


# 1.130 20-Jul-2015 nicm

Add an option (history-file) for a file to save/restore command prompt
history, from Olof-Joachim Frahm.


# 1.129 27-May-2015 nicm

Move the jobs output cache into the formats code so that #() work more
generally (for example, again working in set-titles-string).


# 1.128 06-May-2015 nicm

Remove ARRAY_* from history and expand completion to complete a) layout
names and b) targets beginning with -t or -s.


# 1.127 25-Apr-2015 nicm

Make message log a TAILQ.


# 1.126 24-Apr-2015 nicm

Set working directory for run-shell and if-shell.


# 1.125 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_7_BASE
# 1.124 06-Feb-2015 nicm

Use the same time for both calls to format_expand_time.


# 1.123 06-Feb-2015 nicm

status_replace can now become local to status.c and it no longer needs
the jobsflag argument. While here there is no need to repeat work that
format_defaults already does.


# 1.122 06-Feb-2015 nicm

Add format_expand_time and use it instead of status_replace where
command execution is not needed.


# 1.121 05-Feb-2015 nicm

Wrap all the individual format_* calls in a single format_defaults
functions.


# 1.120 01-Feb-2015 nicm

Remove two unused arguments from status_replace.


# 1.119 20-Jan-2015 sthen

typo in comment ;) ok nicm


# 1.118 05-Nov-2014 nicm

Do not put a space between status-left/status-right and the window list,
instead move the space into the defaults for the options (so status-left
now defaults to "[#S] ". From Balazs Kezes.


# 1.117 20-Oct-2014 nicm

Better format for printf format attributes.


# 1.116 08-Oct-2014 nicm

Add xreallocarray and remove nmemb argument from xrealloc.


# 1.115 02-Oct-2014 nicm

Take account of window-status-separator when checking window position,
based on diff from Balazs Kezes.


Revision tags: OPENBSD_5_6_BASE
# 1.114 24-Apr-2014 nicm

There is no longer a need for a paste_stack struct or for global_buffers
to be global. Move to paste.c.


# 1.113 17-Apr-2014 nicm

Remove the monitor-content option and associated bits and bobs. It's
never worked very well. If there is a big demand for it to return, will
consider better ways to do it.


# 1.112 02-Apr-2014 nicm

Do not replace ## with # in status_replace1 because it'll be done later
by the format code.


# 1.111 31-Mar-2014 nicm

Make message-limit a server option.


Revision tags: OPENBSD_5_5_BASE
# 1.110 14-Feb-2014 nicm

Style nit - no space between function name and bracket.


# 1.109 14-Feb-2014 nicm

Check for NULL session and whatnot in status_replace, from Thomas Adam.


# 1.108 28-Jan-2014 nicm

Allow replacing each of the many sets of separate foo-{fg,bg,attr}
options with a single foo-style option. For example:

set -g status-fg yellow
set -g status-bg red
set -g status-attr blink

Becomes:

set -g status-style fg=yellow,bg=red,blink

The -a flag to set can be used to add to rather than replace a style. So:

set -g status-bg red

Becomes:

set -ag status-style bg=red

Currently this is fully backwards compatible (all *-{fg,bg,attr} options
remain) but the plan is to deprecate them over time.

From Tiago Cunha.


Revision tags: OPENBSD_5_4_BASE
# 1.107 05-Jul-2013 nicm

Whitespace nits, from Ben Boeckel.


# 1.106 05-Jul-2013 nicm

Act like vi(1) when moving words, from Ben Boeckel.


# 1.105 05-Jul-2013 nicm

Implement s, S, C mode switch commands in vi(1) mode, from Ben Boeckel.


# 1.104 31-May-2013 nicm

Demote the old single-character replacement variables (#S and friends)
to aliases of formats. From Tiago Cunha.


# 1.103 25-Mar-2013 nicm

Extend jobs to support writing and use that for copy-pipe instead of
popen, from Chris Johnsen.


# 1.102 22-Mar-2013 nicm

evbuffer_readline returns allocated storage, don't leak it.


# 1.101 22-Mar-2013 nicm

Add copy-pipe mode command to copy selection and also pipe to a command.


# 1.100 22-Mar-2013 nicm

No more lint means no more ARGSUSED.


# 1.99 21-Mar-2013 nicm

Aargh. Spaces -> tabs.


# 1.98 21-Mar-2013 nicm

Do not leak formats in status_replace.


# 1.97 21-Mar-2013 nicm

Add a format client_prefix which is 1 if prefix key has been
pressed, used for example #{?client_prefix,X,Y}. Also a few extra
server_client_status needed.


# 1.96 21-Mar-2013 nicm

Allow formats in status options.


Revision tags: OPENBSD_5_3_BASE
# 1.95 27-Nov-2012 nicm

Add window-status-last-* options, from Boris Faure.


Revision tags: OPENBSD_5_2_BASE
# 1.94 10-Jul-2012 nicm

xfree is not particularly helpful, remove it. From Thomas Adam.


# 1.93 09-Jul-2012 nicm

Move a NULL check inside a function, from Tiago Cunha.


# 1.92 29-Apr-2012 nicm

Use int not u_char for colours from options since they may have bit 8
set to mark them as 256-colour. Reported by Chris Johnson.


# 1.91 23-Apr-2012 nicm

Add window-status-separator option, from Thomas Adam.


# 1.90 17-Mar-2012 nicm

Check event_initialized before event_del if event may not have been set
up; libevent2 complains about this. Reported by Moriyoshi Koizumi.


# 1.89 04-Mar-2012 nicm

Add A and I keys for vi status line editing.


# 1.88 03-Mar-2012 nicm

The wlmouse offset should be part of the client, not the server. From
Ailin Nemui.


Revision tags: OPENBSD_5_1_BASE
# 1.87 29-Jan-2012 nicm

Add an option to move the status line to the top of the screen,
requested by many.


# 1.86 26-Jan-2012 nicm

Terminate strftime buffer properly even if a really long format string
is given, from Tiago Cunha.


# 1.85 26-Jan-2012 nicm

Fix memory leak in error path, from Tiago Cunha.


# 1.84 20-Jan-2012 nicm

Add some trivial additional status line attributes from jwcxz at users
dot sourceforge dot net.


# 1.83 20-Jan-2012 nicm

Add space movement keys for vi mode in the status line from Ben Boeckel.


# 1.82 01-Dec-2011 nicm

Make M-f and M-b work the same at the command prompt as in copy mode,
pointed out by Romain Francoise.


# 1.81 15-Nov-2011 nicm

Add word movement and editing command for command prompt editing, from
Ben Boeckel.


# 1.80 15-Nov-2011 nicm

Make window_pane_index work the same as window_index, from Ben Boeckel.


# 1.79 05-Nov-2011 nicm

Option to change status line (message) background when using vi keys and
in command mode. From Ben Boeckel.


# 1.78 20-Aug-2011 nicm

Fix a couple of memory leaks, from marcel partap.


Revision tags: OPENBSD_5_0_BASE
# 1.77 08-Jul-2011 nicm

Make confirm-before prompt customizable with -p option like
command-prompt. Also move responsibility for calling status_replace into
status_prompt_{set,update} and add #W and #P to the default kill-window
and kill-pane prompts. By Tiago Cunha.


# 1.76 02-Jul-2011 nicm

Allow the initial context on prompts to be set with the new -I option to
command-prompt. From Tiago Cunha.


# 1.75 29-Apr-2011 nicm

Only redraw the status line on command update, not the entire client
(big DOH).


# 1.74 24-Apr-2011 nicm

Provide #h for short hostname (no domain) from Michal Mazurek.


# 1.73 18-Apr-2011 nicm

Add an option (mouse-select-window) which allows the mouse to be used by
clicking on the status line, written by hsim at gmx dot li.


# 1.72 29-Mar-2011 nicm

Change -t on display-message to be target-pane for the #[A-Z]
replacements and add -c as target-client.


Revision tags: OPENBSD_4_9_BASE
# 1.71 26-Jan-2011 nicm

Simplify the way jobs work and drop the persist type, so all jobs are
fire-and-forget.

Status jobs now managed with two trees of output (new and old), rather
than storing the output in the jobs themselves. When the status line is
processed any jobs which don't appear in the new tree are started and
the output from the old tree displayed. When a job finishes it updates
the new tree with its output and that is used for any subsequent
redraws. When the status interval expires, the new tree is moved to the
old so that all jobs are run again.

This fixes the "#(echo %H:%M:%S)" problem which would lead to thousands
of identical persistent jobs and high memory use (this can still be
achieved by adding "sleep 30" but that is much less likely to happen by
accident).


# 1.70 03-Jan-2011 nicm

Handle a # at the end of a replacement string (such as status-left)
correctly. Found by Thomas Adam.


# 1.69 01-Jan-2011 nicm

Move the user-visible parts of all options (names, types, limit, default
values) together into one set of tables in options-table.c. Also clean
up and simplify cmd-set-options.c and move a common print function into
option-table.c.


# 1.68 30-Dec-2010 nicm

Change from a per-session stack of buffers to one global stack which is
much more convenient and also simplifies lot of code. This renders
copy-buffer useless and makes buffer-limit now a server option.

By Tiago Cunha.


# 1.67 30-Dec-2010 nicm

Add a function to create window flags rather than doing the same thing
in two places. From Thomas Adam.


# 1.66 11-Dec-2010 nicm

Oops, these functions return a const char *, so make the local variable
const as well.


# 1.65 11-Dec-2010 nicm

Make the prompt history global for all clients which is much more useful than per-client history.


# 1.64 06-Dec-2010 nicm

Add an option to alert (monitor) for silence (lack of activity) in a
window. From Thomas Adam.


Revision tags: OPENBSD_4_8_BASE
# 1.63 21-Jun-2010 nicm

Having a list of winlinks->alerts for each session is stupid, just store
the alert flags directly in the winlink itself.


# 1.62 14-May-2010 nicm

Colour+attribute options for status line alerts, from Alex Alexander.


# 1.61 31-Mar-2010 nicm

Don't accept keys with modifiers as input. Fixes crash reported by Brian
R Landy.


# 1.60 27-Mar-2010 nicm

Don't leak job command in #().


# 1.59 22-Mar-2010 nicm

Dead functions, lint.


Revision tags: OPENBSD_4_7_BASE
# 1.58 27-Jan-2010 nicm

Calculate offset correctly, fixes incorrect offset and prevents crash when
status-left is empty. From Micah Cowan.


# 1.57 26-Jan-2010 nicm

Actually use the copy made when no newline is found, from martynas@.


# 1.56 14-Dec-2009 nicm

Add server options to completion as well.


# 1.55 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.54 03-Dec-2009 nicm

Eliminate duplicate code and ease the passage for server-wide options by adding
a -w flag to set-option and show-options and making setw and showw aliases to
set -w and show -w.

Note: setw and showw are still there, but now aliases for set -w and show -w.


# 1.53 26-Nov-2009 nicm

Tidy up various bits of the paste code, make the data buffer char * and add
comments.


# 1.52 26-Nov-2009 nicm

Remove a couple of unused arguments where possible, and add /* ARGSUSED */ to
the rest to reduce lint output.


# 1.51 20-Nov-2009 nicm

Display UTF-8 properly in status line messages and prompt. Cursor handling is
still way off though.


# 1.50 20-Nov-2009 nicm

Remove oldest messages from log when limit is hit, not newest.


# 1.49 19-Nov-2009 nicm

Get some brackets in the right place so ## works. Also fix a space in a
comment.


# 1.48 19-Nov-2009 nicm

Change status line drawing to create the window list in a separate screen and
then copy it into the status line screen. This allows UTF-8 in window names and
fixes some problems with #[] in window-status-format.


# 1.47 19-Nov-2009 nicm

Two new options, window-status-format and window-status-current-format, which
allow the format of each window in the status line window list to be controlled
using similar # sequences as status-left/right.

This diff also moves part of the way towards UTF-8 support in window names but
it isn't quite there yet.


# 1.46 19-Nov-2009 nicm

Tidy up by breaking the # replacement code into a separate function, also add a
few comments.


# 1.45 19-Nov-2009 nicm

Don't interpret #() for display-message, it usually doesn't make sense and may
leak commands.


# 1.44 18-Nov-2009 nicm

Add a per-client log of status line messages displayed while that client
exists. A new message-limit session option sets the maximum number of entries
and a command, show-messages, shows the log (bound to ~ by default).

This (and prompt history) might be better as a single global log but until
there are global options it is easier for them to be per client.


# 1.43 17-Nov-2009 nicm

Permit top-bit-set characters to be entered in the status line. They could
already be set from the shell and are just passed through when printing (so
invisible characters or displaying on terminals with different character sets
may cause problems).

Note that entering UTF-8 may not work and in any case currently the status line
cannot display it correctly (outside of status-left/status-right).


# 1.42 04-Nov-2009 nicm

Use timeout events for the identify and message timers.


# 1.41 04-Nov-2009 nicm

Switch jobs over to use a bufferevent.


# 1.40 04-Nov-2009 nicm

Unused (but assigned to) variable, found by lint.


# 1.39 01-Nov-2009 nicm

Add a flag for jobs that shouldn't be freed after they've died and use it for
status jobs, then only kill those jobs when status-left, status-right or
set-titles-string is changed.

Fixes problems with changing options from inside #().


# 1.38 10-Oct-2009 nicm

Rather than running status-left, status-right and window title #() with popen
immediately every redraw, queue them up and run them in the background,
starting each once every status-interval. The actual status line uses the
output from the last run.

This brings several advantages:

- tmux itself may be called from inside #() without causing the server to hang;
- likewise, sleep or similar doesn't cause the server to block;
- commands aren't run excessively often when redrawing;
- commands shared by status-left and status-right, or used multiple times, will
only be run once.

run-shell and if-shell still use system()/popen() but will be changed over to
use this too later.


# 1.37 10-Oct-2009 nicm

Add "grouped sessions" which have independent name, options, current window and
so on but where the linked windows are synchronized (ie creating, killing
windows and so on are mirrored between the sessions). A grouped session may be
created by passing -t to new-session.

Had this around for a while, tested by a couple of people.


# 1.36 23-Sep-2009 nicm

Remove PROMPT_HIDDEN code which is now unused.


# 1.35 23-Sep-2009 nicm

Remove the internal tmux locking and instead detach each client and run the
command specified by a new option "lock-command" (by default "lock -np") in
each client.

This means each terminal has to be unlocked individually but simplifies the
code and allows the system password to be used to unlock.

Note that the set-password command is gone, so it will need to be removed from
configuration files, and the -U command line flag has been removed.

This is the third protocol version change so again it is best to stop the tmux
server before upgrading.


# 1.34 20-Sep-2009 nicm

Regularise some fatal messages.


# 1.33 10-Sep-2009 nicm

Permit options such as status-bg to be configured using the entire 256 colour
palette by setting "colour0" to "colour255".


# 1.32 07-Sep-2009 nicm

Give each paste buffer a size member instead of requiring them to be
zero-terminated.


# 1.31 07-Sep-2009 nicm

Permit embedded colour and attributes in status-left and status-right using new
#[] special characters, for example #[fg=red,bg=blue,blink].


# 1.30 02-Sep-2009 nicm

Add a transpose-chars command in edit mode (C-t in emacs mode only). From Kalle
Olavi Niemitalo.


# 1.29 01-Sep-2009 nicm

Use "Password:" with no space for password prompts and don't display a *s for
the password, like pretty much everything else. From martynas@ with minor
tweaks by me.


# 1.28 31-Aug-2009 nicm

Add a new display-panes command, with two options (display-panes-colour and
display-panes-time), which displays a visual indication of the number of each
pane.


# 1.27 19-Aug-2009 nicm

Extend command-prompt with a -p option which is a comma-separated list of one
or more prompts to present in order.

The responses to the prompt are replaced in the template string: %% are
replaced in order, so the first prompt replaces the first %%, the second
replaces the second, and so on. In addition, %1 up to %9 are replaced with the
responses to the first the ninth prompts

The default template is "%1" so the response to the first prompt is processed
as a command.

Note that this changes the behaviour for %% so if there is only one prompt,
only the first %% will be replaced. Templates such as "neww -n '%%' 'ssh %%'"
should be changed to "neww -n '%1' 'ssh %1'".

From Tiago Cunha.


# 1.26 18-Aug-2009 nicm

Add a "delete line" key when editing in the status line or the search up/down
prompt. C-u with emacs keys, d with vi.


# 1.25 13-Aug-2009 nicm

Switch the prompt code to return an empty string when the user enters no
response and reserve NULL for an explicit cancel. Change all callbacks to treat
them the same so no functional change.

Also add cancel key bindings to emacs mode which were missing.


# 1.24 08-Aug-2009 nicm

Options to set the colours and attributes for status-left/-right. From Thomas
Adam, thanks.


# 1.23 05-Aug-2009 nicm

If colours are not supported by the terminal, try to emulate a coloured
background by setting or clearing the reverse attribute.

This makes a few applications which don't use the reverse attribute themselves
a little happier, and allows the status, message and mode options to have
default attributes and fg/bg options that work as expected when set as reverse.


# 1.22 30-Jul-2009 nicm

Plug some memory leaks.


# 1.21 28-Jul-2009 nicm

Next step towards customisable mode keys: build each default table of keys into
a named tree on start and use that for lookups. Also add command to string
translation tables and modify list-keys to show the the mode key bindings (new
-t argument).


# 1.20 27-Jul-2009 nicm

Change mode key bindings from big switches into a set of tables. Rather than
lumping them all together, split editing keys from those used in choice/more
mode and those for copy/scroll mode.

Tidier and clearer, and the first step towards customisable mode keys.


# 1.19 27-Jul-2009 nicm

Get rid of empty mode_key_free function.


# 1.18 27-Jul-2009 nicm

Add a key to delete to end of line at the prompt (^K in emacs mode, C/D in vi).

From Kalle Olavi Niemitalo.


# 1.17 26-Jul-2009 nicm

Calculate the space available for the prompt buffer and the cursor position
correctly, and make it work when the screen is not wide enough.

Noticed by Kalle Olavi Niemitalo.


# 1.16 21-Jul-2009 nicm

Remove a couple of unused functions and fix a type ("FALLTHOUGH"), found by
lint.


# 1.15 20-Jul-2009 nicm

Add a status-justify option to allow the window list in the status line to be
positioned at the left, centre, or right.


# 1.14 20-Jul-2009 nicm

New options, window-status-current-{fg,bg,attr}, to set the fg, bg and
attributes with which the current window is shown in the status line. From
Johan Friis, thanks.


# 1.13 17-Jul-2009 nicm

- New command display-message (alias display) to display a message in the
status line (bound to "i" and displays the current window and time by
default). The same substitutions are applied as for status-left/right.
- Add support for including the window index (#I), pane index (#P) and window
name (#W) in the message, and status-left or status-right.
- Bump protocol version.

From Tiago Cunha, thanks!


# 1.12 17-Jul-2009 nicm

Memory could be leaked if a second prompt or message appeared while another was
still present, so add a separate prompt free callback and make the _clear
function responsible for calling it if necessary (rather than the individual
prompt callbacks). Also make both messages and prompts clear any existing when
a new is set.

In addition, the screen could be modified while the prompt is there, restore
the redraw-entire-screen behaviour on prompt clear; add a comment as a
reminder.


# 1.11 16-Jul-2009 nicm

Remove some duplicate code that was causing the status line to be redrawn even
when it hadn't changed.


# 1.10 15-Jul-2009 nicm

Make status_message_set a variadic printf-like function. No functional change -
helpful for a couple of things coming soon.


# 1.9 15-Jul-2009 nicm

Having to update NSETOPTION/NSETWINDOWOPTION when adding new options is a bit
annoying and it is only use for iterating, so use a sentinel to mark the end of
each array instead. Different fix for a problem pointed out by Kalle Olavi
Niemitalo.


# 1.8 14-Jul-2009 nicm

For some reason when clearing status/message it was redrawing the entire client
not just the status line. Changing this also revealed the check for the status
line was incorrect when drawing the pane.


# 1.7 14-Jul-2009 nicm

Instead of faking up a status line in status_redraw, use the same code to
redraw it as to draw the entire screen, just skip all lines but the last.

This makes horizontal split redraw properly when the status line is off.


# 1.6 12-Jul-2009 nicm

Add a "back to indentation" key in copy mode to move the cursor to the first
non-whitespace character. ^ with vi and M-m with emacs key bindings. Another
from Kalle Olavi Niemitalo, thanks.


Revision tags: OPENBSD_4_6_BASE
# 1.5 26-Jun-2009 nicm

Status line fixes: don't truncate status-right now the length calculation is
done for UTF-8, limit to the maximum length correctly when printing, and always
print a space even if the left string is longer than the width available.


# 1.4 04-Jun-2009 nicm

If the prompt is hidden or a password is sent with -U, zero it before freeing
it.


# 1.3 03-Jun-2009 nicm

New session option, status-utf8, to control the interpretation of top-bit-set
characters in status-left and status-right (if on, they are treated as UTF-8;
otherwise passed through).


# 1.2 03-Jun-2009 nicm

Add a UTF-8 aware string length function and make UTF-8 in
status-left/status-right work properly. At the moment any top-bit-set
characters are assumed to be UTF-8: a status-utf8 option to configure this will
come shortly.


# 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.202 12-Mar-2020 nicm

Add C-g to cancel command prompt with vi(1) keys as well as emacs, and q
in command mode.


# 1.201 27-Jan-2020 nicm

Add support for adding a note to a key binding (with bind-key -N) and
use this to add descriptions to the default key bindings. A new -N flag
to list-keys shows key bindings with notes rather than the default
bind-key command used to create them. Change the default ? binding to
use this to show a readable summary of keys.

Also extend command-prompt to return the name of the key pressed and add
a default binding (/) to show the note for the next key pressed

Suggested by Alex Tremblay in GitHub issue 2000.


Revision tags: OPENBSD_6_6_BASE
# 1.200 28-May-2019 nicm

Redraw status line if size changes, GitHub issue 1762. Also fix length
of target buffer when pasting into status line.


# 1.199 23-May-2019 nicm

Fix length calculation for pasting UTF-8 characters in the status line,
GitHub issue 1753.


# 1.198 11-May-2019 nicm

Do not reduce window height by status line height for control mode
clients, from George Nachman.


# 1.197 03-May-2019 nicm

Fix reverse attribute in status line, GitHub issue 1709.


# 1.196 26-Apr-2019 nicm

Merge hooks into options and make each one an array option. This allows
multiple commands to be easily bound to one hook. set-hook and
show-hooks remain but they are now variants of set-option and
show-options. show-options now has a -H flag to show hooks (by default
they are not shown).


# 1.195 25-Apr-2019 nicm

options_array_item_value cannot return NULL.


# 1.194 23-Apr-2019 nicm

Somehow missed these bits in last commit.


# 1.193 23-Apr-2019 nicm

Indicate an array option with a flag rather than a special type so that
in future will not have to be strings.


Revision tags: OPENBSD_6_5_BASE
# 1.192 18-Mar-2019 nicm

Extend the #[] style syntax and use that together with previous format
changes to allow the status line to be entirely configured with a single
option.

Now that it is possible to configure their content, enable the existing
code that lets the status line be multiple lines in height. The status
option can now take a value of 2, 3, 4 or 5 (as well as the previous on
or off) to configure more than one line. The new status-format array
option configures the format of each line, the default just references
the existing status-* options, although some of the more obscure status
options may be eliminated in time.

Additions to the #[] syntax are: "align" to specify alignment (left,
centre, right), "list" for the window list and "range" to configure
ranges of text for the mouse bindings.

The "align" keyword can also be used to specify alignment of entries in
tree mode and the pane status lines.


# 1.191 18-Mar-2019 nicm

Make array options a sparse tree instead of an array of char * and
remove the size limit.


# 1.190 18-Mar-2019 nicm

With force, kill previous job before starting new. Fixes problem
reported by Scott Mcdermott in GitHub issue 1627.


# 1.189 16-Mar-2019 nicm

Use a pointer for the active screen in the status line instead of
copying them around all the time.


# 1.188 16-Mar-2019 nicm

Give status_save_old the client so it can do the reinit too.


# 1.187 16-Mar-2019 nicm

Tidy and rename some bits of status line code.


# 1.186 15-Mar-2019 nicm

Move status line free into its own function.


# 1.185 14-Mar-2019 nicm

Store the time in the format tree rather than passing it around.


# 1.184 12-Mar-2019 nicm

DECRC and DECSC apparently need to preserve origin mode as well, based
on a fix from Marc Reisner.


# 1.183 09-Feb-2019 nicm

Completion of command-alias members.


# 1.182 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.181 29-Aug-2018 nicm

Keep any text killed in the command prompt with C-w and yank it with
C-y, only use the top buffer if no text has previously been killed. This
and previous change promped by discussion with kn@.


# 1.180 29-Aug-2018 nicm

Add C-Left and C-Right as aliases for M-b and M-f.


# 1.179 22-Aug-2018 nicm

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


# 1.178 20-Aug-2018 nicm

Move offset of window list into status struct.


# 1.177 19-Aug-2018 nicm

Add a client redraw-window flag instead of the redraw-all flag and for
all just use the three flags together (window, borders, status).


Revision tags: OPENBSD_6_3_BASE
# 1.176 22-Feb-2018 nicm

Remove an unused variable.


# 1.175 05-Feb-2018 nicm

Add struct status_line to hold status line members of struct client, not
used yet but will be soon. From Thomas Adam.


# 1.174 01-Jan-2018 nicm

Add C-g at command prompt for emacs people, GitHub issue 1213.


# 1.173 27-Dec-2017 nicm

Draw command prompt correctly with status line off.


# 1.172 18-Dec-2017 nicm

Remove unused variable from Thomas Adam.


# 1.171 02-Nov-2017 nicm

Add a "fast" version of screen_write_copy for tree mode that doesn't do
all the checks and selection and marking stuff needed for copy mode.


# 1.170 20-Oct-2017 nicm

Clear status line with spaces again so reverse works, spotted by sthen.


# 1.169 16-Oct-2017 nicm

Infrastructure for drawing status lines of more than one line in height,
still only one is allowed but this lets tmux draw bigger ones.


Revision tags: OPENBSD_6_2_BASE
# 1.168 29-May-2017 nicm

Add a flag to stop the prompt input being expanded.


# 1.167 29-May-2017 nicm

Store a copy of the old status line, will be needed soon for new choose mode.


# 1.166 17-May-2017 nicm

Tidy command prompt callbacks and pass in the client.


# 1.165 03-May-2017 nicm

Add a format for the last search string in copy mode and fix the prompt
so it can work when in -I, suggested by Suraj N Kurapati.


# 1.164 01-May-2017 nicm

In order that people can use formats like #D in #() in the status line
and not have to wait for an update when they change pane, we allow
commands to run more than once a second if the expanded form
changes. Unfortunately this can mean them being run far too often
(pretty much continually) when multiple clients exist, because some
formats (including #D) will always differ between clients.

To avoid this, give each client its own tree of jobs which means that
the same command will be different instances for each client - similar
to how we have the tag to separate commands for different panes.

GitHub issue 889; test case reported by Paul Johnson.


# 1.163 22-Apr-2017 nicm

Memory leak from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.162 09-Feb-2017 nicm

Break the message storage function into its own function, useful for
debugging.


# 1.161 03-Feb-2017 nicm

Cache status line position to reduce option lookups during output.


# 1.160 03-Feb-2017 nicm

Add a window or pane id "tag" to each format tree and use it to separate
jobs, this means that if the same job is used for different windows or
panes (for example in pane-border-format), it will be run separately for
each pane.


# 1.159 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.158 06-Jan-2017 nicm

Incremental search in copy mode (on for emacs keys by default) - much
the same as normal searching but updates the cursor position and marked
search terms as you type. C-r and C-s in the prompt repeat the search,
once finished searching (with Enter), N and n work as before.


# 1.157 05-Jan-2017 nicm

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


# 1.156 07-Dec-2016 nicm

Do not clear the prompt when a message is shown, just leave it around and
return to it when the message is finished.


# 1.155 12-Oct-2016 nicm

Drop the edit mode key tables and just use fixed key bindings for the
command prompt.


# 1.154 12-Oct-2016 nicm

The repeat prompt in both emacs and vi (and the old one in tmux) doesn't
support line editing and instead executes a command as soon as a
non-number key is pressed. Add a -N flag to command-prompt for the same
in copy mode. Reported by Theo Buehler.


# 1.153 11-Oct-2016 nicm

Fundamental change to how copy mode key bindings work:

The vi-copy and emacs-copy mode key tables are gone, and instead copy
mode commands are bound in one of two normal key tables ("copy-mode" or
"copy-mode-vi"). Keys are bound to "send-keys -X copy-mode-command". So:

bind -temacs-copy C-Up scroll-up
bind -temacs-copy -R5 WheelUpPane scroll-up

Becomes:

bind -Tcopy-mode C-Up send -X scroll-up
bind -Tcopy-mode WheelUpPane send -N5 -X scroll-up

This allows the full command parser and command set to be used - for
example, we can use the normal command prompt for searching, jumping,
and so on instead of a custom one:

bind -Tcopy-mode C-r command-prompt -p'search up' "send -X search-backward '%%'"

command-prompt also gets a -1 option to only require on key press, which
is needed for jumping.

The plan is to get rid of mode keys entirely, so more to come eventually.


# 1.152 11-Oct-2016 nicm

Support UTF-8 entry into the command prompt.


# 1.151 10-Oct-2016 nicm

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


# 1.150 12-Sep-2016 nicm

Allow repeat count to be specified in mode key tables with bind-key -R,
and set the default repeat count to 5 for WheelUp and WheelDown in
copy-mode.


Revision tags: OPENBSD_6_0_BASE
# 1.149 06-Jun-2016 nicm

Allow #[] in window-status-separator.


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

I no longer use my SourceForge address so replace it.


# 1.147 01-Jan-2016 nicm

Don't rely on a calculation wrapping when applying message-limit, and
break out of the loop early. From Nicolas Viennot.


# 1.146 11-Dec-2015 nicm

Style nits and line wrapping of function declarations.


# 1.145 11-Dec-2015 nicm

Add cmdq as an argument to format_create and add a format for the
command name (will also be used for more later).


# 1.144 08-Dec-2015 nicm

Remove format_create_flags and just pass flags to format_create.


# 1.143 22-Nov-2015 tim

If display-time is set to 0, show status messages until a key is pressed;
OK nicm@


# 1.142 20-Nov-2015 nicm

Instead of separate tables for different types of options, give each
option a scope type (server, session, window) in one table.


# 1.141 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.140 13-Nov-2015 nicm

Long overdue change to the way we store cells in the grid: now, instead
of storing a full grid_cell with UTF-8 data and everything, store a new
type grid_cell_entry. This can either be the cell itself (for ASCII
cells), or an offset into an extended array (per line) for UTF-8
data.

This avoid a large (8 byte) overhead on non-UTF-8 cells (by far the
majority for most users) without the complexity of the shadow array we
had before. Grid memory without any UTF-8 is about half.

The disadvantage that cells can no longer be modified in place and need
to be copied out of the grid and back but it turned out to be lot less
complicated than I expected.


# 1.139 12-Nov-2015 nicm

Nuke the utf8 and status-utf8 options and make tmux only a UTF-8
terminal. We still support non-UTF-8 terminals outside tmux, but inside
it is always UTF-8 (as when the utf8 and status-utf8 options were on).


# 1.138 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.137 27-Oct-2015 nicm

Move struct options into options.c.


# 1.136 20-Oct-2015 nicm

Use client pointer not file descriptor in logging.


# 1.135 14-Sep-2015 nicm

Make refresh-client force update of jobs, from Sina Siadat.


# 1.134 29-Aug-2015 nicm

Move struct paste_buffer out of tmux.h.


# 1.133 28-Aug-2015 nicm

Run status update on a per-client timer at status-interval.


Revision tags: OPENBSD_5_8_BASE
# 1.132 29-Jul-2015 nicm

status_out and associated data structures are no longer used.


# 1.131 28-Jul-2015 nicm

Tidy up the way terminals are described and move some structs out of tmux.h.


# 1.130 20-Jul-2015 nicm

Add an option (history-file) for a file to save/restore command prompt
history, from Olof-Joachim Frahm.


# 1.129 27-May-2015 nicm

Move the jobs output cache into the formats code so that #() work more
generally (for example, again working in set-titles-string).


# 1.128 06-May-2015 nicm

Remove ARRAY_* from history and expand completion to complete a) layout
names and b) targets beginning with -t or -s.


# 1.127 25-Apr-2015 nicm

Make message log a TAILQ.


# 1.126 24-Apr-2015 nicm

Set working directory for run-shell and if-shell.


# 1.125 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_7_BASE
# 1.124 06-Feb-2015 nicm

Use the same time for both calls to format_expand_time.


# 1.123 06-Feb-2015 nicm

status_replace can now become local to status.c and it no longer needs
the jobsflag argument. While here there is no need to repeat work that
format_defaults already does.


# 1.122 06-Feb-2015 nicm

Add format_expand_time and use it instead of status_replace where
command execution is not needed.


# 1.121 05-Feb-2015 nicm

Wrap all the individual format_* calls in a single format_defaults
functions.


# 1.120 01-Feb-2015 nicm

Remove two unused arguments from status_replace.


# 1.119 20-Jan-2015 sthen

typo in comment ;) ok nicm


# 1.118 05-Nov-2014 nicm

Do not put a space between status-left/status-right and the window list,
instead move the space into the defaults for the options (so status-left
now defaults to "[#S] ". From Balazs Kezes.


# 1.117 20-Oct-2014 nicm

Better format for printf format attributes.


# 1.116 08-Oct-2014 nicm

Add xreallocarray and remove nmemb argument from xrealloc.


# 1.115 02-Oct-2014 nicm

Take account of window-status-separator when checking window position,
based on diff from Balazs Kezes.


Revision tags: OPENBSD_5_6_BASE
# 1.114 24-Apr-2014 nicm

There is no longer a need for a paste_stack struct or for global_buffers
to be global. Move to paste.c.


# 1.113 17-Apr-2014 nicm

Remove the monitor-content option and associated bits and bobs. It's
never worked very well. If there is a big demand for it to return, will
consider better ways to do it.


# 1.112 02-Apr-2014 nicm

Do not replace ## with # in status_replace1 because it'll be done later
by the format code.


# 1.111 31-Mar-2014 nicm

Make message-limit a server option.


Revision tags: OPENBSD_5_5_BASE
# 1.110 14-Feb-2014 nicm

Style nit - no space between function name and bracket.


# 1.109 14-Feb-2014 nicm

Check for NULL session and whatnot in status_replace, from Thomas Adam.


# 1.108 28-Jan-2014 nicm

Allow replacing each of the many sets of separate foo-{fg,bg,attr}
options with a single foo-style option. For example:

set -g status-fg yellow
set -g status-bg red
set -g status-attr blink

Becomes:

set -g status-style fg=yellow,bg=red,blink

The -a flag to set can be used to add to rather than replace a style. So:

set -g status-bg red

Becomes:

set -ag status-style bg=red

Currently this is fully backwards compatible (all *-{fg,bg,attr} options
remain) but the plan is to deprecate them over time.

From Tiago Cunha.


Revision tags: OPENBSD_5_4_BASE
# 1.107 05-Jul-2013 nicm

Whitespace nits, from Ben Boeckel.


# 1.106 05-Jul-2013 nicm

Act like vi(1) when moving words, from Ben Boeckel.


# 1.105 05-Jul-2013 nicm

Implement s, S, C mode switch commands in vi(1) mode, from Ben Boeckel.


# 1.104 31-May-2013 nicm

Demote the old single-character replacement variables (#S and friends)
to aliases of formats. From Tiago Cunha.


# 1.103 25-Mar-2013 nicm

Extend jobs to support writing and use that for copy-pipe instead of
popen, from Chris Johnsen.


# 1.102 22-Mar-2013 nicm

evbuffer_readline returns allocated storage, don't leak it.


# 1.101 22-Mar-2013 nicm

Add copy-pipe mode command to copy selection and also pipe to a command.


# 1.100 22-Mar-2013 nicm

No more lint means no more ARGSUSED.


# 1.99 21-Mar-2013 nicm

Aargh. Spaces -> tabs.


# 1.98 21-Mar-2013 nicm

Do not leak formats in status_replace.


# 1.97 21-Mar-2013 nicm

Add a format client_prefix which is 1 if prefix key has been
pressed, used for example #{?client_prefix,X,Y}. Also a few extra
server_client_status needed.


# 1.96 21-Mar-2013 nicm

Allow formats in status options.


Revision tags: OPENBSD_5_3_BASE
# 1.95 27-Nov-2012 nicm

Add window-status-last-* options, from Boris Faure.


Revision tags: OPENBSD_5_2_BASE
# 1.94 10-Jul-2012 nicm

xfree is not particularly helpful, remove it. From Thomas Adam.


# 1.93 09-Jul-2012 nicm

Move a NULL check inside a function, from Tiago Cunha.


# 1.92 29-Apr-2012 nicm

Use int not u_char for colours from options since they may have bit 8
set to mark them as 256-colour. Reported by Chris Johnson.


# 1.91 23-Apr-2012 nicm

Add window-status-separator option, from Thomas Adam.


# 1.90 17-Mar-2012 nicm

Check event_initialized before event_del if event may not have been set
up; libevent2 complains about this. Reported by Moriyoshi Koizumi.


# 1.89 04-Mar-2012 nicm

Add A and I keys for vi status line editing.


# 1.88 03-Mar-2012 nicm

The wlmouse offset should be part of the client, not the server. From
Ailin Nemui.


Revision tags: OPENBSD_5_1_BASE
# 1.87 29-Jan-2012 nicm

Add an option to move the status line to the top of the screen,
requested by many.


# 1.86 26-Jan-2012 nicm

Terminate strftime buffer properly even if a really long format string
is given, from Tiago Cunha.


# 1.85 26-Jan-2012 nicm

Fix memory leak in error path, from Tiago Cunha.


# 1.84 20-Jan-2012 nicm

Add some trivial additional status line attributes from jwcxz at users
dot sourceforge dot net.


# 1.83 20-Jan-2012 nicm

Add space movement keys for vi mode in the status line from Ben Boeckel.


# 1.82 01-Dec-2011 nicm

Make M-f and M-b work the same at the command prompt as in copy mode,
pointed out by Romain Francoise.


# 1.81 15-Nov-2011 nicm

Add word movement and editing command for command prompt editing, from
Ben Boeckel.


# 1.80 15-Nov-2011 nicm

Make window_pane_index work the same as window_index, from Ben Boeckel.


# 1.79 05-Nov-2011 nicm

Option to change status line (message) background when using vi keys and
in command mode. From Ben Boeckel.


# 1.78 20-Aug-2011 nicm

Fix a couple of memory leaks, from marcel partap.


Revision tags: OPENBSD_5_0_BASE
# 1.77 08-Jul-2011 nicm

Make confirm-before prompt customizable with -p option like
command-prompt. Also move responsibility for calling status_replace into
status_prompt_{set,update} and add #W and #P to the default kill-window
and kill-pane prompts. By Tiago Cunha.


# 1.76 02-Jul-2011 nicm

Allow the initial context on prompts to be set with the new -I option to
command-prompt. From Tiago Cunha.


# 1.75 29-Apr-2011 nicm

Only redraw the status line on command update, not the entire client
(big DOH).


# 1.74 24-Apr-2011 nicm

Provide #h for short hostname (no domain) from Michal Mazurek.


# 1.73 18-Apr-2011 nicm

Add an option (mouse-select-window) which allows the mouse to be used by
clicking on the status line, written by hsim at gmx dot li.


# 1.72 29-Mar-2011 nicm

Change -t on display-message to be target-pane for the #[A-Z]
replacements and add -c as target-client.


Revision tags: OPENBSD_4_9_BASE
# 1.71 26-Jan-2011 nicm

Simplify the way jobs work and drop the persist type, so all jobs are
fire-and-forget.

Status jobs now managed with two trees of output (new and old), rather
than storing the output in the jobs themselves. When the status line is
processed any jobs which don't appear in the new tree are started and
the output from the old tree displayed. When a job finishes it updates
the new tree with its output and that is used for any subsequent
redraws. When the status interval expires, the new tree is moved to the
old so that all jobs are run again.

This fixes the "#(echo %H:%M:%S)" problem which would lead to thousands
of identical persistent jobs and high memory use (this can still be
achieved by adding "sleep 30" but that is much less likely to happen by
accident).


# 1.70 03-Jan-2011 nicm

Handle a # at the end of a replacement string (such as status-left)
correctly. Found by Thomas Adam.


# 1.69 01-Jan-2011 nicm

Move the user-visible parts of all options (names, types, limit, default
values) together into one set of tables in options-table.c. Also clean
up and simplify cmd-set-options.c and move a common print function into
option-table.c.


# 1.68 30-Dec-2010 nicm

Change from a per-session stack of buffers to one global stack which is
much more convenient and also simplifies lot of code. This renders
copy-buffer useless and makes buffer-limit now a server option.

By Tiago Cunha.


# 1.67 30-Dec-2010 nicm

Add a function to create window flags rather than doing the same thing
in two places. From Thomas Adam.


# 1.66 11-Dec-2010 nicm

Oops, these functions return a const char *, so make the local variable
const as well.


# 1.65 11-Dec-2010 nicm

Make the prompt history global for all clients which is much more useful than per-client history.


# 1.64 06-Dec-2010 nicm

Add an option to alert (monitor) for silence (lack of activity) in a
window. From Thomas Adam.


Revision tags: OPENBSD_4_8_BASE
# 1.63 21-Jun-2010 nicm

Having a list of winlinks->alerts for each session is stupid, just store
the alert flags directly in the winlink itself.


# 1.62 14-May-2010 nicm

Colour+attribute options for status line alerts, from Alex Alexander.


# 1.61 31-Mar-2010 nicm

Don't accept keys with modifiers as input. Fixes crash reported by Brian
R Landy.


# 1.60 27-Mar-2010 nicm

Don't leak job command in #().


# 1.59 22-Mar-2010 nicm

Dead functions, lint.


Revision tags: OPENBSD_4_7_BASE
# 1.58 27-Jan-2010 nicm

Calculate offset correctly, fixes incorrect offset and prevents crash when
status-left is empty. From Micah Cowan.


# 1.57 26-Jan-2010 nicm

Actually use the copy made when no newline is found, from martynas@.


# 1.56 14-Dec-2009 nicm

Add server options to completion as well.


# 1.55 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.54 03-Dec-2009 nicm

Eliminate duplicate code and ease the passage for server-wide options by adding
a -w flag to set-option and show-options and making setw and showw aliases to
set -w and show -w.

Note: setw and showw are still there, but now aliases for set -w and show -w.


# 1.53 26-Nov-2009 nicm

Tidy up various bits of the paste code, make the data buffer char * and add
comments.


# 1.52 26-Nov-2009 nicm

Remove a couple of unused arguments where possible, and add /* ARGSUSED */ to
the rest to reduce lint output.


# 1.51 20-Nov-2009 nicm

Display UTF-8 properly in status line messages and prompt. Cursor handling is
still way off though.


# 1.50 20-Nov-2009 nicm

Remove oldest messages from log when limit is hit, not newest.


# 1.49 19-Nov-2009 nicm

Get some brackets in the right place so ## works. Also fix a space in a
comment.


# 1.48 19-Nov-2009 nicm

Change status line drawing to create the window list in a separate screen and
then copy it into the status line screen. This allows UTF-8 in window names and
fixes some problems with #[] in window-status-format.


# 1.47 19-Nov-2009 nicm

Two new options, window-status-format and window-status-current-format, which
allow the format of each window in the status line window list to be controlled
using similar # sequences as status-left/right.

This diff also moves part of the way towards UTF-8 support in window names but
it isn't quite there yet.


# 1.46 19-Nov-2009 nicm

Tidy up by breaking the # replacement code into a separate function, also add a
few comments.


# 1.45 19-Nov-2009 nicm

Don't interpret #() for display-message, it usually doesn't make sense and may
leak commands.


# 1.44 18-Nov-2009 nicm

Add a per-client log of status line messages displayed while that client
exists. A new message-limit session option sets the maximum number of entries
and a command, show-messages, shows the log (bound to ~ by default).

This (and prompt history) might be better as a single global log but until
there are global options it is easier for them to be per client.


# 1.43 17-Nov-2009 nicm

Permit top-bit-set characters to be entered in the status line. They could
already be set from the shell and are just passed through when printing (so
invisible characters or displaying on terminals with different character sets
may cause problems).

Note that entering UTF-8 may not work and in any case currently the status line
cannot display it correctly (outside of status-left/status-right).


# 1.42 04-Nov-2009 nicm

Use timeout events for the identify and message timers.


# 1.41 04-Nov-2009 nicm

Switch jobs over to use a bufferevent.


# 1.40 04-Nov-2009 nicm

Unused (but assigned to) variable, found by lint.


# 1.39 01-Nov-2009 nicm

Add a flag for jobs that shouldn't be freed after they've died and use it for
status jobs, then only kill those jobs when status-left, status-right or
set-titles-string is changed.

Fixes problems with changing options from inside #().


# 1.38 10-Oct-2009 nicm

Rather than running status-left, status-right and window title #() with popen
immediately every redraw, queue them up and run them in the background,
starting each once every status-interval. The actual status line uses the
output from the last run.

This brings several advantages:

- tmux itself may be called from inside #() without causing the server to hang;
- likewise, sleep or similar doesn't cause the server to block;
- commands aren't run excessively often when redrawing;
- commands shared by status-left and status-right, or used multiple times, will
only be run once.

run-shell and if-shell still use system()/popen() but will be changed over to
use this too later.


# 1.37 10-Oct-2009 nicm

Add "grouped sessions" which have independent name, options, current window and
so on but where the linked windows are synchronized (ie creating, killing
windows and so on are mirrored between the sessions). A grouped session may be
created by passing -t to new-session.

Had this around for a while, tested by a couple of people.


# 1.36 23-Sep-2009 nicm

Remove PROMPT_HIDDEN code which is now unused.


# 1.35 23-Sep-2009 nicm

Remove the internal tmux locking and instead detach each client and run the
command specified by a new option "lock-command" (by default "lock -np") in
each client.

This means each terminal has to be unlocked individually but simplifies the
code and allows the system password to be used to unlock.

Note that the set-password command is gone, so it will need to be removed from
configuration files, and the -U command line flag has been removed.

This is the third protocol version change so again it is best to stop the tmux
server before upgrading.


# 1.34 20-Sep-2009 nicm

Regularise some fatal messages.


# 1.33 10-Sep-2009 nicm

Permit options such as status-bg to be configured using the entire 256 colour
palette by setting "colour0" to "colour255".


# 1.32 07-Sep-2009 nicm

Give each paste buffer a size member instead of requiring them to be
zero-terminated.


# 1.31 07-Sep-2009 nicm

Permit embedded colour and attributes in status-left and status-right using new
#[] special characters, for example #[fg=red,bg=blue,blink].


# 1.30 02-Sep-2009 nicm

Add a transpose-chars command in edit mode (C-t in emacs mode only). From Kalle
Olavi Niemitalo.


# 1.29 01-Sep-2009 nicm

Use "Password:" with no space for password prompts and don't display a *s for
the password, like pretty much everything else. From martynas@ with minor
tweaks by me.


# 1.28 31-Aug-2009 nicm

Add a new display-panes command, with two options (display-panes-colour and
display-panes-time), which displays a visual indication of the number of each
pane.


# 1.27 19-Aug-2009 nicm

Extend command-prompt with a -p option which is a comma-separated list of one
or more prompts to present in order.

The responses to the prompt are replaced in the template string: %% are
replaced in order, so the first prompt replaces the first %%, the second
replaces the second, and so on. In addition, %1 up to %9 are replaced with the
responses to the first the ninth prompts

The default template is "%1" so the response to the first prompt is processed
as a command.

Note that this changes the behaviour for %% so if there is only one prompt,
only the first %% will be replaced. Templates such as "neww -n '%%' 'ssh %%'"
should be changed to "neww -n '%1' 'ssh %1'".

From Tiago Cunha.


# 1.26 18-Aug-2009 nicm

Add a "delete line" key when editing in the status line or the search up/down
prompt. C-u with emacs keys, d with vi.


# 1.25 13-Aug-2009 nicm

Switch the prompt code to return an empty string when the user enters no
response and reserve NULL for an explicit cancel. Change all callbacks to treat
them the same so no functional change.

Also add cancel key bindings to emacs mode which were missing.


# 1.24 08-Aug-2009 nicm

Options to set the colours and attributes for status-left/-right. From Thomas
Adam, thanks.


# 1.23 05-Aug-2009 nicm

If colours are not supported by the terminal, try to emulate a coloured
background by setting or clearing the reverse attribute.

This makes a few applications which don't use the reverse attribute themselves
a little happier, and allows the status, message and mode options to have
default attributes and fg/bg options that work as expected when set as reverse.


# 1.22 30-Jul-2009 nicm

Plug some memory leaks.


# 1.21 28-Jul-2009 nicm

Next step towards customisable mode keys: build each default table of keys into
a named tree on start and use that for lookups. Also add command to string
translation tables and modify list-keys to show the the mode key bindings (new
-t argument).


# 1.20 27-Jul-2009 nicm

Change mode key bindings from big switches into a set of tables. Rather than
lumping them all together, split editing keys from those used in choice/more
mode and those for copy/scroll mode.

Tidier and clearer, and the first step towards customisable mode keys.


# 1.19 27-Jul-2009 nicm

Get rid of empty mode_key_free function.


# 1.18 27-Jul-2009 nicm

Add a key to delete to end of line at the prompt (^K in emacs mode, C/D in vi).

From Kalle Olavi Niemitalo.


# 1.17 26-Jul-2009 nicm

Calculate the space available for the prompt buffer and the cursor position
correctly, and make it work when the screen is not wide enough.

Noticed by Kalle Olavi Niemitalo.


# 1.16 21-Jul-2009 nicm

Remove a couple of unused functions and fix a type ("FALLTHOUGH"), found by
lint.


# 1.15 20-Jul-2009 nicm

Add a status-justify option to allow the window list in the status line to be
positioned at the left, centre, or right.


# 1.14 20-Jul-2009 nicm

New options, window-status-current-{fg,bg,attr}, to set the fg, bg and
attributes with which the current window is shown in the status line. From
Johan Friis, thanks.


# 1.13 17-Jul-2009 nicm

- New command display-message (alias display) to display a message in the
status line (bound to "i" and displays the current window and time by
default). The same substitutions are applied as for status-left/right.
- Add support for including the window index (#I), pane index (#P) and window
name (#W) in the message, and status-left or status-right.
- Bump protocol version.

From Tiago Cunha, thanks!


# 1.12 17-Jul-2009 nicm

Memory could be leaked if a second prompt or message appeared while another was
still present, so add a separate prompt free callback and make the _clear
function responsible for calling it if necessary (rather than the individual
prompt callbacks). Also make both messages and prompts clear any existing when
a new is set.

In addition, the screen could be modified while the prompt is there, restore
the redraw-entire-screen behaviour on prompt clear; add a comment as a
reminder.


# 1.11 16-Jul-2009 nicm

Remove some duplicate code that was causing the status line to be redrawn even
when it hadn't changed.


# 1.10 15-Jul-2009 nicm

Make status_message_set a variadic printf-like function. No functional change -
helpful for a couple of things coming soon.


# 1.9 15-Jul-2009 nicm

Having to update NSETOPTION/NSETWINDOWOPTION when adding new options is a bit
annoying and it is only use for iterating, so use a sentinel to mark the end of
each array instead. Different fix for a problem pointed out by Kalle Olavi
Niemitalo.


# 1.8 14-Jul-2009 nicm

For some reason when clearing status/message it was redrawing the entire client
not just the status line. Changing this also revealed the check for the status
line was incorrect when drawing the pane.


# 1.7 14-Jul-2009 nicm

Instead of faking up a status line in status_redraw, use the same code to
redraw it as to draw the entire screen, just skip all lines but the last.

This makes horizontal split redraw properly when the status line is off.


# 1.6 12-Jul-2009 nicm

Add a "back to indentation" key in copy mode to move the cursor to the first
non-whitespace character. ^ with vi and M-m with emacs key bindings. Another
from Kalle Olavi Niemitalo, thanks.


Revision tags: OPENBSD_4_6_BASE
# 1.5 26-Jun-2009 nicm

Status line fixes: don't truncate status-right now the length calculation is
done for UTF-8, limit to the maximum length correctly when printing, and always
print a space even if the left string is longer than the width available.


# 1.4 04-Jun-2009 nicm

If the prompt is hidden or a password is sent with -U, zero it before freeing
it.


# 1.3 03-Jun-2009 nicm

New session option, status-utf8, to control the interpretation of top-bit-set
characters in status-left and status-right (if on, they are treated as UTF-8;
otherwise passed through).


# 1.2 03-Jun-2009 nicm

Add a UTF-8 aware string length function and make UTF-8 in
status-left/status-right work properly. At the moment any top-bit-set
characters are assumed to be UTF-8: a status-utf8 option to configure this will
come shortly.


# 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.201 27-Jan-2020 nicm

Add support for adding a note to a key binding (with bind-key -N) and
use this to add descriptions to the default key bindings. A new -N flag
to list-keys shows key bindings with notes rather than the default
bind-key command used to create them. Change the default ? binding to
use this to show a readable summary of keys.

Also extend command-prompt to return the name of the key pressed and add
a default binding (/) to show the note for the next key pressed

Suggested by Alex Tremblay in GitHub issue 2000.


Revision tags: OPENBSD_6_6_BASE
# 1.200 28-May-2019 nicm

Redraw status line if size changes, GitHub issue 1762. Also fix length
of target buffer when pasting into status line.


# 1.199 23-May-2019 nicm

Fix length calculation for pasting UTF-8 characters in the status line,
GitHub issue 1753.


# 1.198 11-May-2019 nicm

Do not reduce window height by status line height for control mode
clients, from George Nachman.


# 1.197 03-May-2019 nicm

Fix reverse attribute in status line, GitHub issue 1709.


# 1.196 26-Apr-2019 nicm

Merge hooks into options and make each one an array option. This allows
multiple commands to be easily bound to one hook. set-hook and
show-hooks remain but they are now variants of set-option and
show-options. show-options now has a -H flag to show hooks (by default
they are not shown).


# 1.195 25-Apr-2019 nicm

options_array_item_value cannot return NULL.


# 1.194 23-Apr-2019 nicm

Somehow missed these bits in last commit.


# 1.193 23-Apr-2019 nicm

Indicate an array option with a flag rather than a special type so that
in future will not have to be strings.


Revision tags: OPENBSD_6_5_BASE
# 1.192 18-Mar-2019 nicm

Extend the #[] style syntax and use that together with previous format
changes to allow the status line to be entirely configured with a single
option.

Now that it is possible to configure their content, enable the existing
code that lets the status line be multiple lines in height. The status
option can now take a value of 2, 3, 4 or 5 (as well as the previous on
or off) to configure more than one line. The new status-format array
option configures the format of each line, the default just references
the existing status-* options, although some of the more obscure status
options may be eliminated in time.

Additions to the #[] syntax are: "align" to specify alignment (left,
centre, right), "list" for the window list and "range" to configure
ranges of text for the mouse bindings.

The "align" keyword can also be used to specify alignment of entries in
tree mode and the pane status lines.


# 1.191 18-Mar-2019 nicm

Make array options a sparse tree instead of an array of char * and
remove the size limit.


# 1.190 18-Mar-2019 nicm

With force, kill previous job before starting new. Fixes problem
reported by Scott Mcdermott in GitHub issue 1627.


# 1.189 16-Mar-2019 nicm

Use a pointer for the active screen in the status line instead of
copying them around all the time.


# 1.188 16-Mar-2019 nicm

Give status_save_old the client so it can do the reinit too.


# 1.187 16-Mar-2019 nicm

Tidy and rename some bits of status line code.


# 1.186 15-Mar-2019 nicm

Move status line free into its own function.


# 1.185 14-Mar-2019 nicm

Store the time in the format tree rather than passing it around.


# 1.184 12-Mar-2019 nicm

DECRC and DECSC apparently need to preserve origin mode as well, based
on a fix from Marc Reisner.


# 1.183 09-Feb-2019 nicm

Completion of command-alias members.


# 1.182 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.181 29-Aug-2018 nicm

Keep any text killed in the command prompt with C-w and yank it with
C-y, only use the top buffer if no text has previously been killed. This
and previous change promped by discussion with kn@.


# 1.180 29-Aug-2018 nicm

Add C-Left and C-Right as aliases for M-b and M-f.


# 1.179 22-Aug-2018 nicm

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


# 1.178 20-Aug-2018 nicm

Move offset of window list into status struct.


# 1.177 19-Aug-2018 nicm

Add a client redraw-window flag instead of the redraw-all flag and for
all just use the three flags together (window, borders, status).


Revision tags: OPENBSD_6_3_BASE
# 1.176 22-Feb-2018 nicm

Remove an unused variable.


# 1.175 05-Feb-2018 nicm

Add struct status_line to hold status line members of struct client, not
used yet but will be soon. From Thomas Adam.


# 1.174 01-Jan-2018 nicm

Add C-g at command prompt for emacs people, GitHub issue 1213.


# 1.173 27-Dec-2017 nicm

Draw command prompt correctly with status line off.


# 1.172 18-Dec-2017 nicm

Remove unused variable from Thomas Adam.


# 1.171 02-Nov-2017 nicm

Add a "fast" version of screen_write_copy for tree mode that doesn't do
all the checks and selection and marking stuff needed for copy mode.


# 1.170 20-Oct-2017 nicm

Clear status line with spaces again so reverse works, spotted by sthen.


# 1.169 16-Oct-2017 nicm

Infrastructure for drawing status lines of more than one line in height,
still only one is allowed but this lets tmux draw bigger ones.


Revision tags: OPENBSD_6_2_BASE
# 1.168 29-May-2017 nicm

Add a flag to stop the prompt input being expanded.


# 1.167 29-May-2017 nicm

Store a copy of the old status line, will be needed soon for new choose mode.


# 1.166 17-May-2017 nicm

Tidy command prompt callbacks and pass in the client.


# 1.165 03-May-2017 nicm

Add a format for the last search string in copy mode and fix the prompt
so it can work when in -I, suggested by Suraj N Kurapati.


# 1.164 01-May-2017 nicm

In order that people can use formats like #D in #() in the status line
and not have to wait for an update when they change pane, we allow
commands to run more than once a second if the expanded form
changes. Unfortunately this can mean them being run far too often
(pretty much continually) when multiple clients exist, because some
formats (including #D) will always differ between clients.

To avoid this, give each client its own tree of jobs which means that
the same command will be different instances for each client - similar
to how we have the tag to separate commands for different panes.

GitHub issue 889; test case reported by Paul Johnson.


# 1.163 22-Apr-2017 nicm

Memory leak from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.162 09-Feb-2017 nicm

Break the message storage function into its own function, useful for
debugging.


# 1.161 03-Feb-2017 nicm

Cache status line position to reduce option lookups during output.


# 1.160 03-Feb-2017 nicm

Add a window or pane id "tag" to each format tree and use it to separate
jobs, this means that if the same job is used for different windows or
panes (for example in pane-border-format), it will be run separately for
each pane.


# 1.159 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.158 06-Jan-2017 nicm

Incremental search in copy mode (on for emacs keys by default) - much
the same as normal searching but updates the cursor position and marked
search terms as you type. C-r and C-s in the prompt repeat the search,
once finished searching (with Enter), N and n work as before.


# 1.157 05-Jan-2017 nicm

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


# 1.156 07-Dec-2016 nicm

Do not clear the prompt when a message is shown, just leave it around and
return to it when the message is finished.


# 1.155 12-Oct-2016 nicm

Drop the edit mode key tables and just use fixed key bindings for the
command prompt.


# 1.154 12-Oct-2016 nicm

The repeat prompt in both emacs and vi (and the old one in tmux) doesn't
support line editing and instead executes a command as soon as a
non-number key is pressed. Add a -N flag to command-prompt for the same
in copy mode. Reported by Theo Buehler.


# 1.153 11-Oct-2016 nicm

Fundamental change to how copy mode key bindings work:

The vi-copy and emacs-copy mode key tables are gone, and instead copy
mode commands are bound in one of two normal key tables ("copy-mode" or
"copy-mode-vi"). Keys are bound to "send-keys -X copy-mode-command". So:

bind -temacs-copy C-Up scroll-up
bind -temacs-copy -R5 WheelUpPane scroll-up

Becomes:

bind -Tcopy-mode C-Up send -X scroll-up
bind -Tcopy-mode WheelUpPane send -N5 -X scroll-up

This allows the full command parser and command set to be used - for
example, we can use the normal command prompt for searching, jumping,
and so on instead of a custom one:

bind -Tcopy-mode C-r command-prompt -p'search up' "send -X search-backward '%%'"

command-prompt also gets a -1 option to only require on key press, which
is needed for jumping.

The plan is to get rid of mode keys entirely, so more to come eventually.


# 1.152 11-Oct-2016 nicm

Support UTF-8 entry into the command prompt.


# 1.151 10-Oct-2016 nicm

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


# 1.150 12-Sep-2016 nicm

Allow repeat count to be specified in mode key tables with bind-key -R,
and set the default repeat count to 5 for WheelUp and WheelDown in
copy-mode.


Revision tags: OPENBSD_6_0_BASE
# 1.149 06-Jun-2016 nicm

Allow #[] in window-status-separator.


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

I no longer use my SourceForge address so replace it.


# 1.147 01-Jan-2016 nicm

Don't rely on a calculation wrapping when applying message-limit, and
break out of the loop early. From Nicolas Viennot.


# 1.146 11-Dec-2015 nicm

Style nits and line wrapping of function declarations.


# 1.145 11-Dec-2015 nicm

Add cmdq as an argument to format_create and add a format for the
command name (will also be used for more later).


# 1.144 08-Dec-2015 nicm

Remove format_create_flags and just pass flags to format_create.


# 1.143 22-Nov-2015 tim

If display-time is set to 0, show status messages until a key is pressed;
OK nicm@


# 1.142 20-Nov-2015 nicm

Instead of separate tables for different types of options, give each
option a scope type (server, session, window) in one table.


# 1.141 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.140 13-Nov-2015 nicm

Long overdue change to the way we store cells in the grid: now, instead
of storing a full grid_cell with UTF-8 data and everything, store a new
type grid_cell_entry. This can either be the cell itself (for ASCII
cells), or an offset into an extended array (per line) for UTF-8
data.

This avoid a large (8 byte) overhead on non-UTF-8 cells (by far the
majority for most users) without the complexity of the shadow array we
had before. Grid memory without any UTF-8 is about half.

The disadvantage that cells can no longer be modified in place and need
to be copied out of the grid and back but it turned out to be lot less
complicated than I expected.


# 1.139 12-Nov-2015 nicm

Nuke the utf8 and status-utf8 options and make tmux only a UTF-8
terminal. We still support non-UTF-8 terminals outside tmux, but inside
it is always UTF-8 (as when the utf8 and status-utf8 options were on).


# 1.138 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.137 27-Oct-2015 nicm

Move struct options into options.c.


# 1.136 20-Oct-2015 nicm

Use client pointer not file descriptor in logging.


# 1.135 14-Sep-2015 nicm

Make refresh-client force update of jobs, from Sina Siadat.


# 1.134 29-Aug-2015 nicm

Move struct paste_buffer out of tmux.h.


# 1.133 28-Aug-2015 nicm

Run status update on a per-client timer at status-interval.


Revision tags: OPENBSD_5_8_BASE
# 1.132 29-Jul-2015 nicm

status_out and associated data structures are no longer used.


# 1.131 28-Jul-2015 nicm

Tidy up the way terminals are described and move some structs out of tmux.h.


# 1.130 20-Jul-2015 nicm

Add an option (history-file) for a file to save/restore command prompt
history, from Olof-Joachim Frahm.


# 1.129 27-May-2015 nicm

Move the jobs output cache into the formats code so that #() work more
generally (for example, again working in set-titles-string).


# 1.128 06-May-2015 nicm

Remove ARRAY_* from history and expand completion to complete a) layout
names and b) targets beginning with -t or -s.


# 1.127 25-Apr-2015 nicm

Make message log a TAILQ.


# 1.126 24-Apr-2015 nicm

Set working directory for run-shell and if-shell.


# 1.125 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_7_BASE
# 1.124 06-Feb-2015 nicm

Use the same time for both calls to format_expand_time.


# 1.123 06-Feb-2015 nicm

status_replace can now become local to status.c and it no longer needs
the jobsflag argument. While here there is no need to repeat work that
format_defaults already does.


# 1.122 06-Feb-2015 nicm

Add format_expand_time and use it instead of status_replace where
command execution is not needed.


# 1.121 05-Feb-2015 nicm

Wrap all the individual format_* calls in a single format_defaults
functions.


# 1.120 01-Feb-2015 nicm

Remove two unused arguments from status_replace.


# 1.119 20-Jan-2015 sthen

typo in comment ;) ok nicm


# 1.118 05-Nov-2014 nicm

Do not put a space between status-left/status-right and the window list,
instead move the space into the defaults for the options (so status-left
now defaults to "[#S] ". From Balazs Kezes.


# 1.117 20-Oct-2014 nicm

Better format for printf format attributes.


# 1.116 08-Oct-2014 nicm

Add xreallocarray and remove nmemb argument from xrealloc.


# 1.115 02-Oct-2014 nicm

Take account of window-status-separator when checking window position,
based on diff from Balazs Kezes.


Revision tags: OPENBSD_5_6_BASE
# 1.114 24-Apr-2014 nicm

There is no longer a need for a paste_stack struct or for global_buffers
to be global. Move to paste.c.


# 1.113 17-Apr-2014 nicm

Remove the monitor-content option and associated bits and bobs. It's
never worked very well. If there is a big demand for it to return, will
consider better ways to do it.


# 1.112 02-Apr-2014 nicm

Do not replace ## with # in status_replace1 because it'll be done later
by the format code.


# 1.111 31-Mar-2014 nicm

Make message-limit a server option.


Revision tags: OPENBSD_5_5_BASE
# 1.110 14-Feb-2014 nicm

Style nit - no space between function name and bracket.


# 1.109 14-Feb-2014 nicm

Check for NULL session and whatnot in status_replace, from Thomas Adam.


# 1.108 28-Jan-2014 nicm

Allow replacing each of the many sets of separate foo-{fg,bg,attr}
options with a single foo-style option. For example:

set -g status-fg yellow
set -g status-bg red
set -g status-attr blink

Becomes:

set -g status-style fg=yellow,bg=red,blink

The -a flag to set can be used to add to rather than replace a style. So:

set -g status-bg red

Becomes:

set -ag status-style bg=red

Currently this is fully backwards compatible (all *-{fg,bg,attr} options
remain) but the plan is to deprecate them over time.

From Tiago Cunha.


Revision tags: OPENBSD_5_4_BASE
# 1.107 05-Jul-2013 nicm

Whitespace nits, from Ben Boeckel.


# 1.106 05-Jul-2013 nicm

Act like vi(1) when moving words, from Ben Boeckel.


# 1.105 05-Jul-2013 nicm

Implement s, S, C mode switch commands in vi(1) mode, from Ben Boeckel.


# 1.104 31-May-2013 nicm

Demote the old single-character replacement variables (#S and friends)
to aliases of formats. From Tiago Cunha.


# 1.103 25-Mar-2013 nicm

Extend jobs to support writing and use that for copy-pipe instead of
popen, from Chris Johnsen.


# 1.102 22-Mar-2013 nicm

evbuffer_readline returns allocated storage, don't leak it.


# 1.101 22-Mar-2013 nicm

Add copy-pipe mode command to copy selection and also pipe to a command.


# 1.100 22-Mar-2013 nicm

No more lint means no more ARGSUSED.


# 1.99 21-Mar-2013 nicm

Aargh. Spaces -> tabs.


# 1.98 21-Mar-2013 nicm

Do not leak formats in status_replace.


# 1.97 21-Mar-2013 nicm

Add a format client_prefix which is 1 if prefix key has been
pressed, used for example #{?client_prefix,X,Y}. Also a few extra
server_client_status needed.


# 1.96 21-Mar-2013 nicm

Allow formats in status options.


Revision tags: OPENBSD_5_3_BASE
# 1.95 27-Nov-2012 nicm

Add window-status-last-* options, from Boris Faure.


Revision tags: OPENBSD_5_2_BASE
# 1.94 10-Jul-2012 nicm

xfree is not particularly helpful, remove it. From Thomas Adam.


# 1.93 09-Jul-2012 nicm

Move a NULL check inside a function, from Tiago Cunha.


# 1.92 29-Apr-2012 nicm

Use int not u_char for colours from options since they may have bit 8
set to mark them as 256-colour. Reported by Chris Johnson.


# 1.91 23-Apr-2012 nicm

Add window-status-separator option, from Thomas Adam.


# 1.90 17-Mar-2012 nicm

Check event_initialized before event_del if event may not have been set
up; libevent2 complains about this. Reported by Moriyoshi Koizumi.


# 1.89 04-Mar-2012 nicm

Add A and I keys for vi status line editing.


# 1.88 03-Mar-2012 nicm

The wlmouse offset should be part of the client, not the server. From
Ailin Nemui.


Revision tags: OPENBSD_5_1_BASE
# 1.87 29-Jan-2012 nicm

Add an option to move the status line to the top of the screen,
requested by many.


# 1.86 26-Jan-2012 nicm

Terminate strftime buffer properly even if a really long format string
is given, from Tiago Cunha.


# 1.85 26-Jan-2012 nicm

Fix memory leak in error path, from Tiago Cunha.


# 1.84 20-Jan-2012 nicm

Add some trivial additional status line attributes from jwcxz at users
dot sourceforge dot net.


# 1.83 20-Jan-2012 nicm

Add space movement keys for vi mode in the status line from Ben Boeckel.


# 1.82 01-Dec-2011 nicm

Make M-f and M-b work the same at the command prompt as in copy mode,
pointed out by Romain Francoise.


# 1.81 15-Nov-2011 nicm

Add word movement and editing command for command prompt editing, from
Ben Boeckel.


# 1.80 15-Nov-2011 nicm

Make window_pane_index work the same as window_index, from Ben Boeckel.


# 1.79 05-Nov-2011 nicm

Option to change status line (message) background when using vi keys and
in command mode. From Ben Boeckel.


# 1.78 20-Aug-2011 nicm

Fix a couple of memory leaks, from marcel partap.


Revision tags: OPENBSD_5_0_BASE
# 1.77 08-Jul-2011 nicm

Make confirm-before prompt customizable with -p option like
command-prompt. Also move responsibility for calling status_replace into
status_prompt_{set,update} and add #W and #P to the default kill-window
and kill-pane prompts. By Tiago Cunha.


# 1.76 02-Jul-2011 nicm

Allow the initial context on prompts to be set with the new -I option to
command-prompt. From Tiago Cunha.


# 1.75 29-Apr-2011 nicm

Only redraw the status line on command update, not the entire client
(big DOH).


# 1.74 24-Apr-2011 nicm

Provide #h for short hostname (no domain) from Michal Mazurek.


# 1.73 18-Apr-2011 nicm

Add an option (mouse-select-window) which allows the mouse to be used by
clicking on the status line, written by hsim at gmx dot li.


# 1.72 29-Mar-2011 nicm

Change -t on display-message to be target-pane for the #[A-Z]
replacements and add -c as target-client.


Revision tags: OPENBSD_4_9_BASE
# 1.71 26-Jan-2011 nicm

Simplify the way jobs work and drop the persist type, so all jobs are
fire-and-forget.

Status jobs now managed with two trees of output (new and old), rather
than storing the output in the jobs themselves. When the status line is
processed any jobs which don't appear in the new tree are started and
the output from the old tree displayed. When a job finishes it updates
the new tree with its output and that is used for any subsequent
redraws. When the status interval expires, the new tree is moved to the
old so that all jobs are run again.

This fixes the "#(echo %H:%M:%S)" problem which would lead to thousands
of identical persistent jobs and high memory use (this can still be
achieved by adding "sleep 30" but that is much less likely to happen by
accident).


# 1.70 03-Jan-2011 nicm

Handle a # at the end of a replacement string (such as status-left)
correctly. Found by Thomas Adam.


# 1.69 01-Jan-2011 nicm

Move the user-visible parts of all options (names, types, limit, default
values) together into one set of tables in options-table.c. Also clean
up and simplify cmd-set-options.c and move a common print function into
option-table.c.


# 1.68 30-Dec-2010 nicm

Change from a per-session stack of buffers to one global stack which is
much more convenient and also simplifies lot of code. This renders
copy-buffer useless and makes buffer-limit now a server option.

By Tiago Cunha.


# 1.67 30-Dec-2010 nicm

Add a function to create window flags rather than doing the same thing
in two places. From Thomas Adam.


# 1.66 11-Dec-2010 nicm

Oops, these functions return a const char *, so make the local variable
const as well.


# 1.65 11-Dec-2010 nicm

Make the prompt history global for all clients which is much more useful than per-client history.


# 1.64 06-Dec-2010 nicm

Add an option to alert (monitor) for silence (lack of activity) in a
window. From Thomas Adam.


Revision tags: OPENBSD_4_8_BASE
# 1.63 21-Jun-2010 nicm

Having a list of winlinks->alerts for each session is stupid, just store
the alert flags directly in the winlink itself.


# 1.62 14-May-2010 nicm

Colour+attribute options for status line alerts, from Alex Alexander.


# 1.61 31-Mar-2010 nicm

Don't accept keys with modifiers as input. Fixes crash reported by Brian
R Landy.


# 1.60 27-Mar-2010 nicm

Don't leak job command in #().


# 1.59 22-Mar-2010 nicm

Dead functions, lint.


Revision tags: OPENBSD_4_7_BASE
# 1.58 27-Jan-2010 nicm

Calculate offset correctly, fixes incorrect offset and prevents crash when
status-left is empty. From Micah Cowan.


# 1.57 26-Jan-2010 nicm

Actually use the copy made when no newline is found, from martynas@.


# 1.56 14-Dec-2009 nicm

Add server options to completion as well.


# 1.55 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.54 03-Dec-2009 nicm

Eliminate duplicate code and ease the passage for server-wide options by adding
a -w flag to set-option and show-options and making setw and showw aliases to
set -w and show -w.

Note: setw and showw are still there, but now aliases for set -w and show -w.


# 1.53 26-Nov-2009 nicm

Tidy up various bits of the paste code, make the data buffer char * and add
comments.


# 1.52 26-Nov-2009 nicm

Remove a couple of unused arguments where possible, and add /* ARGSUSED */ to
the rest to reduce lint output.


# 1.51 20-Nov-2009 nicm

Display UTF-8 properly in status line messages and prompt. Cursor handling is
still way off though.


# 1.50 20-Nov-2009 nicm

Remove oldest messages from log when limit is hit, not newest.


# 1.49 19-Nov-2009 nicm

Get some brackets in the right place so ## works. Also fix a space in a
comment.


# 1.48 19-Nov-2009 nicm

Change status line drawing to create the window list in a separate screen and
then copy it into the status line screen. This allows UTF-8 in window names and
fixes some problems with #[] in window-status-format.


# 1.47 19-Nov-2009 nicm

Two new options, window-status-format and window-status-current-format, which
allow the format of each window in the status line window list to be controlled
using similar # sequences as status-left/right.

This diff also moves part of the way towards UTF-8 support in window names but
it isn't quite there yet.


# 1.46 19-Nov-2009 nicm

Tidy up by breaking the # replacement code into a separate function, also add a
few comments.


# 1.45 19-Nov-2009 nicm

Don't interpret #() for display-message, it usually doesn't make sense and may
leak commands.


# 1.44 18-Nov-2009 nicm

Add a per-client log of status line messages displayed while that client
exists. A new message-limit session option sets the maximum number of entries
and a command, show-messages, shows the log (bound to ~ by default).

This (and prompt history) might be better as a single global log but until
there are global options it is easier for them to be per client.


# 1.43 17-Nov-2009 nicm

Permit top-bit-set characters to be entered in the status line. They could
already be set from the shell and are just passed through when printing (so
invisible characters or displaying on terminals with different character sets
may cause problems).

Note that entering UTF-8 may not work and in any case currently the status line
cannot display it correctly (outside of status-left/status-right).


# 1.42 04-Nov-2009 nicm

Use timeout events for the identify and message timers.


# 1.41 04-Nov-2009 nicm

Switch jobs over to use a bufferevent.


# 1.40 04-Nov-2009 nicm

Unused (but assigned to) variable, found by lint.


# 1.39 01-Nov-2009 nicm

Add a flag for jobs that shouldn't be freed after they've died and use it for
status jobs, then only kill those jobs when status-left, status-right or
set-titles-string is changed.

Fixes problems with changing options from inside #().


# 1.38 10-Oct-2009 nicm

Rather than running status-left, status-right and window title #() with popen
immediately every redraw, queue them up and run them in the background,
starting each once every status-interval. The actual status line uses the
output from the last run.

This brings several advantages:

- tmux itself may be called from inside #() without causing the server to hang;
- likewise, sleep or similar doesn't cause the server to block;
- commands aren't run excessively often when redrawing;
- commands shared by status-left and status-right, or used multiple times, will
only be run once.

run-shell and if-shell still use system()/popen() but will be changed over to
use this too later.


# 1.37 10-Oct-2009 nicm

Add "grouped sessions" which have independent name, options, current window and
so on but where the linked windows are synchronized (ie creating, killing
windows and so on are mirrored between the sessions). A grouped session may be
created by passing -t to new-session.

Had this around for a while, tested by a couple of people.


# 1.36 23-Sep-2009 nicm

Remove PROMPT_HIDDEN code which is now unused.


# 1.35 23-Sep-2009 nicm

Remove the internal tmux locking and instead detach each client and run the
command specified by a new option "lock-command" (by default "lock -np") in
each client.

This means each terminal has to be unlocked individually but simplifies the
code and allows the system password to be used to unlock.

Note that the set-password command is gone, so it will need to be removed from
configuration files, and the -U command line flag has been removed.

This is the third protocol version change so again it is best to stop the tmux
server before upgrading.


# 1.34 20-Sep-2009 nicm

Regularise some fatal messages.


# 1.33 10-Sep-2009 nicm

Permit options such as status-bg to be configured using the entire 256 colour
palette by setting "colour0" to "colour255".


# 1.32 07-Sep-2009 nicm

Give each paste buffer a size member instead of requiring them to be
zero-terminated.


# 1.31 07-Sep-2009 nicm

Permit embedded colour and attributes in status-left and status-right using new
#[] special characters, for example #[fg=red,bg=blue,blink].


# 1.30 02-Sep-2009 nicm

Add a transpose-chars command in edit mode (C-t in emacs mode only). From Kalle
Olavi Niemitalo.


# 1.29 01-Sep-2009 nicm

Use "Password:" with no space for password prompts and don't display a *s for
the password, like pretty much everything else. From martynas@ with minor
tweaks by me.


# 1.28 31-Aug-2009 nicm

Add a new display-panes command, with two options (display-panes-colour and
display-panes-time), which displays a visual indication of the number of each
pane.


# 1.27 19-Aug-2009 nicm

Extend command-prompt with a -p option which is a comma-separated list of one
or more prompts to present in order.

The responses to the prompt are replaced in the template string: %% are
replaced in order, so the first prompt replaces the first %%, the second
replaces the second, and so on. In addition, %1 up to %9 are replaced with the
responses to the first the ninth prompts

The default template is "%1" so the response to the first prompt is processed
as a command.

Note that this changes the behaviour for %% so if there is only one prompt,
only the first %% will be replaced. Templates such as "neww -n '%%' 'ssh %%'"
should be changed to "neww -n '%1' 'ssh %1'".

From Tiago Cunha.


# 1.26 18-Aug-2009 nicm

Add a "delete line" key when editing in the status line or the search up/down
prompt. C-u with emacs keys, d with vi.


# 1.25 13-Aug-2009 nicm

Switch the prompt code to return an empty string when the user enters no
response and reserve NULL for an explicit cancel. Change all callbacks to treat
them the same so no functional change.

Also add cancel key bindings to emacs mode which were missing.


# 1.24 08-Aug-2009 nicm

Options to set the colours and attributes for status-left/-right. From Thomas
Adam, thanks.


# 1.23 05-Aug-2009 nicm

If colours are not supported by the terminal, try to emulate a coloured
background by setting or clearing the reverse attribute.

This makes a few applications which don't use the reverse attribute themselves
a little happier, and allows the status, message and mode options to have
default attributes and fg/bg options that work as expected when set as reverse.


# 1.22 30-Jul-2009 nicm

Plug some memory leaks.


# 1.21 28-Jul-2009 nicm

Next step towards customisable mode keys: build each default table of keys into
a named tree on start and use that for lookups. Also add command to string
translation tables and modify list-keys to show the the mode key bindings (new
-t argument).


# 1.20 27-Jul-2009 nicm

Change mode key bindings from big switches into a set of tables. Rather than
lumping them all together, split editing keys from those used in choice/more
mode and those for copy/scroll mode.

Tidier and clearer, and the first step towards customisable mode keys.


# 1.19 27-Jul-2009 nicm

Get rid of empty mode_key_free function.


# 1.18 27-Jul-2009 nicm

Add a key to delete to end of line at the prompt (^K in emacs mode, C/D in vi).

From Kalle Olavi Niemitalo.


# 1.17 26-Jul-2009 nicm

Calculate the space available for the prompt buffer and the cursor position
correctly, and make it work when the screen is not wide enough.

Noticed by Kalle Olavi Niemitalo.


# 1.16 21-Jul-2009 nicm

Remove a couple of unused functions and fix a type ("FALLTHOUGH"), found by
lint.


# 1.15 20-Jul-2009 nicm

Add a status-justify option to allow the window list in the status line to be
positioned at the left, centre, or right.


# 1.14 20-Jul-2009 nicm

New options, window-status-current-{fg,bg,attr}, to set the fg, bg and
attributes with which the current window is shown in the status line. From
Johan Friis, thanks.


# 1.13 17-Jul-2009 nicm

- New command display-message (alias display) to display a message in the
status line (bound to "i" and displays the current window and time by
default). The same substitutions are applied as for status-left/right.
- Add support for including the window index (#I), pane index (#P) and window
name (#W) in the message, and status-left or status-right.
- Bump protocol version.

From Tiago Cunha, thanks!


# 1.12 17-Jul-2009 nicm

Memory could be leaked if a second prompt or message appeared while another was
still present, so add a separate prompt free callback and make the _clear
function responsible for calling it if necessary (rather than the individual
prompt callbacks). Also make both messages and prompts clear any existing when
a new is set.

In addition, the screen could be modified while the prompt is there, restore
the redraw-entire-screen behaviour on prompt clear; add a comment as a
reminder.


# 1.11 16-Jul-2009 nicm

Remove some duplicate code that was causing the status line to be redrawn even
when it hadn't changed.


# 1.10 15-Jul-2009 nicm

Make status_message_set a variadic printf-like function. No functional change -
helpful for a couple of things coming soon.


# 1.9 15-Jul-2009 nicm

Having to update NSETOPTION/NSETWINDOWOPTION when adding new options is a bit
annoying and it is only use for iterating, so use a sentinel to mark the end of
each array instead. Different fix for a problem pointed out by Kalle Olavi
Niemitalo.


# 1.8 14-Jul-2009 nicm

For some reason when clearing status/message it was redrawing the entire client
not just the status line. Changing this also revealed the check for the status
line was incorrect when drawing the pane.


# 1.7 14-Jul-2009 nicm

Instead of faking up a status line in status_redraw, use the same code to
redraw it as to draw the entire screen, just skip all lines but the last.

This makes horizontal split redraw properly when the status line is off.


# 1.6 12-Jul-2009 nicm

Add a "back to indentation" key in copy mode to move the cursor to the first
non-whitespace character. ^ with vi and M-m with emacs key bindings. Another
from Kalle Olavi Niemitalo, thanks.


Revision tags: OPENBSD_4_6_BASE
# 1.5 26-Jun-2009 nicm

Status line fixes: don't truncate status-right now the length calculation is
done for UTF-8, limit to the maximum length correctly when printing, and always
print a space even if the left string is longer than the width available.


# 1.4 04-Jun-2009 nicm

If the prompt is hidden or a password is sent with -U, zero it before freeing
it.


# 1.3 03-Jun-2009 nicm

New session option, status-utf8, to control the interpretation of top-bit-set
characters in status-left and status-right (if on, they are treated as UTF-8;
otherwise passed through).


# 1.2 03-Jun-2009 nicm

Add a UTF-8 aware string length function and make UTF-8 in
status-left/status-right work properly. At the moment any top-bit-set
characters are assumed to be UTF-8: a status-utf8 option to configure this will
come shortly.


# 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.200 28-May-2019 nicm

Redraw status line if size changes, GitHub issue 1762. Also fix length
of target buffer when pasting into status line.


# 1.199 23-May-2019 nicm

Fix length calculation for pasting UTF-8 characters in the status line,
GitHub issue 1753.


# 1.198 11-May-2019 nicm

Do not reduce window height by status line height for control mode
clients, from George Nachman.


# 1.197 03-May-2019 nicm

Fix reverse attribute in status line, GitHub issue 1709.


# 1.196 26-Apr-2019 nicm

Merge hooks into options and make each one an array option. This allows
multiple commands to be easily bound to one hook. set-hook and
show-hooks remain but they are now variants of set-option and
show-options. show-options now has a -H flag to show hooks (by default
they are not shown).


# 1.195 25-Apr-2019 nicm

options_array_item_value cannot return NULL.


# 1.194 23-Apr-2019 nicm

Somehow missed these bits in last commit.


# 1.193 23-Apr-2019 nicm

Indicate an array option with a flag rather than a special type so that
in future will not have to be strings.


Revision tags: OPENBSD_6_5_BASE
# 1.192 18-Mar-2019 nicm

Extend the #[] style syntax and use that together with previous format
changes to allow the status line to be entirely configured with a single
option.

Now that it is possible to configure their content, enable the existing
code that lets the status line be multiple lines in height. The status
option can now take a value of 2, 3, 4 or 5 (as well as the previous on
or off) to configure more than one line. The new status-format array
option configures the format of each line, the default just references
the existing status-* options, although some of the more obscure status
options may be eliminated in time.

Additions to the #[] syntax are: "align" to specify alignment (left,
centre, right), "list" for the window list and "range" to configure
ranges of text for the mouse bindings.

The "align" keyword can also be used to specify alignment of entries in
tree mode and the pane status lines.


# 1.191 18-Mar-2019 nicm

Make array options a sparse tree instead of an array of char * and
remove the size limit.


# 1.190 18-Mar-2019 nicm

With force, kill previous job before starting new. Fixes problem
reported by Scott Mcdermott in GitHub issue 1627.


# 1.189 16-Mar-2019 nicm

Use a pointer for the active screen in the status line instead of
copying them around all the time.


# 1.188 16-Mar-2019 nicm

Give status_save_old the client so it can do the reinit too.


# 1.187 16-Mar-2019 nicm

Tidy and rename some bits of status line code.


# 1.186 15-Mar-2019 nicm

Move status line free into its own function.


# 1.185 14-Mar-2019 nicm

Store the time in the format tree rather than passing it around.


# 1.184 12-Mar-2019 nicm

DECRC and DECSC apparently need to preserve origin mode as well, based
on a fix from Marc Reisner.


# 1.183 09-Feb-2019 nicm

Completion of command-alias members.


# 1.182 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.181 29-Aug-2018 nicm

Keep any text killed in the command prompt with C-w and yank it with
C-y, only use the top buffer if no text has previously been killed. This
and previous change promped by discussion with kn@.


# 1.180 29-Aug-2018 nicm

Add C-Left and C-Right as aliases for M-b and M-f.


# 1.179 22-Aug-2018 nicm

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


# 1.178 20-Aug-2018 nicm

Move offset of window list into status struct.


# 1.177 19-Aug-2018 nicm

Add a client redraw-window flag instead of the redraw-all flag and for
all just use the three flags together (window, borders, status).


Revision tags: OPENBSD_6_3_BASE
# 1.176 22-Feb-2018 nicm

Remove an unused variable.


# 1.175 05-Feb-2018 nicm

Add struct status_line to hold status line members of struct client, not
used yet but will be soon. From Thomas Adam.


# 1.174 01-Jan-2018 nicm

Add C-g at command prompt for emacs people, GitHub issue 1213.


# 1.173 27-Dec-2017 nicm

Draw command prompt correctly with status line off.


# 1.172 18-Dec-2017 nicm

Remove unused variable from Thomas Adam.


# 1.171 02-Nov-2017 nicm

Add a "fast" version of screen_write_copy for tree mode that doesn't do
all the checks and selection and marking stuff needed for copy mode.


# 1.170 20-Oct-2017 nicm

Clear status line with spaces again so reverse works, spotted by sthen.


# 1.169 16-Oct-2017 nicm

Infrastructure for drawing status lines of more than one line in height,
still only one is allowed but this lets tmux draw bigger ones.


Revision tags: OPENBSD_6_2_BASE
# 1.168 29-May-2017 nicm

Add a flag to stop the prompt input being expanded.


# 1.167 29-May-2017 nicm

Store a copy of the old status line, will be needed soon for new choose mode.


# 1.166 17-May-2017 nicm

Tidy command prompt callbacks and pass in the client.


# 1.165 03-May-2017 nicm

Add a format for the last search string in copy mode and fix the prompt
so it can work when in -I, suggested by Suraj N Kurapati.


# 1.164 01-May-2017 nicm

In order that people can use formats like #D in #() in the status line
and not have to wait for an update when they change pane, we allow
commands to run more than once a second if the expanded form
changes. Unfortunately this can mean them being run far too often
(pretty much continually) when multiple clients exist, because some
formats (including #D) will always differ between clients.

To avoid this, give each client its own tree of jobs which means that
the same command will be different instances for each client - similar
to how we have the tag to separate commands for different panes.

GitHub issue 889; test case reported by Paul Johnson.


# 1.163 22-Apr-2017 nicm

Memory leak from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.162 09-Feb-2017 nicm

Break the message storage function into its own function, useful for
debugging.


# 1.161 03-Feb-2017 nicm

Cache status line position to reduce option lookups during output.


# 1.160 03-Feb-2017 nicm

Add a window or pane id "tag" to each format tree and use it to separate
jobs, this means that if the same job is used for different windows or
panes (for example in pane-border-format), it will be run separately for
each pane.


# 1.159 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.158 06-Jan-2017 nicm

Incremental search in copy mode (on for emacs keys by default) - much
the same as normal searching but updates the cursor position and marked
search terms as you type. C-r and C-s in the prompt repeat the search,
once finished searching (with Enter), N and n work as before.


# 1.157 05-Jan-2017 nicm

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


# 1.156 07-Dec-2016 nicm

Do not clear the prompt when a message is shown, just leave it around and
return to it when the message is finished.


# 1.155 12-Oct-2016 nicm

Drop the edit mode key tables and just use fixed key bindings for the
command prompt.


# 1.154 12-Oct-2016 nicm

The repeat prompt in both emacs and vi (and the old one in tmux) doesn't
support line editing and instead executes a command as soon as a
non-number key is pressed. Add a -N flag to command-prompt for the same
in copy mode. Reported by Theo Buehler.


# 1.153 11-Oct-2016 nicm

Fundamental change to how copy mode key bindings work:

The vi-copy and emacs-copy mode key tables are gone, and instead copy
mode commands are bound in one of two normal key tables ("copy-mode" or
"copy-mode-vi"). Keys are bound to "send-keys -X copy-mode-command". So:

bind -temacs-copy C-Up scroll-up
bind -temacs-copy -R5 WheelUpPane scroll-up

Becomes:

bind -Tcopy-mode C-Up send -X scroll-up
bind -Tcopy-mode WheelUpPane send -N5 -X scroll-up

This allows the full command parser and command set to be used - for
example, we can use the normal command prompt for searching, jumping,
and so on instead of a custom one:

bind -Tcopy-mode C-r command-prompt -p'search up' "send -X search-backward '%%'"

command-prompt also gets a -1 option to only require on key press, which
is needed for jumping.

The plan is to get rid of mode keys entirely, so more to come eventually.


# 1.152 11-Oct-2016 nicm

Support UTF-8 entry into the command prompt.


# 1.151 10-Oct-2016 nicm

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


# 1.150 12-Sep-2016 nicm

Allow repeat count to be specified in mode key tables with bind-key -R,
and set the default repeat count to 5 for WheelUp and WheelDown in
copy-mode.


Revision tags: OPENBSD_6_0_BASE
# 1.149 06-Jun-2016 nicm

Allow #[] in window-status-separator.


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

I no longer use my SourceForge address so replace it.


# 1.147 01-Jan-2016 nicm

Don't rely on a calculation wrapping when applying message-limit, and
break out of the loop early. From Nicolas Viennot.


# 1.146 11-Dec-2015 nicm

Style nits and line wrapping of function declarations.


# 1.145 11-Dec-2015 nicm

Add cmdq as an argument to format_create and add a format for the
command name (will also be used for more later).


# 1.144 08-Dec-2015 nicm

Remove format_create_flags and just pass flags to format_create.


# 1.143 22-Nov-2015 tim

If display-time is set to 0, show status messages until a key is pressed;
OK nicm@


# 1.142 20-Nov-2015 nicm

Instead of separate tables for different types of options, give each
option a scope type (server, session, window) in one table.


# 1.141 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.140 13-Nov-2015 nicm

Long overdue change to the way we store cells in the grid: now, instead
of storing a full grid_cell with UTF-8 data and everything, store a new
type grid_cell_entry. This can either be the cell itself (for ASCII
cells), or an offset into an extended array (per line) for UTF-8
data.

This avoid a large (8 byte) overhead on non-UTF-8 cells (by far the
majority for most users) without the complexity of the shadow array we
had before. Grid memory without any UTF-8 is about half.

The disadvantage that cells can no longer be modified in place and need
to be copied out of the grid and back but it turned out to be lot less
complicated than I expected.


# 1.139 12-Nov-2015 nicm

Nuke the utf8 and status-utf8 options and make tmux only a UTF-8
terminal. We still support non-UTF-8 terminals outside tmux, but inside
it is always UTF-8 (as when the utf8 and status-utf8 options were on).


# 1.138 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.137 27-Oct-2015 nicm

Move struct options into options.c.


# 1.136 20-Oct-2015 nicm

Use client pointer not file descriptor in logging.


# 1.135 14-Sep-2015 nicm

Make refresh-client force update of jobs, from Sina Siadat.


# 1.134 29-Aug-2015 nicm

Move struct paste_buffer out of tmux.h.


# 1.133 28-Aug-2015 nicm

Run status update on a per-client timer at status-interval.


Revision tags: OPENBSD_5_8_BASE
# 1.132 29-Jul-2015 nicm

status_out and associated data structures are no longer used.


# 1.131 28-Jul-2015 nicm

Tidy up the way terminals are described and move some structs out of tmux.h.


# 1.130 20-Jul-2015 nicm

Add an option (history-file) for a file to save/restore command prompt
history, from Olof-Joachim Frahm.


# 1.129 27-May-2015 nicm

Move the jobs output cache into the formats code so that #() work more
generally (for example, again working in set-titles-string).


# 1.128 06-May-2015 nicm

Remove ARRAY_* from history and expand completion to complete a) layout
names and b) targets beginning with -t or -s.


# 1.127 25-Apr-2015 nicm

Make message log a TAILQ.


# 1.126 24-Apr-2015 nicm

Set working directory for run-shell and if-shell.


# 1.125 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_7_BASE
# 1.124 06-Feb-2015 nicm

Use the same time for both calls to format_expand_time.


# 1.123 06-Feb-2015 nicm

status_replace can now become local to status.c and it no longer needs
the jobsflag argument. While here there is no need to repeat work that
format_defaults already does.


# 1.122 06-Feb-2015 nicm

Add format_expand_time and use it instead of status_replace where
command execution is not needed.


# 1.121 05-Feb-2015 nicm

Wrap all the individual format_* calls in a single format_defaults
functions.


# 1.120 01-Feb-2015 nicm

Remove two unused arguments from status_replace.


# 1.119 20-Jan-2015 sthen

typo in comment ;) ok nicm


# 1.118 05-Nov-2014 nicm

Do not put a space between status-left/status-right and the window list,
instead move the space into the defaults for the options (so status-left
now defaults to "[#S] ". From Balazs Kezes.


# 1.117 20-Oct-2014 nicm

Better format for printf format attributes.


# 1.116 08-Oct-2014 nicm

Add xreallocarray and remove nmemb argument from xrealloc.


# 1.115 02-Oct-2014 nicm

Take account of window-status-separator when checking window position,
based on diff from Balazs Kezes.


Revision tags: OPENBSD_5_6_BASE
# 1.114 24-Apr-2014 nicm

There is no longer a need for a paste_stack struct or for global_buffers
to be global. Move to paste.c.


# 1.113 17-Apr-2014 nicm

Remove the monitor-content option and associated bits and bobs. It's
never worked very well. If there is a big demand for it to return, will
consider better ways to do it.


# 1.112 02-Apr-2014 nicm

Do not replace ## with # in status_replace1 because it'll be done later
by the format code.


# 1.111 31-Mar-2014 nicm

Make message-limit a server option.


Revision tags: OPENBSD_5_5_BASE
# 1.110 14-Feb-2014 nicm

Style nit - no space between function name and bracket.


# 1.109 14-Feb-2014 nicm

Check for NULL session and whatnot in status_replace, from Thomas Adam.


# 1.108 28-Jan-2014 nicm

Allow replacing each of the many sets of separate foo-{fg,bg,attr}
options with a single foo-style option. For example:

set -g status-fg yellow
set -g status-bg red
set -g status-attr blink

Becomes:

set -g status-style fg=yellow,bg=red,blink

The -a flag to set can be used to add to rather than replace a style. So:

set -g status-bg red

Becomes:

set -ag status-style bg=red

Currently this is fully backwards compatible (all *-{fg,bg,attr} options
remain) but the plan is to deprecate them over time.

From Tiago Cunha.


Revision tags: OPENBSD_5_4_BASE
# 1.107 05-Jul-2013 nicm

Whitespace nits, from Ben Boeckel.


# 1.106 05-Jul-2013 nicm

Act like vi(1) when moving words, from Ben Boeckel.


# 1.105 05-Jul-2013 nicm

Implement s, S, C mode switch commands in vi(1) mode, from Ben Boeckel.


# 1.104 31-May-2013 nicm

Demote the old single-character replacement variables (#S and friends)
to aliases of formats. From Tiago Cunha.


# 1.103 25-Mar-2013 nicm

Extend jobs to support writing and use that for copy-pipe instead of
popen, from Chris Johnsen.


# 1.102 22-Mar-2013 nicm

evbuffer_readline returns allocated storage, don't leak it.


# 1.101 22-Mar-2013 nicm

Add copy-pipe mode command to copy selection and also pipe to a command.


# 1.100 22-Mar-2013 nicm

No more lint means no more ARGSUSED.


# 1.99 21-Mar-2013 nicm

Aargh. Spaces -> tabs.


# 1.98 21-Mar-2013 nicm

Do not leak formats in status_replace.


# 1.97 21-Mar-2013 nicm

Add a format client_prefix which is 1 if prefix key has been
pressed, used for example #{?client_prefix,X,Y}. Also a few extra
server_client_status needed.


# 1.96 21-Mar-2013 nicm

Allow formats in status options.


Revision tags: OPENBSD_5_3_BASE
# 1.95 27-Nov-2012 nicm

Add window-status-last-* options, from Boris Faure.


Revision tags: OPENBSD_5_2_BASE
# 1.94 10-Jul-2012 nicm

xfree is not particularly helpful, remove it. From Thomas Adam.


# 1.93 09-Jul-2012 nicm

Move a NULL check inside a function, from Tiago Cunha.


# 1.92 29-Apr-2012 nicm

Use int not u_char for colours from options since they may have bit 8
set to mark them as 256-colour. Reported by Chris Johnson.


# 1.91 23-Apr-2012 nicm

Add window-status-separator option, from Thomas Adam.


# 1.90 17-Mar-2012 nicm

Check event_initialized before event_del if event may not have been set
up; libevent2 complains about this. Reported by Moriyoshi Koizumi.


# 1.89 04-Mar-2012 nicm

Add A and I keys for vi status line editing.


# 1.88 03-Mar-2012 nicm

The wlmouse offset should be part of the client, not the server. From
Ailin Nemui.


Revision tags: OPENBSD_5_1_BASE
# 1.87 29-Jan-2012 nicm

Add an option to move the status line to the top of the screen,
requested by many.


# 1.86 26-Jan-2012 nicm

Terminate strftime buffer properly even if a really long format string
is given, from Tiago Cunha.


# 1.85 26-Jan-2012 nicm

Fix memory leak in error path, from Tiago Cunha.


# 1.84 20-Jan-2012 nicm

Add some trivial additional status line attributes from jwcxz at users
dot sourceforge dot net.


# 1.83 20-Jan-2012 nicm

Add space movement keys for vi mode in the status line from Ben Boeckel.


# 1.82 01-Dec-2011 nicm

Make M-f and M-b work the same at the command prompt as in copy mode,
pointed out by Romain Francoise.


# 1.81 15-Nov-2011 nicm

Add word movement and editing command for command prompt editing, from
Ben Boeckel.


# 1.80 15-Nov-2011 nicm

Make window_pane_index work the same as window_index, from Ben Boeckel.


# 1.79 05-Nov-2011 nicm

Option to change status line (message) background when using vi keys and
in command mode. From Ben Boeckel.


# 1.78 20-Aug-2011 nicm

Fix a couple of memory leaks, from marcel partap.


Revision tags: OPENBSD_5_0_BASE
# 1.77 08-Jul-2011 nicm

Make confirm-before prompt customizable with -p option like
command-prompt. Also move responsibility for calling status_replace into
status_prompt_{set,update} and add #W and #P to the default kill-window
and kill-pane prompts. By Tiago Cunha.


# 1.76 02-Jul-2011 nicm

Allow the initial context on prompts to be set with the new -I option to
command-prompt. From Tiago Cunha.


# 1.75 29-Apr-2011 nicm

Only redraw the status line on command update, not the entire client
(big DOH).


# 1.74 24-Apr-2011 nicm

Provide #h for short hostname (no domain) from Michal Mazurek.


# 1.73 18-Apr-2011 nicm

Add an option (mouse-select-window) which allows the mouse to be used by
clicking on the status line, written by hsim at gmx dot li.


# 1.72 29-Mar-2011 nicm

Change -t on display-message to be target-pane for the #[A-Z]
replacements and add -c as target-client.


Revision tags: OPENBSD_4_9_BASE
# 1.71 26-Jan-2011 nicm

Simplify the way jobs work and drop the persist type, so all jobs are
fire-and-forget.

Status jobs now managed with two trees of output (new and old), rather
than storing the output in the jobs themselves. When the status line is
processed any jobs which don't appear in the new tree are started and
the output from the old tree displayed. When a job finishes it updates
the new tree with its output and that is used for any subsequent
redraws. When the status interval expires, the new tree is moved to the
old so that all jobs are run again.

This fixes the "#(echo %H:%M:%S)" problem which would lead to thousands
of identical persistent jobs and high memory use (this can still be
achieved by adding "sleep 30" but that is much less likely to happen by
accident).


# 1.70 03-Jan-2011 nicm

Handle a # at the end of a replacement string (such as status-left)
correctly. Found by Thomas Adam.


# 1.69 01-Jan-2011 nicm

Move the user-visible parts of all options (names, types, limit, default
values) together into one set of tables in options-table.c. Also clean
up and simplify cmd-set-options.c and move a common print function into
option-table.c.


# 1.68 30-Dec-2010 nicm

Change from a per-session stack of buffers to one global stack which is
much more convenient and also simplifies lot of code. This renders
copy-buffer useless and makes buffer-limit now a server option.

By Tiago Cunha.


# 1.67 30-Dec-2010 nicm

Add a function to create window flags rather than doing the same thing
in two places. From Thomas Adam.


# 1.66 11-Dec-2010 nicm

Oops, these functions return a const char *, so make the local variable
const as well.


# 1.65 11-Dec-2010 nicm

Make the prompt history global for all clients which is much more useful than per-client history.


# 1.64 06-Dec-2010 nicm

Add an option to alert (monitor) for silence (lack of activity) in a
window. From Thomas Adam.


Revision tags: OPENBSD_4_8_BASE
# 1.63 21-Jun-2010 nicm

Having a list of winlinks->alerts for each session is stupid, just store
the alert flags directly in the winlink itself.


# 1.62 14-May-2010 nicm

Colour+attribute options for status line alerts, from Alex Alexander.


# 1.61 31-Mar-2010 nicm

Don't accept keys with modifiers as input. Fixes crash reported by Brian
R Landy.


# 1.60 27-Mar-2010 nicm

Don't leak job command in #().


# 1.59 22-Mar-2010 nicm

Dead functions, lint.


Revision tags: OPENBSD_4_7_BASE
# 1.58 27-Jan-2010 nicm

Calculate offset correctly, fixes incorrect offset and prevents crash when
status-left is empty. From Micah Cowan.


# 1.57 26-Jan-2010 nicm

Actually use the copy made when no newline is found, from martynas@.


# 1.56 14-Dec-2009 nicm

Add server options to completion as well.


# 1.55 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.54 03-Dec-2009 nicm

Eliminate duplicate code and ease the passage for server-wide options by adding
a -w flag to set-option and show-options and making setw and showw aliases to
set -w and show -w.

Note: setw and showw are still there, but now aliases for set -w and show -w.


# 1.53 26-Nov-2009 nicm

Tidy up various bits of the paste code, make the data buffer char * and add
comments.


# 1.52 26-Nov-2009 nicm

Remove a couple of unused arguments where possible, and add /* ARGSUSED */ to
the rest to reduce lint output.


# 1.51 20-Nov-2009 nicm

Display UTF-8 properly in status line messages and prompt. Cursor handling is
still way off though.


# 1.50 20-Nov-2009 nicm

Remove oldest messages from log when limit is hit, not newest.


# 1.49 19-Nov-2009 nicm

Get some brackets in the right place so ## works. Also fix a space in a
comment.


# 1.48 19-Nov-2009 nicm

Change status line drawing to create the window list in a separate screen and
then copy it into the status line screen. This allows UTF-8 in window names and
fixes some problems with #[] in window-status-format.


# 1.47 19-Nov-2009 nicm

Two new options, window-status-format and window-status-current-format, which
allow the format of each window in the status line window list to be controlled
using similar # sequences as status-left/right.

This diff also moves part of the way towards UTF-8 support in window names but
it isn't quite there yet.


# 1.46 19-Nov-2009 nicm

Tidy up by breaking the # replacement code into a separate function, also add a
few comments.


# 1.45 19-Nov-2009 nicm

Don't interpret #() for display-message, it usually doesn't make sense and may
leak commands.


# 1.44 18-Nov-2009 nicm

Add a per-client log of status line messages displayed while that client
exists. A new message-limit session option sets the maximum number of entries
and a command, show-messages, shows the log (bound to ~ by default).

This (and prompt history) might be better as a single global log but until
there are global options it is easier for them to be per client.


# 1.43 17-Nov-2009 nicm

Permit top-bit-set characters to be entered in the status line. They could
already be set from the shell and are just passed through when printing (so
invisible characters or displaying on terminals with different character sets
may cause problems).

Note that entering UTF-8 may not work and in any case currently the status line
cannot display it correctly (outside of status-left/status-right).


# 1.42 04-Nov-2009 nicm

Use timeout events for the identify and message timers.


# 1.41 04-Nov-2009 nicm

Switch jobs over to use a bufferevent.


# 1.40 04-Nov-2009 nicm

Unused (but assigned to) variable, found by lint.


# 1.39 01-Nov-2009 nicm

Add a flag for jobs that shouldn't be freed after they've died and use it for
status jobs, then only kill those jobs when status-left, status-right or
set-titles-string is changed.

Fixes problems with changing options from inside #().


# 1.38 10-Oct-2009 nicm

Rather than running status-left, status-right and window title #() with popen
immediately every redraw, queue them up and run them in the background,
starting each once every status-interval. The actual status line uses the
output from the last run.

This brings several advantages:

- tmux itself may be called from inside #() without causing the server to hang;
- likewise, sleep or similar doesn't cause the server to block;
- commands aren't run excessively often when redrawing;
- commands shared by status-left and status-right, or used multiple times, will
only be run once.

run-shell and if-shell still use system()/popen() but will be changed over to
use this too later.


# 1.37 10-Oct-2009 nicm

Add "grouped sessions" which have independent name, options, current window and
so on but where the linked windows are synchronized (ie creating, killing
windows and so on are mirrored between the sessions). A grouped session may be
created by passing -t to new-session.

Had this around for a while, tested by a couple of people.


# 1.36 23-Sep-2009 nicm

Remove PROMPT_HIDDEN code which is now unused.


# 1.35 23-Sep-2009 nicm

Remove the internal tmux locking and instead detach each client and run the
command specified by a new option "lock-command" (by default "lock -np") in
each client.

This means each terminal has to be unlocked individually but simplifies the
code and allows the system password to be used to unlock.

Note that the set-password command is gone, so it will need to be removed from
configuration files, and the -U command line flag has been removed.

This is the third protocol version change so again it is best to stop the tmux
server before upgrading.


# 1.34 20-Sep-2009 nicm

Regularise some fatal messages.


# 1.33 10-Sep-2009 nicm

Permit options such as status-bg to be configured using the entire 256 colour
palette by setting "colour0" to "colour255".


# 1.32 07-Sep-2009 nicm

Give each paste buffer a size member instead of requiring them to be
zero-terminated.


# 1.31 07-Sep-2009 nicm

Permit embedded colour and attributes in status-left and status-right using new
#[] special characters, for example #[fg=red,bg=blue,blink].


# 1.30 02-Sep-2009 nicm

Add a transpose-chars command in edit mode (C-t in emacs mode only). From Kalle
Olavi Niemitalo.


# 1.29 01-Sep-2009 nicm

Use "Password:" with no space for password prompts and don't display a *s for
the password, like pretty much everything else. From martynas@ with minor
tweaks by me.


# 1.28 31-Aug-2009 nicm

Add a new display-panes command, with two options (display-panes-colour and
display-panes-time), which displays a visual indication of the number of each
pane.


# 1.27 19-Aug-2009 nicm

Extend command-prompt with a -p option which is a comma-separated list of one
or more prompts to present in order.

The responses to the prompt are replaced in the template string: %% are
replaced in order, so the first prompt replaces the first %%, the second
replaces the second, and so on. In addition, %1 up to %9 are replaced with the
responses to the first the ninth prompts

The default template is "%1" so the response to the first prompt is processed
as a command.

Note that this changes the behaviour for %% so if there is only one prompt,
only the first %% will be replaced. Templates such as "neww -n '%%' 'ssh %%'"
should be changed to "neww -n '%1' 'ssh %1'".

From Tiago Cunha.


# 1.26 18-Aug-2009 nicm

Add a "delete line" key when editing in the status line or the search up/down
prompt. C-u with emacs keys, d with vi.


# 1.25 13-Aug-2009 nicm

Switch the prompt code to return an empty string when the user enters no
response and reserve NULL for an explicit cancel. Change all callbacks to treat
them the same so no functional change.

Also add cancel key bindings to emacs mode which were missing.


# 1.24 08-Aug-2009 nicm

Options to set the colours and attributes for status-left/-right. From Thomas
Adam, thanks.


# 1.23 05-Aug-2009 nicm

If colours are not supported by the terminal, try to emulate a coloured
background by setting or clearing the reverse attribute.

This makes a few applications which don't use the reverse attribute themselves
a little happier, and allows the status, message and mode options to have
default attributes and fg/bg options that work as expected when set as reverse.


# 1.22 30-Jul-2009 nicm

Plug some memory leaks.


# 1.21 28-Jul-2009 nicm

Next step towards customisable mode keys: build each default table of keys into
a named tree on start and use that for lookups. Also add command to string
translation tables and modify list-keys to show the the mode key bindings (new
-t argument).


# 1.20 27-Jul-2009 nicm

Change mode key bindings from big switches into a set of tables. Rather than
lumping them all together, split editing keys from those used in choice/more
mode and those for copy/scroll mode.

Tidier and clearer, and the first step towards customisable mode keys.


# 1.19 27-Jul-2009 nicm

Get rid of empty mode_key_free function.


# 1.18 27-Jul-2009 nicm

Add a key to delete to end of line at the prompt (^K in emacs mode, C/D in vi).

From Kalle Olavi Niemitalo.


# 1.17 26-Jul-2009 nicm

Calculate the space available for the prompt buffer and the cursor position
correctly, and make it work when the screen is not wide enough.

Noticed by Kalle Olavi Niemitalo.


# 1.16 21-Jul-2009 nicm

Remove a couple of unused functions and fix a type ("FALLTHOUGH"), found by
lint.


# 1.15 20-Jul-2009 nicm

Add a status-justify option to allow the window list in the status line to be
positioned at the left, centre, or right.


# 1.14 20-Jul-2009 nicm

New options, window-status-current-{fg,bg,attr}, to set the fg, bg and
attributes with which the current window is shown in the status line. From
Johan Friis, thanks.


# 1.13 17-Jul-2009 nicm

- New command display-message (alias display) to display a message in the
status line (bound to "i" and displays the current window and time by
default). The same substitutions are applied as for status-left/right.
- Add support for including the window index (#I), pane index (#P) and window
name (#W) in the message, and status-left or status-right.
- Bump protocol version.

From Tiago Cunha, thanks!


# 1.12 17-Jul-2009 nicm

Memory could be leaked if a second prompt or message appeared while another was
still present, so add a separate prompt free callback and make the _clear
function responsible for calling it if necessary (rather than the individual
prompt callbacks). Also make both messages and prompts clear any existing when
a new is set.

In addition, the screen could be modified while the prompt is there, restore
the redraw-entire-screen behaviour on prompt clear; add a comment as a
reminder.


# 1.11 16-Jul-2009 nicm

Remove some duplicate code that was causing the status line to be redrawn even
when it hadn't changed.


# 1.10 15-Jul-2009 nicm

Make status_message_set a variadic printf-like function. No functional change -
helpful for a couple of things coming soon.


# 1.9 15-Jul-2009 nicm

Having to update NSETOPTION/NSETWINDOWOPTION when adding new options is a bit
annoying and it is only use for iterating, so use a sentinel to mark the end of
each array instead. Different fix for a problem pointed out by Kalle Olavi
Niemitalo.


# 1.8 14-Jul-2009 nicm

For some reason when clearing status/message it was redrawing the entire client
not just the status line. Changing this also revealed the check for the status
line was incorrect when drawing the pane.


# 1.7 14-Jul-2009 nicm

Instead of faking up a status line in status_redraw, use the same code to
redraw it as to draw the entire screen, just skip all lines but the last.

This makes horizontal split redraw properly when the status line is off.


# 1.6 12-Jul-2009 nicm

Add a "back to indentation" key in copy mode to move the cursor to the first
non-whitespace character. ^ with vi and M-m with emacs key bindings. Another
from Kalle Olavi Niemitalo, thanks.


Revision tags: OPENBSD_4_6_BASE
# 1.5 26-Jun-2009 nicm

Status line fixes: don't truncate status-right now the length calculation is
done for UTF-8, limit to the maximum length correctly when printing, and always
print a space even if the left string is longer than the width available.


# 1.4 04-Jun-2009 nicm

If the prompt is hidden or a password is sent with -U, zero it before freeing
it.


# 1.3 03-Jun-2009 nicm

New session option, status-utf8, to control the interpretation of top-bit-set
characters in status-left and status-right (if on, they are treated as UTF-8;
otherwise passed through).


# 1.2 03-Jun-2009 nicm

Add a UTF-8 aware string length function and make UTF-8 in
status-left/status-right work properly. At the moment any top-bit-set
characters are assumed to be UTF-8: a status-utf8 option to configure this will
come shortly.


# 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.199 23-May-2019 nicm

Fix length calculation for pasting UTF-8 characters in the status line,
GitHub issue 1753.


# 1.198 11-May-2019 nicm

Do not reduce window height by status line height for control mode
clients, from George Nachman.


# 1.197 03-May-2019 nicm

Fix reverse attribute in status line, GitHub issue 1709.


# 1.196 26-Apr-2019 nicm

Merge hooks into options and make each one an array option. This allows
multiple commands to be easily bound to one hook. set-hook and
show-hooks remain but they are now variants of set-option and
show-options. show-options now has a -H flag to show hooks (by default
they are not shown).


# 1.195 25-Apr-2019 nicm

options_array_item_value cannot return NULL.


# 1.194 23-Apr-2019 nicm

Somehow missed these bits in last commit.


# 1.193 23-Apr-2019 nicm

Indicate an array option with a flag rather than a special type so that
in future will not have to be strings.


Revision tags: OPENBSD_6_5_BASE
# 1.192 18-Mar-2019 nicm

Extend the #[] style syntax and use that together with previous format
changes to allow the status line to be entirely configured with a single
option.

Now that it is possible to configure their content, enable the existing
code that lets the status line be multiple lines in height. The status
option can now take a value of 2, 3, 4 or 5 (as well as the previous on
or off) to configure more than one line. The new status-format array
option configures the format of each line, the default just references
the existing status-* options, although some of the more obscure status
options may be eliminated in time.

Additions to the #[] syntax are: "align" to specify alignment (left,
centre, right), "list" for the window list and "range" to configure
ranges of text for the mouse bindings.

The "align" keyword can also be used to specify alignment of entries in
tree mode and the pane status lines.


# 1.191 18-Mar-2019 nicm

Make array options a sparse tree instead of an array of char * and
remove the size limit.


# 1.190 18-Mar-2019 nicm

With force, kill previous job before starting new. Fixes problem
reported by Scott Mcdermott in GitHub issue 1627.


# 1.189 16-Mar-2019 nicm

Use a pointer for the active screen in the status line instead of
copying them around all the time.


# 1.188 16-Mar-2019 nicm

Give status_save_old the client so it can do the reinit too.


# 1.187 16-Mar-2019 nicm

Tidy and rename some bits of status line code.


# 1.186 15-Mar-2019 nicm

Move status line free into its own function.


# 1.185 14-Mar-2019 nicm

Store the time in the format tree rather than passing it around.


# 1.184 12-Mar-2019 nicm

DECRC and DECSC apparently need to preserve origin mode as well, based
on a fix from Marc Reisner.


# 1.183 09-Feb-2019 nicm

Completion of command-alias members.


# 1.182 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.181 29-Aug-2018 nicm

Keep any text killed in the command prompt with C-w and yank it with
C-y, only use the top buffer if no text has previously been killed. This
and previous change promped by discussion with kn@.


# 1.180 29-Aug-2018 nicm

Add C-Left and C-Right as aliases for M-b and M-f.


# 1.179 22-Aug-2018 nicm

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


# 1.178 20-Aug-2018 nicm

Move offset of window list into status struct.


# 1.177 19-Aug-2018 nicm

Add a client redraw-window flag instead of the redraw-all flag and for
all just use the three flags together (window, borders, status).


Revision tags: OPENBSD_6_3_BASE
# 1.176 22-Feb-2018 nicm

Remove an unused variable.


# 1.175 05-Feb-2018 nicm

Add struct status_line to hold status line members of struct client, not
used yet but will be soon. From Thomas Adam.


# 1.174 01-Jan-2018 nicm

Add C-g at command prompt for emacs people, GitHub issue 1213.


# 1.173 27-Dec-2017 nicm

Draw command prompt correctly with status line off.


# 1.172 18-Dec-2017 nicm

Remove unused variable from Thomas Adam.


# 1.171 02-Nov-2017 nicm

Add a "fast" version of screen_write_copy for tree mode that doesn't do
all the checks and selection and marking stuff needed for copy mode.


# 1.170 20-Oct-2017 nicm

Clear status line with spaces again so reverse works, spotted by sthen.


# 1.169 16-Oct-2017 nicm

Infrastructure for drawing status lines of more than one line in height,
still only one is allowed but this lets tmux draw bigger ones.


Revision tags: OPENBSD_6_2_BASE
# 1.168 29-May-2017 nicm

Add a flag to stop the prompt input being expanded.


# 1.167 29-May-2017 nicm

Store a copy of the old status line, will be needed soon for new choose mode.


# 1.166 17-May-2017 nicm

Tidy command prompt callbacks and pass in the client.


# 1.165 03-May-2017 nicm

Add a format for the last search string in copy mode and fix the prompt
so it can work when in -I, suggested by Suraj N Kurapati.


# 1.164 01-May-2017 nicm

In order that people can use formats like #D in #() in the status line
and not have to wait for an update when they change pane, we allow
commands to run more than once a second if the expanded form
changes. Unfortunately this can mean them being run far too often
(pretty much continually) when multiple clients exist, because some
formats (including #D) will always differ between clients.

To avoid this, give each client its own tree of jobs which means that
the same command will be different instances for each client - similar
to how we have the tag to separate commands for different panes.

GitHub issue 889; test case reported by Paul Johnson.


# 1.163 22-Apr-2017 nicm

Memory leak from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.162 09-Feb-2017 nicm

Break the message storage function into its own function, useful for
debugging.


# 1.161 03-Feb-2017 nicm

Cache status line position to reduce option lookups during output.


# 1.160 03-Feb-2017 nicm

Add a window or pane id "tag" to each format tree and use it to separate
jobs, this means that if the same job is used for different windows or
panes (for example in pane-border-format), it will be run separately for
each pane.


# 1.159 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.158 06-Jan-2017 nicm

Incremental search in copy mode (on for emacs keys by default) - much
the same as normal searching but updates the cursor position and marked
search terms as you type. C-r and C-s in the prompt repeat the search,
once finished searching (with Enter), N and n work as before.


# 1.157 05-Jan-2017 nicm

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


# 1.156 07-Dec-2016 nicm

Do not clear the prompt when a message is shown, just leave it around and
return to it when the message is finished.


# 1.155 12-Oct-2016 nicm

Drop the edit mode key tables and just use fixed key bindings for the
command prompt.


# 1.154 12-Oct-2016 nicm

The repeat prompt in both emacs and vi (and the old one in tmux) doesn't
support line editing and instead executes a command as soon as a
non-number key is pressed. Add a -N flag to command-prompt for the same
in copy mode. Reported by Theo Buehler.


# 1.153 11-Oct-2016 nicm

Fundamental change to how copy mode key bindings work:

The vi-copy and emacs-copy mode key tables are gone, and instead copy
mode commands are bound in one of two normal key tables ("copy-mode" or
"copy-mode-vi"). Keys are bound to "send-keys -X copy-mode-command". So:

bind -temacs-copy C-Up scroll-up
bind -temacs-copy -R5 WheelUpPane scroll-up

Becomes:

bind -Tcopy-mode C-Up send -X scroll-up
bind -Tcopy-mode WheelUpPane send -N5 -X scroll-up

This allows the full command parser and command set to be used - for
example, we can use the normal command prompt for searching, jumping,
and so on instead of a custom one:

bind -Tcopy-mode C-r command-prompt -p'search up' "send -X search-backward '%%'"

command-prompt also gets a -1 option to only require on key press, which
is needed for jumping.

The plan is to get rid of mode keys entirely, so more to come eventually.


# 1.152 11-Oct-2016 nicm

Support UTF-8 entry into the command prompt.


# 1.151 10-Oct-2016 nicm

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


# 1.150 12-Sep-2016 nicm

Allow repeat count to be specified in mode key tables with bind-key -R,
and set the default repeat count to 5 for WheelUp and WheelDown in
copy-mode.


Revision tags: OPENBSD_6_0_BASE
# 1.149 06-Jun-2016 nicm

Allow #[] in window-status-separator.


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

I no longer use my SourceForge address so replace it.


# 1.147 01-Jan-2016 nicm

Don't rely on a calculation wrapping when applying message-limit, and
break out of the loop early. From Nicolas Viennot.


# 1.146 11-Dec-2015 nicm

Style nits and line wrapping of function declarations.


# 1.145 11-Dec-2015 nicm

Add cmdq as an argument to format_create and add a format for the
command name (will also be used for more later).


# 1.144 08-Dec-2015 nicm

Remove format_create_flags and just pass flags to format_create.


# 1.143 22-Nov-2015 tim

If display-time is set to 0, show status messages until a key is pressed;
OK nicm@


# 1.142 20-Nov-2015 nicm

Instead of separate tables for different types of options, give each
option a scope type (server, session, window) in one table.


# 1.141 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.140 13-Nov-2015 nicm

Long overdue change to the way we store cells in the grid: now, instead
of storing a full grid_cell with UTF-8 data and everything, store a new
type grid_cell_entry. This can either be the cell itself (for ASCII
cells), or an offset into an extended array (per line) for UTF-8
data.

This avoid a large (8 byte) overhead on non-UTF-8 cells (by far the
majority for most users) without the complexity of the shadow array we
had before. Grid memory without any UTF-8 is about half.

The disadvantage that cells can no longer be modified in place and need
to be copied out of the grid and back but it turned out to be lot less
complicated than I expected.


# 1.139 12-Nov-2015 nicm

Nuke the utf8 and status-utf8 options and make tmux only a UTF-8
terminal. We still support non-UTF-8 terminals outside tmux, but inside
it is always UTF-8 (as when the utf8 and status-utf8 options were on).


# 1.138 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.137 27-Oct-2015 nicm

Move struct options into options.c.


# 1.136 20-Oct-2015 nicm

Use client pointer not file descriptor in logging.


# 1.135 14-Sep-2015 nicm

Make refresh-client force update of jobs, from Sina Siadat.


# 1.134 29-Aug-2015 nicm

Move struct paste_buffer out of tmux.h.


# 1.133 28-Aug-2015 nicm

Run status update on a per-client timer at status-interval.


Revision tags: OPENBSD_5_8_BASE
# 1.132 29-Jul-2015 nicm

status_out and associated data structures are no longer used.


# 1.131 28-Jul-2015 nicm

Tidy up the way terminals are described and move some structs out of tmux.h.


# 1.130 20-Jul-2015 nicm

Add an option (history-file) for a file to save/restore command prompt
history, from Olof-Joachim Frahm.


# 1.129 27-May-2015 nicm

Move the jobs output cache into the formats code so that #() work more
generally (for example, again working in set-titles-string).


# 1.128 06-May-2015 nicm

Remove ARRAY_* from history and expand completion to complete a) layout
names and b) targets beginning with -t or -s.


# 1.127 25-Apr-2015 nicm

Make message log a TAILQ.


# 1.126 24-Apr-2015 nicm

Set working directory for run-shell and if-shell.


# 1.125 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_7_BASE
# 1.124 06-Feb-2015 nicm

Use the same time for both calls to format_expand_time.


# 1.123 06-Feb-2015 nicm

status_replace can now become local to status.c and it no longer needs
the jobsflag argument. While here there is no need to repeat work that
format_defaults already does.


# 1.122 06-Feb-2015 nicm

Add format_expand_time and use it instead of status_replace where
command execution is not needed.


# 1.121 05-Feb-2015 nicm

Wrap all the individual format_* calls in a single format_defaults
functions.


# 1.120 01-Feb-2015 nicm

Remove two unused arguments from status_replace.


# 1.119 20-Jan-2015 sthen

typo in comment ;) ok nicm


# 1.118 05-Nov-2014 nicm

Do not put a space between status-left/status-right and the window list,
instead move the space into the defaults for the options (so status-left
now defaults to "[#S] ". From Balazs Kezes.


# 1.117 20-Oct-2014 nicm

Better format for printf format attributes.


# 1.116 08-Oct-2014 nicm

Add xreallocarray and remove nmemb argument from xrealloc.


# 1.115 02-Oct-2014 nicm

Take account of window-status-separator when checking window position,
based on diff from Balazs Kezes.


Revision tags: OPENBSD_5_6_BASE
# 1.114 24-Apr-2014 nicm

There is no longer a need for a paste_stack struct or for global_buffers
to be global. Move to paste.c.


# 1.113 17-Apr-2014 nicm

Remove the monitor-content option and associated bits and bobs. It's
never worked very well. If there is a big demand for it to return, will
consider better ways to do it.


# 1.112 02-Apr-2014 nicm

Do not replace ## with # in status_replace1 because it'll be done later
by the format code.


# 1.111 31-Mar-2014 nicm

Make message-limit a server option.


Revision tags: OPENBSD_5_5_BASE
# 1.110 14-Feb-2014 nicm

Style nit - no space between function name and bracket.


# 1.109 14-Feb-2014 nicm

Check for NULL session and whatnot in status_replace, from Thomas Adam.


# 1.108 28-Jan-2014 nicm

Allow replacing each of the many sets of separate foo-{fg,bg,attr}
options with a single foo-style option. For example:

set -g status-fg yellow
set -g status-bg red
set -g status-attr blink

Becomes:

set -g status-style fg=yellow,bg=red,blink

The -a flag to set can be used to add to rather than replace a style. So:

set -g status-bg red

Becomes:

set -ag status-style bg=red

Currently this is fully backwards compatible (all *-{fg,bg,attr} options
remain) but the plan is to deprecate them over time.

From Tiago Cunha.


Revision tags: OPENBSD_5_4_BASE
# 1.107 05-Jul-2013 nicm

Whitespace nits, from Ben Boeckel.


# 1.106 05-Jul-2013 nicm

Act like vi(1) when moving words, from Ben Boeckel.


# 1.105 05-Jul-2013 nicm

Implement s, S, C mode switch commands in vi(1) mode, from Ben Boeckel.


# 1.104 31-May-2013 nicm

Demote the old single-character replacement variables (#S and friends)
to aliases of formats. From Tiago Cunha.


# 1.103 25-Mar-2013 nicm

Extend jobs to support writing and use that for copy-pipe instead of
popen, from Chris Johnsen.


# 1.102 22-Mar-2013 nicm

evbuffer_readline returns allocated storage, don't leak it.


# 1.101 22-Mar-2013 nicm

Add copy-pipe mode command to copy selection and also pipe to a command.


# 1.100 22-Mar-2013 nicm

No more lint means no more ARGSUSED.


# 1.99 21-Mar-2013 nicm

Aargh. Spaces -> tabs.


# 1.98 21-Mar-2013 nicm

Do not leak formats in status_replace.


# 1.97 21-Mar-2013 nicm

Add a format client_prefix which is 1 if prefix key has been
pressed, used for example #{?client_prefix,X,Y}. Also a few extra
server_client_status needed.


# 1.96 21-Mar-2013 nicm

Allow formats in status options.


Revision tags: OPENBSD_5_3_BASE
# 1.95 27-Nov-2012 nicm

Add window-status-last-* options, from Boris Faure.


Revision tags: OPENBSD_5_2_BASE
# 1.94 10-Jul-2012 nicm

xfree is not particularly helpful, remove it. From Thomas Adam.


# 1.93 09-Jul-2012 nicm

Move a NULL check inside a function, from Tiago Cunha.


# 1.92 29-Apr-2012 nicm

Use int not u_char for colours from options since they may have bit 8
set to mark them as 256-colour. Reported by Chris Johnson.


# 1.91 23-Apr-2012 nicm

Add window-status-separator option, from Thomas Adam.


# 1.90 17-Mar-2012 nicm

Check event_initialized before event_del if event may not have been set
up; libevent2 complains about this. Reported by Moriyoshi Koizumi.


# 1.89 04-Mar-2012 nicm

Add A and I keys for vi status line editing.


# 1.88 03-Mar-2012 nicm

The wlmouse offset should be part of the client, not the server. From
Ailin Nemui.


Revision tags: OPENBSD_5_1_BASE
# 1.87 29-Jan-2012 nicm

Add an option to move the status line to the top of the screen,
requested by many.


# 1.86 26-Jan-2012 nicm

Terminate strftime buffer properly even if a really long format string
is given, from Tiago Cunha.


# 1.85 26-Jan-2012 nicm

Fix memory leak in error path, from Tiago Cunha.


# 1.84 20-Jan-2012 nicm

Add some trivial additional status line attributes from jwcxz at users
dot sourceforge dot net.


# 1.83 20-Jan-2012 nicm

Add space movement keys for vi mode in the status line from Ben Boeckel.


# 1.82 01-Dec-2011 nicm

Make M-f and M-b work the same at the command prompt as in copy mode,
pointed out by Romain Francoise.


# 1.81 15-Nov-2011 nicm

Add word movement and editing command for command prompt editing, from
Ben Boeckel.


# 1.80 15-Nov-2011 nicm

Make window_pane_index work the same as window_index, from Ben Boeckel.


# 1.79 05-Nov-2011 nicm

Option to change status line (message) background when using vi keys and
in command mode. From Ben Boeckel.


# 1.78 20-Aug-2011 nicm

Fix a couple of memory leaks, from marcel partap.


Revision tags: OPENBSD_5_0_BASE
# 1.77 08-Jul-2011 nicm

Make confirm-before prompt customizable with -p option like
command-prompt. Also move responsibility for calling status_replace into
status_prompt_{set,update} and add #W and #P to the default kill-window
and kill-pane prompts. By Tiago Cunha.


# 1.76 02-Jul-2011 nicm

Allow the initial context on prompts to be set with the new -I option to
command-prompt. From Tiago Cunha.


# 1.75 29-Apr-2011 nicm

Only redraw the status line on command update, not the entire client
(big DOH).


# 1.74 24-Apr-2011 nicm

Provide #h for short hostname (no domain) from Michal Mazurek.


# 1.73 18-Apr-2011 nicm

Add an option (mouse-select-window) which allows the mouse to be used by
clicking on the status line, written by hsim at gmx dot li.


# 1.72 29-Mar-2011 nicm

Change -t on display-message to be target-pane for the #[A-Z]
replacements and add -c as target-client.


Revision tags: OPENBSD_4_9_BASE
# 1.71 26-Jan-2011 nicm

Simplify the way jobs work and drop the persist type, so all jobs are
fire-and-forget.

Status jobs now managed with two trees of output (new and old), rather
than storing the output in the jobs themselves. When the status line is
processed any jobs which don't appear in the new tree are started and
the output from the old tree displayed. When a job finishes it updates
the new tree with its output and that is used for any subsequent
redraws. When the status interval expires, the new tree is moved to the
old so that all jobs are run again.

This fixes the "#(echo %H:%M:%S)" problem which would lead to thousands
of identical persistent jobs and high memory use (this can still be
achieved by adding "sleep 30" but that is much less likely to happen by
accident).


# 1.70 03-Jan-2011 nicm

Handle a # at the end of a replacement string (such as status-left)
correctly. Found by Thomas Adam.


# 1.69 01-Jan-2011 nicm

Move the user-visible parts of all options (names, types, limit, default
values) together into one set of tables in options-table.c. Also clean
up and simplify cmd-set-options.c and move a common print function into
option-table.c.


# 1.68 30-Dec-2010 nicm

Change from a per-session stack of buffers to one global stack which is
much more convenient and also simplifies lot of code. This renders
copy-buffer useless and makes buffer-limit now a server option.

By Tiago Cunha.


# 1.67 30-Dec-2010 nicm

Add a function to create window flags rather than doing the same thing
in two places. From Thomas Adam.


# 1.66 11-Dec-2010 nicm

Oops, these functions return a const char *, so make the local variable
const as well.


# 1.65 11-Dec-2010 nicm

Make the prompt history global for all clients which is much more useful than per-client history.


# 1.64 06-Dec-2010 nicm

Add an option to alert (monitor) for silence (lack of activity) in a
window. From Thomas Adam.


Revision tags: OPENBSD_4_8_BASE
# 1.63 21-Jun-2010 nicm

Having a list of winlinks->alerts for each session is stupid, just store
the alert flags directly in the winlink itself.


# 1.62 14-May-2010 nicm

Colour+attribute options for status line alerts, from Alex Alexander.


# 1.61 31-Mar-2010 nicm

Don't accept keys with modifiers as input. Fixes crash reported by Brian
R Landy.


# 1.60 27-Mar-2010 nicm

Don't leak job command in #().


# 1.59 22-Mar-2010 nicm

Dead functions, lint.


Revision tags: OPENBSD_4_7_BASE
# 1.58 27-Jan-2010 nicm

Calculate offset correctly, fixes incorrect offset and prevents crash when
status-left is empty. From Micah Cowan.


# 1.57 26-Jan-2010 nicm

Actually use the copy made when no newline is found, from martynas@.


# 1.56 14-Dec-2009 nicm

Add server options to completion as well.


# 1.55 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.54 03-Dec-2009 nicm

Eliminate duplicate code and ease the passage for server-wide options by adding
a -w flag to set-option and show-options and making setw and showw aliases to
set -w and show -w.

Note: setw and showw are still there, but now aliases for set -w and show -w.


# 1.53 26-Nov-2009 nicm

Tidy up various bits of the paste code, make the data buffer char * and add
comments.


# 1.52 26-Nov-2009 nicm

Remove a couple of unused arguments where possible, and add /* ARGSUSED */ to
the rest to reduce lint output.


# 1.51 20-Nov-2009 nicm

Display UTF-8 properly in status line messages and prompt. Cursor handling is
still way off though.


# 1.50 20-Nov-2009 nicm

Remove oldest messages from log when limit is hit, not newest.


# 1.49 19-Nov-2009 nicm

Get some brackets in the right place so ## works. Also fix a space in a
comment.


# 1.48 19-Nov-2009 nicm

Change status line drawing to create the window list in a separate screen and
then copy it into the status line screen. This allows UTF-8 in window names and
fixes some problems with #[] in window-status-format.


# 1.47 19-Nov-2009 nicm

Two new options, window-status-format and window-status-current-format, which
allow the format of each window in the status line window list to be controlled
using similar # sequences as status-left/right.

This diff also moves part of the way towards UTF-8 support in window names but
it isn't quite there yet.


# 1.46 19-Nov-2009 nicm

Tidy up by breaking the # replacement code into a separate function, also add a
few comments.


# 1.45 19-Nov-2009 nicm

Don't interpret #() for display-message, it usually doesn't make sense and may
leak commands.


# 1.44 18-Nov-2009 nicm

Add a per-client log of status line messages displayed while that client
exists. A new message-limit session option sets the maximum number of entries
and a command, show-messages, shows the log (bound to ~ by default).

This (and prompt history) might be better as a single global log but until
there are global options it is easier for them to be per client.


# 1.43 17-Nov-2009 nicm

Permit top-bit-set characters to be entered in the status line. They could
already be set from the shell and are just passed through when printing (so
invisible characters or displaying on terminals with different character sets
may cause problems).

Note that entering UTF-8 may not work and in any case currently the status line
cannot display it correctly (outside of status-left/status-right).


# 1.42 04-Nov-2009 nicm

Use timeout events for the identify and message timers.


# 1.41 04-Nov-2009 nicm

Switch jobs over to use a bufferevent.


# 1.40 04-Nov-2009 nicm

Unused (but assigned to) variable, found by lint.


# 1.39 01-Nov-2009 nicm

Add a flag for jobs that shouldn't be freed after they've died and use it for
status jobs, then only kill those jobs when status-left, status-right or
set-titles-string is changed.

Fixes problems with changing options from inside #().


# 1.38 10-Oct-2009 nicm

Rather than running status-left, status-right and window title #() with popen
immediately every redraw, queue them up and run them in the background,
starting each once every status-interval. The actual status line uses the
output from the last run.

This brings several advantages:

- tmux itself may be called from inside #() without causing the server to hang;
- likewise, sleep or similar doesn't cause the server to block;
- commands aren't run excessively often when redrawing;
- commands shared by status-left and status-right, or used multiple times, will
only be run once.

run-shell and if-shell still use system()/popen() but will be changed over to
use this too later.


# 1.37 10-Oct-2009 nicm

Add "grouped sessions" which have independent name, options, current window and
so on but where the linked windows are synchronized (ie creating, killing
windows and so on are mirrored between the sessions). A grouped session may be
created by passing -t to new-session.

Had this around for a while, tested by a couple of people.


# 1.36 23-Sep-2009 nicm

Remove PROMPT_HIDDEN code which is now unused.


# 1.35 23-Sep-2009 nicm

Remove the internal tmux locking and instead detach each client and run the
command specified by a new option "lock-command" (by default "lock -np") in
each client.

This means each terminal has to be unlocked individually but simplifies the
code and allows the system password to be used to unlock.

Note that the set-password command is gone, so it will need to be removed from
configuration files, and the -U command line flag has been removed.

This is the third protocol version change so again it is best to stop the tmux
server before upgrading.


# 1.34 20-Sep-2009 nicm

Regularise some fatal messages.


# 1.33 10-Sep-2009 nicm

Permit options such as status-bg to be configured using the entire 256 colour
palette by setting "colour0" to "colour255".


# 1.32 07-Sep-2009 nicm

Give each paste buffer a size member instead of requiring them to be
zero-terminated.


# 1.31 07-Sep-2009 nicm

Permit embedded colour and attributes in status-left and status-right using new
#[] special characters, for example #[fg=red,bg=blue,blink].


# 1.30 02-Sep-2009 nicm

Add a transpose-chars command in edit mode (C-t in emacs mode only). From Kalle
Olavi Niemitalo.


# 1.29 01-Sep-2009 nicm

Use "Password:" with no space for password prompts and don't display a *s for
the password, like pretty much everything else. From martynas@ with minor
tweaks by me.


# 1.28 31-Aug-2009 nicm

Add a new display-panes command, with two options (display-panes-colour and
display-panes-time), which displays a visual indication of the number of each
pane.


# 1.27 19-Aug-2009 nicm

Extend command-prompt with a -p option which is a comma-separated list of one
or more prompts to present in order.

The responses to the prompt are replaced in the template string: %% are
replaced in order, so the first prompt replaces the first %%, the second
replaces the second, and so on. In addition, %1 up to %9 are replaced with the
responses to the first the ninth prompts

The default template is "%1" so the response to the first prompt is processed
as a command.

Note that this changes the behaviour for %% so if there is only one prompt,
only the first %% will be replaced. Templates such as "neww -n '%%' 'ssh %%'"
should be changed to "neww -n '%1' 'ssh %1'".

From Tiago Cunha.


# 1.26 18-Aug-2009 nicm

Add a "delete line" key when editing in the status line or the search up/down
prompt. C-u with emacs keys, d with vi.


# 1.25 13-Aug-2009 nicm

Switch the prompt code to return an empty string when the user enters no
response and reserve NULL for an explicit cancel. Change all callbacks to treat
them the same so no functional change.

Also add cancel key bindings to emacs mode which were missing.


# 1.24 08-Aug-2009 nicm

Options to set the colours and attributes for status-left/-right. From Thomas
Adam, thanks.


# 1.23 05-Aug-2009 nicm

If colours are not supported by the terminal, try to emulate a coloured
background by setting or clearing the reverse attribute.

This makes a few applications which don't use the reverse attribute themselves
a little happier, and allows the status, message and mode options to have
default attributes and fg/bg options that work as expected when set as reverse.


# 1.22 30-Jul-2009 nicm

Plug some memory leaks.


# 1.21 28-Jul-2009 nicm

Next step towards customisable mode keys: build each default table of keys into
a named tree on start and use that for lookups. Also add command to string
translation tables and modify list-keys to show the the mode key bindings (new
-t argument).


# 1.20 27-Jul-2009 nicm

Change mode key bindings from big switches into a set of tables. Rather than
lumping them all together, split editing keys from those used in choice/more
mode and those for copy/scroll mode.

Tidier and clearer, and the first step towards customisable mode keys.


# 1.19 27-Jul-2009 nicm

Get rid of empty mode_key_free function.


# 1.18 27-Jul-2009 nicm

Add a key to delete to end of line at the prompt (^K in emacs mode, C/D in vi).

From Kalle Olavi Niemitalo.


# 1.17 26-Jul-2009 nicm

Calculate the space available for the prompt buffer and the cursor position
correctly, and make it work when the screen is not wide enough.

Noticed by Kalle Olavi Niemitalo.


# 1.16 21-Jul-2009 nicm

Remove a couple of unused functions and fix a type ("FALLTHOUGH"), found by
lint.


# 1.15 20-Jul-2009 nicm

Add a status-justify option to allow the window list in the status line to be
positioned at the left, centre, or right.


# 1.14 20-Jul-2009 nicm

New options, window-status-current-{fg,bg,attr}, to set the fg, bg and
attributes with which the current window is shown in the status line. From
Johan Friis, thanks.


# 1.13 17-Jul-2009 nicm

- New command display-message (alias display) to display a message in the
status line (bound to "i" and displays the current window and time by
default). The same substitutions are applied as for status-left/right.
- Add support for including the window index (#I), pane index (#P) and window
name (#W) in the message, and status-left or status-right.
- Bump protocol version.

From Tiago Cunha, thanks!


# 1.12 17-Jul-2009 nicm

Memory could be leaked if a second prompt or message appeared while another was
still present, so add a separate prompt free callback and make the _clear
function responsible for calling it if necessary (rather than the individual
prompt callbacks). Also make both messages and prompts clear any existing when
a new is set.

In addition, the screen could be modified while the prompt is there, restore
the redraw-entire-screen behaviour on prompt clear; add a comment as a
reminder.


# 1.11 16-Jul-2009 nicm

Remove some duplicate code that was causing the status line to be redrawn even
when it hadn't changed.


# 1.10 15-Jul-2009 nicm

Make status_message_set a variadic printf-like function. No functional change -
helpful for a couple of things coming soon.


# 1.9 15-Jul-2009 nicm

Having to update NSETOPTION/NSETWINDOWOPTION when adding new options is a bit
annoying and it is only use for iterating, so use a sentinel to mark the end of
each array instead. Different fix for a problem pointed out by Kalle Olavi
Niemitalo.


# 1.8 14-Jul-2009 nicm

For some reason when clearing status/message it was redrawing the entire client
not just the status line. Changing this also revealed the check for the status
line was incorrect when drawing the pane.


# 1.7 14-Jul-2009 nicm

Instead of faking up a status line in status_redraw, use the same code to
redraw it as to draw the entire screen, just skip all lines but the last.

This makes horizontal split redraw properly when the status line is off.


# 1.6 12-Jul-2009 nicm

Add a "back to indentation" key in copy mode to move the cursor to the first
non-whitespace character. ^ with vi and M-m with emacs key bindings. Another
from Kalle Olavi Niemitalo, thanks.


Revision tags: OPENBSD_4_6_BASE
# 1.5 26-Jun-2009 nicm

Status line fixes: don't truncate status-right now the length calculation is
done for UTF-8, limit to the maximum length correctly when printing, and always
print a space even if the left string is longer than the width available.


# 1.4 04-Jun-2009 nicm

If the prompt is hidden or a password is sent with -U, zero it before freeing
it.


# 1.3 03-Jun-2009 nicm

New session option, status-utf8, to control the interpretation of top-bit-set
characters in status-left and status-right (if on, they are treated as UTF-8;
otherwise passed through).


# 1.2 03-Jun-2009 nicm

Add a UTF-8 aware string length function and make UTF-8 in
status-left/status-right work properly. At the moment any top-bit-set
characters are assumed to be UTF-8: a status-utf8 option to configure this will
come shortly.


# 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.198 11-May-2019 nicm

Do not reduce window height by status line height for control mode
clients, from George Nachman.


# 1.197 03-May-2019 nicm

Fix reverse attribute in status line, GitHub issue 1709.


# 1.196 26-Apr-2019 nicm

Merge hooks into options and make each one an array option. This allows
multiple commands to be easily bound to one hook. set-hook and
show-hooks remain but they are now variants of set-option and
show-options. show-options now has a -H flag to show hooks (by default
they are not shown).


# 1.195 25-Apr-2019 nicm

options_array_item_value cannot return NULL.


# 1.194 23-Apr-2019 nicm

Somehow missed these bits in last commit.


# 1.193 23-Apr-2019 nicm

Indicate an array option with a flag rather than a special type so that
in future will not have to be strings.


Revision tags: OPENBSD_6_5_BASE
# 1.192 18-Mar-2019 nicm

Extend the #[] style syntax and use that together with previous format
changes to allow the status line to be entirely configured with a single
option.

Now that it is possible to configure their content, enable the existing
code that lets the status line be multiple lines in height. The status
option can now take a value of 2, 3, 4 or 5 (as well as the previous on
or off) to configure more than one line. The new status-format array
option configures the format of each line, the default just references
the existing status-* options, although some of the more obscure status
options may be eliminated in time.

Additions to the #[] syntax are: "align" to specify alignment (left,
centre, right), "list" for the window list and "range" to configure
ranges of text for the mouse bindings.

The "align" keyword can also be used to specify alignment of entries in
tree mode and the pane status lines.


# 1.191 18-Mar-2019 nicm

Make array options a sparse tree instead of an array of char * and
remove the size limit.


# 1.190 18-Mar-2019 nicm

With force, kill previous job before starting new. Fixes problem
reported by Scott Mcdermott in GitHub issue 1627.


# 1.189 16-Mar-2019 nicm

Use a pointer for the active screen in the status line instead of
copying them around all the time.


# 1.188 16-Mar-2019 nicm

Give status_save_old the client so it can do the reinit too.


# 1.187 16-Mar-2019 nicm

Tidy and rename some bits of status line code.


# 1.186 15-Mar-2019 nicm

Move status line free into its own function.


# 1.185 14-Mar-2019 nicm

Store the time in the format tree rather than passing it around.


# 1.184 12-Mar-2019 nicm

DECRC and DECSC apparently need to preserve origin mode as well, based
on a fix from Marc Reisner.


# 1.183 09-Feb-2019 nicm

Completion of command-alias members.


# 1.182 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.181 29-Aug-2018 nicm

Keep any text killed in the command prompt with C-w and yank it with
C-y, only use the top buffer if no text has previously been killed. This
and previous change promped by discussion with kn@.


# 1.180 29-Aug-2018 nicm

Add C-Left and C-Right as aliases for M-b and M-f.


# 1.179 22-Aug-2018 nicm

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


# 1.178 20-Aug-2018 nicm

Move offset of window list into status struct.


# 1.177 19-Aug-2018 nicm

Add a client redraw-window flag instead of the redraw-all flag and for
all just use the three flags together (window, borders, status).


Revision tags: OPENBSD_6_3_BASE
# 1.176 22-Feb-2018 nicm

Remove an unused variable.


# 1.175 05-Feb-2018 nicm

Add struct status_line to hold status line members of struct client, not
used yet but will be soon. From Thomas Adam.


# 1.174 01-Jan-2018 nicm

Add C-g at command prompt for emacs people, GitHub issue 1213.


# 1.173 27-Dec-2017 nicm

Draw command prompt correctly with status line off.


# 1.172 18-Dec-2017 nicm

Remove unused variable from Thomas Adam.


# 1.171 02-Nov-2017 nicm

Add a "fast" version of screen_write_copy for tree mode that doesn't do
all the checks and selection and marking stuff needed for copy mode.


# 1.170 20-Oct-2017 nicm

Clear status line with spaces again so reverse works, spotted by sthen.


# 1.169 16-Oct-2017 nicm

Infrastructure for drawing status lines of more than one line in height,
still only one is allowed but this lets tmux draw bigger ones.


Revision tags: OPENBSD_6_2_BASE
# 1.168 29-May-2017 nicm

Add a flag to stop the prompt input being expanded.


# 1.167 29-May-2017 nicm

Store a copy of the old status line, will be needed soon for new choose mode.


# 1.166 17-May-2017 nicm

Tidy command prompt callbacks and pass in the client.


# 1.165 03-May-2017 nicm

Add a format for the last search string in copy mode and fix the prompt
so it can work when in -I, suggested by Suraj N Kurapati.


# 1.164 01-May-2017 nicm

In order that people can use formats like #D in #() in the status line
and not have to wait for an update when they change pane, we allow
commands to run more than once a second if the expanded form
changes. Unfortunately this can mean them being run far too often
(pretty much continually) when multiple clients exist, because some
formats (including #D) will always differ between clients.

To avoid this, give each client its own tree of jobs which means that
the same command will be different instances for each client - similar
to how we have the tag to separate commands for different panes.

GitHub issue 889; test case reported by Paul Johnson.


# 1.163 22-Apr-2017 nicm

Memory leak from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.162 09-Feb-2017 nicm

Break the message storage function into its own function, useful for
debugging.


# 1.161 03-Feb-2017 nicm

Cache status line position to reduce option lookups during output.


# 1.160 03-Feb-2017 nicm

Add a window or pane id "tag" to each format tree and use it to separate
jobs, this means that if the same job is used for different windows or
panes (for example in pane-border-format), it will be run separately for
each pane.


# 1.159 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.158 06-Jan-2017 nicm

Incremental search in copy mode (on for emacs keys by default) - much
the same as normal searching but updates the cursor position and marked
search terms as you type. C-r and C-s in the prompt repeat the search,
once finished searching (with Enter), N and n work as before.


# 1.157 05-Jan-2017 nicm

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


# 1.156 07-Dec-2016 nicm

Do not clear the prompt when a message is shown, just leave it around and
return to it when the message is finished.


# 1.155 12-Oct-2016 nicm

Drop the edit mode key tables and just use fixed key bindings for the
command prompt.


# 1.154 12-Oct-2016 nicm

The repeat prompt in both emacs and vi (and the old one in tmux) doesn't
support line editing and instead executes a command as soon as a
non-number key is pressed. Add a -N flag to command-prompt for the same
in copy mode. Reported by Theo Buehler.


# 1.153 11-Oct-2016 nicm

Fundamental change to how copy mode key bindings work:

The vi-copy and emacs-copy mode key tables are gone, and instead copy
mode commands are bound in one of two normal key tables ("copy-mode" or
"copy-mode-vi"). Keys are bound to "send-keys -X copy-mode-command". So:

bind -temacs-copy C-Up scroll-up
bind -temacs-copy -R5 WheelUpPane scroll-up

Becomes:

bind -Tcopy-mode C-Up send -X scroll-up
bind -Tcopy-mode WheelUpPane send -N5 -X scroll-up

This allows the full command parser and command set to be used - for
example, we can use the normal command prompt for searching, jumping,
and so on instead of a custom one:

bind -Tcopy-mode C-r command-prompt -p'search up' "send -X search-backward '%%'"

command-prompt also gets a -1 option to only require on key press, which
is needed for jumping.

The plan is to get rid of mode keys entirely, so more to come eventually.


# 1.152 11-Oct-2016 nicm

Support UTF-8 entry into the command prompt.


# 1.151 10-Oct-2016 nicm

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


# 1.150 12-Sep-2016 nicm

Allow repeat count to be specified in mode key tables with bind-key -R,
and set the default repeat count to 5 for WheelUp and WheelDown in
copy-mode.


Revision tags: OPENBSD_6_0_BASE
# 1.149 06-Jun-2016 nicm

Allow #[] in window-status-separator.


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

I no longer use my SourceForge address so replace it.


# 1.147 01-Jan-2016 nicm

Don't rely on a calculation wrapping when applying message-limit, and
break out of the loop early. From Nicolas Viennot.


# 1.146 11-Dec-2015 nicm

Style nits and line wrapping of function declarations.


# 1.145 11-Dec-2015 nicm

Add cmdq as an argument to format_create and add a format for the
command name (will also be used for more later).


# 1.144 08-Dec-2015 nicm

Remove format_create_flags and just pass flags to format_create.


# 1.143 22-Nov-2015 tim

If display-time is set to 0, show status messages until a key is pressed;
OK nicm@


# 1.142 20-Nov-2015 nicm

Instead of separate tables for different types of options, give each
option a scope type (server, session, window) in one table.


# 1.141 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.140 13-Nov-2015 nicm

Long overdue change to the way we store cells in the grid: now, instead
of storing a full grid_cell with UTF-8 data and everything, store a new
type grid_cell_entry. This can either be the cell itself (for ASCII
cells), or an offset into an extended array (per line) for UTF-8
data.

This avoid a large (8 byte) overhead on non-UTF-8 cells (by far the
majority for most users) without the complexity of the shadow array we
had before. Grid memory without any UTF-8 is about half.

The disadvantage that cells can no longer be modified in place and need
to be copied out of the grid and back but it turned out to be lot less
complicated than I expected.


# 1.139 12-Nov-2015 nicm

Nuke the utf8 and status-utf8 options and make tmux only a UTF-8
terminal. We still support non-UTF-8 terminals outside tmux, but inside
it is always UTF-8 (as when the utf8 and status-utf8 options were on).


# 1.138 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.137 27-Oct-2015 nicm

Move struct options into options.c.


# 1.136 20-Oct-2015 nicm

Use client pointer not file descriptor in logging.


# 1.135 14-Sep-2015 nicm

Make refresh-client force update of jobs, from Sina Siadat.


# 1.134 29-Aug-2015 nicm

Move struct paste_buffer out of tmux.h.


# 1.133 28-Aug-2015 nicm

Run status update on a per-client timer at status-interval.


Revision tags: OPENBSD_5_8_BASE
# 1.132 29-Jul-2015 nicm

status_out and associated data structures are no longer used.


# 1.131 28-Jul-2015 nicm

Tidy up the way terminals are described and move some structs out of tmux.h.


# 1.130 20-Jul-2015 nicm

Add an option (history-file) for a file to save/restore command prompt
history, from Olof-Joachim Frahm.


# 1.129 27-May-2015 nicm

Move the jobs output cache into the formats code so that #() work more
generally (for example, again working in set-titles-string).


# 1.128 06-May-2015 nicm

Remove ARRAY_* from history and expand completion to complete a) layout
names and b) targets beginning with -t or -s.


# 1.127 25-Apr-2015 nicm

Make message log a TAILQ.


# 1.126 24-Apr-2015 nicm

Set working directory for run-shell and if-shell.


# 1.125 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_7_BASE
# 1.124 06-Feb-2015 nicm

Use the same time for both calls to format_expand_time.


# 1.123 06-Feb-2015 nicm

status_replace can now become local to status.c and it no longer needs
the jobsflag argument. While here there is no need to repeat work that
format_defaults already does.


# 1.122 06-Feb-2015 nicm

Add format_expand_time and use it instead of status_replace where
command execution is not needed.


# 1.121 05-Feb-2015 nicm

Wrap all the individual format_* calls in a single format_defaults
functions.


# 1.120 01-Feb-2015 nicm

Remove two unused arguments from status_replace.


# 1.119 20-Jan-2015 sthen

typo in comment ;) ok nicm


# 1.118 05-Nov-2014 nicm

Do not put a space between status-left/status-right and the window list,
instead move the space into the defaults for the options (so status-left
now defaults to "[#S] ". From Balazs Kezes.


# 1.117 20-Oct-2014 nicm

Better format for printf format attributes.


# 1.116 08-Oct-2014 nicm

Add xreallocarray and remove nmemb argument from xrealloc.


# 1.115 02-Oct-2014 nicm

Take account of window-status-separator when checking window position,
based on diff from Balazs Kezes.


Revision tags: OPENBSD_5_6_BASE
# 1.114 24-Apr-2014 nicm

There is no longer a need for a paste_stack struct or for global_buffers
to be global. Move to paste.c.


# 1.113 17-Apr-2014 nicm

Remove the monitor-content option and associated bits and bobs. It's
never worked very well. If there is a big demand for it to return, will
consider better ways to do it.


# 1.112 02-Apr-2014 nicm

Do not replace ## with # in status_replace1 because it'll be done later
by the format code.


# 1.111 31-Mar-2014 nicm

Make message-limit a server option.


Revision tags: OPENBSD_5_5_BASE
# 1.110 14-Feb-2014 nicm

Style nit - no space between function name and bracket.


# 1.109 14-Feb-2014 nicm

Check for NULL session and whatnot in status_replace, from Thomas Adam.


# 1.108 28-Jan-2014 nicm

Allow replacing each of the many sets of separate foo-{fg,bg,attr}
options with a single foo-style option. For example:

set -g status-fg yellow
set -g status-bg red
set -g status-attr blink

Becomes:

set -g status-style fg=yellow,bg=red,blink

The -a flag to set can be used to add to rather than replace a style. So:

set -g status-bg red

Becomes:

set -ag status-style bg=red

Currently this is fully backwards compatible (all *-{fg,bg,attr} options
remain) but the plan is to deprecate them over time.

From Tiago Cunha.


Revision tags: OPENBSD_5_4_BASE
# 1.107 05-Jul-2013 nicm

Whitespace nits, from Ben Boeckel.


# 1.106 05-Jul-2013 nicm

Act like vi(1) when moving words, from Ben Boeckel.


# 1.105 05-Jul-2013 nicm

Implement s, S, C mode switch commands in vi(1) mode, from Ben Boeckel.


# 1.104 31-May-2013 nicm

Demote the old single-character replacement variables (#S and friends)
to aliases of formats. From Tiago Cunha.


# 1.103 25-Mar-2013 nicm

Extend jobs to support writing and use that for copy-pipe instead of
popen, from Chris Johnsen.


# 1.102 22-Mar-2013 nicm

evbuffer_readline returns allocated storage, don't leak it.


# 1.101 22-Mar-2013 nicm

Add copy-pipe mode command to copy selection and also pipe to a command.


# 1.100 22-Mar-2013 nicm

No more lint means no more ARGSUSED.


# 1.99 21-Mar-2013 nicm

Aargh. Spaces -> tabs.


# 1.98 21-Mar-2013 nicm

Do not leak formats in status_replace.


# 1.97 21-Mar-2013 nicm

Add a format client_prefix which is 1 if prefix key has been
pressed, used for example #{?client_prefix,X,Y}. Also a few extra
server_client_status needed.


# 1.96 21-Mar-2013 nicm

Allow formats in status options.


Revision tags: OPENBSD_5_3_BASE
# 1.95 27-Nov-2012 nicm

Add window-status-last-* options, from Boris Faure.


Revision tags: OPENBSD_5_2_BASE
# 1.94 10-Jul-2012 nicm

xfree is not particularly helpful, remove it. From Thomas Adam.


# 1.93 09-Jul-2012 nicm

Move a NULL check inside a function, from Tiago Cunha.


# 1.92 29-Apr-2012 nicm

Use int not u_char for colours from options since they may have bit 8
set to mark them as 256-colour. Reported by Chris Johnson.


# 1.91 23-Apr-2012 nicm

Add window-status-separator option, from Thomas Adam.


# 1.90 17-Mar-2012 nicm

Check event_initialized before event_del if event may not have been set
up; libevent2 complains about this. Reported by Moriyoshi Koizumi.


# 1.89 04-Mar-2012 nicm

Add A and I keys for vi status line editing.


# 1.88 03-Mar-2012 nicm

The wlmouse offset should be part of the client, not the server. From
Ailin Nemui.


Revision tags: OPENBSD_5_1_BASE
# 1.87 29-Jan-2012 nicm

Add an option to move the status line to the top of the screen,
requested by many.


# 1.86 26-Jan-2012 nicm

Terminate strftime buffer properly even if a really long format string
is given, from Tiago Cunha.


# 1.85 26-Jan-2012 nicm

Fix memory leak in error path, from Tiago Cunha.


# 1.84 20-Jan-2012 nicm

Add some trivial additional status line attributes from jwcxz at users
dot sourceforge dot net.


# 1.83 20-Jan-2012 nicm

Add space movement keys for vi mode in the status line from Ben Boeckel.


# 1.82 01-Dec-2011 nicm

Make M-f and M-b work the same at the command prompt as in copy mode,
pointed out by Romain Francoise.


# 1.81 15-Nov-2011 nicm

Add word movement and editing command for command prompt editing, from
Ben Boeckel.


# 1.80 15-Nov-2011 nicm

Make window_pane_index work the same as window_index, from Ben Boeckel.


# 1.79 05-Nov-2011 nicm

Option to change status line (message) background when using vi keys and
in command mode. From Ben Boeckel.


# 1.78 20-Aug-2011 nicm

Fix a couple of memory leaks, from marcel partap.


Revision tags: OPENBSD_5_0_BASE
# 1.77 08-Jul-2011 nicm

Make confirm-before prompt customizable with -p option like
command-prompt. Also move responsibility for calling status_replace into
status_prompt_{set,update} and add #W and #P to the default kill-window
and kill-pane prompts. By Tiago Cunha.


# 1.76 02-Jul-2011 nicm

Allow the initial context on prompts to be set with the new -I option to
command-prompt. From Tiago Cunha.


# 1.75 29-Apr-2011 nicm

Only redraw the status line on command update, not the entire client
(big DOH).


# 1.74 24-Apr-2011 nicm

Provide #h for short hostname (no domain) from Michal Mazurek.


# 1.73 18-Apr-2011 nicm

Add an option (mouse-select-window) which allows the mouse to be used by
clicking on the status line, written by hsim at gmx dot li.


# 1.72 29-Mar-2011 nicm

Change -t on display-message to be target-pane for the #[A-Z]
replacements and add -c as target-client.


Revision tags: OPENBSD_4_9_BASE
# 1.71 26-Jan-2011 nicm

Simplify the way jobs work and drop the persist type, so all jobs are
fire-and-forget.

Status jobs now managed with two trees of output (new and old), rather
than storing the output in the jobs themselves. When the status line is
processed any jobs which don't appear in the new tree are started and
the output from the old tree displayed. When a job finishes it updates
the new tree with its output and that is used for any subsequent
redraws. When the status interval expires, the new tree is moved to the
old so that all jobs are run again.

This fixes the "#(echo %H:%M:%S)" problem which would lead to thousands
of identical persistent jobs and high memory use (this can still be
achieved by adding "sleep 30" but that is much less likely to happen by
accident).


# 1.70 03-Jan-2011 nicm

Handle a # at the end of a replacement string (such as status-left)
correctly. Found by Thomas Adam.


# 1.69 01-Jan-2011 nicm

Move the user-visible parts of all options (names, types, limit, default
values) together into one set of tables in options-table.c. Also clean
up and simplify cmd-set-options.c and move a common print function into
option-table.c.


# 1.68 30-Dec-2010 nicm

Change from a per-session stack of buffers to one global stack which is
much more convenient and also simplifies lot of code. This renders
copy-buffer useless and makes buffer-limit now a server option.

By Tiago Cunha.


# 1.67 30-Dec-2010 nicm

Add a function to create window flags rather than doing the same thing
in two places. From Thomas Adam.


# 1.66 11-Dec-2010 nicm

Oops, these functions return a const char *, so make the local variable
const as well.


# 1.65 11-Dec-2010 nicm

Make the prompt history global for all clients which is much more useful than per-client history.


# 1.64 06-Dec-2010 nicm

Add an option to alert (monitor) for silence (lack of activity) in a
window. From Thomas Adam.


Revision tags: OPENBSD_4_8_BASE
# 1.63 21-Jun-2010 nicm

Having a list of winlinks->alerts for each session is stupid, just store
the alert flags directly in the winlink itself.


# 1.62 14-May-2010 nicm

Colour+attribute options for status line alerts, from Alex Alexander.


# 1.61 31-Mar-2010 nicm

Don't accept keys with modifiers as input. Fixes crash reported by Brian
R Landy.


# 1.60 27-Mar-2010 nicm

Don't leak job command in #().


# 1.59 22-Mar-2010 nicm

Dead functions, lint.


Revision tags: OPENBSD_4_7_BASE
# 1.58 27-Jan-2010 nicm

Calculate offset correctly, fixes incorrect offset and prevents crash when
status-left is empty. From Micah Cowan.


# 1.57 26-Jan-2010 nicm

Actually use the copy made when no newline is found, from martynas@.


# 1.56 14-Dec-2009 nicm

Add server options to completion as well.


# 1.55 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.54 03-Dec-2009 nicm

Eliminate duplicate code and ease the passage for server-wide options by adding
a -w flag to set-option and show-options and making setw and showw aliases to
set -w and show -w.

Note: setw and showw are still there, but now aliases for set -w and show -w.


# 1.53 26-Nov-2009 nicm

Tidy up various bits of the paste code, make the data buffer char * and add
comments.


# 1.52 26-Nov-2009 nicm

Remove a couple of unused arguments where possible, and add /* ARGSUSED */ to
the rest to reduce lint output.


# 1.51 20-Nov-2009 nicm

Display UTF-8 properly in status line messages and prompt. Cursor handling is
still way off though.


# 1.50 20-Nov-2009 nicm

Remove oldest messages from log when limit is hit, not newest.


# 1.49 19-Nov-2009 nicm

Get some brackets in the right place so ## works. Also fix a space in a
comment.


# 1.48 19-Nov-2009 nicm

Change status line drawing to create the window list in a separate screen and
then copy it into the status line screen. This allows UTF-8 in window names and
fixes some problems with #[] in window-status-format.


# 1.47 19-Nov-2009 nicm

Two new options, window-status-format and window-status-current-format, which
allow the format of each window in the status line window list to be controlled
using similar # sequences as status-left/right.

This diff also moves part of the way towards UTF-8 support in window names but
it isn't quite there yet.


# 1.46 19-Nov-2009 nicm

Tidy up by breaking the # replacement code into a separate function, also add a
few comments.


# 1.45 19-Nov-2009 nicm

Don't interpret #() for display-message, it usually doesn't make sense and may
leak commands.


# 1.44 18-Nov-2009 nicm

Add a per-client log of status line messages displayed while that client
exists. A new message-limit session option sets the maximum number of entries
and a command, show-messages, shows the log (bound to ~ by default).

This (and prompt history) might be better as a single global log but until
there are global options it is easier for them to be per client.


# 1.43 17-Nov-2009 nicm

Permit top-bit-set characters to be entered in the status line. They could
already be set from the shell and are just passed through when printing (so
invisible characters or displaying on terminals with different character sets
may cause problems).

Note that entering UTF-8 may not work and in any case currently the status line
cannot display it correctly (outside of status-left/status-right).


# 1.42 04-Nov-2009 nicm

Use timeout events for the identify and message timers.


# 1.41 04-Nov-2009 nicm

Switch jobs over to use a bufferevent.


# 1.40 04-Nov-2009 nicm

Unused (but assigned to) variable, found by lint.


# 1.39 01-Nov-2009 nicm

Add a flag for jobs that shouldn't be freed after they've died and use it for
status jobs, then only kill those jobs when status-left, status-right or
set-titles-string is changed.

Fixes problems with changing options from inside #().


# 1.38 10-Oct-2009 nicm

Rather than running status-left, status-right and window title #() with popen
immediately every redraw, queue them up and run them in the background,
starting each once every status-interval. The actual status line uses the
output from the last run.

This brings several advantages:

- tmux itself may be called from inside #() without causing the server to hang;
- likewise, sleep or similar doesn't cause the server to block;
- commands aren't run excessively often when redrawing;
- commands shared by status-left and status-right, or used multiple times, will
only be run once.

run-shell and if-shell still use system()/popen() but will be changed over to
use this too later.


# 1.37 10-Oct-2009 nicm

Add "grouped sessions" which have independent name, options, current window and
so on but where the linked windows are synchronized (ie creating, killing
windows and so on are mirrored between the sessions). A grouped session may be
created by passing -t to new-session.

Had this around for a while, tested by a couple of people.


# 1.36 23-Sep-2009 nicm

Remove PROMPT_HIDDEN code which is now unused.


# 1.35 23-Sep-2009 nicm

Remove the internal tmux locking and instead detach each client and run the
command specified by a new option "lock-command" (by default "lock -np") in
each client.

This means each terminal has to be unlocked individually but simplifies the
code and allows the system password to be used to unlock.

Note that the set-password command is gone, so it will need to be removed from
configuration files, and the -U command line flag has been removed.

This is the third protocol version change so again it is best to stop the tmux
server before upgrading.


# 1.34 20-Sep-2009 nicm

Regularise some fatal messages.


# 1.33 10-Sep-2009 nicm

Permit options such as status-bg to be configured using the entire 256 colour
palette by setting "colour0" to "colour255".


# 1.32 07-Sep-2009 nicm

Give each paste buffer a size member instead of requiring them to be
zero-terminated.


# 1.31 07-Sep-2009 nicm

Permit embedded colour and attributes in status-left and status-right using new
#[] special characters, for example #[fg=red,bg=blue,blink].


# 1.30 02-Sep-2009 nicm

Add a transpose-chars command in edit mode (C-t in emacs mode only). From Kalle
Olavi Niemitalo.


# 1.29 01-Sep-2009 nicm

Use "Password:" with no space for password prompts and don't display a *s for
the password, like pretty much everything else. From martynas@ with minor
tweaks by me.


# 1.28 31-Aug-2009 nicm

Add a new display-panes command, with two options (display-panes-colour and
display-panes-time), which displays a visual indication of the number of each
pane.


# 1.27 19-Aug-2009 nicm

Extend command-prompt with a -p option which is a comma-separated list of one
or more prompts to present in order.

The responses to the prompt are replaced in the template string: %% are
replaced in order, so the first prompt replaces the first %%, the second
replaces the second, and so on. In addition, %1 up to %9 are replaced with the
responses to the first the ninth prompts

The default template is "%1" so the response to the first prompt is processed
as a command.

Note that this changes the behaviour for %% so if there is only one prompt,
only the first %% will be replaced. Templates such as "neww -n '%%' 'ssh %%'"
should be changed to "neww -n '%1' 'ssh %1'".

From Tiago Cunha.


# 1.26 18-Aug-2009 nicm

Add a "delete line" key when editing in the status line or the search up/down
prompt. C-u with emacs keys, d with vi.


# 1.25 13-Aug-2009 nicm

Switch the prompt code to return an empty string when the user enters no
response and reserve NULL for an explicit cancel. Change all callbacks to treat
them the same so no functional change.

Also add cancel key bindings to emacs mode which were missing.


# 1.24 08-Aug-2009 nicm

Options to set the colours and attributes for status-left/-right. From Thomas
Adam, thanks.


# 1.23 05-Aug-2009 nicm

If colours are not supported by the terminal, try to emulate a coloured
background by setting or clearing the reverse attribute.

This makes a few applications which don't use the reverse attribute themselves
a little happier, and allows the status, message and mode options to have
default attributes and fg/bg options that work as expected when set as reverse.


# 1.22 30-Jul-2009 nicm

Plug some memory leaks.


# 1.21 28-Jul-2009 nicm

Next step towards customisable mode keys: build each default table of keys into
a named tree on start and use that for lookups. Also add command to string
translation tables and modify list-keys to show the the mode key bindings (new
-t argument).


# 1.20 27-Jul-2009 nicm

Change mode key bindings from big switches into a set of tables. Rather than
lumping them all together, split editing keys from those used in choice/more
mode and those for copy/scroll mode.

Tidier and clearer, and the first step towards customisable mode keys.


# 1.19 27-Jul-2009 nicm

Get rid of empty mode_key_free function.


# 1.18 27-Jul-2009 nicm

Add a key to delete to end of line at the prompt (^K in emacs mode, C/D in vi).

From Kalle Olavi Niemitalo.


# 1.17 26-Jul-2009 nicm

Calculate the space available for the prompt buffer and the cursor position
correctly, and make it work when the screen is not wide enough.

Noticed by Kalle Olavi Niemitalo.


# 1.16 21-Jul-2009 nicm

Remove a couple of unused functions and fix a type ("FALLTHOUGH"), found by
lint.


# 1.15 20-Jul-2009 nicm

Add a status-justify option to allow the window list in the status line to be
positioned at the left, centre, or right.


# 1.14 20-Jul-2009 nicm

New options, window-status-current-{fg,bg,attr}, to set the fg, bg and
attributes with which the current window is shown in the status line. From
Johan Friis, thanks.


# 1.13 17-Jul-2009 nicm

- New command display-message (alias display) to display a message in the
status line (bound to "i" and displays the current window and time by
default). The same substitutions are applied as for status-left/right.
- Add support for including the window index (#I), pane index (#P) and window
name (#W) in the message, and status-left or status-right.
- Bump protocol version.

From Tiago Cunha, thanks!


# 1.12 17-Jul-2009 nicm

Memory could be leaked if a second prompt or message appeared while another was
still present, so add a separate prompt free callback and make the _clear
function responsible for calling it if necessary (rather than the individual
prompt callbacks). Also make both messages and prompts clear any existing when
a new is set.

In addition, the screen could be modified while the prompt is there, restore
the redraw-entire-screen behaviour on prompt clear; add a comment as a
reminder.


# 1.11 16-Jul-2009 nicm

Remove some duplicate code that was causing the status line to be redrawn even
when it hadn't changed.


# 1.10 15-Jul-2009 nicm

Make status_message_set a variadic printf-like function. No functional change -
helpful for a couple of things coming soon.


# 1.9 15-Jul-2009 nicm

Having to update NSETOPTION/NSETWINDOWOPTION when adding new options is a bit
annoying and it is only use for iterating, so use a sentinel to mark the end of
each array instead. Different fix for a problem pointed out by Kalle Olavi
Niemitalo.


# 1.8 14-Jul-2009 nicm

For some reason when clearing status/message it was redrawing the entire client
not just the status line. Changing this also revealed the check for the status
line was incorrect when drawing the pane.


# 1.7 14-Jul-2009 nicm

Instead of faking up a status line in status_redraw, use the same code to
redraw it as to draw the entire screen, just skip all lines but the last.

This makes horizontal split redraw properly when the status line is off.


# 1.6 12-Jul-2009 nicm

Add a "back to indentation" key in copy mode to move the cursor to the first
non-whitespace character. ^ with vi and M-m with emacs key bindings. Another
from Kalle Olavi Niemitalo, thanks.


Revision tags: OPENBSD_4_6_BASE
# 1.5 26-Jun-2009 nicm

Status line fixes: don't truncate status-right now the length calculation is
done for UTF-8, limit to the maximum length correctly when printing, and always
print a space even if the left string is longer than the width available.


# 1.4 04-Jun-2009 nicm

If the prompt is hidden or a password is sent with -U, zero it before freeing
it.


# 1.3 03-Jun-2009 nicm

New session option, status-utf8, to control the interpretation of top-bit-set
characters in status-left and status-right (if on, they are treated as UTF-8;
otherwise passed through).


# 1.2 03-Jun-2009 nicm

Add a UTF-8 aware string length function and make UTF-8 in
status-left/status-right work properly. At the moment any top-bit-set
characters are assumed to be UTF-8: a status-utf8 option to configure this will
come shortly.


# 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.197 03-May-2019 nicm

Fix reverse attribute in status line, GitHub issue 1709.


# 1.196 26-Apr-2019 nicm

Merge hooks into options and make each one an array option. This allows
multiple commands to be easily bound to one hook. set-hook and
show-hooks remain but they are now variants of set-option and
show-options. show-options now has a -H flag to show hooks (by default
they are not shown).


# 1.195 25-Apr-2019 nicm

options_array_item_value cannot return NULL.


# 1.194 23-Apr-2019 nicm

Somehow missed these bits in last commit.


# 1.193 23-Apr-2019 nicm

Indicate an array option with a flag rather than a special type so that
in future will not have to be strings.


Revision tags: OPENBSD_6_5_BASE
# 1.192 18-Mar-2019 nicm

Extend the #[] style syntax and use that together with previous format
changes to allow the status line to be entirely configured with a single
option.

Now that it is possible to configure their content, enable the existing
code that lets the status line be multiple lines in height. The status
option can now take a value of 2, 3, 4 or 5 (as well as the previous on
or off) to configure more than one line. The new status-format array
option configures the format of each line, the default just references
the existing status-* options, although some of the more obscure status
options may be eliminated in time.

Additions to the #[] syntax are: "align" to specify alignment (left,
centre, right), "list" for the window list and "range" to configure
ranges of text for the mouse bindings.

The "align" keyword can also be used to specify alignment of entries in
tree mode and the pane status lines.


# 1.191 18-Mar-2019 nicm

Make array options a sparse tree instead of an array of char * and
remove the size limit.


# 1.190 18-Mar-2019 nicm

With force, kill previous job before starting new. Fixes problem
reported by Scott Mcdermott in GitHub issue 1627.


# 1.189 16-Mar-2019 nicm

Use a pointer for the active screen in the status line instead of
copying them around all the time.


# 1.188 16-Mar-2019 nicm

Give status_save_old the client so it can do the reinit too.


# 1.187 16-Mar-2019 nicm

Tidy and rename some bits of status line code.


# 1.186 15-Mar-2019 nicm

Move status line free into its own function.


# 1.185 14-Mar-2019 nicm

Store the time in the format tree rather than passing it around.


# 1.184 12-Mar-2019 nicm

DECRC and DECSC apparently need to preserve origin mode as well, based
on a fix from Marc Reisner.


# 1.183 09-Feb-2019 nicm

Completion of command-alias members.


# 1.182 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.181 29-Aug-2018 nicm

Keep any text killed in the command prompt with C-w and yank it with
C-y, only use the top buffer if no text has previously been killed. This
and previous change promped by discussion with kn@.


# 1.180 29-Aug-2018 nicm

Add C-Left and C-Right as aliases for M-b and M-f.


# 1.179 22-Aug-2018 nicm

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


# 1.178 20-Aug-2018 nicm

Move offset of window list into status struct.


# 1.177 19-Aug-2018 nicm

Add a client redraw-window flag instead of the redraw-all flag and for
all just use the three flags together (window, borders, status).


Revision tags: OPENBSD_6_3_BASE
# 1.176 22-Feb-2018 nicm

Remove an unused variable.


# 1.175 05-Feb-2018 nicm

Add struct status_line to hold status line members of struct client, not
used yet but will be soon. From Thomas Adam.


# 1.174 01-Jan-2018 nicm

Add C-g at command prompt for emacs people, GitHub issue 1213.


# 1.173 27-Dec-2017 nicm

Draw command prompt correctly with status line off.


# 1.172 18-Dec-2017 nicm

Remove unused variable from Thomas Adam.


# 1.171 02-Nov-2017 nicm

Add a "fast" version of screen_write_copy for tree mode that doesn't do
all the checks and selection and marking stuff needed for copy mode.


# 1.170 20-Oct-2017 nicm

Clear status line with spaces again so reverse works, spotted by sthen.


# 1.169 16-Oct-2017 nicm

Infrastructure for drawing status lines of more than one line in height,
still only one is allowed but this lets tmux draw bigger ones.


Revision tags: OPENBSD_6_2_BASE
# 1.168 29-May-2017 nicm

Add a flag to stop the prompt input being expanded.


# 1.167 29-May-2017 nicm

Store a copy of the old status line, will be needed soon for new choose mode.


# 1.166 17-May-2017 nicm

Tidy command prompt callbacks and pass in the client.


# 1.165 03-May-2017 nicm

Add a format for the last search string in copy mode and fix the prompt
so it can work when in -I, suggested by Suraj N Kurapati.


# 1.164 01-May-2017 nicm

In order that people can use formats like #D in #() in the status line
and not have to wait for an update when they change pane, we allow
commands to run more than once a second if the expanded form
changes. Unfortunately this can mean them being run far too often
(pretty much continually) when multiple clients exist, because some
formats (including #D) will always differ between clients.

To avoid this, give each client its own tree of jobs which means that
the same command will be different instances for each client - similar
to how we have the tag to separate commands for different panes.

GitHub issue 889; test case reported by Paul Johnson.


# 1.163 22-Apr-2017 nicm

Memory leak from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.162 09-Feb-2017 nicm

Break the message storage function into its own function, useful for
debugging.


# 1.161 03-Feb-2017 nicm

Cache status line position to reduce option lookups during output.


# 1.160 03-Feb-2017 nicm

Add a window or pane id "tag" to each format tree and use it to separate
jobs, this means that if the same job is used for different windows or
panes (for example in pane-border-format), it will be run separately for
each pane.


# 1.159 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.158 06-Jan-2017 nicm

Incremental search in copy mode (on for emacs keys by default) - much
the same as normal searching but updates the cursor position and marked
search terms as you type. C-r and C-s in the prompt repeat the search,
once finished searching (with Enter), N and n work as before.


# 1.157 05-Jan-2017 nicm

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


# 1.156 07-Dec-2016 nicm

Do not clear the prompt when a message is shown, just leave it around and
return to it when the message is finished.


# 1.155 12-Oct-2016 nicm

Drop the edit mode key tables and just use fixed key bindings for the
command prompt.


# 1.154 12-Oct-2016 nicm

The repeat prompt in both emacs and vi (and the old one in tmux) doesn't
support line editing and instead executes a command as soon as a
non-number key is pressed. Add a -N flag to command-prompt for the same
in copy mode. Reported by Theo Buehler.


# 1.153 11-Oct-2016 nicm

Fundamental change to how copy mode key bindings work:

The vi-copy and emacs-copy mode key tables are gone, and instead copy
mode commands are bound in one of two normal key tables ("copy-mode" or
"copy-mode-vi"). Keys are bound to "send-keys -X copy-mode-command". So:

bind -temacs-copy C-Up scroll-up
bind -temacs-copy -R5 WheelUpPane scroll-up

Becomes:

bind -Tcopy-mode C-Up send -X scroll-up
bind -Tcopy-mode WheelUpPane send -N5 -X scroll-up

This allows the full command parser and command set to be used - for
example, we can use the normal command prompt for searching, jumping,
and so on instead of a custom one:

bind -Tcopy-mode C-r command-prompt -p'search up' "send -X search-backward '%%'"

command-prompt also gets a -1 option to only require on key press, which
is needed for jumping.

The plan is to get rid of mode keys entirely, so more to come eventually.


# 1.152 11-Oct-2016 nicm

Support UTF-8 entry into the command prompt.


# 1.151 10-Oct-2016 nicm

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


# 1.150 12-Sep-2016 nicm

Allow repeat count to be specified in mode key tables with bind-key -R,
and set the default repeat count to 5 for WheelUp and WheelDown in
copy-mode.


Revision tags: OPENBSD_6_0_BASE
# 1.149 06-Jun-2016 nicm

Allow #[] in window-status-separator.


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

I no longer use my SourceForge address so replace it.


# 1.147 01-Jan-2016 nicm

Don't rely on a calculation wrapping when applying message-limit, and
break out of the loop early. From Nicolas Viennot.


# 1.146 11-Dec-2015 nicm

Style nits and line wrapping of function declarations.


# 1.145 11-Dec-2015 nicm

Add cmdq as an argument to format_create and add a format for the
command name (will also be used for more later).


# 1.144 08-Dec-2015 nicm

Remove format_create_flags and just pass flags to format_create.


# 1.143 22-Nov-2015 tim

If display-time is set to 0, show status messages until a key is pressed;
OK nicm@


# 1.142 20-Nov-2015 nicm

Instead of separate tables for different types of options, give each
option a scope type (server, session, window) in one table.


# 1.141 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.140 13-Nov-2015 nicm

Long overdue change to the way we store cells in the grid: now, instead
of storing a full grid_cell with UTF-8 data and everything, store a new
type grid_cell_entry. This can either be the cell itself (for ASCII
cells), or an offset into an extended array (per line) for UTF-8
data.

This avoid a large (8 byte) overhead on non-UTF-8 cells (by far the
majority for most users) without the complexity of the shadow array we
had before. Grid memory without any UTF-8 is about half.

The disadvantage that cells can no longer be modified in place and need
to be copied out of the grid and back but it turned out to be lot less
complicated than I expected.


# 1.139 12-Nov-2015 nicm

Nuke the utf8 and status-utf8 options and make tmux only a UTF-8
terminal. We still support non-UTF-8 terminals outside tmux, but inside
it is always UTF-8 (as when the utf8 and status-utf8 options were on).


# 1.138 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.137 27-Oct-2015 nicm

Move struct options into options.c.


# 1.136 20-Oct-2015 nicm

Use client pointer not file descriptor in logging.


# 1.135 14-Sep-2015 nicm

Make refresh-client force update of jobs, from Sina Siadat.


# 1.134 29-Aug-2015 nicm

Move struct paste_buffer out of tmux.h.


# 1.133 28-Aug-2015 nicm

Run status update on a per-client timer at status-interval.


Revision tags: OPENBSD_5_8_BASE
# 1.132 29-Jul-2015 nicm

status_out and associated data structures are no longer used.


# 1.131 28-Jul-2015 nicm

Tidy up the way terminals are described and move some structs out of tmux.h.


# 1.130 20-Jul-2015 nicm

Add an option (history-file) for a file to save/restore command prompt
history, from Olof-Joachim Frahm.


# 1.129 27-May-2015 nicm

Move the jobs output cache into the formats code so that #() work more
generally (for example, again working in set-titles-string).


# 1.128 06-May-2015 nicm

Remove ARRAY_* from history and expand completion to complete a) layout
names and b) targets beginning with -t or -s.


# 1.127 25-Apr-2015 nicm

Make message log a TAILQ.


# 1.126 24-Apr-2015 nicm

Set working directory for run-shell and if-shell.


# 1.125 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_7_BASE
# 1.124 06-Feb-2015 nicm

Use the same time for both calls to format_expand_time.


# 1.123 06-Feb-2015 nicm

status_replace can now become local to status.c and it no longer needs
the jobsflag argument. While here there is no need to repeat work that
format_defaults already does.


# 1.122 06-Feb-2015 nicm

Add format_expand_time and use it instead of status_replace where
command execution is not needed.


# 1.121 05-Feb-2015 nicm

Wrap all the individual format_* calls in a single format_defaults
functions.


# 1.120 01-Feb-2015 nicm

Remove two unused arguments from status_replace.


# 1.119 20-Jan-2015 sthen

typo in comment ;) ok nicm


# 1.118 05-Nov-2014 nicm

Do not put a space between status-left/status-right and the window list,
instead move the space into the defaults for the options (so status-left
now defaults to "[#S] ". From Balazs Kezes.


# 1.117 20-Oct-2014 nicm

Better format for printf format attributes.


# 1.116 08-Oct-2014 nicm

Add xreallocarray and remove nmemb argument from xrealloc.


# 1.115 02-Oct-2014 nicm

Take account of window-status-separator when checking window position,
based on diff from Balazs Kezes.


Revision tags: OPENBSD_5_6_BASE
# 1.114 24-Apr-2014 nicm

There is no longer a need for a paste_stack struct or for global_buffers
to be global. Move to paste.c.


# 1.113 17-Apr-2014 nicm

Remove the monitor-content option and associated bits and bobs. It's
never worked very well. If there is a big demand for it to return, will
consider better ways to do it.


# 1.112 02-Apr-2014 nicm

Do not replace ## with # in status_replace1 because it'll be done later
by the format code.


# 1.111 31-Mar-2014 nicm

Make message-limit a server option.


Revision tags: OPENBSD_5_5_BASE
# 1.110 14-Feb-2014 nicm

Style nit - no space between function name and bracket.


# 1.109 14-Feb-2014 nicm

Check for NULL session and whatnot in status_replace, from Thomas Adam.


# 1.108 28-Jan-2014 nicm

Allow replacing each of the many sets of separate foo-{fg,bg,attr}
options with a single foo-style option. For example:

set -g status-fg yellow
set -g status-bg red
set -g status-attr blink

Becomes:

set -g status-style fg=yellow,bg=red,blink

The -a flag to set can be used to add to rather than replace a style. So:

set -g status-bg red

Becomes:

set -ag status-style bg=red

Currently this is fully backwards compatible (all *-{fg,bg,attr} options
remain) but the plan is to deprecate them over time.

From Tiago Cunha.


Revision tags: OPENBSD_5_4_BASE
# 1.107 05-Jul-2013 nicm

Whitespace nits, from Ben Boeckel.


# 1.106 05-Jul-2013 nicm

Act like vi(1) when moving words, from Ben Boeckel.


# 1.105 05-Jul-2013 nicm

Implement s, S, C mode switch commands in vi(1) mode, from Ben Boeckel.


# 1.104 31-May-2013 nicm

Demote the old single-character replacement variables (#S and friends)
to aliases of formats. From Tiago Cunha.


# 1.103 25-Mar-2013 nicm

Extend jobs to support writing and use that for copy-pipe instead of
popen, from Chris Johnsen.


# 1.102 22-Mar-2013 nicm

evbuffer_readline returns allocated storage, don't leak it.


# 1.101 22-Mar-2013 nicm

Add copy-pipe mode command to copy selection and also pipe to a command.


# 1.100 22-Mar-2013 nicm

No more lint means no more ARGSUSED.


# 1.99 21-Mar-2013 nicm

Aargh. Spaces -> tabs.


# 1.98 21-Mar-2013 nicm

Do not leak formats in status_replace.


# 1.97 21-Mar-2013 nicm

Add a format client_prefix which is 1 if prefix key has been
pressed, used for example #{?client_prefix,X,Y}. Also a few extra
server_client_status needed.


# 1.96 21-Mar-2013 nicm

Allow formats in status options.


Revision tags: OPENBSD_5_3_BASE
# 1.95 27-Nov-2012 nicm

Add window-status-last-* options, from Boris Faure.


Revision tags: OPENBSD_5_2_BASE
# 1.94 10-Jul-2012 nicm

xfree is not particularly helpful, remove it. From Thomas Adam.


# 1.93 09-Jul-2012 nicm

Move a NULL check inside a function, from Tiago Cunha.


# 1.92 29-Apr-2012 nicm

Use int not u_char for colours from options since they may have bit 8
set to mark them as 256-colour. Reported by Chris Johnson.


# 1.91 23-Apr-2012 nicm

Add window-status-separator option, from Thomas Adam.


# 1.90 17-Mar-2012 nicm

Check event_initialized before event_del if event may not have been set
up; libevent2 complains about this. Reported by Moriyoshi Koizumi.


# 1.89 04-Mar-2012 nicm

Add A and I keys for vi status line editing.


# 1.88 03-Mar-2012 nicm

The wlmouse offset should be part of the client, not the server. From
Ailin Nemui.


Revision tags: OPENBSD_5_1_BASE
# 1.87 29-Jan-2012 nicm

Add an option to move the status line to the top of the screen,
requested by many.


# 1.86 26-Jan-2012 nicm

Terminate strftime buffer properly even if a really long format string
is given, from Tiago Cunha.


# 1.85 26-Jan-2012 nicm

Fix memory leak in error path, from Tiago Cunha.


# 1.84 20-Jan-2012 nicm

Add some trivial additional status line attributes from jwcxz at users
dot sourceforge dot net.


# 1.83 20-Jan-2012 nicm

Add space movement keys for vi mode in the status line from Ben Boeckel.


# 1.82 01-Dec-2011 nicm

Make M-f and M-b work the same at the command prompt as in copy mode,
pointed out by Romain Francoise.


# 1.81 15-Nov-2011 nicm

Add word movement and editing command for command prompt editing, from
Ben Boeckel.


# 1.80 15-Nov-2011 nicm

Make window_pane_index work the same as window_index, from Ben Boeckel.


# 1.79 05-Nov-2011 nicm

Option to change status line (message) background when using vi keys and
in command mode. From Ben Boeckel.


# 1.78 20-Aug-2011 nicm

Fix a couple of memory leaks, from marcel partap.


Revision tags: OPENBSD_5_0_BASE
# 1.77 08-Jul-2011 nicm

Make confirm-before prompt customizable with -p option like
command-prompt. Also move responsibility for calling status_replace into
status_prompt_{set,update} and add #W and #P to the default kill-window
and kill-pane prompts. By Tiago Cunha.


# 1.76 02-Jul-2011 nicm

Allow the initial context on prompts to be set with the new -I option to
command-prompt. From Tiago Cunha.


# 1.75 29-Apr-2011 nicm

Only redraw the status line on command update, not the entire client
(big DOH).


# 1.74 24-Apr-2011 nicm

Provide #h for short hostname (no domain) from Michal Mazurek.


# 1.73 18-Apr-2011 nicm

Add an option (mouse-select-window) which allows the mouse to be used by
clicking on the status line, written by hsim at gmx dot li.


# 1.72 29-Mar-2011 nicm

Change -t on display-message to be target-pane for the #[A-Z]
replacements and add -c as target-client.


Revision tags: OPENBSD_4_9_BASE
# 1.71 26-Jan-2011 nicm

Simplify the way jobs work and drop the persist type, so all jobs are
fire-and-forget.

Status jobs now managed with two trees of output (new and old), rather
than storing the output in the jobs themselves. When the status line is
processed any jobs which don't appear in the new tree are started and
the output from the old tree displayed. When a job finishes it updates
the new tree with its output and that is used for any subsequent
redraws. When the status interval expires, the new tree is moved to the
old so that all jobs are run again.

This fixes the "#(echo %H:%M:%S)" problem which would lead to thousands
of identical persistent jobs and high memory use (this can still be
achieved by adding "sleep 30" but that is much less likely to happen by
accident).


# 1.70 03-Jan-2011 nicm

Handle a # at the end of a replacement string (such as status-left)
correctly. Found by Thomas Adam.


# 1.69 01-Jan-2011 nicm

Move the user-visible parts of all options (names, types, limit, default
values) together into one set of tables in options-table.c. Also clean
up and simplify cmd-set-options.c and move a common print function into
option-table.c.


# 1.68 30-Dec-2010 nicm

Change from a per-session stack of buffers to one global stack which is
much more convenient and also simplifies lot of code. This renders
copy-buffer useless and makes buffer-limit now a server option.

By Tiago Cunha.


# 1.67 30-Dec-2010 nicm

Add a function to create window flags rather than doing the same thing
in two places. From Thomas Adam.


# 1.66 11-Dec-2010 nicm

Oops, these functions return a const char *, so make the local variable
const as well.


# 1.65 11-Dec-2010 nicm

Make the prompt history global for all clients which is much more useful than per-client history.


# 1.64 06-Dec-2010 nicm

Add an option to alert (monitor) for silence (lack of activity) in a
window. From Thomas Adam.


Revision tags: OPENBSD_4_8_BASE
# 1.63 21-Jun-2010 nicm

Having a list of winlinks->alerts for each session is stupid, just store
the alert flags directly in the winlink itself.


# 1.62 14-May-2010 nicm

Colour+attribute options for status line alerts, from Alex Alexander.


# 1.61 31-Mar-2010 nicm

Don't accept keys with modifiers as input. Fixes crash reported by Brian
R Landy.


# 1.60 27-Mar-2010 nicm

Don't leak job command in #().


# 1.59 22-Mar-2010 nicm

Dead functions, lint.


Revision tags: OPENBSD_4_7_BASE
# 1.58 27-Jan-2010 nicm

Calculate offset correctly, fixes incorrect offset and prevents crash when
status-left is empty. From Micah Cowan.


# 1.57 26-Jan-2010 nicm

Actually use the copy made when no newline is found, from martynas@.


# 1.56 14-Dec-2009 nicm

Add server options to completion as well.


# 1.55 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.54 03-Dec-2009 nicm

Eliminate duplicate code and ease the passage for server-wide options by adding
a -w flag to set-option and show-options and making setw and showw aliases to
set -w and show -w.

Note: setw and showw are still there, but now aliases for set -w and show -w.


# 1.53 26-Nov-2009 nicm

Tidy up various bits of the paste code, make the data buffer char * and add
comments.


# 1.52 26-Nov-2009 nicm

Remove a couple of unused arguments where possible, and add /* ARGSUSED */ to
the rest to reduce lint output.


# 1.51 20-Nov-2009 nicm

Display UTF-8 properly in status line messages and prompt. Cursor handling is
still way off though.


# 1.50 20-Nov-2009 nicm

Remove oldest messages from log when limit is hit, not newest.


# 1.49 19-Nov-2009 nicm

Get some brackets in the right place so ## works. Also fix a space in a
comment.


# 1.48 19-Nov-2009 nicm

Change status line drawing to create the window list in a separate screen and
then copy it into the status line screen. This allows UTF-8 in window names and
fixes some problems with #[] in window-status-format.


# 1.47 19-Nov-2009 nicm

Two new options, window-status-format and window-status-current-format, which
allow the format of each window in the status line window list to be controlled
using similar # sequences as status-left/right.

This diff also moves part of the way towards UTF-8 support in window names but
it isn't quite there yet.


# 1.46 19-Nov-2009 nicm

Tidy up by breaking the # replacement code into a separate function, also add a
few comments.


# 1.45 19-Nov-2009 nicm

Don't interpret #() for display-message, it usually doesn't make sense and may
leak commands.


# 1.44 18-Nov-2009 nicm

Add a per-client log of status line messages displayed while that client
exists. A new message-limit session option sets the maximum number of entries
and a command, show-messages, shows the log (bound to ~ by default).

This (and prompt history) might be better as a single global log but until
there are global options it is easier for them to be per client.


# 1.43 17-Nov-2009 nicm

Permit top-bit-set characters to be entered in the status line. They could
already be set from the shell and are just passed through when printing (so
invisible characters or displaying on terminals with different character sets
may cause problems).

Note that entering UTF-8 may not work and in any case currently the status line
cannot display it correctly (outside of status-left/status-right).


# 1.42 04-Nov-2009 nicm

Use timeout events for the identify and message timers.


# 1.41 04-Nov-2009 nicm

Switch jobs over to use a bufferevent.


# 1.40 04-Nov-2009 nicm

Unused (but assigned to) variable, found by lint.


# 1.39 01-Nov-2009 nicm

Add a flag for jobs that shouldn't be freed after they've died and use it for
status jobs, then only kill those jobs when status-left, status-right or
set-titles-string is changed.

Fixes problems with changing options from inside #().


# 1.38 10-Oct-2009 nicm

Rather than running status-left, status-right and window title #() with popen
immediately every redraw, queue them up and run them in the background,
starting each once every status-interval. The actual status line uses the
output from the last run.

This brings several advantages:

- tmux itself may be called from inside #() without causing the server to hang;
- likewise, sleep or similar doesn't cause the server to block;
- commands aren't run excessively often when redrawing;
- commands shared by status-left and status-right, or used multiple times, will
only be run once.

run-shell and if-shell still use system()/popen() but will be changed over to
use this too later.


# 1.37 10-Oct-2009 nicm

Add "grouped sessions" which have independent name, options, current window and
so on but where the linked windows are synchronized (ie creating, killing
windows and so on are mirrored between the sessions). A grouped session may be
created by passing -t to new-session.

Had this around for a while, tested by a couple of people.


# 1.36 23-Sep-2009 nicm

Remove PROMPT_HIDDEN code which is now unused.


# 1.35 23-Sep-2009 nicm

Remove the internal tmux locking and instead detach each client and run the
command specified by a new option "lock-command" (by default "lock -np") in
each client.

This means each terminal has to be unlocked individually but simplifies the
code and allows the system password to be used to unlock.

Note that the set-password command is gone, so it will need to be removed from
configuration files, and the -U command line flag has been removed.

This is the third protocol version change so again it is best to stop the tmux
server before upgrading.


# 1.34 20-Sep-2009 nicm

Regularise some fatal messages.


# 1.33 10-Sep-2009 nicm

Permit options such as status-bg to be configured using the entire 256 colour
palette by setting "colour0" to "colour255".


# 1.32 07-Sep-2009 nicm

Give each paste buffer a size member instead of requiring them to be
zero-terminated.


# 1.31 07-Sep-2009 nicm

Permit embedded colour and attributes in status-left and status-right using new
#[] special characters, for example #[fg=red,bg=blue,blink].


# 1.30 02-Sep-2009 nicm

Add a transpose-chars command in edit mode (C-t in emacs mode only). From Kalle
Olavi Niemitalo.


# 1.29 01-Sep-2009 nicm

Use "Password:" with no space for password prompts and don't display a *s for
the password, like pretty much everything else. From martynas@ with minor
tweaks by me.


# 1.28 31-Aug-2009 nicm

Add a new display-panes command, with two options (display-panes-colour and
display-panes-time), which displays a visual indication of the number of each
pane.


# 1.27 19-Aug-2009 nicm

Extend command-prompt with a -p option which is a comma-separated list of one
or more prompts to present in order.

The responses to the prompt are replaced in the template string: %% are
replaced in order, so the first prompt replaces the first %%, the second
replaces the second, and so on. In addition, %1 up to %9 are replaced with the
responses to the first the ninth prompts

The default template is "%1" so the response to the first prompt is processed
as a command.

Note that this changes the behaviour for %% so if there is only one prompt,
only the first %% will be replaced. Templates such as "neww -n '%%' 'ssh %%'"
should be changed to "neww -n '%1' 'ssh %1'".

From Tiago Cunha.


# 1.26 18-Aug-2009 nicm

Add a "delete line" key when editing in the status line or the search up/down
prompt. C-u with emacs keys, d with vi.


# 1.25 13-Aug-2009 nicm

Switch the prompt code to return an empty string when the user enters no
response and reserve NULL for an explicit cancel. Change all callbacks to treat
them the same so no functional change.

Also add cancel key bindings to emacs mode which were missing.


# 1.24 08-Aug-2009 nicm

Options to set the colours and attributes for status-left/-right. From Thomas
Adam, thanks.


# 1.23 05-Aug-2009 nicm

If colours are not supported by the terminal, try to emulate a coloured
background by setting or clearing the reverse attribute.

This makes a few applications which don't use the reverse attribute themselves
a little happier, and allows the status, message and mode options to have
default attributes and fg/bg options that work as expected when set as reverse.


# 1.22 30-Jul-2009 nicm

Plug some memory leaks.


# 1.21 28-Jul-2009 nicm

Next step towards customisable mode keys: build each default table of keys into
a named tree on start and use that for lookups. Also add command to string
translation tables and modify list-keys to show the the mode key bindings (new
-t argument).


# 1.20 27-Jul-2009 nicm

Change mode key bindings from big switches into a set of tables. Rather than
lumping them all together, split editing keys from those used in choice/more
mode and those for copy/scroll mode.

Tidier and clearer, and the first step towards customisable mode keys.


# 1.19 27-Jul-2009 nicm

Get rid of empty mode_key_free function.


# 1.18 27-Jul-2009 nicm

Add a key to delete to end of line at the prompt (^K in emacs mode, C/D in vi).

From Kalle Olavi Niemitalo.


# 1.17 26-Jul-2009 nicm

Calculate the space available for the prompt buffer and the cursor position
correctly, and make it work when the screen is not wide enough.

Noticed by Kalle Olavi Niemitalo.


# 1.16 21-Jul-2009 nicm

Remove a couple of unused functions and fix a type ("FALLTHOUGH"), found by
lint.


# 1.15 20-Jul-2009 nicm

Add a status-justify option to allow the window list in the status line to be
positioned at the left, centre, or right.


# 1.14 20-Jul-2009 nicm

New options, window-status-current-{fg,bg,attr}, to set the fg, bg and
attributes with which the current window is shown in the status line. From
Johan Friis, thanks.


# 1.13 17-Jul-2009 nicm

- New command display-message (alias display) to display a message in the
status line (bound to "i" and displays the current window and time by
default). The same substitutions are applied as for status-left/right.
- Add support for including the window index (#I), pane index (#P) and window
name (#W) in the message, and status-left or status-right.
- Bump protocol version.

From Tiago Cunha, thanks!


# 1.12 17-Jul-2009 nicm

Memory could be leaked if a second prompt or message appeared while another was
still present, so add a separate prompt free callback and make the _clear
function responsible for calling it if necessary (rather than the individual
prompt callbacks). Also make both messages and prompts clear any existing when
a new is set.

In addition, the screen could be modified while the prompt is there, restore
the redraw-entire-screen behaviour on prompt clear; add a comment as a
reminder.


# 1.11 16-Jul-2009 nicm

Remove some duplicate code that was causing the status line to be redrawn even
when it hadn't changed.


# 1.10 15-Jul-2009 nicm

Make status_message_set a variadic printf-like function. No functional change -
helpful for a couple of things coming soon.


# 1.9 15-Jul-2009 nicm

Having to update NSETOPTION/NSETWINDOWOPTION when adding new options is a bit
annoying and it is only use for iterating, so use a sentinel to mark the end of
each array instead. Different fix for a problem pointed out by Kalle Olavi
Niemitalo.


# 1.8 14-Jul-2009 nicm

For some reason when clearing status/message it was redrawing the entire client
not just the status line. Changing this also revealed the check for the status
line was incorrect when drawing the pane.


# 1.7 14-Jul-2009 nicm

Instead of faking up a status line in status_redraw, use the same code to
redraw it as to draw the entire screen, just skip all lines but the last.

This makes horizontal split redraw properly when the status line is off.


# 1.6 12-Jul-2009 nicm

Add a "back to indentation" key in copy mode to move the cursor to the first
non-whitespace character. ^ with vi and M-m with emacs key bindings. Another
from Kalle Olavi Niemitalo, thanks.


Revision tags: OPENBSD_4_6_BASE
# 1.5 26-Jun-2009 nicm

Status line fixes: don't truncate status-right now the length calculation is
done for UTF-8, limit to the maximum length correctly when printing, and always
print a space even if the left string is longer than the width available.


# 1.4 04-Jun-2009 nicm

If the prompt is hidden or a password is sent with -U, zero it before freeing
it.


# 1.3 03-Jun-2009 nicm

New session option, status-utf8, to control the interpretation of top-bit-set
characters in status-left and status-right (if on, they are treated as UTF-8;
otherwise passed through).


# 1.2 03-Jun-2009 nicm

Add a UTF-8 aware string length function and make UTF-8 in
status-left/status-right work properly. At the moment any top-bit-set
characters are assumed to be UTF-8: a status-utf8 option to configure this will
come shortly.


# 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.196 26-Apr-2019 nicm

Merge hooks into options and make each one an array option. This allows
multiple commands to be easily bound to one hook. set-hook and
show-hooks remain but they are now variants of set-option and
show-options. show-options now has a -H flag to show hooks (by default
they are not shown).


# 1.195 25-Apr-2019 nicm

options_array_item_value cannot return NULL.


# 1.194 23-Apr-2019 nicm

Somehow missed these bits in last commit.


# 1.193 23-Apr-2019 nicm

Indicate an array option with a flag rather than a special type so that
in future will not have to be strings.


Revision tags: OPENBSD_6_5_BASE
# 1.192 18-Mar-2019 nicm

Extend the #[] style syntax and use that together with previous format
changes to allow the status line to be entirely configured with a single
option.

Now that it is possible to configure their content, enable the existing
code that lets the status line be multiple lines in height. The status
option can now take a value of 2, 3, 4 or 5 (as well as the previous on
or off) to configure more than one line. The new status-format array
option configures the format of each line, the default just references
the existing status-* options, although some of the more obscure status
options may be eliminated in time.

Additions to the #[] syntax are: "align" to specify alignment (left,
centre, right), "list" for the window list and "range" to configure
ranges of text for the mouse bindings.

The "align" keyword can also be used to specify alignment of entries in
tree mode and the pane status lines.


# 1.191 18-Mar-2019 nicm

Make array options a sparse tree instead of an array of char * and
remove the size limit.


# 1.190 18-Mar-2019 nicm

With force, kill previous job before starting new. Fixes problem
reported by Scott Mcdermott in GitHub issue 1627.


# 1.189 16-Mar-2019 nicm

Use a pointer for the active screen in the status line instead of
copying them around all the time.


# 1.188 16-Mar-2019 nicm

Give status_save_old the client so it can do the reinit too.


# 1.187 16-Mar-2019 nicm

Tidy and rename some bits of status line code.


# 1.186 15-Mar-2019 nicm

Move status line free into its own function.


# 1.185 14-Mar-2019 nicm

Store the time in the format tree rather than passing it around.


# 1.184 12-Mar-2019 nicm

DECRC and DECSC apparently need to preserve origin mode as well, based
on a fix from Marc Reisner.


# 1.183 09-Feb-2019 nicm

Completion of command-alias members.


# 1.182 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.181 29-Aug-2018 nicm

Keep any text killed in the command prompt with C-w and yank it with
C-y, only use the top buffer if no text has previously been killed. This
and previous change promped by discussion with kn@.


# 1.180 29-Aug-2018 nicm

Add C-Left and C-Right as aliases for M-b and M-f.


# 1.179 22-Aug-2018 nicm

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


# 1.178 20-Aug-2018 nicm

Move offset of window list into status struct.


# 1.177 19-Aug-2018 nicm

Add a client redraw-window flag instead of the redraw-all flag and for
all just use the three flags together (window, borders, status).


Revision tags: OPENBSD_6_3_BASE
# 1.176 22-Feb-2018 nicm

Remove an unused variable.


# 1.175 05-Feb-2018 nicm

Add struct status_line to hold status line members of struct client, not
used yet but will be soon. From Thomas Adam.


# 1.174 01-Jan-2018 nicm

Add C-g at command prompt for emacs people, GitHub issue 1213.


# 1.173 27-Dec-2017 nicm

Draw command prompt correctly with status line off.


# 1.172 18-Dec-2017 nicm

Remove unused variable from Thomas Adam.


# 1.171 02-Nov-2017 nicm

Add a "fast" version of screen_write_copy for tree mode that doesn't do
all the checks and selection and marking stuff needed for copy mode.


# 1.170 20-Oct-2017 nicm

Clear status line with spaces again so reverse works, spotted by sthen.


# 1.169 16-Oct-2017 nicm

Infrastructure for drawing status lines of more than one line in height,
still only one is allowed but this lets tmux draw bigger ones.


Revision tags: OPENBSD_6_2_BASE
# 1.168 29-May-2017 nicm

Add a flag to stop the prompt input being expanded.


# 1.167 29-May-2017 nicm

Store a copy of the old status line, will be needed soon for new choose mode.


# 1.166 17-May-2017 nicm

Tidy command prompt callbacks and pass in the client.


# 1.165 03-May-2017 nicm

Add a format for the last search string in copy mode and fix the prompt
so it can work when in -I, suggested by Suraj N Kurapati.


# 1.164 01-May-2017 nicm

In order that people can use formats like #D in #() in the status line
and not have to wait for an update when they change pane, we allow
commands to run more than once a second if the expanded form
changes. Unfortunately this can mean them being run far too often
(pretty much continually) when multiple clients exist, because some
formats (including #D) will always differ between clients.

To avoid this, give each client its own tree of jobs which means that
the same command will be different instances for each client - similar
to how we have the tag to separate commands for different panes.

GitHub issue 889; test case reported by Paul Johnson.


# 1.163 22-Apr-2017 nicm

Memory leak from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.162 09-Feb-2017 nicm

Break the message storage function into its own function, useful for
debugging.


# 1.161 03-Feb-2017 nicm

Cache status line position to reduce option lookups during output.


# 1.160 03-Feb-2017 nicm

Add a window or pane id "tag" to each format tree and use it to separate
jobs, this means that if the same job is used for different windows or
panes (for example in pane-border-format), it will be run separately for
each pane.


# 1.159 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.158 06-Jan-2017 nicm

Incremental search in copy mode (on for emacs keys by default) - much
the same as normal searching but updates the cursor position and marked
search terms as you type. C-r and C-s in the prompt repeat the search,
once finished searching (with Enter), N and n work as before.


# 1.157 05-Jan-2017 nicm

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


# 1.156 07-Dec-2016 nicm

Do not clear the prompt when a message is shown, just leave it around and
return to it when the message is finished.


# 1.155 12-Oct-2016 nicm

Drop the edit mode key tables and just use fixed key bindings for the
command prompt.


# 1.154 12-Oct-2016 nicm

The repeat prompt in both emacs and vi (and the old one in tmux) doesn't
support line editing and instead executes a command as soon as a
non-number key is pressed. Add a -N flag to command-prompt for the same
in copy mode. Reported by Theo Buehler.


# 1.153 11-Oct-2016 nicm

Fundamental change to how copy mode key bindings work:

The vi-copy and emacs-copy mode key tables are gone, and instead copy
mode commands are bound in one of two normal key tables ("copy-mode" or
"copy-mode-vi"). Keys are bound to "send-keys -X copy-mode-command". So:

bind -temacs-copy C-Up scroll-up
bind -temacs-copy -R5 WheelUpPane scroll-up

Becomes:

bind -Tcopy-mode C-Up send -X scroll-up
bind -Tcopy-mode WheelUpPane send -N5 -X scroll-up

This allows the full command parser and command set to be used - for
example, we can use the normal command prompt for searching, jumping,
and so on instead of a custom one:

bind -Tcopy-mode C-r command-prompt -p'search up' "send -X search-backward '%%'"

command-prompt also gets a -1 option to only require on key press, which
is needed for jumping.

The plan is to get rid of mode keys entirely, so more to come eventually.


# 1.152 11-Oct-2016 nicm

Support UTF-8 entry into the command prompt.


# 1.151 10-Oct-2016 nicm

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


# 1.150 12-Sep-2016 nicm

Allow repeat count to be specified in mode key tables with bind-key -R,
and set the default repeat count to 5 for WheelUp and WheelDown in
copy-mode.


Revision tags: OPENBSD_6_0_BASE
# 1.149 06-Jun-2016 nicm

Allow #[] in window-status-separator.


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

I no longer use my SourceForge address so replace it.


# 1.147 01-Jan-2016 nicm

Don't rely on a calculation wrapping when applying message-limit, and
break out of the loop early. From Nicolas Viennot.


# 1.146 11-Dec-2015 nicm

Style nits and line wrapping of function declarations.


# 1.145 11-Dec-2015 nicm

Add cmdq as an argument to format_create and add a format for the
command name (will also be used for more later).


# 1.144 08-Dec-2015 nicm

Remove format_create_flags and just pass flags to format_create.


# 1.143 22-Nov-2015 tim

If display-time is set to 0, show status messages until a key is pressed;
OK nicm@


# 1.142 20-Nov-2015 nicm

Instead of separate tables for different types of options, give each
option a scope type (server, session, window) in one table.


# 1.141 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.140 13-Nov-2015 nicm

Long overdue change to the way we store cells in the grid: now, instead
of storing a full grid_cell with UTF-8 data and everything, store a new
type grid_cell_entry. This can either be the cell itself (for ASCII
cells), or an offset into an extended array (per line) for UTF-8
data.

This avoid a large (8 byte) overhead on non-UTF-8 cells (by far the
majority for most users) without the complexity of the shadow array we
had before. Grid memory without any UTF-8 is about half.

The disadvantage that cells can no longer be modified in place and need
to be copied out of the grid and back but it turned out to be lot less
complicated than I expected.


# 1.139 12-Nov-2015 nicm

Nuke the utf8 and status-utf8 options and make tmux only a UTF-8
terminal. We still support non-UTF-8 terminals outside tmux, but inside
it is always UTF-8 (as when the utf8 and status-utf8 options were on).


# 1.138 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.137 27-Oct-2015 nicm

Move struct options into options.c.


# 1.136 20-Oct-2015 nicm

Use client pointer not file descriptor in logging.


# 1.135 14-Sep-2015 nicm

Make refresh-client force update of jobs, from Sina Siadat.


# 1.134 29-Aug-2015 nicm

Move struct paste_buffer out of tmux.h.


# 1.133 28-Aug-2015 nicm

Run status update on a per-client timer at status-interval.


Revision tags: OPENBSD_5_8_BASE
# 1.132 29-Jul-2015 nicm

status_out and associated data structures are no longer used.


# 1.131 28-Jul-2015 nicm

Tidy up the way terminals are described and move some structs out of tmux.h.


# 1.130 20-Jul-2015 nicm

Add an option (history-file) for a file to save/restore command prompt
history, from Olof-Joachim Frahm.


# 1.129 27-May-2015 nicm

Move the jobs output cache into the formats code so that #() work more
generally (for example, again working in set-titles-string).


# 1.128 06-May-2015 nicm

Remove ARRAY_* from history and expand completion to complete a) layout
names and b) targets beginning with -t or -s.


# 1.127 25-Apr-2015 nicm

Make message log a TAILQ.


# 1.126 24-Apr-2015 nicm

Set working directory for run-shell and if-shell.


# 1.125 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_7_BASE
# 1.124 06-Feb-2015 nicm

Use the same time for both calls to format_expand_time.


# 1.123 06-Feb-2015 nicm

status_replace can now become local to status.c and it no longer needs
the jobsflag argument. While here there is no need to repeat work that
format_defaults already does.


# 1.122 06-Feb-2015 nicm

Add format_expand_time and use it instead of status_replace where
command execution is not needed.


# 1.121 05-Feb-2015 nicm

Wrap all the individual format_* calls in a single format_defaults
functions.


# 1.120 01-Feb-2015 nicm

Remove two unused arguments from status_replace.


# 1.119 20-Jan-2015 sthen

typo in comment ;) ok nicm


# 1.118 05-Nov-2014 nicm

Do not put a space between status-left/status-right and the window list,
instead move the space into the defaults for the options (so status-left
now defaults to "[#S] ". From Balazs Kezes.


# 1.117 20-Oct-2014 nicm

Better format for printf format attributes.


# 1.116 08-Oct-2014 nicm

Add xreallocarray and remove nmemb argument from xrealloc.


# 1.115 02-Oct-2014 nicm

Take account of window-status-separator when checking window position,
based on diff from Balazs Kezes.


Revision tags: OPENBSD_5_6_BASE
# 1.114 24-Apr-2014 nicm

There is no longer a need for a paste_stack struct or for global_buffers
to be global. Move to paste.c.


# 1.113 17-Apr-2014 nicm

Remove the monitor-content option and associated bits and bobs. It's
never worked very well. If there is a big demand for it to return, will
consider better ways to do it.


# 1.112 02-Apr-2014 nicm

Do not replace ## with # in status_replace1 because it'll be done later
by the format code.


# 1.111 31-Mar-2014 nicm

Make message-limit a server option.


Revision tags: OPENBSD_5_5_BASE
# 1.110 14-Feb-2014 nicm

Style nit - no space between function name and bracket.


# 1.109 14-Feb-2014 nicm

Check for NULL session and whatnot in status_replace, from Thomas Adam.


# 1.108 28-Jan-2014 nicm

Allow replacing each of the many sets of separate foo-{fg,bg,attr}
options with a single foo-style option. For example:

set -g status-fg yellow
set -g status-bg red
set -g status-attr blink

Becomes:

set -g status-style fg=yellow,bg=red,blink

The -a flag to set can be used to add to rather than replace a style. So:

set -g status-bg red

Becomes:

set -ag status-style bg=red

Currently this is fully backwards compatible (all *-{fg,bg,attr} options
remain) but the plan is to deprecate them over time.

From Tiago Cunha.


Revision tags: OPENBSD_5_4_BASE
# 1.107 05-Jul-2013 nicm

Whitespace nits, from Ben Boeckel.


# 1.106 05-Jul-2013 nicm

Act like vi(1) when moving words, from Ben Boeckel.


# 1.105 05-Jul-2013 nicm

Implement s, S, C mode switch commands in vi(1) mode, from Ben Boeckel.


# 1.104 31-May-2013 nicm

Demote the old single-character replacement variables (#S and friends)
to aliases of formats. From Tiago Cunha.


# 1.103 25-Mar-2013 nicm

Extend jobs to support writing and use that for copy-pipe instead of
popen, from Chris Johnsen.


# 1.102 22-Mar-2013 nicm

evbuffer_readline returns allocated storage, don't leak it.


# 1.101 22-Mar-2013 nicm

Add copy-pipe mode command to copy selection and also pipe to a command.


# 1.100 22-Mar-2013 nicm

No more lint means no more ARGSUSED.


# 1.99 21-Mar-2013 nicm

Aargh. Spaces -> tabs.


# 1.98 21-Mar-2013 nicm

Do not leak formats in status_replace.


# 1.97 21-Mar-2013 nicm

Add a format client_prefix which is 1 if prefix key has been
pressed, used for example #{?client_prefix,X,Y}. Also a few extra
server_client_status needed.


# 1.96 21-Mar-2013 nicm

Allow formats in status options.


Revision tags: OPENBSD_5_3_BASE
# 1.95 27-Nov-2012 nicm

Add window-status-last-* options, from Boris Faure.


Revision tags: OPENBSD_5_2_BASE
# 1.94 10-Jul-2012 nicm

xfree is not particularly helpful, remove it. From Thomas Adam.


# 1.93 09-Jul-2012 nicm

Move a NULL check inside a function, from Tiago Cunha.


# 1.92 29-Apr-2012 nicm

Use int not u_char for colours from options since they may have bit 8
set to mark them as 256-colour. Reported by Chris Johnson.


# 1.91 23-Apr-2012 nicm

Add window-status-separator option, from Thomas Adam.


# 1.90 17-Mar-2012 nicm

Check event_initialized before event_del if event may not have been set
up; libevent2 complains about this. Reported by Moriyoshi Koizumi.


# 1.89 04-Mar-2012 nicm

Add A and I keys for vi status line editing.


# 1.88 03-Mar-2012 nicm

The wlmouse offset should be part of the client, not the server. From
Ailin Nemui.


Revision tags: OPENBSD_5_1_BASE
# 1.87 29-Jan-2012 nicm

Add an option to move the status line to the top of the screen,
requested by many.


# 1.86 26-Jan-2012 nicm

Terminate strftime buffer properly even if a really long format string
is given, from Tiago Cunha.


# 1.85 26-Jan-2012 nicm

Fix memory leak in error path, from Tiago Cunha.


# 1.84 20-Jan-2012 nicm

Add some trivial additional status line attributes from jwcxz at users
dot sourceforge dot net.


# 1.83 20-Jan-2012 nicm

Add space movement keys for vi mode in the status line from Ben Boeckel.


# 1.82 01-Dec-2011 nicm

Make M-f and M-b work the same at the command prompt as in copy mode,
pointed out by Romain Francoise.


# 1.81 15-Nov-2011 nicm

Add word movement and editing command for command prompt editing, from
Ben Boeckel.


# 1.80 15-Nov-2011 nicm

Make window_pane_index work the same as window_index, from Ben Boeckel.


# 1.79 05-Nov-2011 nicm

Option to change status line (message) background when using vi keys and
in command mode. From Ben Boeckel.


# 1.78 20-Aug-2011 nicm

Fix a couple of memory leaks, from marcel partap.


Revision tags: OPENBSD_5_0_BASE
# 1.77 08-Jul-2011 nicm

Make confirm-before prompt customizable with -p option like
command-prompt. Also move responsibility for calling status_replace into
status_prompt_{set,update} and add #W and #P to the default kill-window
and kill-pane prompts. By Tiago Cunha.


# 1.76 02-Jul-2011 nicm

Allow the initial context on prompts to be set with the new -I option to
command-prompt. From Tiago Cunha.


# 1.75 29-Apr-2011 nicm

Only redraw the status line on command update, not the entire client
(big DOH).


# 1.74 24-Apr-2011 nicm

Provide #h for short hostname (no domain) from Michal Mazurek.


# 1.73 18-Apr-2011 nicm

Add an option (mouse-select-window) which allows the mouse to be used by
clicking on the status line, written by hsim at gmx dot li.


# 1.72 29-Mar-2011 nicm

Change -t on display-message to be target-pane for the #[A-Z]
replacements and add -c as target-client.


Revision tags: OPENBSD_4_9_BASE
# 1.71 26-Jan-2011 nicm

Simplify the way jobs work and drop the persist type, so all jobs are
fire-and-forget.

Status jobs now managed with two trees of output (new and old), rather
than storing the output in the jobs themselves. When the status line is
processed any jobs which don't appear in the new tree are started and
the output from the old tree displayed. When a job finishes it updates
the new tree with its output and that is used for any subsequent
redraws. When the status interval expires, the new tree is moved to the
old so that all jobs are run again.

This fixes the "#(echo %H:%M:%S)" problem which would lead to thousands
of identical persistent jobs and high memory use (this can still be
achieved by adding "sleep 30" but that is much less likely to happen by
accident).


# 1.70 03-Jan-2011 nicm

Handle a # at the end of a replacement string (such as status-left)
correctly. Found by Thomas Adam.


# 1.69 01-Jan-2011 nicm

Move the user-visible parts of all options (names, types, limit, default
values) together into one set of tables in options-table.c. Also clean
up and simplify cmd-set-options.c and move a common print function into
option-table.c.


# 1.68 30-Dec-2010 nicm

Change from a per-session stack of buffers to one global stack which is
much more convenient and also simplifies lot of code. This renders
copy-buffer useless and makes buffer-limit now a server option.

By Tiago Cunha.


# 1.67 30-Dec-2010 nicm

Add a function to create window flags rather than doing the same thing
in two places. From Thomas Adam.


# 1.66 11-Dec-2010 nicm

Oops, these functions return a const char *, so make the local variable
const as well.


# 1.65 11-Dec-2010 nicm

Make the prompt history global for all clients which is much more useful than per-client history.


# 1.64 06-Dec-2010 nicm

Add an option to alert (monitor) for silence (lack of activity) in a
window. From Thomas Adam.


Revision tags: OPENBSD_4_8_BASE
# 1.63 21-Jun-2010 nicm

Having a list of winlinks->alerts for each session is stupid, just store
the alert flags directly in the winlink itself.


# 1.62 14-May-2010 nicm

Colour+attribute options for status line alerts, from Alex Alexander.


# 1.61 31-Mar-2010 nicm

Don't accept keys with modifiers as input. Fixes crash reported by Brian
R Landy.


# 1.60 27-Mar-2010 nicm

Don't leak job command in #().


# 1.59 22-Mar-2010 nicm

Dead functions, lint.


Revision tags: OPENBSD_4_7_BASE
# 1.58 27-Jan-2010 nicm

Calculate offset correctly, fixes incorrect offset and prevents crash when
status-left is empty. From Micah Cowan.


# 1.57 26-Jan-2010 nicm

Actually use the copy made when no newline is found, from martynas@.


# 1.56 14-Dec-2009 nicm

Add server options to completion as well.


# 1.55 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.54 03-Dec-2009 nicm

Eliminate duplicate code and ease the passage for server-wide options by adding
a -w flag to set-option and show-options and making setw and showw aliases to
set -w and show -w.

Note: setw and showw are still there, but now aliases for set -w and show -w.


# 1.53 26-Nov-2009 nicm

Tidy up various bits of the paste code, make the data buffer char * and add
comments.


# 1.52 26-Nov-2009 nicm

Remove a couple of unused arguments where possible, and add /* ARGSUSED */ to
the rest to reduce lint output.


# 1.51 20-Nov-2009 nicm

Display UTF-8 properly in status line messages and prompt. Cursor handling is
still way off though.


# 1.50 20-Nov-2009 nicm

Remove oldest messages from log when limit is hit, not newest.


# 1.49 19-Nov-2009 nicm

Get some brackets in the right place so ## works. Also fix a space in a
comment.


# 1.48 19-Nov-2009 nicm

Change status line drawing to create the window list in a separate screen and
then copy it into the status line screen. This allows UTF-8 in window names and
fixes some problems with #[] in window-status-format.


# 1.47 19-Nov-2009 nicm

Two new options, window-status-format and window-status-current-format, which
allow the format of each window in the status line window list to be controlled
using similar # sequences as status-left/right.

This diff also moves part of the way towards UTF-8 support in window names but
it isn't quite there yet.


# 1.46 19-Nov-2009 nicm

Tidy up by breaking the # replacement code into a separate function, also add a
few comments.


# 1.45 19-Nov-2009 nicm

Don't interpret #() for display-message, it usually doesn't make sense and may
leak commands.


# 1.44 18-Nov-2009 nicm

Add a per-client log of status line messages displayed while that client
exists. A new message-limit session option sets the maximum number of entries
and a command, show-messages, shows the log (bound to ~ by default).

This (and prompt history) might be better as a single global log but until
there are global options it is easier for them to be per client.


# 1.43 17-Nov-2009 nicm

Permit top-bit-set characters to be entered in the status line. They could
already be set from the shell and are just passed through when printing (so
invisible characters or displaying on terminals with different character sets
may cause problems).

Note that entering UTF-8 may not work and in any case currently the status line
cannot display it correctly (outside of status-left/status-right).


# 1.42 04-Nov-2009 nicm

Use timeout events for the identify and message timers.


# 1.41 04-Nov-2009 nicm

Switch jobs over to use a bufferevent.


# 1.40 04-Nov-2009 nicm

Unused (but assigned to) variable, found by lint.


# 1.39 01-Nov-2009 nicm

Add a flag for jobs that shouldn't be freed after they've died and use it for
status jobs, then only kill those jobs when status-left, status-right or
set-titles-string is changed.

Fixes problems with changing options from inside #().


# 1.38 10-Oct-2009 nicm

Rather than running status-left, status-right and window title #() with popen
immediately every redraw, queue them up and run them in the background,
starting each once every status-interval. The actual status line uses the
output from the last run.

This brings several advantages:

- tmux itself may be called from inside #() without causing the server to hang;
- likewise, sleep or similar doesn't cause the server to block;
- commands aren't run excessively often when redrawing;
- commands shared by status-left and status-right, or used multiple times, will
only be run once.

run-shell and if-shell still use system()/popen() but will be changed over to
use this too later.


# 1.37 10-Oct-2009 nicm

Add "grouped sessions" which have independent name, options, current window and
so on but where the linked windows are synchronized (ie creating, killing
windows and so on are mirrored between the sessions). A grouped session may be
created by passing -t to new-session.

Had this around for a while, tested by a couple of people.


# 1.36 23-Sep-2009 nicm

Remove PROMPT_HIDDEN code which is now unused.


# 1.35 23-Sep-2009 nicm

Remove the internal tmux locking and instead detach each client and run the
command specified by a new option "lock-command" (by default "lock -np") in
each client.

This means each terminal has to be unlocked individually but simplifies the
code and allows the system password to be used to unlock.

Note that the set-password command is gone, so it will need to be removed from
configuration files, and the -U command line flag has been removed.

This is the third protocol version change so again it is best to stop the tmux
server before upgrading.


# 1.34 20-Sep-2009 nicm

Regularise some fatal messages.


# 1.33 10-Sep-2009 nicm

Permit options such as status-bg to be configured using the entire 256 colour
palette by setting "colour0" to "colour255".


# 1.32 07-Sep-2009 nicm

Give each paste buffer a size member instead of requiring them to be
zero-terminated.


# 1.31 07-Sep-2009 nicm

Permit embedded colour and attributes in status-left and status-right using new
#[] special characters, for example #[fg=red,bg=blue,blink].


# 1.30 02-Sep-2009 nicm

Add a transpose-chars command in edit mode (C-t in emacs mode only). From Kalle
Olavi Niemitalo.


# 1.29 01-Sep-2009 nicm

Use "Password:" with no space for password prompts and don't display a *s for
the password, like pretty much everything else. From martynas@ with minor
tweaks by me.


# 1.28 31-Aug-2009 nicm

Add a new display-panes command, with two options (display-panes-colour and
display-panes-time), which displays a visual indication of the number of each
pane.


# 1.27 19-Aug-2009 nicm

Extend command-prompt with a -p option which is a comma-separated list of one
or more prompts to present in order.

The responses to the prompt are replaced in the template string: %% are
replaced in order, so the first prompt replaces the first %%, the second
replaces the second, and so on. In addition, %1 up to %9 are replaced with the
responses to the first the ninth prompts

The default template is "%1" so the response to the first prompt is processed
as a command.

Note that this changes the behaviour for %% so if there is only one prompt,
only the first %% will be replaced. Templates such as "neww -n '%%' 'ssh %%'"
should be changed to "neww -n '%1' 'ssh %1'".

From Tiago Cunha.


# 1.26 18-Aug-2009 nicm

Add a "delete line" key when editing in the status line or the search up/down
prompt. C-u with emacs keys, d with vi.


# 1.25 13-Aug-2009 nicm

Switch the prompt code to return an empty string when the user enters no
response and reserve NULL for an explicit cancel. Change all callbacks to treat
them the same so no functional change.

Also add cancel key bindings to emacs mode which were missing.


# 1.24 08-Aug-2009 nicm

Options to set the colours and attributes for status-left/-right. From Thomas
Adam, thanks.


# 1.23 05-Aug-2009 nicm

If colours are not supported by the terminal, try to emulate a coloured
background by setting or clearing the reverse attribute.

This makes a few applications which don't use the reverse attribute themselves
a little happier, and allows the status, message and mode options to have
default attributes and fg/bg options that work as expected when set as reverse.


# 1.22 30-Jul-2009 nicm

Plug some memory leaks.


# 1.21 28-Jul-2009 nicm

Next step towards customisable mode keys: build each default table of keys into
a named tree on start and use that for lookups. Also add command to string
translation tables and modify list-keys to show the the mode key bindings (new
-t argument).


# 1.20 27-Jul-2009 nicm

Change mode key bindings from big switches into a set of tables. Rather than
lumping them all together, split editing keys from those used in choice/more
mode and those for copy/scroll mode.

Tidier and clearer, and the first step towards customisable mode keys.


# 1.19 27-Jul-2009 nicm

Get rid of empty mode_key_free function.


# 1.18 27-Jul-2009 nicm

Add a key to delete to end of line at the prompt (^K in emacs mode, C/D in vi).

From Kalle Olavi Niemitalo.


# 1.17 26-Jul-2009 nicm

Calculate the space available for the prompt buffer and the cursor position
correctly, and make it work when the screen is not wide enough.

Noticed by Kalle Olavi Niemitalo.


# 1.16 21-Jul-2009 nicm

Remove a couple of unused functions and fix a type ("FALLTHOUGH"), found by
lint.


# 1.15 20-Jul-2009 nicm

Add a status-justify option to allow the window list in the status line to be
positioned at the left, centre, or right.


# 1.14 20-Jul-2009 nicm

New options, window-status-current-{fg,bg,attr}, to set the fg, bg and
attributes with which the current window is shown in the status line. From
Johan Friis, thanks.


# 1.13 17-Jul-2009 nicm

- New command display-message (alias display) to display a message in the
status line (bound to "i" and displays the current window and time by
default). The same substitutions are applied as for status-left/right.
- Add support for including the window index (#I), pane index (#P) and window
name (#W) in the message, and status-left or status-right.
- Bump protocol version.

From Tiago Cunha, thanks!


# 1.12 17-Jul-2009 nicm

Memory could be leaked if a second prompt or message appeared while another was
still present, so add a separate prompt free callback and make the _clear
function responsible for calling it if necessary (rather than the individual
prompt callbacks). Also make both messages and prompts clear any existing when
a new is set.

In addition, the screen could be modified while the prompt is there, restore
the redraw-entire-screen behaviour on prompt clear; add a comment as a
reminder.


# 1.11 16-Jul-2009 nicm

Remove some duplicate code that was causing the status line to be redrawn even
when it hadn't changed.


# 1.10 15-Jul-2009 nicm

Make status_message_set a variadic printf-like function. No functional change -
helpful for a couple of things coming soon.


# 1.9 15-Jul-2009 nicm

Having to update NSETOPTION/NSETWINDOWOPTION when adding new options is a bit
annoying and it is only use for iterating, so use a sentinel to mark the end of
each array instead. Different fix for a problem pointed out by Kalle Olavi
Niemitalo.


# 1.8 14-Jul-2009 nicm

For some reason when clearing status/message it was redrawing the entire client
not just the status line. Changing this also revealed the check for the status
line was incorrect when drawing the pane.


# 1.7 14-Jul-2009 nicm

Instead of faking up a status line in status_redraw, use the same code to
redraw it as to draw the entire screen, just skip all lines but the last.

This makes horizontal split redraw properly when the status line is off.


# 1.6 12-Jul-2009 nicm

Add a "back to indentation" key in copy mode to move the cursor to the first
non-whitespace character. ^ with vi and M-m with emacs key bindings. Another
from Kalle Olavi Niemitalo, thanks.


Revision tags: OPENBSD_4_6_BASE
# 1.5 26-Jun-2009 nicm

Status line fixes: don't truncate status-right now the length calculation is
done for UTF-8, limit to the maximum length correctly when printing, and always
print a space even if the left string is longer than the width available.


# 1.4 04-Jun-2009 nicm

If the prompt is hidden or a password is sent with -U, zero it before freeing
it.


# 1.3 03-Jun-2009 nicm

New session option, status-utf8, to control the interpretation of top-bit-set
characters in status-left and status-right (if on, they are treated as UTF-8;
otherwise passed through).


# 1.2 03-Jun-2009 nicm

Add a UTF-8 aware string length function and make UTF-8 in
status-left/status-right work properly. At the moment any top-bit-set
characters are assumed to be UTF-8: a status-utf8 option to configure this will
come shortly.


# 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.183 09-Feb-2019 nicm

Completion of command-alias members.


# 1.182 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.181 29-Aug-2018 nicm

Keep any text killed in the command prompt with C-w and yank it with
C-y, only use the top buffer if no text has previously been killed. This
and previous change promped by discussion with kn@.


# 1.180 29-Aug-2018 nicm

Add C-Left and C-Right as aliases for M-b and M-f.


# 1.179 22-Aug-2018 nicm

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


# 1.178 20-Aug-2018 nicm

Move offset of window list into status struct.


# 1.177 19-Aug-2018 nicm

Add a client redraw-window flag instead of the redraw-all flag and for
all just use the three flags together (window, borders, status).


Revision tags: OPENBSD_6_3_BASE
# 1.176 22-Feb-2018 nicm

Remove an unused variable.


# 1.175 05-Feb-2018 nicm

Add struct status_line to hold status line members of struct client, not
used yet but will be soon. From Thomas Adam.


# 1.174 01-Jan-2018 nicm

Add C-g at command prompt for emacs people, GitHub issue 1213.


# 1.173 27-Dec-2017 nicm

Draw command prompt correctly with status line off.


# 1.172 18-Dec-2017 nicm

Remove unused variable from Thomas Adam.


# 1.171 02-Nov-2017 nicm

Add a "fast" version of screen_write_copy for tree mode that doesn't do
all the checks and selection and marking stuff needed for copy mode.


# 1.170 20-Oct-2017 nicm

Clear status line with spaces again so reverse works, spotted by sthen.


# 1.169 16-Oct-2017 nicm

Infrastructure for drawing status lines of more than one line in height,
still only one is allowed but this lets tmux draw bigger ones.


Revision tags: OPENBSD_6_2_BASE
# 1.168 29-May-2017 nicm

Add a flag to stop the prompt input being expanded.


# 1.167 29-May-2017 nicm

Store a copy of the old status line, will be needed soon for new choose mode.


# 1.166 17-May-2017 nicm

Tidy command prompt callbacks and pass in the client.


# 1.165 03-May-2017 nicm

Add a format for the last search string in copy mode and fix the prompt
so it can work when in -I, suggested by Suraj N Kurapati.


# 1.164 01-May-2017 nicm

In order that people can use formats like #D in #() in the status line
and not have to wait for an update when they change pane, we allow
commands to run more than once a second if the expanded form
changes. Unfortunately this can mean them being run far too often
(pretty much continually) when multiple clients exist, because some
formats (including #D) will always differ between clients.

To avoid this, give each client its own tree of jobs which means that
the same command will be different instances for each client - similar
to how we have the tag to separate commands for different panes.

GitHub issue 889; test case reported by Paul Johnson.


# 1.163 22-Apr-2017 nicm

Memory leak from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.162 09-Feb-2017 nicm

Break the message storage function into its own function, useful for
debugging.


# 1.161 03-Feb-2017 nicm

Cache status line position to reduce option lookups during output.


# 1.160 03-Feb-2017 nicm

Add a window or pane id "tag" to each format tree and use it to separate
jobs, this means that if the same job is used for different windows or
panes (for example in pane-border-format), it will be run separately for
each pane.


# 1.159 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.158 06-Jan-2017 nicm

Incremental search in copy mode (on for emacs keys by default) - much
the same as normal searching but updates the cursor position and marked
search terms as you type. C-r and C-s in the prompt repeat the search,
once finished searching (with Enter), N and n work as before.


# 1.157 05-Jan-2017 nicm

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


# 1.156 07-Dec-2016 nicm

Do not clear the prompt when a message is shown, just leave it around and
return to it when the message is finished.


# 1.155 12-Oct-2016 nicm

Drop the edit mode key tables and just use fixed key bindings for the
command prompt.


# 1.154 12-Oct-2016 nicm

The repeat prompt in both emacs and vi (and the old one in tmux) doesn't
support line editing and instead executes a command as soon as a
non-number key is pressed. Add a -N flag to command-prompt for the same
in copy mode. Reported by Theo Buehler.


# 1.153 11-Oct-2016 nicm

Fundamental change to how copy mode key bindings work:

The vi-copy and emacs-copy mode key tables are gone, and instead copy
mode commands are bound in one of two normal key tables ("copy-mode" or
"copy-mode-vi"). Keys are bound to "send-keys -X copy-mode-command". So:

bind -temacs-copy C-Up scroll-up
bind -temacs-copy -R5 WheelUpPane scroll-up

Becomes:

bind -Tcopy-mode C-Up send -X scroll-up
bind -Tcopy-mode WheelUpPane send -N5 -X scroll-up

This allows the full command parser and command set to be used - for
example, we can use the normal command prompt for searching, jumping,
and so on instead of a custom one:

bind -Tcopy-mode C-r command-prompt -p'search up' "send -X search-backward '%%'"

command-prompt also gets a -1 option to only require on key press, which
is needed for jumping.

The plan is to get rid of mode keys entirely, so more to come eventually.


# 1.152 11-Oct-2016 nicm

Support UTF-8 entry into the command prompt.


# 1.151 10-Oct-2016 nicm

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


# 1.150 12-Sep-2016 nicm

Allow repeat count to be specified in mode key tables with bind-key -R,
and set the default repeat count to 5 for WheelUp and WheelDown in
copy-mode.


Revision tags: OPENBSD_6_0_BASE
# 1.149 06-Jun-2016 nicm

Allow #[] in window-status-separator.


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

I no longer use my SourceForge address so replace it.


# 1.147 01-Jan-2016 nicm

Don't rely on a calculation wrapping when applying message-limit, and
break out of the loop early. From Nicolas Viennot.


# 1.146 11-Dec-2015 nicm

Style nits and line wrapping of function declarations.


# 1.145 11-Dec-2015 nicm

Add cmdq as an argument to format_create and add a format for the
command name (will also be used for more later).


# 1.144 08-Dec-2015 nicm

Remove format_create_flags and just pass flags to format_create.


# 1.143 22-Nov-2015 tim

If display-time is set to 0, show status messages until a key is pressed;
OK nicm@


# 1.142 20-Nov-2015 nicm

Instead of separate tables for different types of options, give each
option a scope type (server, session, window) in one table.


# 1.141 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.140 13-Nov-2015 nicm

Long overdue change to the way we store cells in the grid: now, instead
of storing a full grid_cell with UTF-8 data and everything, store a new
type grid_cell_entry. This can either be the cell itself (for ASCII
cells), or an offset into an extended array (per line) for UTF-8
data.

This avoid a large (8 byte) overhead on non-UTF-8 cells (by far the
majority for most users) without the complexity of the shadow array we
had before. Grid memory without any UTF-8 is about half.

The disadvantage that cells can no longer be modified in place and need
to be copied out of the grid and back but it turned out to be lot less
complicated than I expected.


# 1.139 12-Nov-2015 nicm

Nuke the utf8 and status-utf8 options and make tmux only a UTF-8
terminal. We still support non-UTF-8 terminals outside tmux, but inside
it is always UTF-8 (as when the utf8 and status-utf8 options were on).


# 1.138 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.137 27-Oct-2015 nicm

Move struct options into options.c.


# 1.136 20-Oct-2015 nicm

Use client pointer not file descriptor in logging.


# 1.135 14-Sep-2015 nicm

Make refresh-client force update of jobs, from Sina Siadat.


# 1.134 29-Aug-2015 nicm

Move struct paste_buffer out of tmux.h.


# 1.133 28-Aug-2015 nicm

Run status update on a per-client timer at status-interval.


Revision tags: OPENBSD_5_8_BASE
# 1.132 29-Jul-2015 nicm

status_out and associated data structures are no longer used.


# 1.131 28-Jul-2015 nicm

Tidy up the way terminals are described and move some structs out of tmux.h.


# 1.130 20-Jul-2015 nicm

Add an option (history-file) for a file to save/restore command prompt
history, from Olof-Joachim Frahm.


# 1.129 27-May-2015 nicm

Move the jobs output cache into the formats code so that #() work more
generally (for example, again working in set-titles-string).


# 1.128 06-May-2015 nicm

Remove ARRAY_* from history and expand completion to complete a) layout
names and b) targets beginning with -t or -s.


# 1.127 25-Apr-2015 nicm

Make message log a TAILQ.


# 1.126 24-Apr-2015 nicm

Set working directory for run-shell and if-shell.


# 1.125 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_7_BASE
# 1.124 06-Feb-2015 nicm

Use the same time for both calls to format_expand_time.


# 1.123 06-Feb-2015 nicm

status_replace can now become local to status.c and it no longer needs
the jobsflag argument. While here there is no need to repeat work that
format_defaults already does.


# 1.122 06-Feb-2015 nicm

Add format_expand_time and use it instead of status_replace where
command execution is not needed.


# 1.121 05-Feb-2015 nicm

Wrap all the individual format_* calls in a single format_defaults
functions.


# 1.120 01-Feb-2015 nicm

Remove two unused arguments from status_replace.


# 1.119 20-Jan-2015 sthen

typo in comment ;) ok nicm


# 1.118 05-Nov-2014 nicm

Do not put a space between status-left/status-right and the window list,
instead move the space into the defaults for the options (so status-left
now defaults to "[#S] ". From Balazs Kezes.


# 1.117 20-Oct-2014 nicm

Better format for printf format attributes.


# 1.116 08-Oct-2014 nicm

Add xreallocarray and remove nmemb argument from xrealloc.


# 1.115 02-Oct-2014 nicm

Take account of window-status-separator when checking window position,
based on diff from Balazs Kezes.


Revision tags: OPENBSD_5_6_BASE
# 1.114 24-Apr-2014 nicm

There is no longer a need for a paste_stack struct or for global_buffers
to be global. Move to paste.c.


# 1.113 17-Apr-2014 nicm

Remove the monitor-content option and associated bits and bobs. It's
never worked very well. If there is a big demand for it to return, will
consider better ways to do it.


# 1.112 02-Apr-2014 nicm

Do not replace ## with # in status_replace1 because it'll be done later
by the format code.


# 1.111 31-Mar-2014 nicm

Make message-limit a server option.


Revision tags: OPENBSD_5_5_BASE
# 1.110 14-Feb-2014 nicm

Style nit - no space between function name and bracket.


# 1.109 14-Feb-2014 nicm

Check for NULL session and whatnot in status_replace, from Thomas Adam.


# 1.108 28-Jan-2014 nicm

Allow replacing each of the many sets of separate foo-{fg,bg,attr}
options with a single foo-style option. For example:

set -g status-fg yellow
set -g status-bg red
set -g status-attr blink

Becomes:

set -g status-style fg=yellow,bg=red,blink

The -a flag to set can be used to add to rather than replace a style. So:

set -g status-bg red

Becomes:

set -ag status-style bg=red

Currently this is fully backwards compatible (all *-{fg,bg,attr} options
remain) but the plan is to deprecate them over time.

From Tiago Cunha.


Revision tags: OPENBSD_5_4_BASE
# 1.107 05-Jul-2013 nicm

Whitespace nits, from Ben Boeckel.


# 1.106 05-Jul-2013 nicm

Act like vi(1) when moving words, from Ben Boeckel.


# 1.105 05-Jul-2013 nicm

Implement s, S, C mode switch commands in vi(1) mode, from Ben Boeckel.


# 1.104 31-May-2013 nicm

Demote the old single-character replacement variables (#S and friends)
to aliases of formats. From Tiago Cunha.


# 1.103 25-Mar-2013 nicm

Extend jobs to support writing and use that for copy-pipe instead of
popen, from Chris Johnsen.


# 1.102 22-Mar-2013 nicm

evbuffer_readline returns allocated storage, don't leak it.


# 1.101 22-Mar-2013 nicm

Add copy-pipe mode command to copy selection and also pipe to a command.


# 1.100 22-Mar-2013 nicm

No more lint means no more ARGSUSED.


# 1.99 21-Mar-2013 nicm

Aargh. Spaces -> tabs.


# 1.98 21-Mar-2013 nicm

Do not leak formats in status_replace.


# 1.97 21-Mar-2013 nicm

Add a format client_prefix which is 1 if prefix key has been
pressed, used for example #{?client_prefix,X,Y}. Also a few extra
server_client_status needed.


# 1.96 21-Mar-2013 nicm

Allow formats in status options.


Revision tags: OPENBSD_5_3_BASE
# 1.95 27-Nov-2012 nicm

Add window-status-last-* options, from Boris Faure.


Revision tags: OPENBSD_5_2_BASE
# 1.94 10-Jul-2012 nicm

xfree is not particularly helpful, remove it. From Thomas Adam.


# 1.93 09-Jul-2012 nicm

Move a NULL check inside a function, from Tiago Cunha.


# 1.92 29-Apr-2012 nicm

Use int not u_char for colours from options since they may have bit 8
set to mark them as 256-colour. Reported by Chris Johnson.


# 1.91 23-Apr-2012 nicm

Add window-status-separator option, from Thomas Adam.


# 1.90 17-Mar-2012 nicm

Check event_initialized before event_del if event may not have been set
up; libevent2 complains about this. Reported by Moriyoshi Koizumi.


# 1.89 04-Mar-2012 nicm

Add A and I keys for vi status line editing.


# 1.88 03-Mar-2012 nicm

The wlmouse offset should be part of the client, not the server. From
Ailin Nemui.


Revision tags: OPENBSD_5_1_BASE
# 1.87 29-Jan-2012 nicm

Add an option to move the status line to the top of the screen,
requested by many.


# 1.86 26-Jan-2012 nicm

Terminate strftime buffer properly even if a really long format string
is given, from Tiago Cunha.


# 1.85 26-Jan-2012 nicm

Fix memory leak in error path, from Tiago Cunha.


# 1.84 20-Jan-2012 nicm

Add some trivial additional status line attributes from jwcxz at users
dot sourceforge dot net.


# 1.83 20-Jan-2012 nicm

Add space movement keys for vi mode in the status line from Ben Boeckel.


# 1.82 01-Dec-2011 nicm

Make M-f and M-b work the same at the command prompt as in copy mode,
pointed out by Romain Francoise.


# 1.81 15-Nov-2011 nicm

Add word movement and editing command for command prompt editing, from
Ben Boeckel.


# 1.80 15-Nov-2011 nicm

Make window_pane_index work the same as window_index, from Ben Boeckel.


# 1.79 05-Nov-2011 nicm

Option to change status line (message) background when using vi keys and
in command mode. From Ben Boeckel.


# 1.78 20-Aug-2011 nicm

Fix a couple of memory leaks, from marcel partap.


Revision tags: OPENBSD_5_0_BASE
# 1.77 08-Jul-2011 nicm

Make confirm-before prompt customizable with -p option like
command-prompt. Also move responsibility for calling status_replace into
status_prompt_{set,update} and add #W and #P to the default kill-window
and kill-pane prompts. By Tiago Cunha.


# 1.76 02-Jul-2011 nicm

Allow the initial context on prompts to be set with the new -I option to
command-prompt. From Tiago Cunha.


# 1.75 29-Apr-2011 nicm

Only redraw the status line on command update, not the entire client
(big DOH).


# 1.74 24-Apr-2011 nicm

Provide #h for short hostname (no domain) from Michal Mazurek.


# 1.73 18-Apr-2011 nicm

Add an option (mouse-select-window) which allows the mouse to be used by
clicking on the status line, written by hsim at gmx dot li.


# 1.72 29-Mar-2011 nicm

Change -t on display-message to be target-pane for the #[A-Z]
replacements and add -c as target-client.


Revision tags: OPENBSD_4_9_BASE
# 1.71 26-Jan-2011 nicm

Simplify the way jobs work and drop the persist type, so all jobs are
fire-and-forget.

Status jobs now managed with two trees of output (new and old), rather
than storing the output in the jobs themselves. When the status line is
processed any jobs which don't appear in the new tree are started and
the output from the old tree displayed. When a job finishes it updates
the new tree with its output and that is used for any subsequent
redraws. When the status interval expires, the new tree is moved to the
old so that all jobs are run again.

This fixes the "#(echo %H:%M:%S)" problem which would lead to thousands
of identical persistent jobs and high memory use (this can still be
achieved by adding "sleep 30" but that is much less likely to happen by
accident).


# 1.70 03-Jan-2011 nicm

Handle a # at the end of a replacement string (such as status-left)
correctly. Found by Thomas Adam.


# 1.69 01-Jan-2011 nicm

Move the user-visible parts of all options (names, types, limit, default
values) together into one set of tables in options-table.c. Also clean
up and simplify cmd-set-options.c and move a common print function into
option-table.c.


# 1.68 30-Dec-2010 nicm

Change from a per-session stack of buffers to one global stack which is
much more convenient and also simplifies lot of code. This renders
copy-buffer useless and makes buffer-limit now a server option.

By Tiago Cunha.


# 1.67 30-Dec-2010 nicm

Add a function to create window flags rather than doing the same thing
in two places. From Thomas Adam.


# 1.66 11-Dec-2010 nicm

Oops, these functions return a const char *, so make the local variable
const as well.


# 1.65 11-Dec-2010 nicm

Make the prompt history global for all clients which is much more useful than per-client history.


# 1.64 06-Dec-2010 nicm

Add an option to alert (monitor) for silence (lack of activity) in a
window. From Thomas Adam.


Revision tags: OPENBSD_4_8_BASE
# 1.63 21-Jun-2010 nicm

Having a list of winlinks->alerts for each session is stupid, just store
the alert flags directly in the winlink itself.


# 1.62 14-May-2010 nicm

Colour+attribute options for status line alerts, from Alex Alexander.


# 1.61 31-Mar-2010 nicm

Don't accept keys with modifiers as input. Fixes crash reported by Brian
R Landy.


# 1.60 27-Mar-2010 nicm

Don't leak job command in #().


# 1.59 22-Mar-2010 nicm

Dead functions, lint.


Revision tags: OPENBSD_4_7_BASE
# 1.58 27-Jan-2010 nicm

Calculate offset correctly, fixes incorrect offset and prevents crash when
status-left is empty. From Micah Cowan.


# 1.57 26-Jan-2010 nicm

Actually use the copy made when no newline is found, from martynas@.


# 1.56 14-Dec-2009 nicm

Add server options to completion as well.


# 1.55 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.54 03-Dec-2009 nicm

Eliminate duplicate code and ease the passage for server-wide options by adding
a -w flag to set-option and show-options and making setw and showw aliases to
set -w and show -w.

Note: setw and showw are still there, but now aliases for set -w and show -w.


# 1.53 26-Nov-2009 nicm

Tidy up various bits of the paste code, make the data buffer char * and add
comments.


# 1.52 26-Nov-2009 nicm

Remove a couple of unused arguments where possible, and add /* ARGSUSED */ to
the rest to reduce lint output.


# 1.51 20-Nov-2009 nicm

Display UTF-8 properly in status line messages and prompt. Cursor handling is
still way off though.


# 1.50 20-Nov-2009 nicm

Remove oldest messages from log when limit is hit, not newest.


# 1.49 19-Nov-2009 nicm

Get some brackets in the right place so ## works. Also fix a space in a
comment.


# 1.48 19-Nov-2009 nicm

Change status line drawing to create the window list in a separate screen and
then copy it into the status line screen. This allows UTF-8 in window names and
fixes some problems with #[] in window-status-format.


# 1.47 19-Nov-2009 nicm

Two new options, window-status-format and window-status-current-format, which
allow the format of each window in the status line window list to be controlled
using similar # sequences as status-left/right.

This diff also moves part of the way towards UTF-8 support in window names but
it isn't quite there yet.


# 1.46 19-Nov-2009 nicm

Tidy up by breaking the # replacement code into a separate function, also add a
few comments.


# 1.45 19-Nov-2009 nicm

Don't interpret #() for display-message, it usually doesn't make sense and may
leak commands.


# 1.44 18-Nov-2009 nicm

Add a per-client log of status line messages displayed while that client
exists. A new message-limit session option sets the maximum number of entries
and a command, show-messages, shows the log (bound to ~ by default).

This (and prompt history) might be better as a single global log but until
there are global options it is easier for them to be per client.


# 1.43 17-Nov-2009 nicm

Permit top-bit-set characters to be entered in the status line. They could
already be set from the shell and are just passed through when printing (so
invisible characters or displaying on terminals with different character sets
may cause problems).

Note that entering UTF-8 may not work and in any case currently the status line
cannot display it correctly (outside of status-left/status-right).


# 1.42 04-Nov-2009 nicm

Use timeout events for the identify and message timers.


# 1.41 04-Nov-2009 nicm

Switch jobs over to use a bufferevent.


# 1.40 04-Nov-2009 nicm

Unused (but assigned to) variable, found by lint.


# 1.39 01-Nov-2009 nicm

Add a flag for jobs that shouldn't be freed after they've died and use it for
status jobs, then only kill those jobs when status-left, status-right or
set-titles-string is changed.

Fixes problems with changing options from inside #().


# 1.38 10-Oct-2009 nicm

Rather than running status-left, status-right and window title #() with popen
immediately every redraw, queue them up and run them in the background,
starting each once every status-interval. The actual status line uses the
output from the last run.

This brings several advantages:

- tmux itself may be called from inside #() without causing the server to hang;
- likewise, sleep or similar doesn't cause the server to block;
- commands aren't run excessively often when redrawing;
- commands shared by status-left and status-right, or used multiple times, will
only be run once.

run-shell and if-shell still use system()/popen() but will be changed over to
use this too later.


# 1.37 10-Oct-2009 nicm

Add "grouped sessions" which have independent name, options, current window and
so on but where the linked windows are synchronized (ie creating, killing
windows and so on are mirrored between the sessions). A grouped session may be
created by passing -t to new-session.

Had this around for a while, tested by a couple of people.


# 1.36 23-Sep-2009 nicm

Remove PROMPT_HIDDEN code which is now unused.


# 1.35 23-Sep-2009 nicm

Remove the internal tmux locking and instead detach each client and run the
command specified by a new option "lock-command" (by default "lock -np") in
each client.

This means each terminal has to be unlocked individually but simplifies the
code and allows the system password to be used to unlock.

Note that the set-password command is gone, so it will need to be removed from
configuration files, and the -U command line flag has been removed.

This is the third protocol version change so again it is best to stop the tmux
server before upgrading.


# 1.34 20-Sep-2009 nicm

Regularise some fatal messages.


# 1.33 10-Sep-2009 nicm

Permit options such as status-bg to be configured using the entire 256 colour
palette by setting "colour0" to "colour255".


# 1.32 07-Sep-2009 nicm

Give each paste buffer a size member instead of requiring them to be
zero-terminated.


# 1.31 07-Sep-2009 nicm

Permit embedded colour and attributes in status-left and status-right using new
#[] special characters, for example #[fg=red,bg=blue,blink].


# 1.30 02-Sep-2009 nicm

Add a transpose-chars command in edit mode (C-t in emacs mode only). From Kalle
Olavi Niemitalo.


# 1.29 01-Sep-2009 nicm

Use "Password:" with no space for password prompts and don't display a *s for
the password, like pretty much everything else. From martynas@ with minor
tweaks by me.


# 1.28 31-Aug-2009 nicm

Add a new display-panes command, with two options (display-panes-colour and
display-panes-time), which displays a visual indication of the number of each
pane.


# 1.27 19-Aug-2009 nicm

Extend command-prompt with a -p option which is a comma-separated list of one
or more prompts to present in order.

The responses to the prompt are replaced in the template string: %% are
replaced in order, so the first prompt replaces the first %%, the second
replaces the second, and so on. In addition, %1 up to %9 are replaced with the
responses to the first the ninth prompts

The default template is "%1" so the response to the first prompt is processed
as a command.

Note that this changes the behaviour for %% so if there is only one prompt,
only the first %% will be replaced. Templates such as "neww -n '%%' 'ssh %%'"
should be changed to "neww -n '%1' 'ssh %1'".

From Tiago Cunha.


# 1.26 18-Aug-2009 nicm

Add a "delete line" key when editing in the status line or the search up/down
prompt. C-u with emacs keys, d with vi.


# 1.25 13-Aug-2009 nicm

Switch the prompt code to return an empty string when the user enters no
response and reserve NULL for an explicit cancel. Change all callbacks to treat
them the same so no functional change.

Also add cancel key bindings to emacs mode which were missing.


# 1.24 08-Aug-2009 nicm

Options to set the colours and attributes for status-left/-right. From Thomas
Adam, thanks.


# 1.23 05-Aug-2009 nicm

If colours are not supported by the terminal, try to emulate a coloured
background by setting or clearing the reverse attribute.

This makes a few applications which don't use the reverse attribute themselves
a little happier, and allows the status, message and mode options to have
default attributes and fg/bg options that work as expected when set as reverse.


# 1.22 30-Jul-2009 nicm

Plug some memory leaks.


# 1.21 28-Jul-2009 nicm

Next step towards customisable mode keys: build each default table of keys into
a named tree on start and use that for lookups. Also add command to string
translation tables and modify list-keys to show the the mode key bindings (new
-t argument).


# 1.20 27-Jul-2009 nicm

Change mode key bindings from big switches into a set of tables. Rather than
lumping them all together, split editing keys from those used in choice/more
mode and those for copy/scroll mode.

Tidier and clearer, and the first step towards customisable mode keys.


# 1.19 27-Jul-2009 nicm

Get rid of empty mode_key_free function.


# 1.18 27-Jul-2009 nicm

Add a key to delete to end of line at the prompt (^K in emacs mode, C/D in vi).

From Kalle Olavi Niemitalo.


# 1.17 26-Jul-2009 nicm

Calculate the space available for the prompt buffer and the cursor position
correctly, and make it work when the screen is not wide enough.

Noticed by Kalle Olavi Niemitalo.


# 1.16 21-Jul-2009 nicm

Remove a couple of unused functions and fix a type ("FALLTHOUGH"), found by
lint.


# 1.15 20-Jul-2009 nicm

Add a status-justify option to allow the window list in the status line to be
positioned at the left, centre, or right.


# 1.14 20-Jul-2009 nicm

New options, window-status-current-{fg,bg,attr}, to set the fg, bg and
attributes with which the current window is shown in the status line. From
Johan Friis, thanks.


# 1.13 17-Jul-2009 nicm

- New command display-message (alias display) to display a message in the
status line (bound to "i" and displays the current window and time by
default). The same substitutions are applied as for status-left/right.
- Add support for including the window index (#I), pane index (#P) and window
name (#W) in the message, and status-left or status-right.
- Bump protocol version.

From Tiago Cunha, thanks!


# 1.12 17-Jul-2009 nicm

Memory could be leaked if a second prompt or message appeared while another was
still present, so add a separate prompt free callback and make the _clear
function responsible for calling it if necessary (rather than the individual
prompt callbacks). Also make both messages and prompts clear any existing when
a new is set.

In addition, the screen could be modified while the prompt is there, restore
the redraw-entire-screen behaviour on prompt clear; add a comment as a
reminder.


# 1.11 16-Jul-2009 nicm

Remove some duplicate code that was causing the status line to be redrawn even
when it hadn't changed.


# 1.10 15-Jul-2009 nicm

Make status_message_set a variadic printf-like function. No functional change -
helpful for a couple of things coming soon.


# 1.9 15-Jul-2009 nicm

Having to update NSETOPTION/NSETWINDOWOPTION when adding new options is a bit
annoying and it is only use for iterating, so use a sentinel to mark the end of
each array instead. Different fix for a problem pointed out by Kalle Olavi
Niemitalo.


# 1.8 14-Jul-2009 nicm

For some reason when clearing status/message it was redrawing the entire client
not just the status line. Changing this also revealed the check for the status
line was incorrect when drawing the pane.


# 1.7 14-Jul-2009 nicm

Instead of faking up a status line in status_redraw, use the same code to
redraw it as to draw the entire screen, just skip all lines but the last.

This makes horizontal split redraw properly when the status line is off.


# 1.6 12-Jul-2009 nicm

Add a "back to indentation" key in copy mode to move the cursor to the first
non-whitespace character. ^ with vi and M-m with emacs key bindings. Another
from Kalle Olavi Niemitalo, thanks.


Revision tags: OPENBSD_4_6_BASE
# 1.5 26-Jun-2009 nicm

Status line fixes: don't truncate status-right now the length calculation is
done for UTF-8, limit to the maximum length correctly when printing, and always
print a space even if the left string is longer than the width available.


# 1.4 04-Jun-2009 nicm

If the prompt is hidden or a password is sent with -U, zero it before freeing
it.


# 1.3 03-Jun-2009 nicm

New session option, status-utf8, to control the interpretation of top-bit-set
characters in status-left and status-right (if on, they are treated as UTF-8;
otherwise passed through).


# 1.2 03-Jun-2009 nicm

Add a UTF-8 aware string length function and make UTF-8 in
status-left/status-right work properly. At the moment any top-bit-set
characters are assumed to be UTF-8: a status-utf8 option to configure this will
come shortly.


# 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.182 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.181 29-Aug-2018 nicm

Keep any text killed in the command prompt with C-w and yank it with
C-y, only use the top buffer if no text has previously been killed. This
and previous change promped by discussion with kn@.


# 1.180 29-Aug-2018 nicm

Add C-Left and C-Right as aliases for M-b and M-f.


# 1.179 22-Aug-2018 nicm

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


# 1.178 20-Aug-2018 nicm

Move offset of window list into status struct.


# 1.177 19-Aug-2018 nicm

Add a client redraw-window flag instead of the redraw-all flag and for
all just use the three flags together (window, borders, status).


Revision tags: OPENBSD_6_3_BASE
# 1.176 22-Feb-2018 nicm

Remove an unused variable.


# 1.175 05-Feb-2018 nicm

Add struct status_line to hold status line members of struct client, not
used yet but will be soon. From Thomas Adam.


# 1.174 01-Jan-2018 nicm

Add C-g at command prompt for emacs people, GitHub issue 1213.


# 1.173 27-Dec-2017 nicm

Draw command prompt correctly with status line off.


# 1.172 18-Dec-2017 nicm

Remove unused variable from Thomas Adam.


# 1.171 02-Nov-2017 nicm

Add a "fast" version of screen_write_copy for tree mode that doesn't do
all the checks and selection and marking stuff needed for copy mode.


# 1.170 20-Oct-2017 nicm

Clear status line with spaces again so reverse works, spotted by sthen.


# 1.169 16-Oct-2017 nicm

Infrastructure for drawing status lines of more than one line in height,
still only one is allowed but this lets tmux draw bigger ones.


Revision tags: OPENBSD_6_2_BASE
# 1.168 29-May-2017 nicm

Add a flag to stop the prompt input being expanded.


# 1.167 29-May-2017 nicm

Store a copy of the old status line, will be needed soon for new choose mode.


# 1.166 17-May-2017 nicm

Tidy command prompt callbacks and pass in the client.


# 1.165 03-May-2017 nicm

Add a format for the last search string in copy mode and fix the prompt
so it can work when in -I, suggested by Suraj N Kurapati.


# 1.164 01-May-2017 nicm

In order that people can use formats like #D in #() in the status line
and not have to wait for an update when they change pane, we allow
commands to run more than once a second if the expanded form
changes. Unfortunately this can mean them being run far too often
(pretty much continually) when multiple clients exist, because some
formats (including #D) will always differ between clients.

To avoid this, give each client its own tree of jobs which means that
the same command will be different instances for each client - similar
to how we have the tag to separate commands for different panes.

GitHub issue 889; test case reported by Paul Johnson.


# 1.163 22-Apr-2017 nicm

Memory leak from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.162 09-Feb-2017 nicm

Break the message storage function into its own function, useful for
debugging.


# 1.161 03-Feb-2017 nicm

Cache status line position to reduce option lookups during output.


# 1.160 03-Feb-2017 nicm

Add a window or pane id "tag" to each format tree and use it to separate
jobs, this means that if the same job is used for different windows or
panes (for example in pane-border-format), it will be run separately for
each pane.


# 1.159 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.158 06-Jan-2017 nicm

Incremental search in copy mode (on for emacs keys by default) - much
the same as normal searching but updates the cursor position and marked
search terms as you type. C-r and C-s in the prompt repeat the search,
once finished searching (with Enter), N and n work as before.


# 1.157 05-Jan-2017 nicm

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


# 1.156 07-Dec-2016 nicm

Do not clear the prompt when a message is shown, just leave it around and
return to it when the message is finished.


# 1.155 12-Oct-2016 nicm

Drop the edit mode key tables and just use fixed key bindings for the
command prompt.


# 1.154 12-Oct-2016 nicm

The repeat prompt in both emacs and vi (and the old one in tmux) doesn't
support line editing and instead executes a command as soon as a
non-number key is pressed. Add a -N flag to command-prompt for the same
in copy mode. Reported by Theo Buehler.


# 1.153 11-Oct-2016 nicm

Fundamental change to how copy mode key bindings work:

The vi-copy and emacs-copy mode key tables are gone, and instead copy
mode commands are bound in one of two normal key tables ("copy-mode" or
"copy-mode-vi"). Keys are bound to "send-keys -X copy-mode-command". So:

bind -temacs-copy C-Up scroll-up
bind -temacs-copy -R5 WheelUpPane scroll-up

Becomes:

bind -Tcopy-mode C-Up send -X scroll-up
bind -Tcopy-mode WheelUpPane send -N5 -X scroll-up

This allows the full command parser and command set to be used - for
example, we can use the normal command prompt for searching, jumping,
and so on instead of a custom one:

bind -Tcopy-mode C-r command-prompt -p'search up' "send -X search-backward '%%'"

command-prompt also gets a -1 option to only require on key press, which
is needed for jumping.

The plan is to get rid of mode keys entirely, so more to come eventually.


# 1.152 11-Oct-2016 nicm

Support UTF-8 entry into the command prompt.


# 1.151 10-Oct-2016 nicm

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


# 1.150 12-Sep-2016 nicm

Allow repeat count to be specified in mode key tables with bind-key -R,
and set the default repeat count to 5 for WheelUp and WheelDown in
copy-mode.


Revision tags: OPENBSD_6_0_BASE
# 1.149 06-Jun-2016 nicm

Allow #[] in window-status-separator.


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

I no longer use my SourceForge address so replace it.


# 1.147 01-Jan-2016 nicm

Don't rely on a calculation wrapping when applying message-limit, and
break out of the loop early. From Nicolas Viennot.


# 1.146 11-Dec-2015 nicm

Style nits and line wrapping of function declarations.


# 1.145 11-Dec-2015 nicm

Add cmdq as an argument to format_create and add a format for the
command name (will also be used for more later).


# 1.144 08-Dec-2015 nicm

Remove format_create_flags and just pass flags to format_create.


# 1.143 22-Nov-2015 tim

If display-time is set to 0, show status messages until a key is pressed;
OK nicm@


# 1.142 20-Nov-2015 nicm

Instead of separate tables for different types of options, give each
option a scope type (server, session, window) in one table.


# 1.141 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.140 13-Nov-2015 nicm

Long overdue change to the way we store cells in the grid: now, instead
of storing a full grid_cell with UTF-8 data and everything, store a new
type grid_cell_entry. This can either be the cell itself (for ASCII
cells), or an offset into an extended array (per line) for UTF-8
data.

This avoid a large (8 byte) overhead on non-UTF-8 cells (by far the
majority for most users) without the complexity of the shadow array we
had before. Grid memory without any UTF-8 is about half.

The disadvantage that cells can no longer be modified in place and need
to be copied out of the grid and back but it turned out to be lot less
complicated than I expected.


# 1.139 12-Nov-2015 nicm

Nuke the utf8 and status-utf8 options and make tmux only a UTF-8
terminal. We still support non-UTF-8 terminals outside tmux, but inside
it is always UTF-8 (as when the utf8 and status-utf8 options were on).


# 1.138 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.137 27-Oct-2015 nicm

Move struct options into options.c.


# 1.136 20-Oct-2015 nicm

Use client pointer not file descriptor in logging.


# 1.135 14-Sep-2015 nicm

Make refresh-client force update of jobs, from Sina Siadat.


# 1.134 29-Aug-2015 nicm

Move struct paste_buffer out of tmux.h.


# 1.133 28-Aug-2015 nicm

Run status update on a per-client timer at status-interval.


Revision tags: OPENBSD_5_8_BASE
# 1.132 29-Jul-2015 nicm

status_out and associated data structures are no longer used.


# 1.131 28-Jul-2015 nicm

Tidy up the way terminals are described and move some structs out of tmux.h.


# 1.130 20-Jul-2015 nicm

Add an option (history-file) for a file to save/restore command prompt
history, from Olof-Joachim Frahm.


# 1.129 27-May-2015 nicm

Move the jobs output cache into the formats code so that #() work more
generally (for example, again working in set-titles-string).


# 1.128 06-May-2015 nicm

Remove ARRAY_* from history and expand completion to complete a) layout
names and b) targets beginning with -t or -s.


# 1.127 25-Apr-2015 nicm

Make message log a TAILQ.


# 1.126 24-Apr-2015 nicm

Set working directory for run-shell and if-shell.


# 1.125 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_7_BASE
# 1.124 06-Feb-2015 nicm

Use the same time for both calls to format_expand_time.


# 1.123 06-Feb-2015 nicm

status_replace can now become local to status.c and it no longer needs
the jobsflag argument. While here there is no need to repeat work that
format_defaults already does.


# 1.122 06-Feb-2015 nicm

Add format_expand_time and use it instead of status_replace where
command execution is not needed.


# 1.121 05-Feb-2015 nicm

Wrap all the individual format_* calls in a single format_defaults
functions.


# 1.120 01-Feb-2015 nicm

Remove two unused arguments from status_replace.


# 1.119 20-Jan-2015 sthen

typo in comment ;) ok nicm


# 1.118 05-Nov-2014 nicm

Do not put a space between status-left/status-right and the window list,
instead move the space into the defaults for the options (so status-left
now defaults to "[#S] ". From Balazs Kezes.


# 1.117 20-Oct-2014 nicm

Better format for printf format attributes.


# 1.116 08-Oct-2014 nicm

Add xreallocarray and remove nmemb argument from xrealloc.


# 1.115 02-Oct-2014 nicm

Take account of window-status-separator when checking window position,
based on diff from Balazs Kezes.


Revision tags: OPENBSD_5_6_BASE
# 1.114 24-Apr-2014 nicm

There is no longer a need for a paste_stack struct or for global_buffers
to be global. Move to paste.c.


# 1.113 17-Apr-2014 nicm

Remove the monitor-content option and associated bits and bobs. It's
never worked very well. If there is a big demand for it to return, will
consider better ways to do it.


# 1.112 02-Apr-2014 nicm

Do not replace ## with # in status_replace1 because it'll be done later
by the format code.


# 1.111 31-Mar-2014 nicm

Make message-limit a server option.


Revision tags: OPENBSD_5_5_BASE
# 1.110 14-Feb-2014 nicm

Style nit - no space between function name and bracket.


# 1.109 14-Feb-2014 nicm

Check for NULL session and whatnot in status_replace, from Thomas Adam.


# 1.108 28-Jan-2014 nicm

Allow replacing each of the many sets of separate foo-{fg,bg,attr}
options with a single foo-style option. For example:

set -g status-fg yellow
set -g status-bg red
set -g status-attr blink

Becomes:

set -g status-style fg=yellow,bg=red,blink

The -a flag to set can be used to add to rather than replace a style. So:

set -g status-bg red

Becomes:

set -ag status-style bg=red

Currently this is fully backwards compatible (all *-{fg,bg,attr} options
remain) but the plan is to deprecate them over time.

From Tiago Cunha.


Revision tags: OPENBSD_5_4_BASE
# 1.107 05-Jul-2013 nicm

Whitespace nits, from Ben Boeckel.


# 1.106 05-Jul-2013 nicm

Act like vi(1) when moving words, from Ben Boeckel.


# 1.105 05-Jul-2013 nicm

Implement s, S, C mode switch commands in vi(1) mode, from Ben Boeckel.


# 1.104 31-May-2013 nicm

Demote the old single-character replacement variables (#S and friends)
to aliases of formats. From Tiago Cunha.


# 1.103 25-Mar-2013 nicm

Extend jobs to support writing and use that for copy-pipe instead of
popen, from Chris Johnsen.


# 1.102 22-Mar-2013 nicm

evbuffer_readline returns allocated storage, don't leak it.


# 1.101 22-Mar-2013 nicm

Add copy-pipe mode command to copy selection and also pipe to a command.


# 1.100 22-Mar-2013 nicm

No more lint means no more ARGSUSED.


# 1.99 21-Mar-2013 nicm

Aargh. Spaces -> tabs.


# 1.98 21-Mar-2013 nicm

Do not leak formats in status_replace.


# 1.97 21-Mar-2013 nicm

Add a format client_prefix which is 1 if prefix key has been
pressed, used for example #{?client_prefix,X,Y}. Also a few extra
server_client_status needed.


# 1.96 21-Mar-2013 nicm

Allow formats in status options.


Revision tags: OPENBSD_5_3_BASE
# 1.95 27-Nov-2012 nicm

Add window-status-last-* options, from Boris Faure.


Revision tags: OPENBSD_5_2_BASE
# 1.94 10-Jul-2012 nicm

xfree is not particularly helpful, remove it. From Thomas Adam.


# 1.93 09-Jul-2012 nicm

Move a NULL check inside a function, from Tiago Cunha.


# 1.92 29-Apr-2012 nicm

Use int not u_char for colours from options since they may have bit 8
set to mark them as 256-colour. Reported by Chris Johnson.


# 1.91 23-Apr-2012 nicm

Add window-status-separator option, from Thomas Adam.


# 1.90 17-Mar-2012 nicm

Check event_initialized before event_del if event may not have been set
up; libevent2 complains about this. Reported by Moriyoshi Koizumi.


# 1.89 04-Mar-2012 nicm

Add A and I keys for vi status line editing.


# 1.88 03-Mar-2012 nicm

The wlmouse offset should be part of the client, not the server. From
Ailin Nemui.


Revision tags: OPENBSD_5_1_BASE
# 1.87 29-Jan-2012 nicm

Add an option to move the status line to the top of the screen,
requested by many.


# 1.86 26-Jan-2012 nicm

Terminate strftime buffer properly even if a really long format string
is given, from Tiago Cunha.


# 1.85 26-Jan-2012 nicm

Fix memory leak in error path, from Tiago Cunha.


# 1.84 20-Jan-2012 nicm

Add some trivial additional status line attributes from jwcxz at users
dot sourceforge dot net.


# 1.83 20-Jan-2012 nicm

Add space movement keys for vi mode in the status line from Ben Boeckel.


# 1.82 01-Dec-2011 nicm

Make M-f and M-b work the same at the command prompt as in copy mode,
pointed out by Romain Francoise.


# 1.81 15-Nov-2011 nicm

Add word movement and editing command for command prompt editing, from
Ben Boeckel.


# 1.80 15-Nov-2011 nicm

Make window_pane_index work the same as window_index, from Ben Boeckel.


# 1.79 05-Nov-2011 nicm

Option to change status line (message) background when using vi keys and
in command mode. From Ben Boeckel.


# 1.78 20-Aug-2011 nicm

Fix a couple of memory leaks, from marcel partap.


Revision tags: OPENBSD_5_0_BASE
# 1.77 08-Jul-2011 nicm

Make confirm-before prompt customizable with -p option like
command-prompt. Also move responsibility for calling status_replace into
status_prompt_{set,update} and add #W and #P to the default kill-window
and kill-pane prompts. By Tiago Cunha.


# 1.76 02-Jul-2011 nicm

Allow the initial context on prompts to be set with the new -I option to
command-prompt. From Tiago Cunha.


# 1.75 29-Apr-2011 nicm

Only redraw the status line on command update, not the entire client
(big DOH).


# 1.74 24-Apr-2011 nicm

Provide #h for short hostname (no domain) from Michal Mazurek.


# 1.73 18-Apr-2011 nicm

Add an option (mouse-select-window) which allows the mouse to be used by
clicking on the status line, written by hsim at gmx dot li.


# 1.72 29-Mar-2011 nicm

Change -t on display-message to be target-pane for the #[A-Z]
replacements and add -c as target-client.


Revision tags: OPENBSD_4_9_BASE
# 1.71 26-Jan-2011 nicm

Simplify the way jobs work and drop the persist type, so all jobs are
fire-and-forget.

Status jobs now managed with two trees of output (new and old), rather
than storing the output in the jobs themselves. When the status line is
processed any jobs which don't appear in the new tree are started and
the output from the old tree displayed. When a job finishes it updates
the new tree with its output and that is used for any subsequent
redraws. When the status interval expires, the new tree is moved to the
old so that all jobs are run again.

This fixes the "#(echo %H:%M:%S)" problem which would lead to thousands
of identical persistent jobs and high memory use (this can still be
achieved by adding "sleep 30" but that is much less likely to happen by
accident).


# 1.70 03-Jan-2011 nicm

Handle a # at the end of a replacement string (such as status-left)
correctly. Found by Thomas Adam.


# 1.69 01-Jan-2011 nicm

Move the user-visible parts of all options (names, types, limit, default
values) together into one set of tables in options-table.c. Also clean
up and simplify cmd-set-options.c and move a common print function into
option-table.c.


# 1.68 30-Dec-2010 nicm

Change from a per-session stack of buffers to one global stack which is
much more convenient and also simplifies lot of code. This renders
copy-buffer useless and makes buffer-limit now a server option.

By Tiago Cunha.


# 1.67 30-Dec-2010 nicm

Add a function to create window flags rather than doing the same thing
in two places. From Thomas Adam.


# 1.66 11-Dec-2010 nicm

Oops, these functions return a const char *, so make the local variable
const as well.


# 1.65 11-Dec-2010 nicm

Make the prompt history global for all clients which is much more useful than per-client history.


# 1.64 06-Dec-2010 nicm

Add an option to alert (monitor) for silence (lack of activity) in a
window. From Thomas Adam.


Revision tags: OPENBSD_4_8_BASE
# 1.63 21-Jun-2010 nicm

Having a list of winlinks->alerts for each session is stupid, just store
the alert flags directly in the winlink itself.


# 1.62 14-May-2010 nicm

Colour+attribute options for status line alerts, from Alex Alexander.


# 1.61 31-Mar-2010 nicm

Don't accept keys with modifiers as input. Fixes crash reported by Brian
R Landy.


# 1.60 27-Mar-2010 nicm

Don't leak job command in #().


# 1.59 22-Mar-2010 nicm

Dead functions, lint.


Revision tags: OPENBSD_4_7_BASE
# 1.58 27-Jan-2010 nicm

Calculate offset correctly, fixes incorrect offset and prevents crash when
status-left is empty. From Micah Cowan.


# 1.57 26-Jan-2010 nicm

Actually use the copy made when no newline is found, from martynas@.


# 1.56 14-Dec-2009 nicm

Add server options to completion as well.


# 1.55 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.54 03-Dec-2009 nicm

Eliminate duplicate code and ease the passage for server-wide options by adding
a -w flag to set-option and show-options and making setw and showw aliases to
set -w and show -w.

Note: setw and showw are still there, but now aliases for set -w and show -w.


# 1.53 26-Nov-2009 nicm

Tidy up various bits of the paste code, make the data buffer char * and add
comments.


# 1.52 26-Nov-2009 nicm

Remove a couple of unused arguments where possible, and add /* ARGSUSED */ to
the rest to reduce lint output.


# 1.51 20-Nov-2009 nicm

Display UTF-8 properly in status line messages and prompt. Cursor handling is
still way off though.


# 1.50 20-Nov-2009 nicm

Remove oldest messages from log when limit is hit, not newest.


# 1.49 19-Nov-2009 nicm

Get some brackets in the right place so ## works. Also fix a space in a
comment.


# 1.48 19-Nov-2009 nicm

Change status line drawing to create the window list in a separate screen and
then copy it into the status line screen. This allows UTF-8 in window names and
fixes some problems with #[] in window-status-format.


# 1.47 19-Nov-2009 nicm

Two new options, window-status-format and window-status-current-format, which
allow the format of each window in the status line window list to be controlled
using similar # sequences as status-left/right.

This diff also moves part of the way towards UTF-8 support in window names but
it isn't quite there yet.


# 1.46 19-Nov-2009 nicm

Tidy up by breaking the # replacement code into a separate function, also add a
few comments.


# 1.45 19-Nov-2009 nicm

Don't interpret #() for display-message, it usually doesn't make sense and may
leak commands.


# 1.44 18-Nov-2009 nicm

Add a per-client log of status line messages displayed while that client
exists. A new message-limit session option sets the maximum number of entries
and a command, show-messages, shows the log (bound to ~ by default).

This (and prompt history) might be better as a single global log but until
there are global options it is easier for them to be per client.


# 1.43 17-Nov-2009 nicm

Permit top-bit-set characters to be entered in the status line. They could
already be set from the shell and are just passed through when printing (so
invisible characters or displaying on terminals with different character sets
may cause problems).

Note that entering UTF-8 may not work and in any case currently the status line
cannot display it correctly (outside of status-left/status-right).


# 1.42 04-Nov-2009 nicm

Use timeout events for the identify and message timers.


# 1.41 04-Nov-2009 nicm

Switch jobs over to use a bufferevent.


# 1.40 04-Nov-2009 nicm

Unused (but assigned to) variable, found by lint.


# 1.39 01-Nov-2009 nicm

Add a flag for jobs that shouldn't be freed after they've died and use it for
status jobs, then only kill those jobs when status-left, status-right or
set-titles-string is changed.

Fixes problems with changing options from inside #().


# 1.38 10-Oct-2009 nicm

Rather than running status-left, status-right and window title #() with popen
immediately every redraw, queue them up and run them in the background,
starting each once every status-interval. The actual status line uses the
output from the last run.

This brings several advantages:

- tmux itself may be called from inside #() without causing the server to hang;
- likewise, sleep or similar doesn't cause the server to block;
- commands aren't run excessively often when redrawing;
- commands shared by status-left and status-right, or used multiple times, will
only be run once.

run-shell and if-shell still use system()/popen() but will be changed over to
use this too later.


# 1.37 10-Oct-2009 nicm

Add "grouped sessions" which have independent name, options, current window and
so on but where the linked windows are synchronized (ie creating, killing
windows and so on are mirrored between the sessions). A grouped session may be
created by passing -t to new-session.

Had this around for a while, tested by a couple of people.


# 1.36 23-Sep-2009 nicm

Remove PROMPT_HIDDEN code which is now unused.


# 1.35 23-Sep-2009 nicm

Remove the internal tmux locking and instead detach each client and run the
command specified by a new option "lock-command" (by default "lock -np") in
each client.

This means each terminal has to be unlocked individually but simplifies the
code and allows the system password to be used to unlock.

Note that the set-password command is gone, so it will need to be removed from
configuration files, and the -U command line flag has been removed.

This is the third protocol version change so again it is best to stop the tmux
server before upgrading.


# 1.34 20-Sep-2009 nicm

Regularise some fatal messages.


# 1.33 10-Sep-2009 nicm

Permit options such as status-bg to be configured using the entire 256 colour
palette by setting "colour0" to "colour255".


# 1.32 07-Sep-2009 nicm

Give each paste buffer a size member instead of requiring them to be
zero-terminated.


# 1.31 07-Sep-2009 nicm

Permit embedded colour and attributes in status-left and status-right using new
#[] special characters, for example #[fg=red,bg=blue,blink].


# 1.30 02-Sep-2009 nicm

Add a transpose-chars command in edit mode (C-t in emacs mode only). From Kalle
Olavi Niemitalo.


# 1.29 01-Sep-2009 nicm

Use "Password:" with no space for password prompts and don't display a *s for
the password, like pretty much everything else. From martynas@ with minor
tweaks by me.


# 1.28 31-Aug-2009 nicm

Add a new display-panes command, with two options (display-panes-colour and
display-panes-time), which displays a visual indication of the number of each
pane.


# 1.27 19-Aug-2009 nicm

Extend command-prompt with a -p option which is a comma-separated list of one
or more prompts to present in order.

The responses to the prompt are replaced in the template string: %% are
replaced in order, so the first prompt replaces the first %%, the second
replaces the second, and so on. In addition, %1 up to %9 are replaced with the
responses to the first the ninth prompts

The default template is "%1" so the response to the first prompt is processed
as a command.

Note that this changes the behaviour for %% so if there is only one prompt,
only the first %% will be replaced. Templates such as "neww -n '%%' 'ssh %%'"
should be changed to "neww -n '%1' 'ssh %1'".

From Tiago Cunha.


# 1.26 18-Aug-2009 nicm

Add a "delete line" key when editing in the status line or the search up/down
prompt. C-u with emacs keys, d with vi.


# 1.25 13-Aug-2009 nicm

Switch the prompt code to return an empty string when the user enters no
response and reserve NULL for an explicit cancel. Change all callbacks to treat
them the same so no functional change.

Also add cancel key bindings to emacs mode which were missing.


# 1.24 08-Aug-2009 nicm

Options to set the colours and attributes for status-left/-right. From Thomas
Adam, thanks.


# 1.23 05-Aug-2009 nicm

If colours are not supported by the terminal, try to emulate a coloured
background by setting or clearing the reverse attribute.

This makes a few applications which don't use the reverse attribute themselves
a little happier, and allows the status, message and mode options to have
default attributes and fg/bg options that work as expected when set as reverse.


# 1.22 30-Jul-2009 nicm

Plug some memory leaks.


# 1.21 28-Jul-2009 nicm

Next step towards customisable mode keys: build each default table of keys into
a named tree on start and use that for lookups. Also add command to string
translation tables and modify list-keys to show the the mode key bindings (new
-t argument).


# 1.20 27-Jul-2009 nicm

Change mode key bindings from big switches into a set of tables. Rather than
lumping them all together, split editing keys from those used in choice/more
mode and those for copy/scroll mode.

Tidier and clearer, and the first step towards customisable mode keys.


# 1.19 27-Jul-2009 nicm

Get rid of empty mode_key_free function.


# 1.18 27-Jul-2009 nicm

Add a key to delete to end of line at the prompt (^K in emacs mode, C/D in vi).

From Kalle Olavi Niemitalo.


# 1.17 26-Jul-2009 nicm

Calculate the space available for the prompt buffer and the cursor position
correctly, and make it work when the screen is not wide enough.

Noticed by Kalle Olavi Niemitalo.


# 1.16 21-Jul-2009 nicm

Remove a couple of unused functions and fix a type ("FALLTHOUGH"), found by
lint.


# 1.15 20-Jul-2009 nicm

Add a status-justify option to allow the window list in the status line to be
positioned at the left, centre, or right.


# 1.14 20-Jul-2009 nicm

New options, window-status-current-{fg,bg,attr}, to set the fg, bg and
attributes with which the current window is shown in the status line. From
Johan Friis, thanks.


# 1.13 17-Jul-2009 nicm

- New command display-message (alias display) to display a message in the
status line (bound to "i" and displays the current window and time by
default). The same substitutions are applied as for status-left/right.
- Add support for including the window index (#I), pane index (#P) and window
name (#W) in the message, and status-left or status-right.
- Bump protocol version.

From Tiago Cunha, thanks!


# 1.12 17-Jul-2009 nicm

Memory could be leaked if a second prompt or message appeared while another was
still present, so add a separate prompt free callback and make the _clear
function responsible for calling it if necessary (rather than the individual
prompt callbacks). Also make both messages and prompts clear any existing when
a new is set.

In addition, the screen could be modified while the prompt is there, restore
the redraw-entire-screen behaviour on prompt clear; add a comment as a
reminder.


# 1.11 16-Jul-2009 nicm

Remove some duplicate code that was causing the status line to be redrawn even
when it hadn't changed.


# 1.10 15-Jul-2009 nicm

Make status_message_set a variadic printf-like function. No functional change -
helpful for a couple of things coming soon.


# 1.9 15-Jul-2009 nicm

Having to update NSETOPTION/NSETWINDOWOPTION when adding new options is a bit
annoying and it is only use for iterating, so use a sentinel to mark the end of
each array instead. Different fix for a problem pointed out by Kalle Olavi
Niemitalo.


# 1.8 14-Jul-2009 nicm

For some reason when clearing status/message it was redrawing the entire client
not just the status line. Changing this also revealed the check for the status
line was incorrect when drawing the pane.


# 1.7 14-Jul-2009 nicm

Instead of faking up a status line in status_redraw, use the same code to
redraw it as to draw the entire screen, just skip all lines but the last.

This makes horizontal split redraw properly when the status line is off.


# 1.6 12-Jul-2009 nicm

Add a "back to indentation" key in copy mode to move the cursor to the first
non-whitespace character. ^ with vi and M-m with emacs key bindings. Another
from Kalle Olavi Niemitalo, thanks.


Revision tags: OPENBSD_4_6_BASE
# 1.5 26-Jun-2009 nicm

Status line fixes: don't truncate status-right now the length calculation is
done for UTF-8, limit to the maximum length correctly when printing, and always
print a space even if the left string is longer than the width available.


# 1.4 04-Jun-2009 nicm

If the prompt is hidden or a password is sent with -U, zero it before freeing
it.


# 1.3 03-Jun-2009 nicm

New session option, status-utf8, to control the interpretation of top-bit-set
characters in status-left and status-right (if on, they are treated as UTF-8;
otherwise passed through).


# 1.2 03-Jun-2009 nicm

Add a UTF-8 aware string length function and make UTF-8 in
status-left/status-right work properly. At the moment any top-bit-set
characters are assumed to be UTF-8: a status-utf8 option to configure this will
come shortly.


# 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.181 29-Aug-2018 nicm

Keep any text killed in the command prompt with C-w and yank it with
C-y, only use the top buffer if no text has previously been killed. This
and previous change promped by discussion with kn@.


# 1.180 29-Aug-2018 nicm

Add C-Left and C-Right as aliases for M-b and M-f.


# 1.179 22-Aug-2018 nicm

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


# 1.178 20-Aug-2018 nicm

Move offset of window list into status struct.


# 1.177 19-Aug-2018 nicm

Add a client redraw-window flag instead of the redraw-all flag and for
all just use the three flags together (window, borders, status).


Revision tags: OPENBSD_6_3_BASE
# 1.176 22-Feb-2018 nicm

Remove an unused variable.


# 1.175 05-Feb-2018 nicm

Add struct status_line to hold status line members of struct client, not
used yet but will be soon. From Thomas Adam.


# 1.174 01-Jan-2018 nicm

Add C-g at command prompt for emacs people, GitHub issue 1213.


# 1.173 27-Dec-2017 nicm

Draw command prompt correctly with status line off.


# 1.172 18-Dec-2017 nicm

Remove unused variable from Thomas Adam.


# 1.171 02-Nov-2017 nicm

Add a "fast" version of screen_write_copy for tree mode that doesn't do
all the checks and selection and marking stuff needed for copy mode.


# 1.170 20-Oct-2017 nicm

Clear status line with spaces again so reverse works, spotted by sthen.


# 1.169 16-Oct-2017 nicm

Infrastructure for drawing status lines of more than one line in height,
still only one is allowed but this lets tmux draw bigger ones.


Revision tags: OPENBSD_6_2_BASE
# 1.168 29-May-2017 nicm

Add a flag to stop the prompt input being expanded.


# 1.167 29-May-2017 nicm

Store a copy of the old status line, will be needed soon for new choose mode.


# 1.166 17-May-2017 nicm

Tidy command prompt callbacks and pass in the client.


# 1.165 03-May-2017 nicm

Add a format for the last search string in copy mode and fix the prompt
so it can work when in -I, suggested by Suraj N Kurapati.


# 1.164 01-May-2017 nicm

In order that people can use formats like #D in #() in the status line
and not have to wait for an update when they change pane, we allow
commands to run more than once a second if the expanded form
changes. Unfortunately this can mean them being run far too often
(pretty much continually) when multiple clients exist, because some
formats (including #D) will always differ between clients.

To avoid this, give each client its own tree of jobs which means that
the same command will be different instances for each client - similar
to how we have the tag to separate commands for different panes.

GitHub issue 889; test case reported by Paul Johnson.


# 1.163 22-Apr-2017 nicm

Memory leak from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.162 09-Feb-2017 nicm

Break the message storage function into its own function, useful for
debugging.


# 1.161 03-Feb-2017 nicm

Cache status line position to reduce option lookups during output.


# 1.160 03-Feb-2017 nicm

Add a window or pane id "tag" to each format tree and use it to separate
jobs, this means that if the same job is used for different windows or
panes (for example in pane-border-format), it will be run separately for
each pane.


# 1.159 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.158 06-Jan-2017 nicm

Incremental search in copy mode (on for emacs keys by default) - much
the same as normal searching but updates the cursor position and marked
search terms as you type. C-r and C-s in the prompt repeat the search,
once finished searching (with Enter), N and n work as before.


# 1.157 05-Jan-2017 nicm

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


# 1.156 07-Dec-2016 nicm

Do not clear the prompt when a message is shown, just leave it around and
return to it when the message is finished.


# 1.155 12-Oct-2016 nicm

Drop the edit mode key tables and just use fixed key bindings for the
command prompt.


# 1.154 12-Oct-2016 nicm

The repeat prompt in both emacs and vi (and the old one in tmux) doesn't
support line editing and instead executes a command as soon as a
non-number key is pressed. Add a -N flag to command-prompt for the same
in copy mode. Reported by Theo Buehler.


# 1.153 11-Oct-2016 nicm

Fundamental change to how copy mode key bindings work:

The vi-copy and emacs-copy mode key tables are gone, and instead copy
mode commands are bound in one of two normal key tables ("copy-mode" or
"copy-mode-vi"). Keys are bound to "send-keys -X copy-mode-command". So:

bind -temacs-copy C-Up scroll-up
bind -temacs-copy -R5 WheelUpPane scroll-up

Becomes:

bind -Tcopy-mode C-Up send -X scroll-up
bind -Tcopy-mode WheelUpPane send -N5 -X scroll-up

This allows the full command parser and command set to be used - for
example, we can use the normal command prompt for searching, jumping,
and so on instead of a custom one:

bind -Tcopy-mode C-r command-prompt -p'search up' "send -X search-backward '%%'"

command-prompt also gets a -1 option to only require on key press, which
is needed for jumping.

The plan is to get rid of mode keys entirely, so more to come eventually.


# 1.152 11-Oct-2016 nicm

Support UTF-8 entry into the command prompt.


# 1.151 10-Oct-2016 nicm

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


# 1.150 12-Sep-2016 nicm

Allow repeat count to be specified in mode key tables with bind-key -R,
and set the default repeat count to 5 for WheelUp and WheelDown in
copy-mode.


Revision tags: OPENBSD_6_0_BASE
# 1.149 06-Jun-2016 nicm

Allow #[] in window-status-separator.


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

I no longer use my SourceForge address so replace it.


# 1.147 01-Jan-2016 nicm

Don't rely on a calculation wrapping when applying message-limit, and
break out of the loop early. From Nicolas Viennot.


# 1.146 11-Dec-2015 nicm

Style nits and line wrapping of function declarations.


# 1.145 11-Dec-2015 nicm

Add cmdq as an argument to format_create and add a format for the
command name (will also be used for more later).


# 1.144 08-Dec-2015 nicm

Remove format_create_flags and just pass flags to format_create.


# 1.143 22-Nov-2015 tim

If display-time is set to 0, show status messages until a key is pressed;
OK nicm@


# 1.142 20-Nov-2015 nicm

Instead of separate tables for different types of options, give each
option a scope type (server, session, window) in one table.


# 1.141 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.140 13-Nov-2015 nicm

Long overdue change to the way we store cells in the grid: now, instead
of storing a full grid_cell with UTF-8 data and everything, store a new
type grid_cell_entry. This can either be the cell itself (for ASCII
cells), or an offset into an extended array (per line) for UTF-8
data.

This avoid a large (8 byte) overhead on non-UTF-8 cells (by far the
majority for most users) without the complexity of the shadow array we
had before. Grid memory without any UTF-8 is about half.

The disadvantage that cells can no longer be modified in place and need
to be copied out of the grid and back but it turned out to be lot less
complicated than I expected.


# 1.139 12-Nov-2015 nicm

Nuke the utf8 and status-utf8 options and make tmux only a UTF-8
terminal. We still support non-UTF-8 terminals outside tmux, but inside
it is always UTF-8 (as when the utf8 and status-utf8 options were on).


# 1.138 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.137 27-Oct-2015 nicm

Move struct options into options.c.


# 1.136 20-Oct-2015 nicm

Use client pointer not file descriptor in logging.


# 1.135 14-Sep-2015 nicm

Make refresh-client force update of jobs, from Sina Siadat.


# 1.134 29-Aug-2015 nicm

Move struct paste_buffer out of tmux.h.


# 1.133 28-Aug-2015 nicm

Run status update on a per-client timer at status-interval.


Revision tags: OPENBSD_5_8_BASE
# 1.132 29-Jul-2015 nicm

status_out and associated data structures are no longer used.


# 1.131 28-Jul-2015 nicm

Tidy up the way terminals are described and move some structs out of tmux.h.


# 1.130 20-Jul-2015 nicm

Add an option (history-file) for a file to save/restore command prompt
history, from Olof-Joachim Frahm.


# 1.129 27-May-2015 nicm

Move the jobs output cache into the formats code so that #() work more
generally (for example, again working in set-titles-string).


# 1.128 06-May-2015 nicm

Remove ARRAY_* from history and expand completion to complete a) layout
names and b) targets beginning with -t or -s.


# 1.127 25-Apr-2015 nicm

Make message log a TAILQ.


# 1.126 24-Apr-2015 nicm

Set working directory for run-shell and if-shell.


# 1.125 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_7_BASE
# 1.124 06-Feb-2015 nicm

Use the same time for both calls to format_expand_time.


# 1.123 06-Feb-2015 nicm

status_replace can now become local to status.c and it no longer needs
the jobsflag argument. While here there is no need to repeat work that
format_defaults already does.


# 1.122 06-Feb-2015 nicm

Add format_expand_time and use it instead of status_replace where
command execution is not needed.


# 1.121 05-Feb-2015 nicm

Wrap all the individual format_* calls in a single format_defaults
functions.


# 1.120 01-Feb-2015 nicm

Remove two unused arguments from status_replace.


# 1.119 20-Jan-2015 sthen

typo in comment ;) ok nicm


# 1.118 05-Nov-2014 nicm

Do not put a space between status-left/status-right and the window list,
instead move the space into the defaults for the options (so status-left
now defaults to "[#S] ". From Balazs Kezes.


# 1.117 20-Oct-2014 nicm

Better format for printf format attributes.


# 1.116 08-Oct-2014 nicm

Add xreallocarray and remove nmemb argument from xrealloc.


# 1.115 02-Oct-2014 nicm

Take account of window-status-separator when checking window position,
based on diff from Balazs Kezes.


Revision tags: OPENBSD_5_6_BASE
# 1.114 24-Apr-2014 nicm

There is no longer a need for a paste_stack struct or for global_buffers
to be global. Move to paste.c.


# 1.113 17-Apr-2014 nicm

Remove the monitor-content option and associated bits and bobs. It's
never worked very well. If there is a big demand for it to return, will
consider better ways to do it.


# 1.112 02-Apr-2014 nicm

Do not replace ## with # in status_replace1 because it'll be done later
by the format code.


# 1.111 31-Mar-2014 nicm

Make message-limit a server option.


Revision tags: OPENBSD_5_5_BASE
# 1.110 14-Feb-2014 nicm

Style nit - no space between function name and bracket.


# 1.109 14-Feb-2014 nicm

Check for NULL session and whatnot in status_replace, from Thomas Adam.


# 1.108 28-Jan-2014 nicm

Allow replacing each of the many sets of separate foo-{fg,bg,attr}
options with a single foo-style option. For example:

set -g status-fg yellow
set -g status-bg red
set -g status-attr blink

Becomes:

set -g status-style fg=yellow,bg=red,blink

The -a flag to set can be used to add to rather than replace a style. So:

set -g status-bg red

Becomes:

set -ag status-style bg=red

Currently this is fully backwards compatible (all *-{fg,bg,attr} options
remain) but the plan is to deprecate them over time.

From Tiago Cunha.


Revision tags: OPENBSD_5_4_BASE
# 1.107 05-Jul-2013 nicm

Whitespace nits, from Ben Boeckel.


# 1.106 05-Jul-2013 nicm

Act like vi(1) when moving words, from Ben Boeckel.


# 1.105 05-Jul-2013 nicm

Implement s, S, C mode switch commands in vi(1) mode, from Ben Boeckel.


# 1.104 31-May-2013 nicm

Demote the old single-character replacement variables (#S and friends)
to aliases of formats. From Tiago Cunha.


# 1.103 25-Mar-2013 nicm

Extend jobs to support writing and use that for copy-pipe instead of
popen, from Chris Johnsen.


# 1.102 22-Mar-2013 nicm

evbuffer_readline returns allocated storage, don't leak it.


# 1.101 22-Mar-2013 nicm

Add copy-pipe mode command to copy selection and also pipe to a command.


# 1.100 22-Mar-2013 nicm

No more lint means no more ARGSUSED.


# 1.99 21-Mar-2013 nicm

Aargh. Spaces -> tabs.


# 1.98 21-Mar-2013 nicm

Do not leak formats in status_replace.


# 1.97 21-Mar-2013 nicm

Add a format client_prefix which is 1 if prefix key has been
pressed, used for example #{?client_prefix,X,Y}. Also a few extra
server_client_status needed.


# 1.96 21-Mar-2013 nicm

Allow formats in status options.


Revision tags: OPENBSD_5_3_BASE
# 1.95 27-Nov-2012 nicm

Add window-status-last-* options, from Boris Faure.


Revision tags: OPENBSD_5_2_BASE
# 1.94 10-Jul-2012 nicm

xfree is not particularly helpful, remove it. From Thomas Adam.


# 1.93 09-Jul-2012 nicm

Move a NULL check inside a function, from Tiago Cunha.


# 1.92 29-Apr-2012 nicm

Use int not u_char for colours from options since they may have bit 8
set to mark them as 256-colour. Reported by Chris Johnson.


# 1.91 23-Apr-2012 nicm

Add window-status-separator option, from Thomas Adam.


# 1.90 17-Mar-2012 nicm

Check event_initialized before event_del if event may not have been set
up; libevent2 complains about this. Reported by Moriyoshi Koizumi.


# 1.89 04-Mar-2012 nicm

Add A and I keys for vi status line editing.


# 1.88 03-Mar-2012 nicm

The wlmouse offset should be part of the client, not the server. From
Ailin Nemui.


Revision tags: OPENBSD_5_1_BASE
# 1.87 29-Jan-2012 nicm

Add an option to move the status line to the top of the screen,
requested by many.


# 1.86 26-Jan-2012 nicm

Terminate strftime buffer properly even if a really long format string
is given, from Tiago Cunha.


# 1.85 26-Jan-2012 nicm

Fix memory leak in error path, from Tiago Cunha.


# 1.84 20-Jan-2012 nicm

Add some trivial additional status line attributes from jwcxz at users
dot sourceforge dot net.


# 1.83 20-Jan-2012 nicm

Add space movement keys for vi mode in the status line from Ben Boeckel.


# 1.82 01-Dec-2011 nicm

Make M-f and M-b work the same at the command prompt as in copy mode,
pointed out by Romain Francoise.


# 1.81 15-Nov-2011 nicm

Add word movement and editing command for command prompt editing, from
Ben Boeckel.


# 1.80 15-Nov-2011 nicm

Make window_pane_index work the same as window_index, from Ben Boeckel.


# 1.79 05-Nov-2011 nicm

Option to change status line (message) background when using vi keys and
in command mode. From Ben Boeckel.


# 1.78 20-Aug-2011 nicm

Fix a couple of memory leaks, from marcel partap.


Revision tags: OPENBSD_5_0_BASE
# 1.77 08-Jul-2011 nicm

Make confirm-before prompt customizable with -p option like
command-prompt. Also move responsibility for calling status_replace into
status_prompt_{set,update} and add #W and #P to the default kill-window
and kill-pane prompts. By Tiago Cunha.


# 1.76 02-Jul-2011 nicm

Allow the initial context on prompts to be set with the new -I option to
command-prompt. From Tiago Cunha.


# 1.75 29-Apr-2011 nicm

Only redraw the status line on command update, not the entire client
(big DOH).


# 1.74 24-Apr-2011 nicm

Provide #h for short hostname (no domain) from Michal Mazurek.


# 1.73 18-Apr-2011 nicm

Add an option (mouse-select-window) which allows the mouse to be used by
clicking on the status line, written by hsim at gmx dot li.


# 1.72 29-Mar-2011 nicm

Change -t on display-message to be target-pane for the #[A-Z]
replacements and add -c as target-client.


Revision tags: OPENBSD_4_9_BASE
# 1.71 26-Jan-2011 nicm

Simplify the way jobs work and drop the persist type, so all jobs are
fire-and-forget.

Status jobs now managed with two trees of output (new and old), rather
than storing the output in the jobs themselves. When the status line is
processed any jobs which don't appear in the new tree are started and
the output from the old tree displayed. When a job finishes it updates
the new tree with its output and that is used for any subsequent
redraws. When the status interval expires, the new tree is moved to the
old so that all jobs are run again.

This fixes the "#(echo %H:%M:%S)" problem which would lead to thousands
of identical persistent jobs and high memory use (this can still be
achieved by adding "sleep 30" but that is much less likely to happen by
accident).


# 1.70 03-Jan-2011 nicm

Handle a # at the end of a replacement string (such as status-left)
correctly. Found by Thomas Adam.


# 1.69 01-Jan-2011 nicm

Move the user-visible parts of all options (names, types, limit, default
values) together into one set of tables in options-table.c. Also clean
up and simplify cmd-set-options.c and move a common print function into
option-table.c.


# 1.68 30-Dec-2010 nicm

Change from a per-session stack of buffers to one global stack which is
much more convenient and also simplifies lot of code. This renders
copy-buffer useless and makes buffer-limit now a server option.

By Tiago Cunha.


# 1.67 30-Dec-2010 nicm

Add a function to create window flags rather than doing the same thing
in two places. From Thomas Adam.


# 1.66 11-Dec-2010 nicm

Oops, these functions return a const char *, so make the local variable
const as well.


# 1.65 11-Dec-2010 nicm

Make the prompt history global for all clients which is much more useful than per-client history.


# 1.64 06-Dec-2010 nicm

Add an option to alert (monitor) for silence (lack of activity) in a
window. From Thomas Adam.


Revision tags: OPENBSD_4_8_BASE
# 1.63 21-Jun-2010 nicm

Having a list of winlinks->alerts for each session is stupid, just store
the alert flags directly in the winlink itself.


# 1.62 14-May-2010 nicm

Colour+attribute options for status line alerts, from Alex Alexander.


# 1.61 31-Mar-2010 nicm

Don't accept keys with modifiers as input. Fixes crash reported by Brian
R Landy.


# 1.60 27-Mar-2010 nicm

Don't leak job command in #().


# 1.59 22-Mar-2010 nicm

Dead functions, lint.


Revision tags: OPENBSD_4_7_BASE
# 1.58 27-Jan-2010 nicm

Calculate offset correctly, fixes incorrect offset and prevents crash when
status-left is empty. From Micah Cowan.


# 1.57 26-Jan-2010 nicm

Actually use the copy made when no newline is found, from martynas@.


# 1.56 14-Dec-2009 nicm

Add server options to completion as well.


# 1.55 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.54 03-Dec-2009 nicm

Eliminate duplicate code and ease the passage for server-wide options by adding
a -w flag to set-option and show-options and making setw and showw aliases to
set -w and show -w.

Note: setw and showw are still there, but now aliases for set -w and show -w.


# 1.53 26-Nov-2009 nicm

Tidy up various bits of the paste code, make the data buffer char * and add
comments.


# 1.52 26-Nov-2009 nicm

Remove a couple of unused arguments where possible, and add /* ARGSUSED */ to
the rest to reduce lint output.


# 1.51 20-Nov-2009 nicm

Display UTF-8 properly in status line messages and prompt. Cursor handling is
still way off though.


# 1.50 20-Nov-2009 nicm

Remove oldest messages from log when limit is hit, not newest.


# 1.49 19-Nov-2009 nicm

Get some brackets in the right place so ## works. Also fix a space in a
comment.


# 1.48 19-Nov-2009 nicm

Change status line drawing to create the window list in a separate screen and
then copy it into the status line screen. This allows UTF-8 in window names and
fixes some problems with #[] in window-status-format.


# 1.47 19-Nov-2009 nicm

Two new options, window-status-format and window-status-current-format, which
allow the format of each window in the status line window list to be controlled
using similar # sequences as status-left/right.

This diff also moves part of the way towards UTF-8 support in window names but
it isn't quite there yet.


# 1.46 19-Nov-2009 nicm

Tidy up by breaking the # replacement code into a separate function, also add a
few comments.


# 1.45 19-Nov-2009 nicm

Don't interpret #() for display-message, it usually doesn't make sense and may
leak commands.


# 1.44 18-Nov-2009 nicm

Add a per-client log of status line messages displayed while that client
exists. A new message-limit session option sets the maximum number of entries
and a command, show-messages, shows the log (bound to ~ by default).

This (and prompt history) might be better as a single global log but until
there are global options it is easier for them to be per client.


# 1.43 17-Nov-2009 nicm

Permit top-bit-set characters to be entered in the status line. They could
already be set from the shell and are just passed through when printing (so
invisible characters or displaying on terminals with different character sets
may cause problems).

Note that entering UTF-8 may not work and in any case currently the status line
cannot display it correctly (outside of status-left/status-right).


# 1.42 04-Nov-2009 nicm

Use timeout events for the identify and message timers.


# 1.41 04-Nov-2009 nicm

Switch jobs over to use a bufferevent.


# 1.40 04-Nov-2009 nicm

Unused (but assigned to) variable, found by lint.


# 1.39 01-Nov-2009 nicm

Add a flag for jobs that shouldn't be freed after they've died and use it for
status jobs, then only kill those jobs when status-left, status-right or
set-titles-string is changed.

Fixes problems with changing options from inside #().


# 1.38 10-Oct-2009 nicm

Rather than running status-left, status-right and window title #() with popen
immediately every redraw, queue them up and run them in the background,
starting each once every status-interval. The actual status line uses the
output from the last run.

This brings several advantages:

- tmux itself may be called from inside #() without causing the server to hang;
- likewise, sleep or similar doesn't cause the server to block;
- commands aren't run excessively often when redrawing;
- commands shared by status-left and status-right, or used multiple times, will
only be run once.

run-shell and if-shell still use system()/popen() but will be changed over to
use this too later.


# 1.37 10-Oct-2009 nicm

Add "grouped sessions" which have independent name, options, current window and
so on but where the linked windows are synchronized (ie creating, killing
windows and so on are mirrored between the sessions). A grouped session may be
created by passing -t to new-session.

Had this around for a while, tested by a couple of people.


# 1.36 23-Sep-2009 nicm

Remove PROMPT_HIDDEN code which is now unused.


# 1.35 23-Sep-2009 nicm

Remove the internal tmux locking and instead detach each client and run the
command specified by a new option "lock-command" (by default "lock -np") in
each client.

This means each terminal has to be unlocked individually but simplifies the
code and allows the system password to be used to unlock.

Note that the set-password command is gone, so it will need to be removed from
configuration files, and the -U command line flag has been removed.

This is the third protocol version change so again it is best to stop the tmux
server before upgrading.


# 1.34 20-Sep-2009 nicm

Regularise some fatal messages.


# 1.33 10-Sep-2009 nicm

Permit options such as status-bg to be configured using the entire 256 colour
palette by setting "colour0" to "colour255".


# 1.32 07-Sep-2009 nicm

Give each paste buffer a size member instead of requiring them to be
zero-terminated.


# 1.31 07-Sep-2009 nicm

Permit embedded colour and attributes in status-left and status-right using new
#[] special characters, for example #[fg=red,bg=blue,blink].


# 1.30 02-Sep-2009 nicm

Add a transpose-chars command in edit mode (C-t in emacs mode only). From Kalle
Olavi Niemitalo.


# 1.29 01-Sep-2009 nicm

Use "Password:" with no space for password prompts and don't display a *s for
the password, like pretty much everything else. From martynas@ with minor
tweaks by me.


# 1.28 31-Aug-2009 nicm

Add a new display-panes command, with two options (display-panes-colour and
display-panes-time), which displays a visual indication of the number of each
pane.


# 1.27 19-Aug-2009 nicm

Extend command-prompt with a -p option which is a comma-separated list of one
or more prompts to present in order.

The responses to the prompt are replaced in the template string: %% are
replaced in order, so the first prompt replaces the first %%, the second
replaces the second, and so on. In addition, %1 up to %9 are replaced with the
responses to the first the ninth prompts

The default template is "%1" so the response to the first prompt is processed
as a command.

Note that this changes the behaviour for %% so if there is only one prompt,
only the first %% will be replaced. Templates such as "neww -n '%%' 'ssh %%'"
should be changed to "neww -n '%1' 'ssh %1'".

From Tiago Cunha.


# 1.26 18-Aug-2009 nicm

Add a "delete line" key when editing in the status line or the search up/down
prompt. C-u with emacs keys, d with vi.


# 1.25 13-Aug-2009 nicm

Switch the prompt code to return an empty string when the user enters no
response and reserve NULL for an explicit cancel. Change all callbacks to treat
them the same so no functional change.

Also add cancel key bindings to emacs mode which were missing.


# 1.24 08-Aug-2009 nicm

Options to set the colours and attributes for status-left/-right. From Thomas
Adam, thanks.


# 1.23 05-Aug-2009 nicm

If colours are not supported by the terminal, try to emulate a coloured
background by setting or clearing the reverse attribute.

This makes a few applications which don't use the reverse attribute themselves
a little happier, and allows the status, message and mode options to have
default attributes and fg/bg options that work as expected when set as reverse.


# 1.22 30-Jul-2009 nicm

Plug some memory leaks.


# 1.21 28-Jul-2009 nicm

Next step towards customisable mode keys: build each default table of keys into
a named tree on start and use that for lookups. Also add command to string
translation tables and modify list-keys to show the the mode key bindings (new
-t argument).


# 1.20 27-Jul-2009 nicm

Change mode key bindings from big switches into a set of tables. Rather than
lumping them all together, split editing keys from those used in choice/more
mode and those for copy/scroll mode.

Tidier and clearer, and the first step towards customisable mode keys.


# 1.19 27-Jul-2009 nicm

Get rid of empty mode_key_free function.


# 1.18 27-Jul-2009 nicm

Add a key to delete to end of line at the prompt (^K in emacs mode, C/D in vi).

From Kalle Olavi Niemitalo.


# 1.17 26-Jul-2009 nicm

Calculate the space available for the prompt buffer and the cursor position
correctly, and make it work when the screen is not wide enough.

Noticed by Kalle Olavi Niemitalo.


# 1.16 21-Jul-2009 nicm

Remove a couple of unused functions and fix a type ("FALLTHOUGH"), found by
lint.


# 1.15 20-Jul-2009 nicm

Add a status-justify option to allow the window list in the status line to be
positioned at the left, centre, or right.


# 1.14 20-Jul-2009 nicm

New options, window-status-current-{fg,bg,attr}, to set the fg, bg and
attributes with which the current window is shown in the status line. From
Johan Friis, thanks.


# 1.13 17-Jul-2009 nicm

- New command display-message (alias display) to display a message in the
status line (bound to "i" and displays the current window and time by
default). The same substitutions are applied as for status-left/right.
- Add support for including the window index (#I), pane index (#P) and window
name (#W) in the message, and status-left or status-right.
- Bump protocol version.

From Tiago Cunha, thanks!


# 1.12 17-Jul-2009 nicm

Memory could be leaked if a second prompt or message appeared while another was
still present, so add a separate prompt free callback and make the _clear
function responsible for calling it if necessary (rather than the individual
prompt callbacks). Also make both messages and prompts clear any existing when
a new is set.

In addition, the screen could be modified while the prompt is there, restore
the redraw-entire-screen behaviour on prompt clear; add a comment as a
reminder.


# 1.11 16-Jul-2009 nicm

Remove some duplicate code that was causing the status line to be redrawn even
when it hadn't changed.


# 1.10 15-Jul-2009 nicm

Make status_message_set a variadic printf-like function. No functional change -
helpful for a couple of things coming soon.


# 1.9 15-Jul-2009 nicm

Having to update NSETOPTION/NSETWINDOWOPTION when adding new options is a bit
annoying and it is only use for iterating, so use a sentinel to mark the end of
each array instead. Different fix for a problem pointed out by Kalle Olavi
Niemitalo.


# 1.8 14-Jul-2009 nicm

For some reason when clearing status/message it was redrawing the entire client
not just the status line. Changing this also revealed the check for the status
line was incorrect when drawing the pane.


# 1.7 14-Jul-2009 nicm

Instead of faking up a status line in status_redraw, use the same code to
redraw it as to draw the entire screen, just skip all lines but the last.

This makes horizontal split redraw properly when the status line is off.


# 1.6 12-Jul-2009 nicm

Add a "back to indentation" key in copy mode to move the cursor to the first
non-whitespace character. ^ with vi and M-m with emacs key bindings. Another
from Kalle Olavi Niemitalo, thanks.


Revision tags: OPENBSD_4_6_BASE
# 1.5 26-Jun-2009 nicm

Status line fixes: don't truncate status-right now the length calculation is
done for UTF-8, limit to the maximum length correctly when printing, and always
print a space even if the left string is longer than the width available.


# 1.4 04-Jun-2009 nicm

If the prompt is hidden or a password is sent with -U, zero it before freeing
it.


# 1.3 03-Jun-2009 nicm

New session option, status-utf8, to control the interpretation of top-bit-set
characters in status-left and status-right (if on, they are treated as UTF-8;
otherwise passed through).


# 1.2 03-Jun-2009 nicm

Add a UTF-8 aware string length function and make UTF-8 in
status-left/status-right work properly. At the moment any top-bit-set
characters are assumed to be UTF-8: a status-utf8 option to configure this will
come shortly.


# 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.176 22-Feb-2018 nicm

Remove an unused variable.


# 1.175 05-Feb-2018 nicm

Add struct status_line to hold status line members of struct client, not
used yet but will be soon. From Thomas Adam.


# 1.174 01-Jan-2018 nicm

Add C-g at command prompt for emacs people, GitHub issue 1213.


# 1.173 27-Dec-2017 nicm

Draw command prompt correctly with status line off.


# 1.172 18-Dec-2017 nicm

Remove unused variable from Thomas Adam.


# 1.171 02-Nov-2017 nicm

Add a "fast" version of screen_write_copy for tree mode that doesn't do
all the checks and selection and marking stuff needed for copy mode.


# 1.170 20-Oct-2017 nicm

Clear status line with spaces again so reverse works, spotted by sthen.


# 1.169 16-Oct-2017 nicm

Infrastructure for drawing status lines of more than one line in height,
still only one is allowed but this lets tmux draw bigger ones.


Revision tags: OPENBSD_6_2_BASE
# 1.168 29-May-2017 nicm

Add a flag to stop the prompt input being expanded.


# 1.167 29-May-2017 nicm

Store a copy of the old status line, will be needed soon for new choose mode.


# 1.166 17-May-2017 nicm

Tidy command prompt callbacks and pass in the client.


# 1.165 03-May-2017 nicm

Add a format for the last search string in copy mode and fix the prompt
so it can work when in -I, suggested by Suraj N Kurapati.


# 1.164 01-May-2017 nicm

In order that people can use formats like #D in #() in the status line
and not have to wait for an update when they change pane, we allow
commands to run more than once a second if the expanded form
changes. Unfortunately this can mean them being run far too often
(pretty much continually) when multiple clients exist, because some
formats (including #D) will always differ between clients.

To avoid this, give each client its own tree of jobs which means that
the same command will be different instances for each client - similar
to how we have the tag to separate commands for different panes.

GitHub issue 889; test case reported by Paul Johnson.


# 1.163 22-Apr-2017 nicm

Memory leak from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.162 09-Feb-2017 nicm

Break the message storage function into its own function, useful for
debugging.


# 1.161 03-Feb-2017 nicm

Cache status line position to reduce option lookups during output.


# 1.160 03-Feb-2017 nicm

Add a window or pane id "tag" to each format tree and use it to separate
jobs, this means that if the same job is used for different windows or
panes (for example in pane-border-format), it will be run separately for
each pane.


# 1.159 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.158 06-Jan-2017 nicm

Incremental search in copy mode (on for emacs keys by default) - much
the same as normal searching but updates the cursor position and marked
search terms as you type. C-r and C-s in the prompt repeat the search,
once finished searching (with Enter), N and n work as before.


# 1.157 05-Jan-2017 nicm

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


# 1.156 07-Dec-2016 nicm

Do not clear the prompt when a message is shown, just leave it around and
return to it when the message is finished.


# 1.155 12-Oct-2016 nicm

Drop the edit mode key tables and just use fixed key bindings for the
command prompt.


# 1.154 12-Oct-2016 nicm

The repeat prompt in both emacs and vi (and the old one in tmux) doesn't
support line editing and instead executes a command as soon as a
non-number key is pressed. Add a -N flag to command-prompt for the same
in copy mode. Reported by Theo Buehler.


# 1.153 11-Oct-2016 nicm

Fundamental change to how copy mode key bindings work:

The vi-copy and emacs-copy mode key tables are gone, and instead copy
mode commands are bound in one of two normal key tables ("copy-mode" or
"copy-mode-vi"). Keys are bound to "send-keys -X copy-mode-command". So:

bind -temacs-copy C-Up scroll-up
bind -temacs-copy -R5 WheelUpPane scroll-up

Becomes:

bind -Tcopy-mode C-Up send -X scroll-up
bind -Tcopy-mode WheelUpPane send -N5 -X scroll-up

This allows the full command parser and command set to be used - for
example, we can use the normal command prompt for searching, jumping,
and so on instead of a custom one:

bind -Tcopy-mode C-r command-prompt -p'search up' "send -X search-backward '%%'"

command-prompt also gets a -1 option to only require on key press, which
is needed for jumping.

The plan is to get rid of mode keys entirely, so more to come eventually.


# 1.152 11-Oct-2016 nicm

Support UTF-8 entry into the command prompt.


# 1.151 10-Oct-2016 nicm

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


# 1.150 12-Sep-2016 nicm

Allow repeat count to be specified in mode key tables with bind-key -R,
and set the default repeat count to 5 for WheelUp and WheelDown in
copy-mode.


Revision tags: OPENBSD_6_0_BASE
# 1.149 06-Jun-2016 nicm

Allow #[] in window-status-separator.


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

I no longer use my SourceForge address so replace it.


# 1.147 01-Jan-2016 nicm

Don't rely on a calculation wrapping when applying message-limit, and
break out of the loop early. From Nicolas Viennot.


# 1.146 11-Dec-2015 nicm

Style nits and line wrapping of function declarations.


# 1.145 11-Dec-2015 nicm

Add cmdq as an argument to format_create and add a format for the
command name (will also be used for more later).


# 1.144 08-Dec-2015 nicm

Remove format_create_flags and just pass flags to format_create.


# 1.143 22-Nov-2015 tim

If display-time is set to 0, show status messages until a key is pressed;
OK nicm@


# 1.142 20-Nov-2015 nicm

Instead of separate tables for different types of options, give each
option a scope type (server, session, window) in one table.


# 1.141 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.140 13-Nov-2015 nicm

Long overdue change to the way we store cells in the grid: now, instead
of storing a full grid_cell with UTF-8 data and everything, store a new
type grid_cell_entry. This can either be the cell itself (for ASCII
cells), or an offset into an extended array (per line) for UTF-8
data.

This avoid a large (8 byte) overhead on non-UTF-8 cells (by far the
majority for most users) without the complexity of the shadow array we
had before. Grid memory without any UTF-8 is about half.

The disadvantage that cells can no longer be modified in place and need
to be copied out of the grid and back but it turned out to be lot less
complicated than I expected.


# 1.139 12-Nov-2015 nicm

Nuke the utf8 and status-utf8 options and make tmux only a UTF-8
terminal. We still support non-UTF-8 terminals outside tmux, but inside
it is always UTF-8 (as when the utf8 and status-utf8 options were on).


# 1.138 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.137 27-Oct-2015 nicm

Move struct options into options.c.


# 1.136 20-Oct-2015 nicm

Use client pointer not file descriptor in logging.


# 1.135 14-Sep-2015 nicm

Make refresh-client force update of jobs, from Sina Siadat.


# 1.134 29-Aug-2015 nicm

Move struct paste_buffer out of tmux.h.


# 1.133 28-Aug-2015 nicm

Run status update on a per-client timer at status-interval.


Revision tags: OPENBSD_5_8_BASE
# 1.132 29-Jul-2015 nicm

status_out and associated data structures are no longer used.


# 1.131 28-Jul-2015 nicm

Tidy up the way terminals are described and move some structs out of tmux.h.


# 1.130 20-Jul-2015 nicm

Add an option (history-file) for a file to save/restore command prompt
history, from Olof-Joachim Frahm.


# 1.129 27-May-2015 nicm

Move the jobs output cache into the formats code so that #() work more
generally (for example, again working in set-titles-string).


# 1.128 06-May-2015 nicm

Remove ARRAY_* from history and expand completion to complete a) layout
names and b) targets beginning with -t or -s.


# 1.127 25-Apr-2015 nicm

Make message log a TAILQ.


# 1.126 24-Apr-2015 nicm

Set working directory for run-shell and if-shell.


# 1.125 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_7_BASE
# 1.124 06-Feb-2015 nicm

Use the same time for both calls to format_expand_time.


# 1.123 06-Feb-2015 nicm

status_replace can now become local to status.c and it no longer needs
the jobsflag argument. While here there is no need to repeat work that
format_defaults already does.


# 1.122 06-Feb-2015 nicm

Add format_expand_time and use it instead of status_replace where
command execution is not needed.


# 1.121 05-Feb-2015 nicm

Wrap all the individual format_* calls in a single format_defaults
functions.


# 1.120 01-Feb-2015 nicm

Remove two unused arguments from status_replace.


# 1.119 20-Jan-2015 sthen

typo in comment ;) ok nicm


# 1.118 05-Nov-2014 nicm

Do not put a space between status-left/status-right and the window list,
instead move the space into the defaults for the options (so status-left
now defaults to "[#S] ". From Balazs Kezes.


# 1.117 20-Oct-2014 nicm

Better format for printf format attributes.


# 1.116 08-Oct-2014 nicm

Add xreallocarray and remove nmemb argument from xrealloc.


# 1.115 02-Oct-2014 nicm

Take account of window-status-separator when checking window position,
based on diff from Balazs Kezes.


Revision tags: OPENBSD_5_6_BASE
# 1.114 24-Apr-2014 nicm

There is no longer a need for a paste_stack struct or for global_buffers
to be global. Move to paste.c.


# 1.113 17-Apr-2014 nicm

Remove the monitor-content option and associated bits and bobs. It's
never worked very well. If there is a big demand for it to return, will
consider better ways to do it.


# 1.112 02-Apr-2014 nicm

Do not replace ## with # in status_replace1 because it'll be done later
by the format code.


# 1.111 31-Mar-2014 nicm

Make message-limit a server option.


Revision tags: OPENBSD_5_5_BASE
# 1.110 14-Feb-2014 nicm

Style nit - no space between function name and bracket.


# 1.109 14-Feb-2014 nicm

Check for NULL session and whatnot in status_replace, from Thomas Adam.


# 1.108 28-Jan-2014 nicm

Allow replacing each of the many sets of separate foo-{fg,bg,attr}
options with a single foo-style option. For example:

set -g status-fg yellow
set -g status-bg red
set -g status-attr blink

Becomes:

set -g status-style fg=yellow,bg=red,blink

The -a flag to set can be used to add to rather than replace a style. So:

set -g status-bg red

Becomes:

set -ag status-style bg=red

Currently this is fully backwards compatible (all *-{fg,bg,attr} options
remain) but the plan is to deprecate them over time.

From Tiago Cunha.


Revision tags: OPENBSD_5_4_BASE
# 1.107 05-Jul-2013 nicm

Whitespace nits, from Ben Boeckel.


# 1.106 05-Jul-2013 nicm

Act like vi(1) when moving words, from Ben Boeckel.


# 1.105 05-Jul-2013 nicm

Implement s, S, C mode switch commands in vi(1) mode, from Ben Boeckel.


# 1.104 31-May-2013 nicm

Demote the old single-character replacement variables (#S and friends)
to aliases of formats. From Tiago Cunha.


# 1.103 25-Mar-2013 nicm

Extend jobs to support writing and use that for copy-pipe instead of
popen, from Chris Johnsen.


# 1.102 22-Mar-2013 nicm

evbuffer_readline returns allocated storage, don't leak it.


# 1.101 22-Mar-2013 nicm

Add copy-pipe mode command to copy selection and also pipe to a command.


# 1.100 22-Mar-2013 nicm

No more lint means no more ARGSUSED.


# 1.99 21-Mar-2013 nicm

Aargh. Spaces -> tabs.


# 1.98 21-Mar-2013 nicm

Do not leak formats in status_replace.


# 1.97 21-Mar-2013 nicm

Add a format client_prefix which is 1 if prefix key has been
pressed, used for example #{?client_prefix,X,Y}. Also a few extra
server_client_status needed.


# 1.96 21-Mar-2013 nicm

Allow formats in status options.


Revision tags: OPENBSD_5_3_BASE
# 1.95 27-Nov-2012 nicm

Add window-status-last-* options, from Boris Faure.


Revision tags: OPENBSD_5_2_BASE
# 1.94 10-Jul-2012 nicm

xfree is not particularly helpful, remove it. From Thomas Adam.


# 1.93 09-Jul-2012 nicm

Move a NULL check inside a function, from Tiago Cunha.


# 1.92 29-Apr-2012 nicm

Use int not u_char for colours from options since they may have bit 8
set to mark them as 256-colour. Reported by Chris Johnson.


# 1.91 23-Apr-2012 nicm

Add window-status-separator option, from Thomas Adam.


# 1.90 17-Mar-2012 nicm

Check event_initialized before event_del if event may not have been set
up; libevent2 complains about this. Reported by Moriyoshi Koizumi.


# 1.89 04-Mar-2012 nicm

Add A and I keys for vi status line editing.


# 1.88 03-Mar-2012 nicm

The wlmouse offset should be part of the client, not the server. From
Ailin Nemui.


Revision tags: OPENBSD_5_1_BASE
# 1.87 29-Jan-2012 nicm

Add an option to move the status line to the top of the screen,
requested by many.


# 1.86 26-Jan-2012 nicm

Terminate strftime buffer properly even if a really long format string
is given, from Tiago Cunha.


# 1.85 26-Jan-2012 nicm

Fix memory leak in error path, from Tiago Cunha.


# 1.84 20-Jan-2012 nicm

Add some trivial additional status line attributes from jwcxz at users
dot sourceforge dot net.


# 1.83 20-Jan-2012 nicm

Add space movement keys for vi mode in the status line from Ben Boeckel.


# 1.82 01-Dec-2011 nicm

Make M-f and M-b work the same at the command prompt as in copy mode,
pointed out by Romain Francoise.


# 1.81 15-Nov-2011 nicm

Add word movement and editing command for command prompt editing, from
Ben Boeckel.


# 1.80 15-Nov-2011 nicm

Make window_pane_index work the same as window_index, from Ben Boeckel.


# 1.79 05-Nov-2011 nicm

Option to change status line (message) background when using vi keys and
in command mode. From Ben Boeckel.


# 1.78 20-Aug-2011 nicm

Fix a couple of memory leaks, from marcel partap.


Revision tags: OPENBSD_5_0_BASE
# 1.77 08-Jul-2011 nicm

Make confirm-before prompt customizable with -p option like
command-prompt. Also move responsibility for calling status_replace into
status_prompt_{set,update} and add #W and #P to the default kill-window
and kill-pane prompts. By Tiago Cunha.


# 1.76 02-Jul-2011 nicm

Allow the initial context on prompts to be set with the new -I option to
command-prompt. From Tiago Cunha.


# 1.75 29-Apr-2011 nicm

Only redraw the status line on command update, not the entire client
(big DOH).


# 1.74 24-Apr-2011 nicm

Provide #h for short hostname (no domain) from Michal Mazurek.


# 1.73 18-Apr-2011 nicm

Add an option (mouse-select-window) which allows the mouse to be used by
clicking on the status line, written by hsim at gmx dot li.


# 1.72 29-Mar-2011 nicm

Change -t on display-message to be target-pane for the #[A-Z]
replacements and add -c as target-client.


Revision tags: OPENBSD_4_9_BASE
# 1.71 26-Jan-2011 nicm

Simplify the way jobs work and drop the persist type, so all jobs are
fire-and-forget.

Status jobs now managed with two trees of output (new and old), rather
than storing the output in the jobs themselves. When the status line is
processed any jobs which don't appear in the new tree are started and
the output from the old tree displayed. When a job finishes it updates
the new tree with its output and that is used for any subsequent
redraws. When the status interval expires, the new tree is moved to the
old so that all jobs are run again.

This fixes the "#(echo %H:%M:%S)" problem which would lead to thousands
of identical persistent jobs and high memory use (this can still be
achieved by adding "sleep 30" but that is much less likely to happen by
accident).


# 1.70 03-Jan-2011 nicm

Handle a # at the end of a replacement string (such as status-left)
correctly. Found by Thomas Adam.


# 1.69 01-Jan-2011 nicm

Move the user-visible parts of all options (names, types, limit, default
values) together into one set of tables in options-table.c. Also clean
up and simplify cmd-set-options.c and move a common print function into
option-table.c.


# 1.68 30-Dec-2010 nicm

Change from a per-session stack of buffers to one global stack which is
much more convenient and also simplifies lot of code. This renders
copy-buffer useless and makes buffer-limit now a server option.

By Tiago Cunha.


# 1.67 30-Dec-2010 nicm

Add a function to create window flags rather than doing the same thing
in two places. From Thomas Adam.


# 1.66 11-Dec-2010 nicm

Oops, these functions return a const char *, so make the local variable
const as well.


# 1.65 11-Dec-2010 nicm

Make the prompt history global for all clients which is much more useful than per-client history.


# 1.64 06-Dec-2010 nicm

Add an option to alert (monitor) for silence (lack of activity) in a
window. From Thomas Adam.


Revision tags: OPENBSD_4_8_BASE
# 1.63 21-Jun-2010 nicm

Having a list of winlinks->alerts for each session is stupid, just store
the alert flags directly in the winlink itself.


# 1.62 14-May-2010 nicm

Colour+attribute options for status line alerts, from Alex Alexander.


# 1.61 31-Mar-2010 nicm

Don't accept keys with modifiers as input. Fixes crash reported by Brian
R Landy.


# 1.60 27-Mar-2010 nicm

Don't leak job command in #().


# 1.59 22-Mar-2010 nicm

Dead functions, lint.


Revision tags: OPENBSD_4_7_BASE
# 1.58 27-Jan-2010 nicm

Calculate offset correctly, fixes incorrect offset and prevents crash when
status-left is empty. From Micah Cowan.


# 1.57 26-Jan-2010 nicm

Actually use the copy made when no newline is found, from martynas@.


# 1.56 14-Dec-2009 nicm

Add server options to completion as well.


# 1.55 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.54 03-Dec-2009 nicm

Eliminate duplicate code and ease the passage for server-wide options by adding
a -w flag to set-option and show-options and making setw and showw aliases to
set -w and show -w.

Note: setw and showw are still there, but now aliases for set -w and show -w.


# 1.53 26-Nov-2009 nicm

Tidy up various bits of the paste code, make the data buffer char * and add
comments.


# 1.52 26-Nov-2009 nicm

Remove a couple of unused arguments where possible, and add /* ARGSUSED */ to
the rest to reduce lint output.


# 1.51 20-Nov-2009 nicm

Display UTF-8 properly in status line messages and prompt. Cursor handling is
still way off though.


# 1.50 20-Nov-2009 nicm

Remove oldest messages from log when limit is hit, not newest.


# 1.49 19-Nov-2009 nicm

Get some brackets in the right place so ## works. Also fix a space in a
comment.


# 1.48 19-Nov-2009 nicm

Change status line drawing to create the window list in a separate screen and
then copy it into the status line screen. This allows UTF-8 in window names and
fixes some problems with #[] in window-status-format.


# 1.47 19-Nov-2009 nicm

Two new options, window-status-format and window-status-current-format, which
allow the format of each window in the status line window list to be controlled
using similar # sequences as status-left/right.

This diff also moves part of the way towards UTF-8 support in window names but
it isn't quite there yet.


# 1.46 19-Nov-2009 nicm

Tidy up by breaking the # replacement code into a separate function, also add a
few comments.


# 1.45 19-Nov-2009 nicm

Don't interpret #() for display-message, it usually doesn't make sense and may
leak commands.


# 1.44 18-Nov-2009 nicm

Add a per-client log of status line messages displayed while that client
exists. A new message-limit session option sets the maximum number of entries
and a command, show-messages, shows the log (bound to ~ by default).

This (and prompt history) might be better as a single global log but until
there are global options it is easier for them to be per client.


# 1.43 17-Nov-2009 nicm

Permit top-bit-set characters to be entered in the status line. They could
already be set from the shell and are just passed through when printing (so
invisible characters or displaying on terminals with different character sets
may cause problems).

Note that entering UTF-8 may not work and in any case currently the status line
cannot display it correctly (outside of status-left/status-right).


# 1.42 04-Nov-2009 nicm

Use timeout events for the identify and message timers.


# 1.41 04-Nov-2009 nicm

Switch jobs over to use a bufferevent.


# 1.40 04-Nov-2009 nicm

Unused (but assigned to) variable, found by lint.


# 1.39 01-Nov-2009 nicm

Add a flag for jobs that shouldn't be freed after they've died and use it for
status jobs, then only kill those jobs when status-left, status-right or
set-titles-string is changed.

Fixes problems with changing options from inside #().


# 1.38 10-Oct-2009 nicm

Rather than running status-left, status-right and window title #() with popen
immediately every redraw, queue them up and run them in the background,
starting each once every status-interval. The actual status line uses the
output from the last run.

This brings several advantages:

- tmux itself may be called from inside #() without causing the server to hang;
- likewise, sleep or similar doesn't cause the server to block;
- commands aren't run excessively often when redrawing;
- commands shared by status-left and status-right, or used multiple times, will
only be run once.

run-shell and if-shell still use system()/popen() but will be changed over to
use this too later.


# 1.37 10-Oct-2009 nicm

Add "grouped sessions" which have independent name, options, current window and
so on but where the linked windows are synchronized (ie creating, killing
windows and so on are mirrored between the sessions). A grouped session may be
created by passing -t to new-session.

Had this around for a while, tested by a couple of people.


# 1.36 23-Sep-2009 nicm

Remove PROMPT_HIDDEN code which is now unused.


# 1.35 23-Sep-2009 nicm

Remove the internal tmux locking and instead detach each client and run the
command specified by a new option "lock-command" (by default "lock -np") in
each client.

This means each terminal has to be unlocked individually but simplifies the
code and allows the system password to be used to unlock.

Note that the set-password command is gone, so it will need to be removed from
configuration files, and the -U command line flag has been removed.

This is the third protocol version change so again it is best to stop the tmux
server before upgrading.


# 1.34 20-Sep-2009 nicm

Regularise some fatal messages.


# 1.33 10-Sep-2009 nicm

Permit options such as status-bg to be configured using the entire 256 colour
palette by setting "colour0" to "colour255".


# 1.32 07-Sep-2009 nicm

Give each paste buffer a size member instead of requiring them to be
zero-terminated.


# 1.31 07-Sep-2009 nicm

Permit embedded colour and attributes in status-left and status-right using new
#[] special characters, for example #[fg=red,bg=blue,blink].


# 1.30 02-Sep-2009 nicm

Add a transpose-chars command in edit mode (C-t in emacs mode only). From Kalle
Olavi Niemitalo.


# 1.29 01-Sep-2009 nicm

Use "Password:" with no space for password prompts and don't display a *s for
the password, like pretty much everything else. From martynas@ with minor
tweaks by me.


# 1.28 31-Aug-2009 nicm

Add a new display-panes command, with two options (display-panes-colour and
display-panes-time), which displays a visual indication of the number of each
pane.


# 1.27 19-Aug-2009 nicm

Extend command-prompt with a -p option which is a comma-separated list of one
or more prompts to present in order.

The responses to the prompt are replaced in the template string: %% are
replaced in order, so the first prompt replaces the first %%, the second
replaces the second, and so on. In addition, %1 up to %9 are replaced with the
responses to the first the ninth prompts

The default template is "%1" so the response to the first prompt is processed
as a command.

Note that this changes the behaviour for %% so if there is only one prompt,
only the first %% will be replaced. Templates such as "neww -n '%%' 'ssh %%'"
should be changed to "neww -n '%1' 'ssh %1'".

From Tiago Cunha.


# 1.26 18-Aug-2009 nicm

Add a "delete line" key when editing in the status line or the search up/down
prompt. C-u with emacs keys, d with vi.


# 1.25 13-Aug-2009 nicm

Switch the prompt code to return an empty string when the user enters no
response and reserve NULL for an explicit cancel. Change all callbacks to treat
them the same so no functional change.

Also add cancel key bindings to emacs mode which were missing.


# 1.24 08-Aug-2009 nicm

Options to set the colours and attributes for status-left/-right. From Thomas
Adam, thanks.


# 1.23 05-Aug-2009 nicm

If colours are not supported by the terminal, try to emulate a coloured
background by setting or clearing the reverse attribute.

This makes a few applications which don't use the reverse attribute themselves
a little happier, and allows the status, message and mode options to have
default attributes and fg/bg options that work as expected when set as reverse.


# 1.22 30-Jul-2009 nicm

Plug some memory leaks.


# 1.21 28-Jul-2009 nicm

Next step towards customisable mode keys: build each default table of keys into
a named tree on start and use that for lookups. Also add command to string
translation tables and modify list-keys to show the the mode key bindings (new
-t argument).


# 1.20 27-Jul-2009 nicm

Change mode key bindings from big switches into a set of tables. Rather than
lumping them all together, split editing keys from those used in choice/more
mode and those for copy/scroll mode.

Tidier and clearer, and the first step towards customisable mode keys.


# 1.19 27-Jul-2009 nicm

Get rid of empty mode_key_free function.


# 1.18 27-Jul-2009 nicm

Add a key to delete to end of line at the prompt (^K in emacs mode, C/D in vi).

From Kalle Olavi Niemitalo.


# 1.17 26-Jul-2009 nicm

Calculate the space available for the prompt buffer and the cursor position
correctly, and make it work when the screen is not wide enough.

Noticed by Kalle Olavi Niemitalo.


# 1.16 21-Jul-2009 nicm

Remove a couple of unused functions and fix a type ("FALLTHOUGH"), found by
lint.


# 1.15 20-Jul-2009 nicm

Add a status-justify option to allow the window list in the status line to be
positioned at the left, centre, or right.


# 1.14 20-Jul-2009 nicm

New options, window-status-current-{fg,bg,attr}, to set the fg, bg and
attributes with which the current window is shown in the status line. From
Johan Friis, thanks.


# 1.13 17-Jul-2009 nicm

- New command display-message (alias display) to display a message in the
status line (bound to "i" and displays the current window and time by
default). The same substitutions are applied as for status-left/right.
- Add support for including the window index (#I), pane index (#P) and window
name (#W) in the message, and status-left or status-right.
- Bump protocol version.

From Tiago Cunha, thanks!


# 1.12 17-Jul-2009 nicm

Memory could be leaked if a second prompt or message appeared while another was
still present, so add a separate prompt free callback and make the _clear
function responsible for calling it if necessary (rather than the individual
prompt callbacks). Also make both messages and prompts clear any existing when
a new is set.

In addition, the screen could be modified while the prompt is there, restore
the redraw-entire-screen behaviour on prompt clear; add a comment as a
reminder.


# 1.11 16-Jul-2009 nicm

Remove some duplicate code that was causing the status line to be redrawn even
when it hadn't changed.


# 1.10 15-Jul-2009 nicm

Make status_message_set a variadic printf-like function. No functional change -
helpful for a couple of things coming soon.


# 1.9 15-Jul-2009 nicm

Having to update NSETOPTION/NSETWINDOWOPTION when adding new options is a bit
annoying and it is only use for iterating, so use a sentinel to mark the end of
each array instead. Different fix for a problem pointed out by Kalle Olavi
Niemitalo.


# 1.8 14-Jul-2009 nicm

For some reason when clearing status/message it was redrawing the entire client
not just the status line. Changing this also revealed the check for the status
line was incorrect when drawing the pane.


# 1.7 14-Jul-2009 nicm

Instead of faking up a status line in status_redraw, use the same code to
redraw it as to draw the entire screen, just skip all lines but the last.

This makes horizontal split redraw properly when the status line is off.


# 1.6 12-Jul-2009 nicm

Add a "back to indentation" key in copy mode to move the cursor to the first
non-whitespace character. ^ with vi and M-m with emacs key bindings. Another
from Kalle Olavi Niemitalo, thanks.


Revision tags: OPENBSD_4_6_BASE
# 1.5 26-Jun-2009 nicm

Status line fixes: don't truncate status-right now the length calculation is
done for UTF-8, limit to the maximum length correctly when printing, and always
print a space even if the left string is longer than the width available.


# 1.4 04-Jun-2009 nicm

If the prompt is hidden or a password is sent with -U, zero it before freeing
it.


# 1.3 03-Jun-2009 nicm

New session option, status-utf8, to control the interpretation of top-bit-set
characters in status-left and status-right (if on, they are treated as UTF-8;
otherwise passed through).


# 1.2 03-Jun-2009 nicm

Add a UTF-8 aware string length function and make UTF-8 in
status-left/status-right work properly. At the moment any top-bit-set
characters are assumed to be UTF-8: a status-utf8 option to configure this will
come shortly.


# 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.175 05-Feb-2018 nicm

Add struct status_line to hold status line members of struct client, not
used yet but will be soon. From Thomas Adam.


# 1.174 01-Jan-2018 nicm

Add C-g at command prompt for emacs people, GitHub issue 1213.


# 1.173 27-Dec-2017 nicm

Draw command prompt correctly with status line off.


# 1.172 18-Dec-2017 nicm

Remove unused variable from Thomas Adam.


# 1.171 02-Nov-2017 nicm

Add a "fast" version of screen_write_copy for tree mode that doesn't do
all the checks and selection and marking stuff needed for copy mode.


# 1.170 20-Oct-2017 nicm

Clear status line with spaces again so reverse works, spotted by sthen.


# 1.169 16-Oct-2017 nicm

Infrastructure for drawing status lines of more than one line in height,
still only one is allowed but this lets tmux draw bigger ones.


Revision tags: OPENBSD_6_2_BASE
# 1.168 29-May-2017 nicm

Add a flag to stop the prompt input being expanded.


# 1.167 29-May-2017 nicm

Store a copy of the old status line, will be needed soon for new choose mode.


# 1.166 17-May-2017 nicm

Tidy command prompt callbacks and pass in the client.


# 1.165 03-May-2017 nicm

Add a format for the last search string in copy mode and fix the prompt
so it can work when in -I, suggested by Suraj N Kurapati.


# 1.164 01-May-2017 nicm

In order that people can use formats like #D in #() in the status line
and not have to wait for an update when they change pane, we allow
commands to run more than once a second if the expanded form
changes. Unfortunately this can mean them being run far too often
(pretty much continually) when multiple clients exist, because some
formats (including #D) will always differ between clients.

To avoid this, give each client its own tree of jobs which means that
the same command will be different instances for each client - similar
to how we have the tag to separate commands for different panes.

GitHub issue 889; test case reported by Paul Johnson.


# 1.163 22-Apr-2017 nicm

Memory leak from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.162 09-Feb-2017 nicm

Break the message storage function into its own function, useful for
debugging.


# 1.161 03-Feb-2017 nicm

Cache status line position to reduce option lookups during output.


# 1.160 03-Feb-2017 nicm

Add a window or pane id "tag" to each format tree and use it to separate
jobs, this means that if the same job is used for different windows or
panes (for example in pane-border-format), it will be run separately for
each pane.


# 1.159 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.158 06-Jan-2017 nicm

Incremental search in copy mode (on for emacs keys by default) - much
the same as normal searching but updates the cursor position and marked
search terms as you type. C-r and C-s in the prompt repeat the search,
once finished searching (with Enter), N and n work as before.


# 1.157 05-Jan-2017 nicm

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


# 1.156 07-Dec-2016 nicm

Do not clear the prompt when a message is shown, just leave it around and
return to it when the message is finished.


# 1.155 12-Oct-2016 nicm

Drop the edit mode key tables and just use fixed key bindings for the
command prompt.


# 1.154 12-Oct-2016 nicm

The repeat prompt in both emacs and vi (and the old one in tmux) doesn't
support line editing and instead executes a command as soon as a
non-number key is pressed. Add a -N flag to command-prompt for the same
in copy mode. Reported by Theo Buehler.


# 1.153 11-Oct-2016 nicm

Fundamental change to how copy mode key bindings work:

The vi-copy and emacs-copy mode key tables are gone, and instead copy
mode commands are bound in one of two normal key tables ("copy-mode" or
"copy-mode-vi"). Keys are bound to "send-keys -X copy-mode-command". So:

bind -temacs-copy C-Up scroll-up
bind -temacs-copy -R5 WheelUpPane scroll-up

Becomes:

bind -Tcopy-mode C-Up send -X scroll-up
bind -Tcopy-mode WheelUpPane send -N5 -X scroll-up

This allows the full command parser and command set to be used - for
example, we can use the normal command prompt for searching, jumping,
and so on instead of a custom one:

bind -Tcopy-mode C-r command-prompt -p'search up' "send -X search-backward '%%'"

command-prompt also gets a -1 option to only require on key press, which
is needed for jumping.

The plan is to get rid of mode keys entirely, so more to come eventually.


# 1.152 11-Oct-2016 nicm

Support UTF-8 entry into the command prompt.


# 1.151 10-Oct-2016 nicm

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


# 1.150 12-Sep-2016 nicm

Allow repeat count to be specified in mode key tables with bind-key -R,
and set the default repeat count to 5 for WheelUp and WheelDown in
copy-mode.


Revision tags: OPENBSD_6_0_BASE
# 1.149 06-Jun-2016 nicm

Allow #[] in window-status-separator.


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

I no longer use my SourceForge address so replace it.


# 1.147 01-Jan-2016 nicm

Don't rely on a calculation wrapping when applying message-limit, and
break out of the loop early. From Nicolas Viennot.


# 1.146 11-Dec-2015 nicm

Style nits and line wrapping of function declarations.


# 1.145 11-Dec-2015 nicm

Add cmdq as an argument to format_create and add a format for the
command name (will also be used for more later).


# 1.144 08-Dec-2015 nicm

Remove format_create_flags and just pass flags to format_create.


# 1.143 22-Nov-2015 tim

If display-time is set to 0, show status messages until a key is pressed;
OK nicm@


# 1.142 20-Nov-2015 nicm

Instead of separate tables for different types of options, give each
option a scope type (server, session, window) in one table.


# 1.141 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.140 13-Nov-2015 nicm

Long overdue change to the way we store cells in the grid: now, instead
of storing a full grid_cell with UTF-8 data and everything, store a new
type grid_cell_entry. This can either be the cell itself (for ASCII
cells), or an offset into an extended array (per line) for UTF-8
data.

This avoid a large (8 byte) overhead on non-UTF-8 cells (by far the
majority for most users) without the complexity of the shadow array we
had before. Grid memory without any UTF-8 is about half.

The disadvantage that cells can no longer be modified in place and need
to be copied out of the grid and back but it turned out to be lot less
complicated than I expected.


# 1.139 12-Nov-2015 nicm

Nuke the utf8 and status-utf8 options and make tmux only a UTF-8
terminal. We still support non-UTF-8 terminals outside tmux, but inside
it is always UTF-8 (as when the utf8 and status-utf8 options were on).


# 1.138 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.137 27-Oct-2015 nicm

Move struct options into options.c.


# 1.136 20-Oct-2015 nicm

Use client pointer not file descriptor in logging.


# 1.135 14-Sep-2015 nicm

Make refresh-client force update of jobs, from Sina Siadat.


# 1.134 29-Aug-2015 nicm

Move struct paste_buffer out of tmux.h.


# 1.133 28-Aug-2015 nicm

Run status update on a per-client timer at status-interval.


Revision tags: OPENBSD_5_8_BASE
# 1.132 29-Jul-2015 nicm

status_out and associated data structures are no longer used.


# 1.131 28-Jul-2015 nicm

Tidy up the way terminals are described and move some structs out of tmux.h.


# 1.130 20-Jul-2015 nicm

Add an option (history-file) for a file to save/restore command prompt
history, from Olof-Joachim Frahm.


# 1.129 27-May-2015 nicm

Move the jobs output cache into the formats code so that #() work more
generally (for example, again working in set-titles-string).


# 1.128 06-May-2015 nicm

Remove ARRAY_* from history and expand completion to complete a) layout
names and b) targets beginning with -t or -s.


# 1.127 25-Apr-2015 nicm

Make message log a TAILQ.


# 1.126 24-Apr-2015 nicm

Set working directory for run-shell and if-shell.


# 1.125 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_7_BASE
# 1.124 06-Feb-2015 nicm

Use the same time for both calls to format_expand_time.


# 1.123 06-Feb-2015 nicm

status_replace can now become local to status.c and it no longer needs
the jobsflag argument. While here there is no need to repeat work that
format_defaults already does.


# 1.122 06-Feb-2015 nicm

Add format_expand_time and use it instead of status_replace where
command execution is not needed.


# 1.121 05-Feb-2015 nicm

Wrap all the individual format_* calls in a single format_defaults
functions.


# 1.120 01-Feb-2015 nicm

Remove two unused arguments from status_replace.


# 1.119 20-Jan-2015 sthen

typo in comment ;) ok nicm


# 1.118 05-Nov-2014 nicm

Do not put a space between status-left/status-right and the window list,
instead move the space into the defaults for the options (so status-left
now defaults to "[#S] ". From Balazs Kezes.


# 1.117 20-Oct-2014 nicm

Better format for printf format attributes.


# 1.116 08-Oct-2014 nicm

Add xreallocarray and remove nmemb argument from xrealloc.


# 1.115 02-Oct-2014 nicm

Take account of window-status-separator when checking window position,
based on diff from Balazs Kezes.


Revision tags: OPENBSD_5_6_BASE
# 1.114 24-Apr-2014 nicm

There is no longer a need for a paste_stack struct or for global_buffers
to be global. Move to paste.c.


# 1.113 17-Apr-2014 nicm

Remove the monitor-content option and associated bits and bobs. It's
never worked very well. If there is a big demand for it to return, will
consider better ways to do it.


# 1.112 02-Apr-2014 nicm

Do not replace ## with # in status_replace1 because it'll be done later
by the format code.


# 1.111 31-Mar-2014 nicm

Make message-limit a server option.


Revision tags: OPENBSD_5_5_BASE
# 1.110 14-Feb-2014 nicm

Style nit - no space between function name and bracket.


# 1.109 14-Feb-2014 nicm

Check for NULL session and whatnot in status_replace, from Thomas Adam.


# 1.108 28-Jan-2014 nicm

Allow replacing each of the many sets of separate foo-{fg,bg,attr}
options with a single foo-style option. For example:

set -g status-fg yellow
set -g status-bg red
set -g status-attr blink

Becomes:

set -g status-style fg=yellow,bg=red,blink

The -a flag to set can be used to add to rather than replace a style. So:

set -g status-bg red

Becomes:

set -ag status-style bg=red

Currently this is fully backwards compatible (all *-{fg,bg,attr} options
remain) but the plan is to deprecate them over time.

From Tiago Cunha.


Revision tags: OPENBSD_5_4_BASE
# 1.107 05-Jul-2013 nicm

Whitespace nits, from Ben Boeckel.


# 1.106 05-Jul-2013 nicm

Act like vi(1) when moving words, from Ben Boeckel.


# 1.105 05-Jul-2013 nicm

Implement s, S, C mode switch commands in vi(1) mode, from Ben Boeckel.


# 1.104 31-May-2013 nicm

Demote the old single-character replacement variables (#S and friends)
to aliases of formats. From Tiago Cunha.


# 1.103 25-Mar-2013 nicm

Extend jobs to support writing and use that for copy-pipe instead of
popen, from Chris Johnsen.


# 1.102 22-Mar-2013 nicm

evbuffer_readline returns allocated storage, don't leak it.


# 1.101 22-Mar-2013 nicm

Add copy-pipe mode command to copy selection and also pipe to a command.


# 1.100 22-Mar-2013 nicm

No more lint means no more ARGSUSED.


# 1.99 21-Mar-2013 nicm

Aargh. Spaces -> tabs.


# 1.98 21-Mar-2013 nicm

Do not leak formats in status_replace.


# 1.97 21-Mar-2013 nicm

Add a format client_prefix which is 1 if prefix key has been
pressed, used for example #{?client_prefix,X,Y}. Also a few extra
server_client_status needed.


# 1.96 21-Mar-2013 nicm

Allow formats in status options.


Revision tags: OPENBSD_5_3_BASE
# 1.95 27-Nov-2012 nicm

Add window-status-last-* options, from Boris Faure.


Revision tags: OPENBSD_5_2_BASE
# 1.94 10-Jul-2012 nicm

xfree is not particularly helpful, remove it. From Thomas Adam.


# 1.93 09-Jul-2012 nicm

Move a NULL check inside a function, from Tiago Cunha.


# 1.92 29-Apr-2012 nicm

Use int not u_char for colours from options since they may have bit 8
set to mark them as 256-colour. Reported by Chris Johnson.


# 1.91 23-Apr-2012 nicm

Add window-status-separator option, from Thomas Adam.


# 1.90 17-Mar-2012 nicm

Check event_initialized before event_del if event may not have been set
up; libevent2 complains about this. Reported by Moriyoshi Koizumi.


# 1.89 04-Mar-2012 nicm

Add A and I keys for vi status line editing.


# 1.88 03-Mar-2012 nicm

The wlmouse offset should be part of the client, not the server. From
Ailin Nemui.


Revision tags: OPENBSD_5_1_BASE
# 1.87 29-Jan-2012 nicm

Add an option to move the status line to the top of the screen,
requested by many.


# 1.86 26-Jan-2012 nicm

Terminate strftime buffer properly even if a really long format string
is given, from Tiago Cunha.


# 1.85 26-Jan-2012 nicm

Fix memory leak in error path, from Tiago Cunha.


# 1.84 20-Jan-2012 nicm

Add some trivial additional status line attributes from jwcxz at users
dot sourceforge dot net.


# 1.83 20-Jan-2012 nicm

Add space movement keys for vi mode in the status line from Ben Boeckel.


# 1.82 01-Dec-2011 nicm

Make M-f and M-b work the same at the command prompt as in copy mode,
pointed out by Romain Francoise.


# 1.81 15-Nov-2011 nicm

Add word movement and editing command for command prompt editing, from
Ben Boeckel.


# 1.80 15-Nov-2011 nicm

Make window_pane_index work the same as window_index, from Ben Boeckel.


# 1.79 05-Nov-2011 nicm

Option to change status line (message) background when using vi keys and
in command mode. From Ben Boeckel.


# 1.78 20-Aug-2011 nicm

Fix a couple of memory leaks, from marcel partap.


Revision tags: OPENBSD_5_0_BASE
# 1.77 08-Jul-2011 nicm

Make confirm-before prompt customizable with -p option like
command-prompt. Also move responsibility for calling status_replace into
status_prompt_{set,update} and add #W and #P to the default kill-window
and kill-pane prompts. By Tiago Cunha.


# 1.76 02-Jul-2011 nicm

Allow the initial context on prompts to be set with the new -I option to
command-prompt. From Tiago Cunha.


# 1.75 29-Apr-2011 nicm

Only redraw the status line on command update, not the entire client
(big DOH).


# 1.74 24-Apr-2011 nicm

Provide #h for short hostname (no domain) from Michal Mazurek.


# 1.73 18-Apr-2011 nicm

Add an option (mouse-select-window) which allows the mouse to be used by
clicking on the status line, written by hsim at gmx dot li.


# 1.72 29-Mar-2011 nicm

Change -t on display-message to be target-pane for the #[A-Z]
replacements and add -c as target-client.


Revision tags: OPENBSD_4_9_BASE
# 1.71 26-Jan-2011 nicm

Simplify the way jobs work and drop the persist type, so all jobs are
fire-and-forget.

Status jobs now managed with two trees of output (new and old), rather
than storing the output in the jobs themselves. When the status line is
processed any jobs which don't appear in the new tree are started and
the output from the old tree displayed. When a job finishes it updates
the new tree with its output and that is used for any subsequent
redraws. When the status interval expires, the new tree is moved to the
old so that all jobs are run again.

This fixes the "#(echo %H:%M:%S)" problem which would lead to thousands
of identical persistent jobs and high memory use (this can still be
achieved by adding "sleep 30" but that is much less likely to happen by
accident).


# 1.70 03-Jan-2011 nicm

Handle a # at the end of a replacement string (such as status-left)
correctly. Found by Thomas Adam.


# 1.69 01-Jan-2011 nicm

Move the user-visible parts of all options (names, types, limit, default
values) together into one set of tables in options-table.c. Also clean
up and simplify cmd-set-options.c and move a common print function into
option-table.c.


# 1.68 30-Dec-2010 nicm

Change from a per-session stack of buffers to one global stack which is
much more convenient and also simplifies lot of code. This renders
copy-buffer useless and makes buffer-limit now a server option.

By Tiago Cunha.


# 1.67 30-Dec-2010 nicm

Add a function to create window flags rather than doing the same thing
in two places. From Thomas Adam.


# 1.66 11-Dec-2010 nicm

Oops, these functions return a const char *, so make the local variable
const as well.


# 1.65 11-Dec-2010 nicm

Make the prompt history global for all clients which is much more useful than per-client history.


# 1.64 06-Dec-2010 nicm

Add an option to alert (monitor) for silence (lack of activity) in a
window. From Thomas Adam.


Revision tags: OPENBSD_4_8_BASE
# 1.63 21-Jun-2010 nicm

Having a list of winlinks->alerts for each session is stupid, just store
the alert flags directly in the winlink itself.


# 1.62 14-May-2010 nicm

Colour+attribute options for status line alerts, from Alex Alexander.


# 1.61 31-Mar-2010 nicm

Don't accept keys with modifiers as input. Fixes crash reported by Brian
R Landy.


# 1.60 27-Mar-2010 nicm

Don't leak job command in #().


# 1.59 22-Mar-2010 nicm

Dead functions, lint.


Revision tags: OPENBSD_4_7_BASE
# 1.58 27-Jan-2010 nicm

Calculate offset correctly, fixes incorrect offset and prevents crash when
status-left is empty. From Micah Cowan.


# 1.57 26-Jan-2010 nicm

Actually use the copy made when no newline is found, from martynas@.


# 1.56 14-Dec-2009 nicm

Add server options to completion as well.


# 1.55 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.54 03-Dec-2009 nicm

Eliminate duplicate code and ease the passage for server-wide options by adding
a -w flag to set-option and show-options and making setw and showw aliases to
set -w and show -w.

Note: setw and showw are still there, but now aliases for set -w and show -w.


# 1.53 26-Nov-2009 nicm

Tidy up various bits of the paste code, make the data buffer char * and add
comments.


# 1.52 26-Nov-2009 nicm

Remove a couple of unused arguments where possible, and add /* ARGSUSED */ to
the rest to reduce lint output.


# 1.51 20-Nov-2009 nicm

Display UTF-8 properly in status line messages and prompt. Cursor handling is
still way off though.


# 1.50 20-Nov-2009 nicm

Remove oldest messages from log when limit is hit, not newest.


# 1.49 19-Nov-2009 nicm

Get some brackets in the right place so ## works. Also fix a space in a
comment.


# 1.48 19-Nov-2009 nicm

Change status line drawing to create the window list in a separate screen and
then copy it into the status line screen. This allows UTF-8 in window names and
fixes some problems with #[] in window-status-format.


# 1.47 19-Nov-2009 nicm

Two new options, window-status-format and window-status-current-format, which
allow the format of each window in the status line window list to be controlled
using similar # sequences as status-left/right.

This diff also moves part of the way towards UTF-8 support in window names but
it isn't quite there yet.


# 1.46 19-Nov-2009 nicm

Tidy up by breaking the # replacement code into a separate function, also add a
few comments.


# 1.45 19-Nov-2009 nicm

Don't interpret #() for display-message, it usually doesn't make sense and may
leak commands.


# 1.44 18-Nov-2009 nicm

Add a per-client log of status line messages displayed while that client
exists. A new message-limit session option sets the maximum number of entries
and a command, show-messages, shows the log (bound to ~ by default).

This (and prompt history) might be better as a single global log but until
there are global options it is easier for them to be per client.


# 1.43 17-Nov-2009 nicm

Permit top-bit-set characters to be entered in the status line. They could
already be set from the shell and are just passed through when printing (so
invisible characters or displaying on terminals with different character sets
may cause problems).

Note that entering UTF-8 may not work and in any case currently the status line
cannot display it correctly (outside of status-left/status-right).


# 1.42 04-Nov-2009 nicm

Use timeout events for the identify and message timers.


# 1.41 04-Nov-2009 nicm

Switch jobs over to use a bufferevent.


# 1.40 04-Nov-2009 nicm

Unused (but assigned to) variable, found by lint.


# 1.39 01-Nov-2009 nicm

Add a flag for jobs that shouldn't be freed after they've died and use it for
status jobs, then only kill those jobs when status-left, status-right or
set-titles-string is changed.

Fixes problems with changing options from inside #().


# 1.38 10-Oct-2009 nicm

Rather than running status-left, status-right and window title #() with popen
immediately every redraw, queue them up and run them in the background,
starting each once every status-interval. The actual status line uses the
output from the last run.

This brings several advantages:

- tmux itself may be called from inside #() without causing the server to hang;
- likewise, sleep or similar doesn't cause the server to block;
- commands aren't run excessively often when redrawing;
- commands shared by status-left and status-right, or used multiple times, will
only be run once.

run-shell and if-shell still use system()/popen() but will be changed over to
use this too later.


# 1.37 10-Oct-2009 nicm

Add "grouped sessions" which have independent name, options, current window and
so on but where the linked windows are synchronized (ie creating, killing
windows and so on are mirrored between the sessions). A grouped session may be
created by passing -t to new-session.

Had this around for a while, tested by a couple of people.


# 1.36 23-Sep-2009 nicm

Remove PROMPT_HIDDEN code which is now unused.


# 1.35 23-Sep-2009 nicm

Remove the internal tmux locking and instead detach each client and run the
command specified by a new option "lock-command" (by default "lock -np") in
each client.

This means each terminal has to be unlocked individually but simplifies the
code and allows the system password to be used to unlock.

Note that the set-password command is gone, so it will need to be removed from
configuration files, and the -U command line flag has been removed.

This is the third protocol version change so again it is best to stop the tmux
server before upgrading.


# 1.34 20-Sep-2009 nicm

Regularise some fatal messages.


# 1.33 10-Sep-2009 nicm

Permit options such as status-bg to be configured using the entire 256 colour
palette by setting "colour0" to "colour255".


# 1.32 07-Sep-2009 nicm

Give each paste buffer a size member instead of requiring them to be
zero-terminated.


# 1.31 07-Sep-2009 nicm

Permit embedded colour and attributes in status-left and status-right using new
#[] special characters, for example #[fg=red,bg=blue,blink].


# 1.30 02-Sep-2009 nicm

Add a transpose-chars command in edit mode (C-t in emacs mode only). From Kalle
Olavi Niemitalo.


# 1.29 01-Sep-2009 nicm

Use "Password:" with no space for password prompts and don't display a *s for
the password, like pretty much everything else. From martynas@ with minor
tweaks by me.


# 1.28 31-Aug-2009 nicm

Add a new display-panes command, with two options (display-panes-colour and
display-panes-time), which displays a visual indication of the number of each
pane.


# 1.27 19-Aug-2009 nicm

Extend command-prompt with a -p option which is a comma-separated list of one
or more prompts to present in order.

The responses to the prompt are replaced in the template string: %% are
replaced in order, so the first prompt replaces the first %%, the second
replaces the second, and so on. In addition, %1 up to %9 are replaced with the
responses to the first the ninth prompts

The default template is "%1" so the response to the first prompt is processed
as a command.

Note that this changes the behaviour for %% so if there is only one prompt,
only the first %% will be replaced. Templates such as "neww -n '%%' 'ssh %%'"
should be changed to "neww -n '%1' 'ssh %1'".

From Tiago Cunha.


# 1.26 18-Aug-2009 nicm

Add a "delete line" key when editing in the status line or the search up/down
prompt. C-u with emacs keys, d with vi.


# 1.25 13-Aug-2009 nicm

Switch the prompt code to return an empty string when the user enters no
response and reserve NULL for an explicit cancel. Change all callbacks to treat
them the same so no functional change.

Also add cancel key bindings to emacs mode which were missing.


# 1.24 08-Aug-2009 nicm

Options to set the colours and attributes for status-left/-right. From Thomas
Adam, thanks.


# 1.23 05-Aug-2009 nicm

If colours are not supported by the terminal, try to emulate a coloured
background by setting or clearing the reverse attribute.

This makes a few applications which don't use the reverse attribute themselves
a little happier, and allows the status, message and mode options to have
default attributes and fg/bg options that work as expected when set as reverse.


# 1.22 30-Jul-2009 nicm

Plug some memory leaks.


# 1.21 28-Jul-2009 nicm

Next step towards customisable mode keys: build each default table of keys into
a named tree on start and use that for lookups. Also add command to string
translation tables and modify list-keys to show the the mode key bindings (new
-t argument).


# 1.20 27-Jul-2009 nicm

Change mode key bindings from big switches into a set of tables. Rather than
lumping them all together, split editing keys from those used in choice/more
mode and those for copy/scroll mode.

Tidier and clearer, and the first step towards customisable mode keys.


# 1.19 27-Jul-2009 nicm

Get rid of empty mode_key_free function.


# 1.18 27-Jul-2009 nicm

Add a key to delete to end of line at the prompt (^K in emacs mode, C/D in vi).

From Kalle Olavi Niemitalo.


# 1.17 26-Jul-2009 nicm

Calculate the space available for the prompt buffer and the cursor position
correctly, and make it work when the screen is not wide enough.

Noticed by Kalle Olavi Niemitalo.


# 1.16 21-Jul-2009 nicm

Remove a couple of unused functions and fix a type ("FALLTHOUGH"), found by
lint.


# 1.15 20-Jul-2009 nicm

Add a status-justify option to allow the window list in the status line to be
positioned at the left, centre, or right.


# 1.14 20-Jul-2009 nicm

New options, window-status-current-{fg,bg,attr}, to set the fg, bg and
attributes with which the current window is shown in the status line. From
Johan Friis, thanks.


# 1.13 17-Jul-2009 nicm

- New command display-message (alias display) to display a message in the
status line (bound to "i" and displays the current window and time by
default). The same substitutions are applied as for status-left/right.
- Add support for including the window index (#I), pane index (#P) and window
name (#W) in the message, and status-left or status-right.
- Bump protocol version.

From Tiago Cunha, thanks!


# 1.12 17-Jul-2009 nicm

Memory could be leaked if a second prompt or message appeared while another was
still present, so add a separate prompt free callback and make the _clear
function responsible for calling it if necessary (rather than the individual
prompt callbacks). Also make both messages and prompts clear any existing when
a new is set.

In addition, the screen could be modified while the prompt is there, restore
the redraw-entire-screen behaviour on prompt clear; add a comment as a
reminder.


# 1.11 16-Jul-2009 nicm

Remove some duplicate code that was causing the status line to be redrawn even
when it hadn't changed.


# 1.10 15-Jul-2009 nicm

Make status_message_set a variadic printf-like function. No functional change -
helpful for a couple of things coming soon.


# 1.9 15-Jul-2009 nicm

Having to update NSETOPTION/NSETWINDOWOPTION when adding new options is a bit
annoying and it is only use for iterating, so use a sentinel to mark the end of
each array instead. Different fix for a problem pointed out by Kalle Olavi
Niemitalo.


# 1.8 14-Jul-2009 nicm

For some reason when clearing status/message it was redrawing the entire client
not just the status line. Changing this also revealed the check for the status
line was incorrect when drawing the pane.


# 1.7 14-Jul-2009 nicm

Instead of faking up a status line in status_redraw, use the same code to
redraw it as to draw the entire screen, just skip all lines but the last.

This makes horizontal split redraw properly when the status line is off.


# 1.6 12-Jul-2009 nicm

Add a "back to indentation" key in copy mode to move the cursor to the first
non-whitespace character. ^ with vi and M-m with emacs key bindings. Another
from Kalle Olavi Niemitalo, thanks.


Revision tags: OPENBSD_4_6_BASE
# 1.5 26-Jun-2009 nicm

Status line fixes: don't truncate status-right now the length calculation is
done for UTF-8, limit to the maximum length correctly when printing, and always
print a space even if the left string is longer than the width available.


# 1.4 04-Jun-2009 nicm

If the prompt is hidden or a password is sent with -U, zero it before freeing
it.


# 1.3 03-Jun-2009 nicm

New session option, status-utf8, to control the interpretation of top-bit-set
characters in status-left and status-right (if on, they are treated as UTF-8;
otherwise passed through).


# 1.2 03-Jun-2009 nicm

Add a UTF-8 aware string length function and make UTF-8 in
status-left/status-right work properly. At the moment any top-bit-set
characters are assumed to be UTF-8: a status-utf8 option to configure this will
come shortly.


# 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.174 01-Jan-2018 nicm

Add C-g at command prompt for emacs people, GitHub issue 1213.


# 1.173 27-Dec-2017 nicm

Draw command prompt correctly with status line off.


# 1.172 18-Dec-2017 nicm

Remove unused variable from Thomas Adam.


# 1.171 02-Nov-2017 nicm

Add a "fast" version of screen_write_copy for tree mode that doesn't do
all the checks and selection and marking stuff needed for copy mode.


# 1.170 20-Oct-2017 nicm

Clear status line with spaces again so reverse works, spotted by sthen.


# 1.169 16-Oct-2017 nicm

Infrastructure for drawing status lines of more than one line in height,
still only one is allowed but this lets tmux draw bigger ones.


Revision tags: OPENBSD_6_2_BASE
# 1.168 29-May-2017 nicm

Add a flag to stop the prompt input being expanded.


# 1.167 29-May-2017 nicm

Store a copy of the old status line, will be needed soon for new choose mode.


# 1.166 17-May-2017 nicm

Tidy command prompt callbacks and pass in the client.


# 1.165 03-May-2017 nicm

Add a format for the last search string in copy mode and fix the prompt
so it can work when in -I, suggested by Suraj N Kurapati.


# 1.164 01-May-2017 nicm

In order that people can use formats like #D in #() in the status line
and not have to wait for an update when they change pane, we allow
commands to run more than once a second if the expanded form
changes. Unfortunately this can mean them being run far too often
(pretty much continually) when multiple clients exist, because some
formats (including #D) will always differ between clients.

To avoid this, give each client its own tree of jobs which means that
the same command will be different instances for each client - similar
to how we have the tag to separate commands for different panes.

GitHub issue 889; test case reported by Paul Johnson.


# 1.163 22-Apr-2017 nicm

Memory leak from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.162 09-Feb-2017 nicm

Break the message storage function into its own function, useful for
debugging.


# 1.161 03-Feb-2017 nicm

Cache status line position to reduce option lookups during output.


# 1.160 03-Feb-2017 nicm

Add a window or pane id "tag" to each format tree and use it to separate
jobs, this means that if the same job is used for different windows or
panes (for example in pane-border-format), it will be run separately for
each pane.


# 1.159 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.158 06-Jan-2017 nicm

Incremental search in copy mode (on for emacs keys by default) - much
the same as normal searching but updates the cursor position and marked
search terms as you type. C-r and C-s in the prompt repeat the search,
once finished searching (with Enter), N and n work as before.


# 1.157 05-Jan-2017 nicm

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


# 1.156 07-Dec-2016 nicm

Do not clear the prompt when a message is shown, just leave it around and
return to it when the message is finished.


# 1.155 12-Oct-2016 nicm

Drop the edit mode key tables and just use fixed key bindings for the
command prompt.


# 1.154 12-Oct-2016 nicm

The repeat prompt in both emacs and vi (and the old one in tmux) doesn't
support line editing and instead executes a command as soon as a
non-number key is pressed. Add a -N flag to command-prompt for the same
in copy mode. Reported by Theo Buehler.


# 1.153 11-Oct-2016 nicm

Fundamental change to how copy mode key bindings work:

The vi-copy and emacs-copy mode key tables are gone, and instead copy
mode commands are bound in one of two normal key tables ("copy-mode" or
"copy-mode-vi"). Keys are bound to "send-keys -X copy-mode-command". So:

bind -temacs-copy C-Up scroll-up
bind -temacs-copy -R5 WheelUpPane scroll-up

Becomes:

bind -Tcopy-mode C-Up send -X scroll-up
bind -Tcopy-mode WheelUpPane send -N5 -X scroll-up

This allows the full command parser and command set to be used - for
example, we can use the normal command prompt for searching, jumping,
and so on instead of a custom one:

bind -Tcopy-mode C-r command-prompt -p'search up' "send -X search-backward '%%'"

command-prompt also gets a -1 option to only require on key press, which
is needed for jumping.

The plan is to get rid of mode keys entirely, so more to come eventually.


# 1.152 11-Oct-2016 nicm

Support UTF-8 entry into the command prompt.


# 1.151 10-Oct-2016 nicm

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


# 1.150 12-Sep-2016 nicm

Allow repeat count to be specified in mode key tables with bind-key -R,
and set the default repeat count to 5 for WheelUp and WheelDown in
copy-mode.


Revision tags: OPENBSD_6_0_BASE
# 1.149 06-Jun-2016 nicm

Allow #[] in window-status-separator.


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

I no longer use my SourceForge address so replace it.


# 1.147 01-Jan-2016 nicm

Don't rely on a calculation wrapping when applying message-limit, and
break out of the loop early. From Nicolas Viennot.


# 1.146 11-Dec-2015 nicm

Style nits and line wrapping of function declarations.


# 1.145 11-Dec-2015 nicm

Add cmdq as an argument to format_create and add a format for the
command name (will also be used for more later).


# 1.144 08-Dec-2015 nicm

Remove format_create_flags and just pass flags to format_create.


# 1.143 22-Nov-2015 tim

If display-time is set to 0, show status messages until a key is pressed;
OK nicm@


# 1.142 20-Nov-2015 nicm

Instead of separate tables for different types of options, give each
option a scope type (server, session, window) in one table.


# 1.141 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.140 13-Nov-2015 nicm

Long overdue change to the way we store cells in the grid: now, instead
of storing a full grid_cell with UTF-8 data and everything, store a new
type grid_cell_entry. This can either be the cell itself (for ASCII
cells), or an offset into an extended array (per line) for UTF-8
data.

This avoid a large (8 byte) overhead on non-UTF-8 cells (by far the
majority for most users) without the complexity of the shadow array we
had before. Grid memory without any UTF-8 is about half.

The disadvantage that cells can no longer be modified in place and need
to be copied out of the grid and back but it turned out to be lot less
complicated than I expected.


# 1.139 12-Nov-2015 nicm

Nuke the utf8 and status-utf8 options and make tmux only a UTF-8
terminal. We still support non-UTF-8 terminals outside tmux, but inside
it is always UTF-8 (as when the utf8 and status-utf8 options were on).


# 1.138 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.137 27-Oct-2015 nicm

Move struct options into options.c.


# 1.136 20-Oct-2015 nicm

Use client pointer not file descriptor in logging.


# 1.135 14-Sep-2015 nicm

Make refresh-client force update of jobs, from Sina Siadat.


# 1.134 29-Aug-2015 nicm

Move struct paste_buffer out of tmux.h.


# 1.133 28-Aug-2015 nicm

Run status update on a per-client timer at status-interval.


Revision tags: OPENBSD_5_8_BASE
# 1.132 29-Jul-2015 nicm

status_out and associated data structures are no longer used.


# 1.131 28-Jul-2015 nicm

Tidy up the way terminals are described and move some structs out of tmux.h.


# 1.130 20-Jul-2015 nicm

Add an option (history-file) for a file to save/restore command prompt
history, from Olof-Joachim Frahm.


# 1.129 27-May-2015 nicm

Move the jobs output cache into the formats code so that #() work more
generally (for example, again working in set-titles-string).


# 1.128 06-May-2015 nicm

Remove ARRAY_* from history and expand completion to complete a) layout
names and b) targets beginning with -t or -s.


# 1.127 25-Apr-2015 nicm

Make message log a TAILQ.


# 1.126 24-Apr-2015 nicm

Set working directory for run-shell and if-shell.


# 1.125 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_7_BASE
# 1.124 06-Feb-2015 nicm

Use the same time for both calls to format_expand_time.


# 1.123 06-Feb-2015 nicm

status_replace can now become local to status.c and it no longer needs
the jobsflag argument. While here there is no need to repeat work that
format_defaults already does.


# 1.122 06-Feb-2015 nicm

Add format_expand_time and use it instead of status_replace where
command execution is not needed.


# 1.121 05-Feb-2015 nicm

Wrap all the individual format_* calls in a single format_defaults
functions.


# 1.120 01-Feb-2015 nicm

Remove two unused arguments from status_replace.


# 1.119 20-Jan-2015 sthen

typo in comment ;) ok nicm


# 1.118 05-Nov-2014 nicm

Do not put a space between status-left/status-right and the window list,
instead move the space into the defaults for the options (so status-left
now defaults to "[#S] ". From Balazs Kezes.


# 1.117 20-Oct-2014 nicm

Better format for printf format attributes.


# 1.116 08-Oct-2014 nicm

Add xreallocarray and remove nmemb argument from xrealloc.


# 1.115 02-Oct-2014 nicm

Take account of window-status-separator when checking window position,
based on diff from Balazs Kezes.


Revision tags: OPENBSD_5_6_BASE
# 1.114 24-Apr-2014 nicm

There is no longer a need for a paste_stack struct or for global_buffers
to be global. Move to paste.c.


# 1.113 17-Apr-2014 nicm

Remove the monitor-content option and associated bits and bobs. It's
never worked very well. If there is a big demand for it to return, will
consider better ways to do it.


# 1.112 02-Apr-2014 nicm

Do not replace ## with # in status_replace1 because it'll be done later
by the format code.


# 1.111 31-Mar-2014 nicm

Make message-limit a server option.


Revision tags: OPENBSD_5_5_BASE
# 1.110 14-Feb-2014 nicm

Style nit - no space between function name and bracket.


# 1.109 14-Feb-2014 nicm

Check for NULL session and whatnot in status_replace, from Thomas Adam.


# 1.108 28-Jan-2014 nicm

Allow replacing each of the many sets of separate foo-{fg,bg,attr}
options with a single foo-style option. For example:

set -g status-fg yellow
set -g status-bg red
set -g status-attr blink

Becomes:

set -g status-style fg=yellow,bg=red,blink

The -a flag to set can be used to add to rather than replace a style. So:

set -g status-bg red

Becomes:

set -ag status-style bg=red

Currently this is fully backwards compatible (all *-{fg,bg,attr} options
remain) but the plan is to deprecate them over time.

From Tiago Cunha.


Revision tags: OPENBSD_5_4_BASE
# 1.107 05-Jul-2013 nicm

Whitespace nits, from Ben Boeckel.


# 1.106 05-Jul-2013 nicm

Act like vi(1) when moving words, from Ben Boeckel.


# 1.105 05-Jul-2013 nicm

Implement s, S, C mode switch commands in vi(1) mode, from Ben Boeckel.


# 1.104 31-May-2013 nicm

Demote the old single-character replacement variables (#S and friends)
to aliases of formats. From Tiago Cunha.


# 1.103 25-Mar-2013 nicm

Extend jobs to support writing and use that for copy-pipe instead of
popen, from Chris Johnsen.


# 1.102 22-Mar-2013 nicm

evbuffer_readline returns allocated storage, don't leak it.


# 1.101 22-Mar-2013 nicm

Add copy-pipe mode command to copy selection and also pipe to a command.


# 1.100 22-Mar-2013 nicm

No more lint means no more ARGSUSED.


# 1.99 21-Mar-2013 nicm

Aargh. Spaces -> tabs.


# 1.98 21-Mar-2013 nicm

Do not leak formats in status_replace.


# 1.97 21-Mar-2013 nicm

Add a format client_prefix which is 1 if prefix key has been
pressed, used for example #{?client_prefix,X,Y}. Also a few extra
server_client_status needed.


# 1.96 21-Mar-2013 nicm

Allow formats in status options.


Revision tags: OPENBSD_5_3_BASE
# 1.95 27-Nov-2012 nicm

Add window-status-last-* options, from Boris Faure.


Revision tags: OPENBSD_5_2_BASE
# 1.94 10-Jul-2012 nicm

xfree is not particularly helpful, remove it. From Thomas Adam.


# 1.93 09-Jul-2012 nicm

Move a NULL check inside a function, from Tiago Cunha.


# 1.92 29-Apr-2012 nicm

Use int not u_char for colours from options since they may have bit 8
set to mark them as 256-colour. Reported by Chris Johnson.


# 1.91 23-Apr-2012 nicm

Add window-status-separator option, from Thomas Adam.


# 1.90 17-Mar-2012 nicm

Check event_initialized before event_del if event may not have been set
up; libevent2 complains about this. Reported by Moriyoshi Koizumi.


# 1.89 04-Mar-2012 nicm

Add A and I keys for vi status line editing.


# 1.88 03-Mar-2012 nicm

The wlmouse offset should be part of the client, not the server. From
Ailin Nemui.


Revision tags: OPENBSD_5_1_BASE
# 1.87 29-Jan-2012 nicm

Add an option to move the status line to the top of the screen,
requested by many.


# 1.86 26-Jan-2012 nicm

Terminate strftime buffer properly even if a really long format string
is given, from Tiago Cunha.


# 1.85 26-Jan-2012 nicm

Fix memory leak in error path, from Tiago Cunha.


# 1.84 20-Jan-2012 nicm

Add some trivial additional status line attributes from jwcxz at users
dot sourceforge dot net.


# 1.83 20-Jan-2012 nicm

Add space movement keys for vi mode in the status line from Ben Boeckel.


# 1.82 01-Dec-2011 nicm

Make M-f and M-b work the same at the command prompt as in copy mode,
pointed out by Romain Francoise.


# 1.81 15-Nov-2011 nicm

Add word movement and editing command for command prompt editing, from
Ben Boeckel.


# 1.80 15-Nov-2011 nicm

Make window_pane_index work the same as window_index, from Ben Boeckel.


# 1.79 05-Nov-2011 nicm

Option to change status line (message) background when using vi keys and
in command mode. From Ben Boeckel.


# 1.78 20-Aug-2011 nicm

Fix a couple of memory leaks, from marcel partap.


Revision tags: OPENBSD_5_0_BASE
# 1.77 08-Jul-2011 nicm

Make confirm-before prompt customizable with -p option like
command-prompt. Also move responsibility for calling status_replace into
status_prompt_{set,update} and add #W and #P to the default kill-window
and kill-pane prompts. By Tiago Cunha.


# 1.76 02-Jul-2011 nicm

Allow the initial context on prompts to be set with the new -I option to
command-prompt. From Tiago Cunha.


# 1.75 29-Apr-2011 nicm

Only redraw the status line on command update, not the entire client
(big DOH).


# 1.74 24-Apr-2011 nicm

Provide #h for short hostname (no domain) from Michal Mazurek.


# 1.73 18-Apr-2011 nicm

Add an option (mouse-select-window) which allows the mouse to be used by
clicking on the status line, written by hsim at gmx dot li.


# 1.72 29-Mar-2011 nicm

Change -t on display-message to be target-pane for the #[A-Z]
replacements and add -c as target-client.


Revision tags: OPENBSD_4_9_BASE
# 1.71 26-Jan-2011 nicm

Simplify the way jobs work and drop the persist type, so all jobs are
fire-and-forget.

Status jobs now managed with two trees of output (new and old), rather
than storing the output in the jobs themselves. When the status line is
processed any jobs which don't appear in the new tree are started and
the output from the old tree displayed. When a job finishes it updates
the new tree with its output and that is used for any subsequent
redraws. When the status interval expires, the new tree is moved to the
old so that all jobs are run again.

This fixes the "#(echo %H:%M:%S)" problem which would lead to thousands
of identical persistent jobs and high memory use (this can still be
achieved by adding "sleep 30" but that is much less likely to happen by
accident).


# 1.70 03-Jan-2011 nicm

Handle a # at the end of a replacement string (such as status-left)
correctly. Found by Thomas Adam.


# 1.69 01-Jan-2011 nicm

Move the user-visible parts of all options (names, types, limit, default
values) together into one set of tables in options-table.c. Also clean
up and simplify cmd-set-options.c and move a common print function into
option-table.c.


# 1.68 30-Dec-2010 nicm

Change from a per-session stack of buffers to one global stack which is
much more convenient and also simplifies lot of code. This renders
copy-buffer useless and makes buffer-limit now a server option.

By Tiago Cunha.


# 1.67 30-Dec-2010 nicm

Add a function to create window flags rather than doing the same thing
in two places. From Thomas Adam.


# 1.66 11-Dec-2010 nicm

Oops, these functions return a const char *, so make the local variable
const as well.


# 1.65 11-Dec-2010 nicm

Make the prompt history global for all clients which is much more useful than per-client history.


# 1.64 06-Dec-2010 nicm

Add an option to alert (monitor) for silence (lack of activity) in a
window. From Thomas Adam.


Revision tags: OPENBSD_4_8_BASE
# 1.63 21-Jun-2010 nicm

Having a list of winlinks->alerts for each session is stupid, just store
the alert flags directly in the winlink itself.


# 1.62 14-May-2010 nicm

Colour+attribute options for status line alerts, from Alex Alexander.


# 1.61 31-Mar-2010 nicm

Don't accept keys with modifiers as input. Fixes crash reported by Brian
R Landy.


# 1.60 27-Mar-2010 nicm

Don't leak job command in #().


# 1.59 22-Mar-2010 nicm

Dead functions, lint.


Revision tags: OPENBSD_4_7_BASE
# 1.58 27-Jan-2010 nicm

Calculate offset correctly, fixes incorrect offset and prevents crash when
status-left is empty. From Micah Cowan.


# 1.57 26-Jan-2010 nicm

Actually use the copy made when no newline is found, from martynas@.


# 1.56 14-Dec-2009 nicm

Add server options to completion as well.


# 1.55 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.54 03-Dec-2009 nicm

Eliminate duplicate code and ease the passage for server-wide options by adding
a -w flag to set-option and show-options and making setw and showw aliases to
set -w and show -w.

Note: setw and showw are still there, but now aliases for set -w and show -w.


# 1.53 26-Nov-2009 nicm

Tidy up various bits of the paste code, make the data buffer char * and add
comments.


# 1.52 26-Nov-2009 nicm

Remove a couple of unused arguments where possible, and add /* ARGSUSED */ to
the rest to reduce lint output.


# 1.51 20-Nov-2009 nicm

Display UTF-8 properly in status line messages and prompt. Cursor handling is
still way off though.


# 1.50 20-Nov-2009 nicm

Remove oldest messages from log when limit is hit, not newest.


# 1.49 19-Nov-2009 nicm

Get some brackets in the right place so ## works. Also fix a space in a
comment.


# 1.48 19-Nov-2009 nicm

Change status line drawing to create the window list in a separate screen and
then copy it into the status line screen. This allows UTF-8 in window names and
fixes some problems with #[] in window-status-format.


# 1.47 19-Nov-2009 nicm

Two new options, window-status-format and window-status-current-format, which
allow the format of each window in the status line window list to be controlled
using similar # sequences as status-left/right.

This diff also moves part of the way towards UTF-8 support in window names but
it isn't quite there yet.


# 1.46 19-Nov-2009 nicm

Tidy up by breaking the # replacement code into a separate function, also add a
few comments.


# 1.45 19-Nov-2009 nicm

Don't interpret #() for display-message, it usually doesn't make sense and may
leak commands.


# 1.44 18-Nov-2009 nicm

Add a per-client log of status line messages displayed while that client
exists. A new message-limit session option sets the maximum number of entries
and a command, show-messages, shows the log (bound to ~ by default).

This (and prompt history) might be better as a single global log but until
there are global options it is easier for them to be per client.


# 1.43 17-Nov-2009 nicm

Permit top-bit-set characters to be entered in the status line. They could
already be set from the shell and are just passed through when printing (so
invisible characters or displaying on terminals with different character sets
may cause problems).

Note that entering UTF-8 may not work and in any case currently the status line
cannot display it correctly (outside of status-left/status-right).


# 1.42 04-Nov-2009 nicm

Use timeout events for the identify and message timers.


# 1.41 04-Nov-2009 nicm

Switch jobs over to use a bufferevent.


# 1.40 04-Nov-2009 nicm

Unused (but assigned to) variable, found by lint.


# 1.39 01-Nov-2009 nicm

Add a flag for jobs that shouldn't be freed after they've died and use it for
status jobs, then only kill those jobs when status-left, status-right or
set-titles-string is changed.

Fixes problems with changing options from inside #().


# 1.38 10-Oct-2009 nicm

Rather than running status-left, status-right and window title #() with popen
immediately every redraw, queue them up and run them in the background,
starting each once every status-interval. The actual status line uses the
output from the last run.

This brings several advantages:

- tmux itself may be called from inside #() without causing the server to hang;
- likewise, sleep or similar doesn't cause the server to block;
- commands aren't run excessively often when redrawing;
- commands shared by status-left and status-right, or used multiple times, will
only be run once.

run-shell and if-shell still use system()/popen() but will be changed over to
use this too later.


# 1.37 10-Oct-2009 nicm

Add "grouped sessions" which have independent name, options, current window and
so on but where the linked windows are synchronized (ie creating, killing
windows and so on are mirrored between the sessions). A grouped session may be
created by passing -t to new-session.

Had this around for a while, tested by a couple of people.


# 1.36 23-Sep-2009 nicm

Remove PROMPT_HIDDEN code which is now unused.


# 1.35 23-Sep-2009 nicm

Remove the internal tmux locking and instead detach each client and run the
command specified by a new option "lock-command" (by default "lock -np") in
each client.

This means each terminal has to be unlocked individually but simplifies the
code and allows the system password to be used to unlock.

Note that the set-password command is gone, so it will need to be removed from
configuration files, and the -U command line flag has been removed.

This is the third protocol version change so again it is best to stop the tmux
server before upgrading.


# 1.34 20-Sep-2009 nicm

Regularise some fatal messages.


# 1.33 10-Sep-2009 nicm

Permit options such as status-bg to be configured using the entire 256 colour
palette by setting "colour0" to "colour255".


# 1.32 07-Sep-2009 nicm

Give each paste buffer a size member instead of requiring them to be
zero-terminated.


# 1.31 07-Sep-2009 nicm

Permit embedded colour and attributes in status-left and status-right using new
#[] special characters, for example #[fg=red,bg=blue,blink].


# 1.30 02-Sep-2009 nicm

Add a transpose-chars command in edit mode (C-t in emacs mode only). From Kalle
Olavi Niemitalo.


# 1.29 01-Sep-2009 nicm

Use "Password:" with no space for password prompts and don't display a *s for
the password, like pretty much everything else. From martynas@ with minor
tweaks by me.


# 1.28 31-Aug-2009 nicm

Add a new display-panes command, with two options (display-panes-colour and
display-panes-time), which displays a visual indication of the number of each
pane.


# 1.27 19-Aug-2009 nicm

Extend command-prompt with a -p option which is a comma-separated list of one
or more prompts to present in order.

The responses to the prompt are replaced in the template string: %% are
replaced in order, so the first prompt replaces the first %%, the second
replaces the second, and so on. In addition, %1 up to %9 are replaced with the
responses to the first the ninth prompts

The default template is "%1" so the response to the first prompt is processed
as a command.

Note that this changes the behaviour for %% so if there is only one prompt,
only the first %% will be replaced. Templates such as "neww -n '%%' 'ssh %%'"
should be changed to "neww -n '%1' 'ssh %1'".

From Tiago Cunha.


# 1.26 18-Aug-2009 nicm

Add a "delete line" key when editing in the status line or the search up/down
prompt. C-u with emacs keys, d with vi.


# 1.25 13-Aug-2009 nicm

Switch the prompt code to return an empty string when the user enters no
response and reserve NULL for an explicit cancel. Change all callbacks to treat
them the same so no functional change.

Also add cancel key bindings to emacs mode which were missing.


# 1.24 08-Aug-2009 nicm

Options to set the colours and attributes for status-left/-right. From Thomas
Adam, thanks.


# 1.23 05-Aug-2009 nicm

If colours are not supported by the terminal, try to emulate a coloured
background by setting or clearing the reverse attribute.

This makes a few applications which don't use the reverse attribute themselves
a little happier, and allows the status, message and mode options to have
default attributes and fg/bg options that work as expected when set as reverse.


# 1.22 30-Jul-2009 nicm

Plug some memory leaks.


# 1.21 28-Jul-2009 nicm

Next step towards customisable mode keys: build each default table of keys into
a named tree on start and use that for lookups. Also add command to string
translation tables and modify list-keys to show the the mode key bindings (new
-t argument).


# 1.20 27-Jul-2009 nicm

Change mode key bindings from big switches into a set of tables. Rather than
lumping them all together, split editing keys from those used in choice/more
mode and those for copy/scroll mode.

Tidier and clearer, and the first step towards customisable mode keys.


# 1.19 27-Jul-2009 nicm

Get rid of empty mode_key_free function.


# 1.18 27-Jul-2009 nicm

Add a key to delete to end of line at the prompt (^K in emacs mode, C/D in vi).

From Kalle Olavi Niemitalo.


# 1.17 26-Jul-2009 nicm

Calculate the space available for the prompt buffer and the cursor position
correctly, and make it work when the screen is not wide enough.

Noticed by Kalle Olavi Niemitalo.


# 1.16 21-Jul-2009 nicm

Remove a couple of unused functions and fix a type ("FALLTHOUGH"), found by
lint.


# 1.15 20-Jul-2009 nicm

Add a status-justify option to allow the window list in the status line to be
positioned at the left, centre, or right.


# 1.14 20-Jul-2009 nicm

New options, window-status-current-{fg,bg,attr}, to set the fg, bg and
attributes with which the current window is shown in the status line. From
Johan Friis, thanks.


# 1.13 17-Jul-2009 nicm

- New command display-message (alias display) to display a message in the
status line (bound to "i" and displays the current window and time by
default). The same substitutions are applied as for status-left/right.
- Add support for including the window index (#I), pane index (#P) and window
name (#W) in the message, and status-left or status-right.
- Bump protocol version.

From Tiago Cunha, thanks!


# 1.12 17-Jul-2009 nicm

Memory could be leaked if a second prompt or message appeared while another was
still present, so add a separate prompt free callback and make the _clear
function responsible for calling it if necessary (rather than the individual
prompt callbacks). Also make both messages and prompts clear any existing when
a new is set.

In addition, the screen could be modified while the prompt is there, restore
the redraw-entire-screen behaviour on prompt clear; add a comment as a
reminder.


# 1.11 16-Jul-2009 nicm

Remove some duplicate code that was causing the status line to be redrawn even
when it hadn't changed.


# 1.10 15-Jul-2009 nicm

Make status_message_set a variadic printf-like function. No functional change -
helpful for a couple of things coming soon.


# 1.9 15-Jul-2009 nicm

Having to update NSETOPTION/NSETWINDOWOPTION when adding new options is a bit
annoying and it is only use for iterating, so use a sentinel to mark the end of
each array instead. Different fix for a problem pointed out by Kalle Olavi
Niemitalo.


# 1.8 14-Jul-2009 nicm

For some reason when clearing status/message it was redrawing the entire client
not just the status line. Changing this also revealed the check for the status
line was incorrect when drawing the pane.


# 1.7 14-Jul-2009 nicm

Instead of faking up a status line in status_redraw, use the same code to
redraw it as to draw the entire screen, just skip all lines but the last.

This makes horizontal split redraw properly when the status line is off.


# 1.6 12-Jul-2009 nicm

Add a "back to indentation" key in copy mode to move the cursor to the first
non-whitespace character. ^ with vi and M-m with emacs key bindings. Another
from Kalle Olavi Niemitalo, thanks.


Revision tags: OPENBSD_4_6_BASE
# 1.5 26-Jun-2009 nicm

Status line fixes: don't truncate status-right now the length calculation is
done for UTF-8, limit to the maximum length correctly when printing, and always
print a space even if the left string is longer than the width available.


# 1.4 04-Jun-2009 nicm

If the prompt is hidden or a password is sent with -U, zero it before freeing
it.


# 1.3 03-Jun-2009 nicm

New session option, status-utf8, to control the interpretation of top-bit-set
characters in status-left and status-right (if on, they are treated as UTF-8;
otherwise passed through).


# 1.2 03-Jun-2009 nicm

Add a UTF-8 aware string length function and make UTF-8 in
status-left/status-right work properly. At the moment any top-bit-set
characters are assumed to be UTF-8: a status-utf8 option to configure this will
come shortly.


# 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