History log of /openbsd-current/usr.bin/tmux/control.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.49 24-Aug-2022 nicm

Check for NULL returns from bufferevent_new.


# 1.48 06-Jul-2022 nicm

Defer reading from control client until the command line command has
completed.


Revision tags: OPENBSD_7_0_BASE OPENBSD_7_1_BASE
# 1.47 25-Aug-2021 nicm

Fix up some printflike attributes.


# 1.46 17-Aug-2021 nicm

Treat a pane that has died the same as no pane when sending data to
control mode clients, GitHub issue 2828.


Revision tags: OPENBSD_6_8_BASE OPENBSD_6_9_BASE
# 1.45 18-Sep-2020 nicm

Some other warnings, GitHub issue 2382.


# 1.44 06-Jul-2020 nicm

Add a way for control mode clients to subscribe to a format and be
notified of changes rather than having to poll. GitHub issue 2242.


# 1.43 18-Jun-2020 nicm

Add a flag to make a client wait for an empty line before exiting in
control mode to avoid stray commands ending up in the shell.


# 1.42 12-Jun-2020 nicm

Check if a pane needs to be paused when output is written rather than
just when it is queued.


# 1.41 11-Jun-2020 nicm

Add a -A option to pause a pane manually.


# 1.40 10-Jun-2020 nicm

Instead of a buffer size limit on each pane, set a limit of 300 seconds
of data for each client in control mode.


# 1.39 10-Jun-2020 nicm

When the pause-after flag is set, send an alternative %extended-output
form instead of %output with the age of the output.


# 1.38 05-Jun-2020 nicm

Add support for pausing a pane when the output buffered for a control
mode client gets too far behind. The pause-after flag with a time is set
on the pane with refresh-client -f and a paused pane may be resumed with
refresh-client -A. GitHub issue 2217.


# 1.37 02-Jun-2020 nicm

Use CLOCK_MONOTONIC for timer measurement and add a timestamp to control
mode %output blocks.


# 1.36 01-Jun-2020 nicm

Remove blocks from queue when pane disappears.


# 1.35 01-Jun-2020 nicm

Instead of sending all data to control mode clients as fast as possible,
add a limit of how much data will be sent to the client and try to use
it for panes with some degree of fairness. GitHub issue 2217, with
George Nachman.


# 1.34 26-May-2020 nicm

Pass the stdout file descriptor from the client as well as stdin and use
them for control clients directly instead of passing everything via the
client.


# 1.33 24-May-2020 nicm

Give control code its own state struct.


# 1.32 22-May-2020 nicm

Move client offset stuff into control.c since only control clients will
need it.


# 1.31 21-May-2020 nicm

Support code for control mode flow control: allow clients to have
separate offsets (used and acknowleged) into the pane buffers; turn off
reading from panes when no clients can accept the data; and add a -A
flag to refresh-client to let clients turn receiving a pane on and off.


Revision tags: OPENBSD_6_7_BASE
# 1.30 13-Apr-2020 nicm

Add helpers for the simple case of parse string and add to command queue.


# 1.29 13-Apr-2020 nicm

When adding a list of commands to the queue, instead of automatically
creating a new state for each group of commands, require the caller to
create one and use it for all the commands in the list. This means the
current target works even with list with multiple groups (which can
happen if they are defined with newlines).


# 1.28 13-Apr-2020 nicm

Move cmdq_state into cmd-queue.c.


# 1.27 13-Apr-2020 nicm

Rename cmdq_shared to cmdq_state which will better reflect what it is
(going to be) used for.


# 1.26 13-Apr-2020 nicm

Also move cmdq_item and cmdq_list into cmd-queue.c (this is to make its
use more clearly defined and preparation for some future work).


# 1.25 12-Dec-2019 nicm

Rewrite the code for reading and writing files. Now, if the client is
not attached, the server process asks it to open the file, similar to
how works for stdin, stdout, stderr. This makes special files like
/dev/fd/X work (used by some shells). stdin, stdout and stderr and
control mode are now just special cases of the same mechanism. This will
also make it easier to use for other commands that read files such as
source-file.


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

Do not leak empty lines, GitHub issue 1824.


# 1.23 31-May-2019 nicm

Allow % strings that are all numbers or %s, and fix a double free. Both
reported by George Nachman, GitHub issues 1765 and 1766.


# 1.22 23-May-2019 nicm

Replace the split parser code (cfg.c and cmd-string.c) with a single
parser using yacc(1). This is a major change but is clearer and simpler
and allows some edge cases to be made more consistent, as well as
tidying up how aliases are handled. It will also allow some further
improvements later.

Entirely the same parser is now used for parsing the configuration file
and for string commands. This means that constructs previously only
available in .tmux.conf, such as %if, can now be used in string commands
(for example, those given to if-shell - not commands invoked from the
shell, they are still parsed by the shell itself).

The only syntax change I am aware of is that #{} outside quotes or a
comment is now considered a format and not a comment, so #{ is now a
syntax error (notably, if it is at the start of a line).

This also adds two new sections to the man page documenting the syntax
and outlining how parsing and command execution works.

Thanks to everyone who sent me test configs (they still all parse
without errors - but this doesn't mean they still work as intended!).

Thanks to Avi Halachmi for testing and man page improvements, also to
jmc@ for reviewing the man page changes.


# 1.21 18-May-2019 nicm

Move the single command flag (CMD_CONTROL) into the shared flags.


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.20 15-Jan-2017 nicm

It is silly for cmd_list_parse to return an integer error when it could
just return NULL.


# 1.19 16-Oct-2016 nicm

Mass rename struct cmd_q to struct cmdq_item and related.


# 1.18 16-Oct-2016 nicm

Rewrite command queue handling. Each client still has a command queue,
but there is also now a global command queue. Instead of command queues
being dispatched on demand from wherever the command happens to be
added, they are now all dispatched from the top level server
loop. Command queues may now also include callbacks as well as commands,
and items may be inserted after the current command as well as at the end.

This all makes command queues significantly more predictable and easier
to use, and avoids the complex multiple nested command queues used by
source-file, if-shell and friends.

A mass rename of struct cmdq to a better name (cmdq_item probably) is
coming.


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.17 19-Jan-2016 nicm

I no longer use my SourceForge address so replace it.


# 1.16 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.15 14-Nov-2015 nicm

Push stdout and stderr to clients more aggressively, and add an event to
continue if the send fails.


Revision tags: OPENBSD_5_8_BASE
# 1.14 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.13 20-Oct-2014 nicm

Better format for printf format attributes.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.12 10-Oct-2013 nicm

Pass flags into cmdq_guard as an argument since sometimes cmdq->cmd can
be NULL. Avoids crash when a command in a command client can't be
parsed.


Revision tags: OPENBSD_5_4_BASE
# 1.11 23-Jun-2013 nicm

Mark control commands specially so the client can identify them, based
on a diff from George Nachman a while back.


# 1.10 26-Mar-2013 nicm

Fix compiler warnings, missing #include. From Thomas Adam.


# 1.9 25-Mar-2013 nicm

Add time and a command count to control mode guards, based on code from
George Nachman.


# 1.8 24-Mar-2013 nicm

Add a command queue to standardize and simplify commands that call other
commands and allow a command to block execution of subsequent
commands. This allows run-shell and if-shell to be synchronous which has
been much requested.

Each client has a default command queue and commands are consumed one at
a time from it. A command may suspend execution from the queue by
returning CMD_RETURN_WAIT and then resume it by calling cmd_continue() -
for example run-shell does this from the callback that is fired after
the job is freed.

When the command queue becomes empty, command clients are automatically
exited (unless attaching). A callback is also fired - this is used for
nested commands in, for example, if-shell which can block execution of
the client's cmdq until a new cmdq becomes empty.

Also merge all the old error/info/print functions together and lose the
old curclient/cmdclient distinction - a cmdq is bound to one client (or
none if in the configuration file), this is a command client if
c->session is NULL otherwise an attached client.


# 1.7 22-Mar-2013 nicm

Need to set clients in context before changing their reference count.


# 1.6 22-Mar-2013 nicm

Remove unnecessary initializers of cmd_ctx.


# 1.5 22-Mar-2013 nicm

Add functions to allocate and free command contexts rather than doing it
all on the stack.


Revision tags: OPENBSD_5_3_BASE
# 1.4 24-Sep-2012 nicm

Add control_write_buffer, from George Nachman.


# 1.3 03-Sep-2012 nicm

Send notifications to control clients. Also don't redraw client when
suspended.


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

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


# 1.1 18-Jun-2012 nicm

Add a skeleton mode to tmux (called "control mode") that let's tmux
commands be sent and output received on stdout. This can be used to
integrate with other terminal emulators and should allow some other
things to be made simpler later. More to come so doesn't do much yet and
deliberately not documented.


# 1.48 06-Jul-2022 nicm

Defer reading from control client until the command line command has
completed.


Revision tags: OPENBSD_7_0_BASE OPENBSD_7_1_BASE
# 1.47 25-Aug-2021 nicm

Fix up some printflike attributes.


# 1.46 17-Aug-2021 nicm

Treat a pane that has died the same as no pane when sending data to
control mode clients, GitHub issue 2828.


Revision tags: OPENBSD_6_8_BASE OPENBSD_6_9_BASE
# 1.45 18-Sep-2020 nicm

Some other warnings, GitHub issue 2382.


# 1.44 06-Jul-2020 nicm

Add a way for control mode clients to subscribe to a format and be
notified of changes rather than having to poll. GitHub issue 2242.


# 1.43 18-Jun-2020 nicm

Add a flag to make a client wait for an empty line before exiting in
control mode to avoid stray commands ending up in the shell.


# 1.42 12-Jun-2020 nicm

Check if a pane needs to be paused when output is written rather than
just when it is queued.


# 1.41 11-Jun-2020 nicm

Add a -A option to pause a pane manually.


# 1.40 10-Jun-2020 nicm

Instead of a buffer size limit on each pane, set a limit of 300 seconds
of data for each client in control mode.


# 1.39 10-Jun-2020 nicm

When the pause-after flag is set, send an alternative %extended-output
form instead of %output with the age of the output.


# 1.38 05-Jun-2020 nicm

Add support for pausing a pane when the output buffered for a control
mode client gets too far behind. The pause-after flag with a time is set
on the pane with refresh-client -f and a paused pane may be resumed with
refresh-client -A. GitHub issue 2217.


# 1.37 02-Jun-2020 nicm

Use CLOCK_MONOTONIC for timer measurement and add a timestamp to control
mode %output blocks.


# 1.36 01-Jun-2020 nicm

Remove blocks from queue when pane disappears.


# 1.35 01-Jun-2020 nicm

Instead of sending all data to control mode clients as fast as possible,
add a limit of how much data will be sent to the client and try to use
it for panes with some degree of fairness. GitHub issue 2217, with
George Nachman.


# 1.34 26-May-2020 nicm

Pass the stdout file descriptor from the client as well as stdin and use
them for control clients directly instead of passing everything via the
client.


# 1.33 24-May-2020 nicm

Give control code its own state struct.


# 1.32 22-May-2020 nicm

Move client offset stuff into control.c since only control clients will
need it.


# 1.31 21-May-2020 nicm

Support code for control mode flow control: allow clients to have
separate offsets (used and acknowleged) into the pane buffers; turn off
reading from panes when no clients can accept the data; and add a -A
flag to refresh-client to let clients turn receiving a pane on and off.


Revision tags: OPENBSD_6_7_BASE
# 1.30 13-Apr-2020 nicm

Add helpers for the simple case of parse string and add to command queue.


# 1.29 13-Apr-2020 nicm

When adding a list of commands to the queue, instead of automatically
creating a new state for each group of commands, require the caller to
create one and use it for all the commands in the list. This means the
current target works even with list with multiple groups (which can
happen if they are defined with newlines).


# 1.28 13-Apr-2020 nicm

Move cmdq_state into cmd-queue.c.


# 1.27 13-Apr-2020 nicm

Rename cmdq_shared to cmdq_state which will better reflect what it is
(going to be) used for.


# 1.26 13-Apr-2020 nicm

Also move cmdq_item and cmdq_list into cmd-queue.c (this is to make its
use more clearly defined and preparation for some future work).


# 1.25 12-Dec-2019 nicm

Rewrite the code for reading and writing files. Now, if the client is
not attached, the server process asks it to open the file, similar to
how works for stdin, stdout, stderr. This makes special files like
/dev/fd/X work (used by some shells). stdin, stdout and stderr and
control mode are now just special cases of the same mechanism. This will
also make it easier to use for other commands that read files such as
source-file.


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

Do not leak empty lines, GitHub issue 1824.


# 1.23 31-May-2019 nicm

Allow % strings that are all numbers or %s, and fix a double free. Both
reported by George Nachman, GitHub issues 1765 and 1766.


# 1.22 23-May-2019 nicm

Replace the split parser code (cfg.c and cmd-string.c) with a single
parser using yacc(1). This is a major change but is clearer and simpler
and allows some edge cases to be made more consistent, as well as
tidying up how aliases are handled. It will also allow some further
improvements later.

Entirely the same parser is now used for parsing the configuration file
and for string commands. This means that constructs previously only
available in .tmux.conf, such as %if, can now be used in string commands
(for example, those given to if-shell - not commands invoked from the
shell, they are still parsed by the shell itself).

The only syntax change I am aware of is that #{} outside quotes or a
comment is now considered a format and not a comment, so #{ is now a
syntax error (notably, if it is at the start of a line).

This also adds two new sections to the man page documenting the syntax
and outlining how parsing and command execution works.

Thanks to everyone who sent me test configs (they still all parse
without errors - but this doesn't mean they still work as intended!).

Thanks to Avi Halachmi for testing and man page improvements, also to
jmc@ for reviewing the man page changes.


# 1.21 18-May-2019 nicm

Move the single command flag (CMD_CONTROL) into the shared flags.


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.20 15-Jan-2017 nicm

It is silly for cmd_list_parse to return an integer error when it could
just return NULL.


# 1.19 16-Oct-2016 nicm

Mass rename struct cmd_q to struct cmdq_item and related.


# 1.18 16-Oct-2016 nicm

Rewrite command queue handling. Each client still has a command queue,
but there is also now a global command queue. Instead of command queues
being dispatched on demand from wherever the command happens to be
added, they are now all dispatched from the top level server
loop. Command queues may now also include callbacks as well as commands,
and items may be inserted after the current command as well as at the end.

This all makes command queues significantly more predictable and easier
to use, and avoids the complex multiple nested command queues used by
source-file, if-shell and friends.

A mass rename of struct cmdq to a better name (cmdq_item probably) is
coming.


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.17 19-Jan-2016 nicm

I no longer use my SourceForge address so replace it.


# 1.16 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.15 14-Nov-2015 nicm

Push stdout and stderr to clients more aggressively, and add an event to
continue if the send fails.


Revision tags: OPENBSD_5_8_BASE
# 1.14 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.13 20-Oct-2014 nicm

Better format for printf format attributes.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.12 10-Oct-2013 nicm

Pass flags into cmdq_guard as an argument since sometimes cmdq->cmd can
be NULL. Avoids crash when a command in a command client can't be
parsed.


Revision tags: OPENBSD_5_4_BASE
# 1.11 23-Jun-2013 nicm

Mark control commands specially so the client can identify them, based
on a diff from George Nachman a while back.


# 1.10 26-Mar-2013 nicm

Fix compiler warnings, missing #include. From Thomas Adam.


# 1.9 25-Mar-2013 nicm

Add time and a command count to control mode guards, based on code from
George Nachman.


# 1.8 24-Mar-2013 nicm

Add a command queue to standardize and simplify commands that call other
commands and allow a command to block execution of subsequent
commands. This allows run-shell and if-shell to be synchronous which has
been much requested.

Each client has a default command queue and commands are consumed one at
a time from it. A command may suspend execution from the queue by
returning CMD_RETURN_WAIT and then resume it by calling cmd_continue() -
for example run-shell does this from the callback that is fired after
the job is freed.

When the command queue becomes empty, command clients are automatically
exited (unless attaching). A callback is also fired - this is used for
nested commands in, for example, if-shell which can block execution of
the client's cmdq until a new cmdq becomes empty.

Also merge all the old error/info/print functions together and lose the
old curclient/cmdclient distinction - a cmdq is bound to one client (or
none if in the configuration file), this is a command client if
c->session is NULL otherwise an attached client.


# 1.7 22-Mar-2013 nicm

Need to set clients in context before changing their reference count.


# 1.6 22-Mar-2013 nicm

Remove unnecessary initializers of cmd_ctx.


# 1.5 22-Mar-2013 nicm

Add functions to allocate and free command contexts rather than doing it
all on the stack.


Revision tags: OPENBSD_5_3_BASE
# 1.4 24-Sep-2012 nicm

Add control_write_buffer, from George Nachman.


# 1.3 03-Sep-2012 nicm

Send notifications to control clients. Also don't redraw client when
suspended.


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

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


# 1.1 18-Jun-2012 nicm

Add a skeleton mode to tmux (called "control mode") that let's tmux
commands be sent and output received on stdout. This can be used to
integrate with other terminal emulators and should allow some other
things to be made simpler later. More to come so doesn't do much yet and
deliberately not documented.


# 1.47 25-Aug-2021 nicm

Fix up some printflike attributes.


# 1.46 17-Aug-2021 nicm

Treat a pane that has died the same as no pane when sending data to
control mode clients, GitHub issue 2828.


Revision tags: OPENBSD_6_8_BASE OPENBSD_6_9_BASE
# 1.45 18-Sep-2020 nicm

Some other warnings, GitHub issue 2382.


# 1.44 06-Jul-2020 nicm

Add a way for control mode clients to subscribe to a format and be
notified of changes rather than having to poll. GitHub issue 2242.


# 1.43 18-Jun-2020 nicm

Add a flag to make a client wait for an empty line before exiting in
control mode to avoid stray commands ending up in the shell.


# 1.42 12-Jun-2020 nicm

Check if a pane needs to be paused when output is written rather than
just when it is queued.


# 1.41 11-Jun-2020 nicm

Add a -A option to pause a pane manually.


# 1.40 10-Jun-2020 nicm

Instead of a buffer size limit on each pane, set a limit of 300 seconds
of data for each client in control mode.


# 1.39 10-Jun-2020 nicm

When the pause-after flag is set, send an alternative %extended-output
form instead of %output with the age of the output.


# 1.38 05-Jun-2020 nicm

Add support for pausing a pane when the output buffered for a control
mode client gets too far behind. The pause-after flag with a time is set
on the pane with refresh-client -f and a paused pane may be resumed with
refresh-client -A. GitHub issue 2217.


# 1.37 02-Jun-2020 nicm

Use CLOCK_MONOTONIC for timer measurement and add a timestamp to control
mode %output blocks.


# 1.36 01-Jun-2020 nicm

Remove blocks from queue when pane disappears.


# 1.35 01-Jun-2020 nicm

Instead of sending all data to control mode clients as fast as possible,
add a limit of how much data will be sent to the client and try to use
it for panes with some degree of fairness. GitHub issue 2217, with
George Nachman.


# 1.34 26-May-2020 nicm

Pass the stdout file descriptor from the client as well as stdin and use
them for control clients directly instead of passing everything via the
client.


# 1.33 24-May-2020 nicm

Give control code its own state struct.


# 1.32 22-May-2020 nicm

Move client offset stuff into control.c since only control clients will
need it.


# 1.31 21-May-2020 nicm

Support code for control mode flow control: allow clients to have
separate offsets (used and acknowleged) into the pane buffers; turn off
reading from panes when no clients can accept the data; and add a -A
flag to refresh-client to let clients turn receiving a pane on and off.


Revision tags: OPENBSD_6_7_BASE
# 1.30 13-Apr-2020 nicm

Add helpers for the simple case of parse string and add to command queue.


# 1.29 13-Apr-2020 nicm

When adding a list of commands to the queue, instead of automatically
creating a new state for each group of commands, require the caller to
create one and use it for all the commands in the list. This means the
current target works even with list with multiple groups (which can
happen if they are defined with newlines).


# 1.28 13-Apr-2020 nicm

Move cmdq_state into cmd-queue.c.


# 1.27 13-Apr-2020 nicm

Rename cmdq_shared to cmdq_state which will better reflect what it is
(going to be) used for.


# 1.26 13-Apr-2020 nicm

Also move cmdq_item and cmdq_list into cmd-queue.c (this is to make its
use more clearly defined and preparation for some future work).


# 1.25 12-Dec-2019 nicm

Rewrite the code for reading and writing files. Now, if the client is
not attached, the server process asks it to open the file, similar to
how works for stdin, stdout, stderr. This makes special files like
/dev/fd/X work (used by some shells). stdin, stdout and stderr and
control mode are now just special cases of the same mechanism. This will
also make it easier to use for other commands that read files such as
source-file.


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

Do not leak empty lines, GitHub issue 1824.


# 1.23 31-May-2019 nicm

Allow % strings that are all numbers or %s, and fix a double free. Both
reported by George Nachman, GitHub issues 1765 and 1766.


# 1.22 23-May-2019 nicm

Replace the split parser code (cfg.c and cmd-string.c) with a single
parser using yacc(1). This is a major change but is clearer and simpler
and allows some edge cases to be made more consistent, as well as
tidying up how aliases are handled. It will also allow some further
improvements later.

Entirely the same parser is now used for parsing the configuration file
and for string commands. This means that constructs previously only
available in .tmux.conf, such as %if, can now be used in string commands
(for example, those given to if-shell - not commands invoked from the
shell, they are still parsed by the shell itself).

The only syntax change I am aware of is that #{} outside quotes or a
comment is now considered a format and not a comment, so #{ is now a
syntax error (notably, if it is at the start of a line).

This also adds two new sections to the man page documenting the syntax
and outlining how parsing and command execution works.

Thanks to everyone who sent me test configs (they still all parse
without errors - but this doesn't mean they still work as intended!).

Thanks to Avi Halachmi for testing and man page improvements, also to
jmc@ for reviewing the man page changes.


# 1.21 18-May-2019 nicm

Move the single command flag (CMD_CONTROL) into the shared flags.


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.20 15-Jan-2017 nicm

It is silly for cmd_list_parse to return an integer error when it could
just return NULL.


# 1.19 16-Oct-2016 nicm

Mass rename struct cmd_q to struct cmdq_item and related.


# 1.18 16-Oct-2016 nicm

Rewrite command queue handling. Each client still has a command queue,
but there is also now a global command queue. Instead of command queues
being dispatched on demand from wherever the command happens to be
added, they are now all dispatched from the top level server
loop. Command queues may now also include callbacks as well as commands,
and items may be inserted after the current command as well as at the end.

This all makes command queues significantly more predictable and easier
to use, and avoids the complex multiple nested command queues used by
source-file, if-shell and friends.

A mass rename of struct cmdq to a better name (cmdq_item probably) is
coming.


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.17 19-Jan-2016 nicm

I no longer use my SourceForge address so replace it.


# 1.16 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.15 14-Nov-2015 nicm

Push stdout and stderr to clients more aggressively, and add an event to
continue if the send fails.


Revision tags: OPENBSD_5_8_BASE
# 1.14 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.13 20-Oct-2014 nicm

Better format for printf format attributes.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.12 10-Oct-2013 nicm

Pass flags into cmdq_guard as an argument since sometimes cmdq->cmd can
be NULL. Avoids crash when a command in a command client can't be
parsed.


Revision tags: OPENBSD_5_4_BASE
# 1.11 23-Jun-2013 nicm

Mark control commands specially so the client can identify them, based
on a diff from George Nachman a while back.


# 1.10 26-Mar-2013 nicm

Fix compiler warnings, missing #include. From Thomas Adam.


# 1.9 25-Mar-2013 nicm

Add time and a command count to control mode guards, based on code from
George Nachman.


# 1.8 24-Mar-2013 nicm

Add a command queue to standardize and simplify commands that call other
commands and allow a command to block execution of subsequent
commands. This allows run-shell and if-shell to be synchronous which has
been much requested.

Each client has a default command queue and commands are consumed one at
a time from it. A command may suspend execution from the queue by
returning CMD_RETURN_WAIT and then resume it by calling cmd_continue() -
for example run-shell does this from the callback that is fired after
the job is freed.

When the command queue becomes empty, command clients are automatically
exited (unless attaching). A callback is also fired - this is used for
nested commands in, for example, if-shell which can block execution of
the client's cmdq until a new cmdq becomes empty.

Also merge all the old error/info/print functions together and lose the
old curclient/cmdclient distinction - a cmdq is bound to one client (or
none if in the configuration file), this is a command client if
c->session is NULL otherwise an attached client.


# 1.7 22-Mar-2013 nicm

Need to set clients in context before changing their reference count.


# 1.6 22-Mar-2013 nicm

Remove unnecessary initializers of cmd_ctx.


# 1.5 22-Mar-2013 nicm

Add functions to allocate and free command contexts rather than doing it
all on the stack.


Revision tags: OPENBSD_5_3_BASE
# 1.4 24-Sep-2012 nicm

Add control_write_buffer, from George Nachman.


# 1.3 03-Sep-2012 nicm

Send notifications to control clients. Also don't redraw client when
suspended.


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

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


# 1.1 18-Jun-2012 nicm

Add a skeleton mode to tmux (called "control mode") that let's tmux
commands be sent and output received on stdout. This can be used to
integrate with other terminal emulators and should allow some other
things to be made simpler later. More to come so doesn't do much yet and
deliberately not documented.


# 1.46 17-Aug-2021 nicm

Treat a pane that has died the same as no pane when sending data to
control mode clients, GitHub issue 2828.


Revision tags: OPENBSD_6_8_BASE OPENBSD_6_9_BASE
# 1.45 18-Sep-2020 nicm

Some other warnings, GitHub issue 2382.


# 1.44 06-Jul-2020 nicm

Add a way for control mode clients to subscribe to a format and be
notified of changes rather than having to poll. GitHub issue 2242.


# 1.43 18-Jun-2020 nicm

Add a flag to make a client wait for an empty line before exiting in
control mode to avoid stray commands ending up in the shell.


# 1.42 12-Jun-2020 nicm

Check if a pane needs to be paused when output is written rather than
just when it is queued.


# 1.41 11-Jun-2020 nicm

Add a -A option to pause a pane manually.


# 1.40 10-Jun-2020 nicm

Instead of a buffer size limit on each pane, set a limit of 300 seconds
of data for each client in control mode.


# 1.39 10-Jun-2020 nicm

When the pause-after flag is set, send an alternative %extended-output
form instead of %output with the age of the output.


# 1.38 05-Jun-2020 nicm

Add support for pausing a pane when the output buffered for a control
mode client gets too far behind. The pause-after flag with a time is set
on the pane with refresh-client -f and a paused pane may be resumed with
refresh-client -A. GitHub issue 2217.


# 1.37 02-Jun-2020 nicm

Use CLOCK_MONOTONIC for timer measurement and add a timestamp to control
mode %output blocks.


# 1.36 01-Jun-2020 nicm

Remove blocks from queue when pane disappears.


# 1.35 01-Jun-2020 nicm

Instead of sending all data to control mode clients as fast as possible,
add a limit of how much data will be sent to the client and try to use
it for panes with some degree of fairness. GitHub issue 2217, with
George Nachman.


# 1.34 26-May-2020 nicm

Pass the stdout file descriptor from the client as well as stdin and use
them for control clients directly instead of passing everything via the
client.


# 1.33 24-May-2020 nicm

Give control code its own state struct.


# 1.32 22-May-2020 nicm

Move client offset stuff into control.c since only control clients will
need it.


# 1.31 21-May-2020 nicm

Support code for control mode flow control: allow clients to have
separate offsets (used and acknowleged) into the pane buffers; turn off
reading from panes when no clients can accept the data; and add a -A
flag to refresh-client to let clients turn receiving a pane on and off.


Revision tags: OPENBSD_6_7_BASE
# 1.30 13-Apr-2020 nicm

Add helpers for the simple case of parse string and add to command queue.


# 1.29 13-Apr-2020 nicm

When adding a list of commands to the queue, instead of automatically
creating a new state for each group of commands, require the caller to
create one and use it for all the commands in the list. This means the
current target works even with list with multiple groups (which can
happen if they are defined with newlines).


# 1.28 13-Apr-2020 nicm

Move cmdq_state into cmd-queue.c.


# 1.27 13-Apr-2020 nicm

Rename cmdq_shared to cmdq_state which will better reflect what it is
(going to be) used for.


# 1.26 13-Apr-2020 nicm

Also move cmdq_item and cmdq_list into cmd-queue.c (this is to make its
use more clearly defined and preparation for some future work).


# 1.25 12-Dec-2019 nicm

Rewrite the code for reading and writing files. Now, if the client is
not attached, the server process asks it to open the file, similar to
how works for stdin, stdout, stderr. This makes special files like
/dev/fd/X work (used by some shells). stdin, stdout and stderr and
control mode are now just special cases of the same mechanism. This will
also make it easier to use for other commands that read files such as
source-file.


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

Do not leak empty lines, GitHub issue 1824.


# 1.23 31-May-2019 nicm

Allow % strings that are all numbers or %s, and fix a double free. Both
reported by George Nachman, GitHub issues 1765 and 1766.


# 1.22 23-May-2019 nicm

Replace the split parser code (cfg.c and cmd-string.c) with a single
parser using yacc(1). This is a major change but is clearer and simpler
and allows some edge cases to be made more consistent, as well as
tidying up how aliases are handled. It will also allow some further
improvements later.

Entirely the same parser is now used for parsing the configuration file
and for string commands. This means that constructs previously only
available in .tmux.conf, such as %if, can now be used in string commands
(for example, those given to if-shell - not commands invoked from the
shell, they are still parsed by the shell itself).

The only syntax change I am aware of is that #{} outside quotes or a
comment is now considered a format and not a comment, so #{ is now a
syntax error (notably, if it is at the start of a line).

This also adds two new sections to the man page documenting the syntax
and outlining how parsing and command execution works.

Thanks to everyone who sent me test configs (they still all parse
without errors - but this doesn't mean they still work as intended!).

Thanks to Avi Halachmi for testing and man page improvements, also to
jmc@ for reviewing the man page changes.


# 1.21 18-May-2019 nicm

Move the single command flag (CMD_CONTROL) into the shared flags.


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.20 15-Jan-2017 nicm

It is silly for cmd_list_parse to return an integer error when it could
just return NULL.


# 1.19 16-Oct-2016 nicm

Mass rename struct cmd_q to struct cmdq_item and related.


# 1.18 16-Oct-2016 nicm

Rewrite command queue handling. Each client still has a command queue,
but there is also now a global command queue. Instead of command queues
being dispatched on demand from wherever the command happens to be
added, they are now all dispatched from the top level server
loop. Command queues may now also include callbacks as well as commands,
and items may be inserted after the current command as well as at the end.

This all makes command queues significantly more predictable and easier
to use, and avoids the complex multiple nested command queues used by
source-file, if-shell and friends.

A mass rename of struct cmdq to a better name (cmdq_item probably) is
coming.


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.17 19-Jan-2016 nicm

I no longer use my SourceForge address so replace it.


# 1.16 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.15 14-Nov-2015 nicm

Push stdout and stderr to clients more aggressively, and add an event to
continue if the send fails.


Revision tags: OPENBSD_5_8_BASE
# 1.14 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.13 20-Oct-2014 nicm

Better format for printf format attributes.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.12 10-Oct-2013 nicm

Pass flags into cmdq_guard as an argument since sometimes cmdq->cmd can
be NULL. Avoids crash when a command in a command client can't be
parsed.


Revision tags: OPENBSD_5_4_BASE
# 1.11 23-Jun-2013 nicm

Mark control commands specially so the client can identify them, based
on a diff from George Nachman a while back.


# 1.10 26-Mar-2013 nicm

Fix compiler warnings, missing #include. From Thomas Adam.


# 1.9 25-Mar-2013 nicm

Add time and a command count to control mode guards, based on code from
George Nachman.


# 1.8 24-Mar-2013 nicm

Add a command queue to standardize and simplify commands that call other
commands and allow a command to block execution of subsequent
commands. This allows run-shell and if-shell to be synchronous which has
been much requested.

Each client has a default command queue and commands are consumed one at
a time from it. A command may suspend execution from the queue by
returning CMD_RETURN_WAIT and then resume it by calling cmd_continue() -
for example run-shell does this from the callback that is fired after
the job is freed.

When the command queue becomes empty, command clients are automatically
exited (unless attaching). A callback is also fired - this is used for
nested commands in, for example, if-shell which can block execution of
the client's cmdq until a new cmdq becomes empty.

Also merge all the old error/info/print functions together and lose the
old curclient/cmdclient distinction - a cmdq is bound to one client (or
none if in the configuration file), this is a command client if
c->session is NULL otherwise an attached client.


# 1.7 22-Mar-2013 nicm

Need to set clients in context before changing their reference count.


# 1.6 22-Mar-2013 nicm

Remove unnecessary initializers of cmd_ctx.


# 1.5 22-Mar-2013 nicm

Add functions to allocate and free command contexts rather than doing it
all on the stack.


Revision tags: OPENBSD_5_3_BASE
# 1.4 24-Sep-2012 nicm

Add control_write_buffer, from George Nachman.


# 1.3 03-Sep-2012 nicm

Send notifications to control clients. Also don't redraw client when
suspended.


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

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


# 1.1 18-Jun-2012 nicm

Add a skeleton mode to tmux (called "control mode") that let's tmux
commands be sent and output received on stdout. This can be used to
integrate with other terminal emulators and should allow some other
things to be made simpler later. More to come so doesn't do much yet and
deliberately not documented.


# 1.45 18-Sep-2020 nicm

Some other warnings, GitHub issue 2382.


# 1.44 06-Jul-2020 nicm

Add a way for control mode clients to subscribe to a format and be
notified of changes rather than having to poll. GitHub issue 2242.


# 1.43 18-Jun-2020 nicm

Add a flag to make a client wait for an empty line before exiting in
control mode to avoid stray commands ending up in the shell.


# 1.42 12-Jun-2020 nicm

Check if a pane needs to be paused when output is written rather than
just when it is queued.


# 1.41 11-Jun-2020 nicm

Add a -A option to pause a pane manually.


# 1.40 10-Jun-2020 nicm

Instead of a buffer size limit on each pane, set a limit of 300 seconds
of data for each client in control mode.


# 1.39 10-Jun-2020 nicm

When the pause-after flag is set, send an alternative %extended-output
form instead of %output with the age of the output.


# 1.38 05-Jun-2020 nicm

Add support for pausing a pane when the output buffered for a control
mode client gets too far behind. The pause-after flag with a time is set
on the pane with refresh-client -f and a paused pane may be resumed with
refresh-client -A. GitHub issue 2217.


# 1.37 02-Jun-2020 nicm

Use CLOCK_MONOTONIC for timer measurement and add a timestamp to control
mode %output blocks.


# 1.36 01-Jun-2020 nicm

Remove blocks from queue when pane disappears.


# 1.35 01-Jun-2020 nicm

Instead of sending all data to control mode clients as fast as possible,
add a limit of how much data will be sent to the client and try to use
it for panes with some degree of fairness. GitHub issue 2217, with
George Nachman.


# 1.34 26-May-2020 nicm

Pass the stdout file descriptor from the client as well as stdin and use
them for control clients directly instead of passing everything via the
client.


# 1.33 24-May-2020 nicm

Give control code its own state struct.


# 1.32 22-May-2020 nicm

Move client offset stuff into control.c since only control clients will
need it.


# 1.31 21-May-2020 nicm

Support code for control mode flow control: allow clients to have
separate offsets (used and acknowleged) into the pane buffers; turn off
reading from panes when no clients can accept the data; and add a -A
flag to refresh-client to let clients turn receiving a pane on and off.


Revision tags: OPENBSD_6_7_BASE
# 1.30 13-Apr-2020 nicm

Add helpers for the simple case of parse string and add to command queue.


# 1.29 13-Apr-2020 nicm

When adding a list of commands to the queue, instead of automatically
creating a new state for each group of commands, require the caller to
create one and use it for all the commands in the list. This means the
current target works even with list with multiple groups (which can
happen if they are defined with newlines).


# 1.28 13-Apr-2020 nicm

Move cmdq_state into cmd-queue.c.


# 1.27 13-Apr-2020 nicm

Rename cmdq_shared to cmdq_state which will better reflect what it is
(going to be) used for.


# 1.26 13-Apr-2020 nicm

Also move cmdq_item and cmdq_list into cmd-queue.c (this is to make its
use more clearly defined and preparation for some future work).


# 1.25 12-Dec-2019 nicm

Rewrite the code for reading and writing files. Now, if the client is
not attached, the server process asks it to open the file, similar to
how works for stdin, stdout, stderr. This makes special files like
/dev/fd/X work (used by some shells). stdin, stdout and stderr and
control mode are now just special cases of the same mechanism. This will
also make it easier to use for other commands that read files such as
source-file.


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

Do not leak empty lines, GitHub issue 1824.


# 1.23 31-May-2019 nicm

Allow % strings that are all numbers or %s, and fix a double free. Both
reported by George Nachman, GitHub issues 1765 and 1766.


# 1.22 23-May-2019 nicm

Replace the split parser code (cfg.c and cmd-string.c) with a single
parser using yacc(1). This is a major change but is clearer and simpler
and allows some edge cases to be made more consistent, as well as
tidying up how aliases are handled. It will also allow some further
improvements later.

Entirely the same parser is now used for parsing the configuration file
and for string commands. This means that constructs previously only
available in .tmux.conf, such as %if, can now be used in string commands
(for example, those given to if-shell - not commands invoked from the
shell, they are still parsed by the shell itself).

The only syntax change I am aware of is that #{} outside quotes or a
comment is now considered a format and not a comment, so #{ is now a
syntax error (notably, if it is at the start of a line).

This also adds two new sections to the man page documenting the syntax
and outlining how parsing and command execution works.

Thanks to everyone who sent me test configs (they still all parse
without errors - but this doesn't mean they still work as intended!).

Thanks to Avi Halachmi for testing and man page improvements, also to
jmc@ for reviewing the man page changes.


# 1.21 18-May-2019 nicm

Move the single command flag (CMD_CONTROL) into the shared flags.


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.20 15-Jan-2017 nicm

It is silly for cmd_list_parse to return an integer error when it could
just return NULL.


# 1.19 16-Oct-2016 nicm

Mass rename struct cmd_q to struct cmdq_item and related.


# 1.18 16-Oct-2016 nicm

Rewrite command queue handling. Each client still has a command queue,
but there is also now a global command queue. Instead of command queues
being dispatched on demand from wherever the command happens to be
added, they are now all dispatched from the top level server
loop. Command queues may now also include callbacks as well as commands,
and items may be inserted after the current command as well as at the end.

This all makes command queues significantly more predictable and easier
to use, and avoids the complex multiple nested command queues used by
source-file, if-shell and friends.

A mass rename of struct cmdq to a better name (cmdq_item probably) is
coming.


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.17 19-Jan-2016 nicm

I no longer use my SourceForge address so replace it.


# 1.16 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.15 14-Nov-2015 nicm

Push stdout and stderr to clients more aggressively, and add an event to
continue if the send fails.


Revision tags: OPENBSD_5_8_BASE
# 1.14 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.13 20-Oct-2014 nicm

Better format for printf format attributes.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.12 10-Oct-2013 nicm

Pass flags into cmdq_guard as an argument since sometimes cmdq->cmd can
be NULL. Avoids crash when a command in a command client can't be
parsed.


Revision tags: OPENBSD_5_4_BASE
# 1.11 23-Jun-2013 nicm

Mark control commands specially so the client can identify them, based
on a diff from George Nachman a while back.


# 1.10 26-Mar-2013 nicm

Fix compiler warnings, missing #include. From Thomas Adam.


# 1.9 25-Mar-2013 nicm

Add time and a command count to control mode guards, based on code from
George Nachman.


# 1.8 24-Mar-2013 nicm

Add a command queue to standardize and simplify commands that call other
commands and allow a command to block execution of subsequent
commands. This allows run-shell and if-shell to be synchronous which has
been much requested.

Each client has a default command queue and commands are consumed one at
a time from it. A command may suspend execution from the queue by
returning CMD_RETURN_WAIT and then resume it by calling cmd_continue() -
for example run-shell does this from the callback that is fired after
the job is freed.

When the command queue becomes empty, command clients are automatically
exited (unless attaching). A callback is also fired - this is used for
nested commands in, for example, if-shell which can block execution of
the client's cmdq until a new cmdq becomes empty.

Also merge all the old error/info/print functions together and lose the
old curclient/cmdclient distinction - a cmdq is bound to one client (or
none if in the configuration file), this is a command client if
c->session is NULL otherwise an attached client.


# 1.7 22-Mar-2013 nicm

Need to set clients in context before changing their reference count.


# 1.6 22-Mar-2013 nicm

Remove unnecessary initializers of cmd_ctx.


# 1.5 22-Mar-2013 nicm

Add functions to allocate and free command contexts rather than doing it
all on the stack.


Revision tags: OPENBSD_5_3_BASE
# 1.4 24-Sep-2012 nicm

Add control_write_buffer, from George Nachman.


# 1.3 03-Sep-2012 nicm

Send notifications to control clients. Also don't redraw client when
suspended.


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

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


# 1.1 18-Jun-2012 nicm

Add a skeleton mode to tmux (called "control mode") that let's tmux
commands be sent and output received on stdout. This can be used to
integrate with other terminal emulators and should allow some other
things to be made simpler later. More to come so doesn't do much yet and
deliberately not documented.


# 1.44 06-Jul-2020 nicm

Add a way for control mode clients to subscribe to a format and be
notified of changes rather than having to poll. GitHub issue 2242.


# 1.43 18-Jun-2020 nicm

Add a flag to make a client wait for an empty line before exiting in
control mode to avoid stray commands ending up in the shell.


# 1.42 12-Jun-2020 nicm

Check if a pane needs to be paused when output is written rather than
just when it is queued.


# 1.41 11-Jun-2020 nicm

Add a -A option to pause a pane manually.


# 1.40 10-Jun-2020 nicm

Instead of a buffer size limit on each pane, set a limit of 300 seconds
of data for each client in control mode.


# 1.39 10-Jun-2020 nicm

When the pause-after flag is set, send an alternative %extended-output
form instead of %output with the age of the output.


# 1.38 05-Jun-2020 nicm

Add support for pausing a pane when the output buffered for a control
mode client gets too far behind. The pause-after flag with a time is set
on the pane with refresh-client -f and a paused pane may be resumed with
refresh-client -A. GitHub issue 2217.


# 1.37 02-Jun-2020 nicm

Use CLOCK_MONOTONIC for timer measurement and add a timestamp to control
mode %output blocks.


# 1.36 01-Jun-2020 nicm

Remove blocks from queue when pane disappears.


# 1.35 01-Jun-2020 nicm

Instead of sending all data to control mode clients as fast as possible,
add a limit of how much data will be sent to the client and try to use
it for panes with some degree of fairness. GitHub issue 2217, with
George Nachman.


# 1.34 26-May-2020 nicm

Pass the stdout file descriptor from the client as well as stdin and use
them for control clients directly instead of passing everything via the
client.


# 1.33 24-May-2020 nicm

Give control code its own state struct.


# 1.32 22-May-2020 nicm

Move client offset stuff into control.c since only control clients will
need it.


# 1.31 21-May-2020 nicm

Support code for control mode flow control: allow clients to have
separate offsets (used and acknowleged) into the pane buffers; turn off
reading from panes when no clients can accept the data; and add a -A
flag to refresh-client to let clients turn receiving a pane on and off.


Revision tags: OPENBSD_6_7_BASE
# 1.30 13-Apr-2020 nicm

Add helpers for the simple case of parse string and add to command queue.


# 1.29 13-Apr-2020 nicm

When adding a list of commands to the queue, instead of automatically
creating a new state for each group of commands, require the caller to
create one and use it for all the commands in the list. This means the
current target works even with list with multiple groups (which can
happen if they are defined with newlines).


# 1.28 13-Apr-2020 nicm

Move cmdq_state into cmd-queue.c.


# 1.27 13-Apr-2020 nicm

Rename cmdq_shared to cmdq_state which will better reflect what it is
(going to be) used for.


# 1.26 13-Apr-2020 nicm

Also move cmdq_item and cmdq_list into cmd-queue.c (this is to make its
use more clearly defined and preparation for some future work).


# 1.25 12-Dec-2019 nicm

Rewrite the code for reading and writing files. Now, if the client is
not attached, the server process asks it to open the file, similar to
how works for stdin, stdout, stderr. This makes special files like
/dev/fd/X work (used by some shells). stdin, stdout and stderr and
control mode are now just special cases of the same mechanism. This will
also make it easier to use for other commands that read files such as
source-file.


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

Do not leak empty lines, GitHub issue 1824.


# 1.23 31-May-2019 nicm

Allow % strings that are all numbers or %s, and fix a double free. Both
reported by George Nachman, GitHub issues 1765 and 1766.


# 1.22 23-May-2019 nicm

Replace the split parser code (cfg.c and cmd-string.c) with a single
parser using yacc(1). This is a major change but is clearer and simpler
and allows some edge cases to be made more consistent, as well as
tidying up how aliases are handled. It will also allow some further
improvements later.

Entirely the same parser is now used for parsing the configuration file
and for string commands. This means that constructs previously only
available in .tmux.conf, such as %if, can now be used in string commands
(for example, those given to if-shell - not commands invoked from the
shell, they are still parsed by the shell itself).

The only syntax change I am aware of is that #{} outside quotes or a
comment is now considered a format and not a comment, so #{ is now a
syntax error (notably, if it is at the start of a line).

This also adds two new sections to the man page documenting the syntax
and outlining how parsing and command execution works.

Thanks to everyone who sent me test configs (they still all parse
without errors - but this doesn't mean they still work as intended!).

Thanks to Avi Halachmi for testing and man page improvements, also to
jmc@ for reviewing the man page changes.


# 1.21 18-May-2019 nicm

Move the single command flag (CMD_CONTROL) into the shared flags.


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.20 15-Jan-2017 nicm

It is silly for cmd_list_parse to return an integer error when it could
just return NULL.


# 1.19 16-Oct-2016 nicm

Mass rename struct cmd_q to struct cmdq_item and related.


# 1.18 16-Oct-2016 nicm

Rewrite command queue handling. Each client still has a command queue,
but there is also now a global command queue. Instead of command queues
being dispatched on demand from wherever the command happens to be
added, they are now all dispatched from the top level server
loop. Command queues may now also include callbacks as well as commands,
and items may be inserted after the current command as well as at the end.

This all makes command queues significantly more predictable and easier
to use, and avoids the complex multiple nested command queues used by
source-file, if-shell and friends.

A mass rename of struct cmdq to a better name (cmdq_item probably) is
coming.


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.17 19-Jan-2016 nicm

I no longer use my SourceForge address so replace it.


# 1.16 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.15 14-Nov-2015 nicm

Push stdout and stderr to clients more aggressively, and add an event to
continue if the send fails.


Revision tags: OPENBSD_5_8_BASE
# 1.14 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.13 20-Oct-2014 nicm

Better format for printf format attributes.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.12 10-Oct-2013 nicm

Pass flags into cmdq_guard as an argument since sometimes cmdq->cmd can
be NULL. Avoids crash when a command in a command client can't be
parsed.


Revision tags: OPENBSD_5_4_BASE
# 1.11 23-Jun-2013 nicm

Mark control commands specially so the client can identify them, based
on a diff from George Nachman a while back.


# 1.10 26-Mar-2013 nicm

Fix compiler warnings, missing #include. From Thomas Adam.


# 1.9 25-Mar-2013 nicm

Add time and a command count to control mode guards, based on code from
George Nachman.


# 1.8 24-Mar-2013 nicm

Add a command queue to standardize and simplify commands that call other
commands and allow a command to block execution of subsequent
commands. This allows run-shell and if-shell to be synchronous which has
been much requested.

Each client has a default command queue and commands are consumed one at
a time from it. A command may suspend execution from the queue by
returning CMD_RETURN_WAIT and then resume it by calling cmd_continue() -
for example run-shell does this from the callback that is fired after
the job is freed.

When the command queue becomes empty, command clients are automatically
exited (unless attaching). A callback is also fired - this is used for
nested commands in, for example, if-shell which can block execution of
the client's cmdq until a new cmdq becomes empty.

Also merge all the old error/info/print functions together and lose the
old curclient/cmdclient distinction - a cmdq is bound to one client (or
none if in the configuration file), this is a command client if
c->session is NULL otherwise an attached client.


# 1.7 22-Mar-2013 nicm

Need to set clients in context before changing their reference count.


# 1.6 22-Mar-2013 nicm

Remove unnecessary initializers of cmd_ctx.


# 1.5 22-Mar-2013 nicm

Add functions to allocate and free command contexts rather than doing it
all on the stack.


Revision tags: OPENBSD_5_3_BASE
# 1.4 24-Sep-2012 nicm

Add control_write_buffer, from George Nachman.


# 1.3 03-Sep-2012 nicm

Send notifications to control clients. Also don't redraw client when
suspended.


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

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


# 1.1 18-Jun-2012 nicm

Add a skeleton mode to tmux (called "control mode") that let's tmux
commands be sent and output received on stdout. This can be used to
integrate with other terminal emulators and should allow some other
things to be made simpler later. More to come so doesn't do much yet and
deliberately not documented.


# 1.43 18-Jun-2020 nicm

Add a flag to make a client wait for an empty line before exiting in
control mode to avoid stray commands ending up in the shell.


# 1.42 12-Jun-2020 nicm

Check if a pane needs to be paused when output is written rather than
just when it is queued.


# 1.41 11-Jun-2020 nicm

Add a -A option to pause a pane manually.


# 1.40 10-Jun-2020 nicm

Instead of a buffer size limit on each pane, set a limit of 300 seconds
of data for each client in control mode.


# 1.39 10-Jun-2020 nicm

When the pause-after flag is set, send an alternative %extended-output
form instead of %output with the age of the output.


# 1.38 05-Jun-2020 nicm

Add support for pausing a pane when the output buffered for a control
mode client gets too far behind. The pause-after flag with a time is set
on the pane with refresh-client -f and a paused pane may be resumed with
refresh-client -A. GitHub issue 2217.


# 1.37 02-Jun-2020 nicm

Use CLOCK_MONOTONIC for timer measurement and add a timestamp to control
mode %output blocks.


# 1.36 01-Jun-2020 nicm

Remove blocks from queue when pane disappears.


# 1.35 01-Jun-2020 nicm

Instead of sending all data to control mode clients as fast as possible,
add a limit of how much data will be sent to the client and try to use
it for panes with some degree of fairness. GitHub issue 2217, with
George Nachman.


# 1.34 26-May-2020 nicm

Pass the stdout file descriptor from the client as well as stdin and use
them for control clients directly instead of passing everything via the
client.


# 1.33 24-May-2020 nicm

Give control code its own state struct.


# 1.32 22-May-2020 nicm

Move client offset stuff into control.c since only control clients will
need it.


# 1.31 21-May-2020 nicm

Support code for control mode flow control: allow clients to have
separate offsets (used and acknowleged) into the pane buffers; turn off
reading from panes when no clients can accept the data; and add a -A
flag to refresh-client to let clients turn receiving a pane on and off.


Revision tags: OPENBSD_6_7_BASE
# 1.30 13-Apr-2020 nicm

Add helpers for the simple case of parse string and add to command queue.


# 1.29 13-Apr-2020 nicm

When adding a list of commands to the queue, instead of automatically
creating a new state for each group of commands, require the caller to
create one and use it for all the commands in the list. This means the
current target works even with list with multiple groups (which can
happen if they are defined with newlines).


# 1.28 13-Apr-2020 nicm

Move cmdq_state into cmd-queue.c.


# 1.27 13-Apr-2020 nicm

Rename cmdq_shared to cmdq_state which will better reflect what it is
(going to be) used for.


# 1.26 13-Apr-2020 nicm

Also move cmdq_item and cmdq_list into cmd-queue.c (this is to make its
use more clearly defined and preparation for some future work).


# 1.25 12-Dec-2019 nicm

Rewrite the code for reading and writing files. Now, if the client is
not attached, the server process asks it to open the file, similar to
how works for stdin, stdout, stderr. This makes special files like
/dev/fd/X work (used by some shells). stdin, stdout and stderr and
control mode are now just special cases of the same mechanism. This will
also make it easier to use for other commands that read files such as
source-file.


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

Do not leak empty lines, GitHub issue 1824.


# 1.23 31-May-2019 nicm

Allow % strings that are all numbers or %s, and fix a double free. Both
reported by George Nachman, GitHub issues 1765 and 1766.


# 1.22 23-May-2019 nicm

Replace the split parser code (cfg.c and cmd-string.c) with a single
parser using yacc(1). This is a major change but is clearer and simpler
and allows some edge cases to be made more consistent, as well as
tidying up how aliases are handled. It will also allow some further
improvements later.

Entirely the same parser is now used for parsing the configuration file
and for string commands. This means that constructs previously only
available in .tmux.conf, such as %if, can now be used in string commands
(for example, those given to if-shell - not commands invoked from the
shell, they are still parsed by the shell itself).

The only syntax change I am aware of is that #{} outside quotes or a
comment is now considered a format and not a comment, so #{ is now a
syntax error (notably, if it is at the start of a line).

This also adds two new sections to the man page documenting the syntax
and outlining how parsing and command execution works.

Thanks to everyone who sent me test configs (they still all parse
without errors - but this doesn't mean they still work as intended!).

Thanks to Avi Halachmi for testing and man page improvements, also to
jmc@ for reviewing the man page changes.


# 1.21 18-May-2019 nicm

Move the single command flag (CMD_CONTROL) into the shared flags.


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.20 15-Jan-2017 nicm

It is silly for cmd_list_parse to return an integer error when it could
just return NULL.


# 1.19 16-Oct-2016 nicm

Mass rename struct cmd_q to struct cmdq_item and related.


# 1.18 16-Oct-2016 nicm

Rewrite command queue handling. Each client still has a command queue,
but there is also now a global command queue. Instead of command queues
being dispatched on demand from wherever the command happens to be
added, they are now all dispatched from the top level server
loop. Command queues may now also include callbacks as well as commands,
and items may be inserted after the current command as well as at the end.

This all makes command queues significantly more predictable and easier
to use, and avoids the complex multiple nested command queues used by
source-file, if-shell and friends.

A mass rename of struct cmdq to a better name (cmdq_item probably) is
coming.


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.17 19-Jan-2016 nicm

I no longer use my SourceForge address so replace it.


# 1.16 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.15 14-Nov-2015 nicm

Push stdout and stderr to clients more aggressively, and add an event to
continue if the send fails.


Revision tags: OPENBSD_5_8_BASE
# 1.14 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.13 20-Oct-2014 nicm

Better format for printf format attributes.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.12 10-Oct-2013 nicm

Pass flags into cmdq_guard as an argument since sometimes cmdq->cmd can
be NULL. Avoids crash when a command in a command client can't be
parsed.


Revision tags: OPENBSD_5_4_BASE
# 1.11 23-Jun-2013 nicm

Mark control commands specially so the client can identify them, based
on a diff from George Nachman a while back.


# 1.10 26-Mar-2013 nicm

Fix compiler warnings, missing #include. From Thomas Adam.


# 1.9 25-Mar-2013 nicm

Add time and a command count to control mode guards, based on code from
George Nachman.


# 1.8 24-Mar-2013 nicm

Add a command queue to standardize and simplify commands that call other
commands and allow a command to block execution of subsequent
commands. This allows run-shell and if-shell to be synchronous which has
been much requested.

Each client has a default command queue and commands are consumed one at
a time from it. A command may suspend execution from the queue by
returning CMD_RETURN_WAIT and then resume it by calling cmd_continue() -
for example run-shell does this from the callback that is fired after
the job is freed.

When the command queue becomes empty, command clients are automatically
exited (unless attaching). A callback is also fired - this is used for
nested commands in, for example, if-shell which can block execution of
the client's cmdq until a new cmdq becomes empty.

Also merge all the old error/info/print functions together and lose the
old curclient/cmdclient distinction - a cmdq is bound to one client (or
none if in the configuration file), this is a command client if
c->session is NULL otherwise an attached client.


# 1.7 22-Mar-2013 nicm

Need to set clients in context before changing their reference count.


# 1.6 22-Mar-2013 nicm

Remove unnecessary initializers of cmd_ctx.


# 1.5 22-Mar-2013 nicm

Add functions to allocate and free command contexts rather than doing it
all on the stack.


Revision tags: OPENBSD_5_3_BASE
# 1.4 24-Sep-2012 nicm

Add control_write_buffer, from George Nachman.


# 1.3 03-Sep-2012 nicm

Send notifications to control clients. Also don't redraw client when
suspended.


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

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


# 1.1 18-Jun-2012 nicm

Add a skeleton mode to tmux (called "control mode") that let's tmux
commands be sent and output received on stdout. This can be used to
integrate with other terminal emulators and should allow some other
things to be made simpler later. More to come so doesn't do much yet and
deliberately not documented.


# 1.42 12-Jun-2020 nicm

Check if a pane needs to be paused when output is written rather than
just when it is queued.


# 1.41 11-Jun-2020 nicm

Add a -A option to pause a pane manually.


# 1.40 10-Jun-2020 nicm

Instead of a buffer size limit on each pane, set a limit of 300 seconds
of data for each client in control mode.


# 1.39 10-Jun-2020 nicm

When the pause-after flag is set, send an alternative %extended-output
form instead of %output with the age of the output.


# 1.38 05-Jun-2020 nicm

Add support for pausing a pane when the output buffered for a control
mode client gets too far behind. The pause-after flag with a time is set
on the pane with refresh-client -f and a paused pane may be resumed with
refresh-client -A. GitHub issue 2217.


# 1.37 02-Jun-2020 nicm

Use CLOCK_MONOTONIC for timer measurement and add a timestamp to control
mode %output blocks.


# 1.36 01-Jun-2020 nicm

Remove blocks from queue when pane disappears.


# 1.35 01-Jun-2020 nicm

Instead of sending all data to control mode clients as fast as possible,
add a limit of how much data will be sent to the client and try to use
it for panes with some degree of fairness. GitHub issue 2217, with
George Nachman.


# 1.34 26-May-2020 nicm

Pass the stdout file descriptor from the client as well as stdin and use
them for control clients directly instead of passing everything via the
client.


# 1.33 24-May-2020 nicm

Give control code its own state struct.


# 1.32 22-May-2020 nicm

Move client offset stuff into control.c since only control clients will
need it.


# 1.31 21-May-2020 nicm

Support code for control mode flow control: allow clients to have
separate offsets (used and acknowleged) into the pane buffers; turn off
reading from panes when no clients can accept the data; and add a -A
flag to refresh-client to let clients turn receiving a pane on and off.


Revision tags: OPENBSD_6_7_BASE
# 1.30 13-Apr-2020 nicm

Add helpers for the simple case of parse string and add to command queue.


# 1.29 13-Apr-2020 nicm

When adding a list of commands to the queue, instead of automatically
creating a new state for each group of commands, require the caller to
create one and use it for all the commands in the list. This means the
current target works even with list with multiple groups (which can
happen if they are defined with newlines).


# 1.28 13-Apr-2020 nicm

Move cmdq_state into cmd-queue.c.


# 1.27 13-Apr-2020 nicm

Rename cmdq_shared to cmdq_state which will better reflect what it is
(going to be) used for.


# 1.26 13-Apr-2020 nicm

Also move cmdq_item and cmdq_list into cmd-queue.c (this is to make its
use more clearly defined and preparation for some future work).


# 1.25 12-Dec-2019 nicm

Rewrite the code for reading and writing files. Now, if the client is
not attached, the server process asks it to open the file, similar to
how works for stdin, stdout, stderr. This makes special files like
/dev/fd/X work (used by some shells). stdin, stdout and stderr and
control mode are now just special cases of the same mechanism. This will
also make it easier to use for other commands that read files such as
source-file.


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

Do not leak empty lines, GitHub issue 1824.


# 1.23 31-May-2019 nicm

Allow % strings that are all numbers or %s, and fix a double free. Both
reported by George Nachman, GitHub issues 1765 and 1766.


# 1.22 23-May-2019 nicm

Replace the split parser code (cfg.c and cmd-string.c) with a single
parser using yacc(1). This is a major change but is clearer and simpler
and allows some edge cases to be made more consistent, as well as
tidying up how aliases are handled. It will also allow some further
improvements later.

Entirely the same parser is now used for parsing the configuration file
and for string commands. This means that constructs previously only
available in .tmux.conf, such as %if, can now be used in string commands
(for example, those given to if-shell - not commands invoked from the
shell, they are still parsed by the shell itself).

The only syntax change I am aware of is that #{} outside quotes or a
comment is now considered a format and not a comment, so #{ is now a
syntax error (notably, if it is at the start of a line).

This also adds two new sections to the man page documenting the syntax
and outlining how parsing and command execution works.

Thanks to everyone who sent me test configs (they still all parse
without errors - but this doesn't mean they still work as intended!).

Thanks to Avi Halachmi for testing and man page improvements, also to
jmc@ for reviewing the man page changes.


# 1.21 18-May-2019 nicm

Move the single command flag (CMD_CONTROL) into the shared flags.


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.20 15-Jan-2017 nicm

It is silly for cmd_list_parse to return an integer error when it could
just return NULL.


# 1.19 16-Oct-2016 nicm

Mass rename struct cmd_q to struct cmdq_item and related.


# 1.18 16-Oct-2016 nicm

Rewrite command queue handling. Each client still has a command queue,
but there is also now a global command queue. Instead of command queues
being dispatched on demand from wherever the command happens to be
added, they are now all dispatched from the top level server
loop. Command queues may now also include callbacks as well as commands,
and items may be inserted after the current command as well as at the end.

This all makes command queues significantly more predictable and easier
to use, and avoids the complex multiple nested command queues used by
source-file, if-shell and friends.

A mass rename of struct cmdq to a better name (cmdq_item probably) is
coming.


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.17 19-Jan-2016 nicm

I no longer use my SourceForge address so replace it.


# 1.16 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.15 14-Nov-2015 nicm

Push stdout and stderr to clients more aggressively, and add an event to
continue if the send fails.


Revision tags: OPENBSD_5_8_BASE
# 1.14 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.13 20-Oct-2014 nicm

Better format for printf format attributes.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.12 10-Oct-2013 nicm

Pass flags into cmdq_guard as an argument since sometimes cmdq->cmd can
be NULL. Avoids crash when a command in a command client can't be
parsed.


Revision tags: OPENBSD_5_4_BASE
# 1.11 23-Jun-2013 nicm

Mark control commands specially so the client can identify them, based
on a diff from George Nachman a while back.


# 1.10 26-Mar-2013 nicm

Fix compiler warnings, missing #include. From Thomas Adam.


# 1.9 25-Mar-2013 nicm

Add time and a command count to control mode guards, based on code from
George Nachman.


# 1.8 24-Mar-2013 nicm

Add a command queue to standardize and simplify commands that call other
commands and allow a command to block execution of subsequent
commands. This allows run-shell and if-shell to be synchronous which has
been much requested.

Each client has a default command queue and commands are consumed one at
a time from it. A command may suspend execution from the queue by
returning CMD_RETURN_WAIT and then resume it by calling cmd_continue() -
for example run-shell does this from the callback that is fired after
the job is freed.

When the command queue becomes empty, command clients are automatically
exited (unless attaching). A callback is also fired - this is used for
nested commands in, for example, if-shell which can block execution of
the client's cmdq until a new cmdq becomes empty.

Also merge all the old error/info/print functions together and lose the
old curclient/cmdclient distinction - a cmdq is bound to one client (or
none if in the configuration file), this is a command client if
c->session is NULL otherwise an attached client.


# 1.7 22-Mar-2013 nicm

Need to set clients in context before changing their reference count.


# 1.6 22-Mar-2013 nicm

Remove unnecessary initializers of cmd_ctx.


# 1.5 22-Mar-2013 nicm

Add functions to allocate and free command contexts rather than doing it
all on the stack.


Revision tags: OPENBSD_5_3_BASE
# 1.4 24-Sep-2012 nicm

Add control_write_buffer, from George Nachman.


# 1.3 03-Sep-2012 nicm

Send notifications to control clients. Also don't redraw client when
suspended.


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

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


# 1.1 18-Jun-2012 nicm

Add a skeleton mode to tmux (called "control mode") that let's tmux
commands be sent and output received on stdout. This can be used to
integrate with other terminal emulators and should allow some other
things to be made simpler later. More to come so doesn't do much yet and
deliberately not documented.


# 1.41 11-Jun-2020 nicm

Add a -A option to pause a pane manually.


# 1.40 10-Jun-2020 nicm

Instead of a buffer size limit on each pane, set a limit of 300 seconds
of data for each client in control mode.


# 1.39 10-Jun-2020 nicm

When the pause-after flag is set, send an alternative %extended-output
form instead of %output with the age of the output.


# 1.38 05-Jun-2020 nicm

Add support for pausing a pane when the output buffered for a control
mode client gets too far behind. The pause-after flag with a time is set
on the pane with refresh-client -f and a paused pane may be resumed with
refresh-client -A. GitHub issue 2217.


# 1.37 02-Jun-2020 nicm

Use CLOCK_MONOTONIC for timer measurement and add a timestamp to control
mode %output blocks.


# 1.36 01-Jun-2020 nicm

Remove blocks from queue when pane disappears.


# 1.35 01-Jun-2020 nicm

Instead of sending all data to control mode clients as fast as possible,
add a limit of how much data will be sent to the client and try to use
it for panes with some degree of fairness. GitHub issue 2217, with
George Nachman.


# 1.34 26-May-2020 nicm

Pass the stdout file descriptor from the client as well as stdin and use
them for control clients directly instead of passing everything via the
client.


# 1.33 24-May-2020 nicm

Give control code its own state struct.


# 1.32 22-May-2020 nicm

Move client offset stuff into control.c since only control clients will
need it.


# 1.31 21-May-2020 nicm

Support code for control mode flow control: allow clients to have
separate offsets (used and acknowleged) into the pane buffers; turn off
reading from panes when no clients can accept the data; and add a -A
flag to refresh-client to let clients turn receiving a pane on and off.


Revision tags: OPENBSD_6_7_BASE
# 1.30 13-Apr-2020 nicm

Add helpers for the simple case of parse string and add to command queue.


# 1.29 13-Apr-2020 nicm

When adding a list of commands to the queue, instead of automatically
creating a new state for each group of commands, require the caller to
create one and use it for all the commands in the list. This means the
current target works even with list with multiple groups (which can
happen if they are defined with newlines).


# 1.28 13-Apr-2020 nicm

Move cmdq_state into cmd-queue.c.


# 1.27 13-Apr-2020 nicm

Rename cmdq_shared to cmdq_state which will better reflect what it is
(going to be) used for.


# 1.26 13-Apr-2020 nicm

Also move cmdq_item and cmdq_list into cmd-queue.c (this is to make its
use more clearly defined and preparation for some future work).


# 1.25 12-Dec-2019 nicm

Rewrite the code for reading and writing files. Now, if the client is
not attached, the server process asks it to open the file, similar to
how works for stdin, stdout, stderr. This makes special files like
/dev/fd/X work (used by some shells). stdin, stdout and stderr and
control mode are now just special cases of the same mechanism. This will
also make it easier to use for other commands that read files such as
source-file.


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

Do not leak empty lines, GitHub issue 1824.


# 1.23 31-May-2019 nicm

Allow % strings that are all numbers or %s, and fix a double free. Both
reported by George Nachman, GitHub issues 1765 and 1766.


# 1.22 23-May-2019 nicm

Replace the split parser code (cfg.c and cmd-string.c) with a single
parser using yacc(1). This is a major change but is clearer and simpler
and allows some edge cases to be made more consistent, as well as
tidying up how aliases are handled. It will also allow some further
improvements later.

Entirely the same parser is now used for parsing the configuration file
and for string commands. This means that constructs previously only
available in .tmux.conf, such as %if, can now be used in string commands
(for example, those given to if-shell - not commands invoked from the
shell, they are still parsed by the shell itself).

The only syntax change I am aware of is that #{} outside quotes or a
comment is now considered a format and not a comment, so #{ is now a
syntax error (notably, if it is at the start of a line).

This also adds two new sections to the man page documenting the syntax
and outlining how parsing and command execution works.

Thanks to everyone who sent me test configs (they still all parse
without errors - but this doesn't mean they still work as intended!).

Thanks to Avi Halachmi for testing and man page improvements, also to
jmc@ for reviewing the man page changes.


# 1.21 18-May-2019 nicm

Move the single command flag (CMD_CONTROL) into the shared flags.


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.20 15-Jan-2017 nicm

It is silly for cmd_list_parse to return an integer error when it could
just return NULL.


# 1.19 16-Oct-2016 nicm

Mass rename struct cmd_q to struct cmdq_item and related.


# 1.18 16-Oct-2016 nicm

Rewrite command queue handling. Each client still has a command queue,
but there is also now a global command queue. Instead of command queues
being dispatched on demand from wherever the command happens to be
added, they are now all dispatched from the top level server
loop. Command queues may now also include callbacks as well as commands,
and items may be inserted after the current command as well as at the end.

This all makes command queues significantly more predictable and easier
to use, and avoids the complex multiple nested command queues used by
source-file, if-shell and friends.

A mass rename of struct cmdq to a better name (cmdq_item probably) is
coming.


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.17 19-Jan-2016 nicm

I no longer use my SourceForge address so replace it.


# 1.16 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.15 14-Nov-2015 nicm

Push stdout and stderr to clients more aggressively, and add an event to
continue if the send fails.


Revision tags: OPENBSD_5_8_BASE
# 1.14 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.13 20-Oct-2014 nicm

Better format for printf format attributes.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.12 10-Oct-2013 nicm

Pass flags into cmdq_guard as an argument since sometimes cmdq->cmd can
be NULL. Avoids crash when a command in a command client can't be
parsed.


Revision tags: OPENBSD_5_4_BASE
# 1.11 23-Jun-2013 nicm

Mark control commands specially so the client can identify them, based
on a diff from George Nachman a while back.


# 1.10 26-Mar-2013 nicm

Fix compiler warnings, missing #include. From Thomas Adam.


# 1.9 25-Mar-2013 nicm

Add time and a command count to control mode guards, based on code from
George Nachman.


# 1.8 24-Mar-2013 nicm

Add a command queue to standardize and simplify commands that call other
commands and allow a command to block execution of subsequent
commands. This allows run-shell and if-shell to be synchronous which has
been much requested.

Each client has a default command queue and commands are consumed one at
a time from it. A command may suspend execution from the queue by
returning CMD_RETURN_WAIT and then resume it by calling cmd_continue() -
for example run-shell does this from the callback that is fired after
the job is freed.

When the command queue becomes empty, command clients are automatically
exited (unless attaching). A callback is also fired - this is used for
nested commands in, for example, if-shell which can block execution of
the client's cmdq until a new cmdq becomes empty.

Also merge all the old error/info/print functions together and lose the
old curclient/cmdclient distinction - a cmdq is bound to one client (or
none if in the configuration file), this is a command client if
c->session is NULL otherwise an attached client.


# 1.7 22-Mar-2013 nicm

Need to set clients in context before changing their reference count.


# 1.6 22-Mar-2013 nicm

Remove unnecessary initializers of cmd_ctx.


# 1.5 22-Mar-2013 nicm

Add functions to allocate and free command contexts rather than doing it
all on the stack.


Revision tags: OPENBSD_5_3_BASE
# 1.4 24-Sep-2012 nicm

Add control_write_buffer, from George Nachman.


# 1.3 03-Sep-2012 nicm

Send notifications to control clients. Also don't redraw client when
suspended.


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

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


# 1.1 18-Jun-2012 nicm

Add a skeleton mode to tmux (called "control mode") that let's tmux
commands be sent and output received on stdout. This can be used to
integrate with other terminal emulators and should allow some other
things to be made simpler later. More to come so doesn't do much yet and
deliberately not documented.


# 1.38 05-Jun-2020 nicm

Add support for pausing a pane when the output buffered for a control
mode client gets too far behind. The pause-after flag with a time is set
on the pane with refresh-client -f and a paused pane may be resumed with
refresh-client -A. GitHub issue 2217.


# 1.37 02-Jun-2020 nicm

Use CLOCK_MONOTONIC for timer measurement and add a timestamp to control
mode %output blocks.


# 1.36 01-Jun-2020 nicm

Remove blocks from queue when pane disappears.


# 1.35 01-Jun-2020 nicm

Instead of sending all data to control mode clients as fast as possible,
add a limit of how much data will be sent to the client and try to use
it for panes with some degree of fairness. GitHub issue 2217, with
George Nachman.


# 1.34 26-May-2020 nicm

Pass the stdout file descriptor from the client as well as stdin and use
them for control clients directly instead of passing everything via the
client.


# 1.33 24-May-2020 nicm

Give control code its own state struct.


# 1.32 22-May-2020 nicm

Move client offset stuff into control.c since only control clients will
need it.


# 1.31 21-May-2020 nicm

Support code for control mode flow control: allow clients to have
separate offsets (used and acknowleged) into the pane buffers; turn off
reading from panes when no clients can accept the data; and add a -A
flag to refresh-client to let clients turn receiving a pane on and off.


Revision tags: OPENBSD_6_7_BASE
# 1.30 13-Apr-2020 nicm

Add helpers for the simple case of parse string and add to command queue.


# 1.29 13-Apr-2020 nicm

When adding a list of commands to the queue, instead of automatically
creating a new state for each group of commands, require the caller to
create one and use it for all the commands in the list. This means the
current target works even with list with multiple groups (which can
happen if they are defined with newlines).


# 1.28 13-Apr-2020 nicm

Move cmdq_state into cmd-queue.c.


# 1.27 13-Apr-2020 nicm

Rename cmdq_shared to cmdq_state which will better reflect what it is
(going to be) used for.


# 1.26 13-Apr-2020 nicm

Also move cmdq_item and cmdq_list into cmd-queue.c (this is to make its
use more clearly defined and preparation for some future work).


# 1.25 12-Dec-2019 nicm

Rewrite the code for reading and writing files. Now, if the client is
not attached, the server process asks it to open the file, similar to
how works for stdin, stdout, stderr. This makes special files like
/dev/fd/X work (used by some shells). stdin, stdout and stderr and
control mode are now just special cases of the same mechanism. This will
also make it easier to use for other commands that read files such as
source-file.


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

Do not leak empty lines, GitHub issue 1824.


# 1.23 31-May-2019 nicm

Allow % strings that are all numbers or %s, and fix a double free. Both
reported by George Nachman, GitHub issues 1765 and 1766.


# 1.22 23-May-2019 nicm

Replace the split parser code (cfg.c and cmd-string.c) with a single
parser using yacc(1). This is a major change but is clearer and simpler
and allows some edge cases to be made more consistent, as well as
tidying up how aliases are handled. It will also allow some further
improvements later.

Entirely the same parser is now used for parsing the configuration file
and for string commands. This means that constructs previously only
available in .tmux.conf, such as %if, can now be used in string commands
(for example, those given to if-shell - not commands invoked from the
shell, they are still parsed by the shell itself).

The only syntax change I am aware of is that #{} outside quotes or a
comment is now considered a format and not a comment, so #{ is now a
syntax error (notably, if it is at the start of a line).

This also adds two new sections to the man page documenting the syntax
and outlining how parsing and command execution works.

Thanks to everyone who sent me test configs (they still all parse
without errors - but this doesn't mean they still work as intended!).

Thanks to Avi Halachmi for testing and man page improvements, also to
jmc@ for reviewing the man page changes.


# 1.21 18-May-2019 nicm

Move the single command flag (CMD_CONTROL) into the shared flags.


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.20 15-Jan-2017 nicm

It is silly for cmd_list_parse to return an integer error when it could
just return NULL.


# 1.19 16-Oct-2016 nicm

Mass rename struct cmd_q to struct cmdq_item and related.


# 1.18 16-Oct-2016 nicm

Rewrite command queue handling. Each client still has a command queue,
but there is also now a global command queue. Instead of command queues
being dispatched on demand from wherever the command happens to be
added, they are now all dispatched from the top level server
loop. Command queues may now also include callbacks as well as commands,
and items may be inserted after the current command as well as at the end.

This all makes command queues significantly more predictable and easier
to use, and avoids the complex multiple nested command queues used by
source-file, if-shell and friends.

A mass rename of struct cmdq to a better name (cmdq_item probably) is
coming.


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.17 19-Jan-2016 nicm

I no longer use my SourceForge address so replace it.


# 1.16 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.15 14-Nov-2015 nicm

Push stdout and stderr to clients more aggressively, and add an event to
continue if the send fails.


Revision tags: OPENBSD_5_8_BASE
# 1.14 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.13 20-Oct-2014 nicm

Better format for printf format attributes.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.12 10-Oct-2013 nicm

Pass flags into cmdq_guard as an argument since sometimes cmdq->cmd can
be NULL. Avoids crash when a command in a command client can't be
parsed.


Revision tags: OPENBSD_5_4_BASE
# 1.11 23-Jun-2013 nicm

Mark control commands specially so the client can identify them, based
on a diff from George Nachman a while back.


# 1.10 26-Mar-2013 nicm

Fix compiler warnings, missing #include. From Thomas Adam.


# 1.9 25-Mar-2013 nicm

Add time and a command count to control mode guards, based on code from
George Nachman.


# 1.8 24-Mar-2013 nicm

Add a command queue to standardize and simplify commands that call other
commands and allow a command to block execution of subsequent
commands. This allows run-shell and if-shell to be synchronous which has
been much requested.

Each client has a default command queue and commands are consumed one at
a time from it. A command may suspend execution from the queue by
returning CMD_RETURN_WAIT and then resume it by calling cmd_continue() -
for example run-shell does this from the callback that is fired after
the job is freed.

When the command queue becomes empty, command clients are automatically
exited (unless attaching). A callback is also fired - this is used for
nested commands in, for example, if-shell which can block execution of
the client's cmdq until a new cmdq becomes empty.

Also merge all the old error/info/print functions together and lose the
old curclient/cmdclient distinction - a cmdq is bound to one client (or
none if in the configuration file), this is a command client if
c->session is NULL otherwise an attached client.


# 1.7 22-Mar-2013 nicm

Need to set clients in context before changing their reference count.


# 1.6 22-Mar-2013 nicm

Remove unnecessary initializers of cmd_ctx.


# 1.5 22-Mar-2013 nicm

Add functions to allocate and free command contexts rather than doing it
all on the stack.


Revision tags: OPENBSD_5_3_BASE
# 1.4 24-Sep-2012 nicm

Add control_write_buffer, from George Nachman.


# 1.3 03-Sep-2012 nicm

Send notifications to control clients. Also don't redraw client when
suspended.


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

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


# 1.1 18-Jun-2012 nicm

Add a skeleton mode to tmux (called "control mode") that let's tmux
commands be sent and output received on stdout. This can be used to
integrate with other terminal emulators and should allow some other
things to be made simpler later. More to come so doesn't do much yet and
deliberately not documented.


# 1.37 02-Jun-2020 nicm

Use CLOCK_MONOTONIC for timer measurement and add a timestamp to control
mode %output blocks.


# 1.36 01-Jun-2020 nicm

Remove blocks from queue when pane disappears.


# 1.35 01-Jun-2020 nicm

Instead of sending all data to control mode clients as fast as possible,
add a limit of how much data will be sent to the client and try to use
it for panes with some degree of fairness. GitHub issue 2217, with
George Nachman.


# 1.34 26-May-2020 nicm

Pass the stdout file descriptor from the client as well as stdin and use
them for control clients directly instead of passing everything via the
client.


# 1.33 24-May-2020 nicm

Give control code its own state struct.


# 1.32 22-May-2020 nicm

Move client offset stuff into control.c since only control clients will
need it.


# 1.31 21-May-2020 nicm

Support code for control mode flow control: allow clients to have
separate offsets (used and acknowleged) into the pane buffers; turn off
reading from panes when no clients can accept the data; and add a -A
flag to refresh-client to let clients turn receiving a pane on and off.


Revision tags: OPENBSD_6_7_BASE
# 1.30 13-Apr-2020 nicm

Add helpers for the simple case of parse string and add to command queue.


# 1.29 13-Apr-2020 nicm

When adding a list of commands to the queue, instead of automatically
creating a new state for each group of commands, require the caller to
create one and use it for all the commands in the list. This means the
current target works even with list with multiple groups (which can
happen if they are defined with newlines).


# 1.28 13-Apr-2020 nicm

Move cmdq_state into cmd-queue.c.


# 1.27 13-Apr-2020 nicm

Rename cmdq_shared to cmdq_state which will better reflect what it is
(going to be) used for.


# 1.26 13-Apr-2020 nicm

Also move cmdq_item and cmdq_list into cmd-queue.c (this is to make its
use more clearly defined and preparation for some future work).


# 1.25 12-Dec-2019 nicm

Rewrite the code for reading and writing files. Now, if the client is
not attached, the server process asks it to open the file, similar to
how works for stdin, stdout, stderr. This makes special files like
/dev/fd/X work (used by some shells). stdin, stdout and stderr and
control mode are now just special cases of the same mechanism. This will
also make it easier to use for other commands that read files such as
source-file.


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

Do not leak empty lines, GitHub issue 1824.


# 1.23 31-May-2019 nicm

Allow % strings that are all numbers or %s, and fix a double free. Both
reported by George Nachman, GitHub issues 1765 and 1766.


# 1.22 23-May-2019 nicm

Replace the split parser code (cfg.c and cmd-string.c) with a single
parser using yacc(1). This is a major change but is clearer and simpler
and allows some edge cases to be made more consistent, as well as
tidying up how aliases are handled. It will also allow some further
improvements later.

Entirely the same parser is now used for parsing the configuration file
and for string commands. This means that constructs previously only
available in .tmux.conf, such as %if, can now be used in string commands
(for example, those given to if-shell - not commands invoked from the
shell, they are still parsed by the shell itself).

The only syntax change I am aware of is that #{} outside quotes or a
comment is now considered a format and not a comment, so #{ is now a
syntax error (notably, if it is at the start of a line).

This also adds two new sections to the man page documenting the syntax
and outlining how parsing and command execution works.

Thanks to everyone who sent me test configs (they still all parse
without errors - but this doesn't mean they still work as intended!).

Thanks to Avi Halachmi for testing and man page improvements, also to
jmc@ for reviewing the man page changes.


# 1.21 18-May-2019 nicm

Move the single command flag (CMD_CONTROL) into the shared flags.


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.20 15-Jan-2017 nicm

It is silly for cmd_list_parse to return an integer error when it could
just return NULL.


# 1.19 16-Oct-2016 nicm

Mass rename struct cmd_q to struct cmdq_item and related.


# 1.18 16-Oct-2016 nicm

Rewrite command queue handling. Each client still has a command queue,
but there is also now a global command queue. Instead of command queues
being dispatched on demand from wherever the command happens to be
added, they are now all dispatched from the top level server
loop. Command queues may now also include callbacks as well as commands,
and items may be inserted after the current command as well as at the end.

This all makes command queues significantly more predictable and easier
to use, and avoids the complex multiple nested command queues used by
source-file, if-shell and friends.

A mass rename of struct cmdq to a better name (cmdq_item probably) is
coming.


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.17 19-Jan-2016 nicm

I no longer use my SourceForge address so replace it.


# 1.16 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.15 14-Nov-2015 nicm

Push stdout and stderr to clients more aggressively, and add an event to
continue if the send fails.


Revision tags: OPENBSD_5_8_BASE
# 1.14 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.13 20-Oct-2014 nicm

Better format for printf format attributes.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.12 10-Oct-2013 nicm

Pass flags into cmdq_guard as an argument since sometimes cmdq->cmd can
be NULL. Avoids crash when a command in a command client can't be
parsed.


Revision tags: OPENBSD_5_4_BASE
# 1.11 23-Jun-2013 nicm

Mark control commands specially so the client can identify them, based
on a diff from George Nachman a while back.


# 1.10 26-Mar-2013 nicm

Fix compiler warnings, missing #include. From Thomas Adam.


# 1.9 25-Mar-2013 nicm

Add time and a command count to control mode guards, based on code from
George Nachman.


# 1.8 24-Mar-2013 nicm

Add a command queue to standardize and simplify commands that call other
commands and allow a command to block execution of subsequent
commands. This allows run-shell and if-shell to be synchronous which has
been much requested.

Each client has a default command queue and commands are consumed one at
a time from it. A command may suspend execution from the queue by
returning CMD_RETURN_WAIT and then resume it by calling cmd_continue() -
for example run-shell does this from the callback that is fired after
the job is freed.

When the command queue becomes empty, command clients are automatically
exited (unless attaching). A callback is also fired - this is used for
nested commands in, for example, if-shell which can block execution of
the client's cmdq until a new cmdq becomes empty.

Also merge all the old error/info/print functions together and lose the
old curclient/cmdclient distinction - a cmdq is bound to one client (or
none if in the configuration file), this is a command client if
c->session is NULL otherwise an attached client.


# 1.7 22-Mar-2013 nicm

Need to set clients in context before changing their reference count.


# 1.6 22-Mar-2013 nicm

Remove unnecessary initializers of cmd_ctx.


# 1.5 22-Mar-2013 nicm

Add functions to allocate and free command contexts rather than doing it
all on the stack.


Revision tags: OPENBSD_5_3_BASE
# 1.4 24-Sep-2012 nicm

Add control_write_buffer, from George Nachman.


# 1.3 03-Sep-2012 nicm

Send notifications to control clients. Also don't redraw client when
suspended.


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

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


# 1.1 18-Jun-2012 nicm

Add a skeleton mode to tmux (called "control mode") that let's tmux
commands be sent and output received on stdout. This can be used to
integrate with other terminal emulators and should allow some other
things to be made simpler later. More to come so doesn't do much yet and
deliberately not documented.


# 1.35 01-Jun-2020 nicm

Instead of sending all data to control mode clients as fast as possible,
add a limit of how much data will be sent to the client and try to use
it for panes with some degree of fairness. GitHub issue 2217, with
George Nachman.


# 1.34 26-May-2020 nicm

Pass the stdout file descriptor from the client as well as stdin and use
them for control clients directly instead of passing everything via the
client.


# 1.33 24-May-2020 nicm

Give control code its own state struct.


# 1.32 22-May-2020 nicm

Move client offset stuff into control.c since only control clients will
need it.


# 1.31 21-May-2020 nicm

Support code for control mode flow control: allow clients to have
separate offsets (used and acknowleged) into the pane buffers; turn off
reading from panes when no clients can accept the data; and add a -A
flag to refresh-client to let clients turn receiving a pane on and off.


Revision tags: OPENBSD_6_7_BASE
# 1.30 13-Apr-2020 nicm

Add helpers for the simple case of parse string and add to command queue.


# 1.29 13-Apr-2020 nicm

When adding a list of commands to the queue, instead of automatically
creating a new state for each group of commands, require the caller to
create one and use it for all the commands in the list. This means the
current target works even with list with multiple groups (which can
happen if they are defined with newlines).


# 1.28 13-Apr-2020 nicm

Move cmdq_state into cmd-queue.c.


# 1.27 13-Apr-2020 nicm

Rename cmdq_shared to cmdq_state which will better reflect what it is
(going to be) used for.


# 1.26 13-Apr-2020 nicm

Also move cmdq_item and cmdq_list into cmd-queue.c (this is to make its
use more clearly defined and preparation for some future work).


# 1.25 12-Dec-2019 nicm

Rewrite the code for reading and writing files. Now, if the client is
not attached, the server process asks it to open the file, similar to
how works for stdin, stdout, stderr. This makes special files like
/dev/fd/X work (used by some shells). stdin, stdout and stderr and
control mode are now just special cases of the same mechanism. This will
also make it easier to use for other commands that read files such as
source-file.


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

Do not leak empty lines, GitHub issue 1824.


# 1.23 31-May-2019 nicm

Allow % strings that are all numbers or %s, and fix a double free. Both
reported by George Nachman, GitHub issues 1765 and 1766.


# 1.22 23-May-2019 nicm

Replace the split parser code (cfg.c and cmd-string.c) with a single
parser using yacc(1). This is a major change but is clearer and simpler
and allows some edge cases to be made more consistent, as well as
tidying up how aliases are handled. It will also allow some further
improvements later.

Entirely the same parser is now used for parsing the configuration file
and for string commands. This means that constructs previously only
available in .tmux.conf, such as %if, can now be used in string commands
(for example, those given to if-shell - not commands invoked from the
shell, they are still parsed by the shell itself).

The only syntax change I am aware of is that #{} outside quotes or a
comment is now considered a format and not a comment, so #{ is now a
syntax error (notably, if it is at the start of a line).

This also adds two new sections to the man page documenting the syntax
and outlining how parsing and command execution works.

Thanks to everyone who sent me test configs (they still all parse
without errors - but this doesn't mean they still work as intended!).

Thanks to Avi Halachmi for testing and man page improvements, also to
jmc@ for reviewing the man page changes.


# 1.21 18-May-2019 nicm

Move the single command flag (CMD_CONTROL) into the shared flags.


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.20 15-Jan-2017 nicm

It is silly for cmd_list_parse to return an integer error when it could
just return NULL.


# 1.19 16-Oct-2016 nicm

Mass rename struct cmd_q to struct cmdq_item and related.


# 1.18 16-Oct-2016 nicm

Rewrite command queue handling. Each client still has a command queue,
but there is also now a global command queue. Instead of command queues
being dispatched on demand from wherever the command happens to be
added, they are now all dispatched from the top level server
loop. Command queues may now also include callbacks as well as commands,
and items may be inserted after the current command as well as at the end.

This all makes command queues significantly more predictable and easier
to use, and avoids the complex multiple nested command queues used by
source-file, if-shell and friends.

A mass rename of struct cmdq to a better name (cmdq_item probably) is
coming.


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.17 19-Jan-2016 nicm

I no longer use my SourceForge address so replace it.


# 1.16 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.15 14-Nov-2015 nicm

Push stdout and stderr to clients more aggressively, and add an event to
continue if the send fails.


Revision tags: OPENBSD_5_8_BASE
# 1.14 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.13 20-Oct-2014 nicm

Better format for printf format attributes.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.12 10-Oct-2013 nicm

Pass flags into cmdq_guard as an argument since sometimes cmdq->cmd can
be NULL. Avoids crash when a command in a command client can't be
parsed.


Revision tags: OPENBSD_5_4_BASE
# 1.11 23-Jun-2013 nicm

Mark control commands specially so the client can identify them, based
on a diff from George Nachman a while back.


# 1.10 26-Mar-2013 nicm

Fix compiler warnings, missing #include. From Thomas Adam.


# 1.9 25-Mar-2013 nicm

Add time and a command count to control mode guards, based on code from
George Nachman.


# 1.8 24-Mar-2013 nicm

Add a command queue to standardize and simplify commands that call other
commands and allow a command to block execution of subsequent
commands. This allows run-shell and if-shell to be synchronous which has
been much requested.

Each client has a default command queue and commands are consumed one at
a time from it. A command may suspend execution from the queue by
returning CMD_RETURN_WAIT and then resume it by calling cmd_continue() -
for example run-shell does this from the callback that is fired after
the job is freed.

When the command queue becomes empty, command clients are automatically
exited (unless attaching). A callback is also fired - this is used for
nested commands in, for example, if-shell which can block execution of
the client's cmdq until a new cmdq becomes empty.

Also merge all the old error/info/print functions together and lose the
old curclient/cmdclient distinction - a cmdq is bound to one client (or
none if in the configuration file), this is a command client if
c->session is NULL otherwise an attached client.


# 1.7 22-Mar-2013 nicm

Need to set clients in context before changing their reference count.


# 1.6 22-Mar-2013 nicm

Remove unnecessary initializers of cmd_ctx.


# 1.5 22-Mar-2013 nicm

Add functions to allocate and free command contexts rather than doing it
all on the stack.


Revision tags: OPENBSD_5_3_BASE
# 1.4 24-Sep-2012 nicm

Add control_write_buffer, from George Nachman.


# 1.3 03-Sep-2012 nicm

Send notifications to control clients. Also don't redraw client when
suspended.


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

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


# 1.1 18-Jun-2012 nicm

Add a skeleton mode to tmux (called "control mode") that let's tmux
commands be sent and output received on stdout. This can be used to
integrate with other terminal emulators and should allow some other
things to be made simpler later. More to come so doesn't do much yet and
deliberately not documented.


# 1.34 26-May-2020 nicm

Pass the stdout file descriptor from the client as well as stdin and use
them for control clients directly instead of passing everything via the
client.


# 1.33 24-May-2020 nicm

Give control code its own state struct.


# 1.32 22-May-2020 nicm

Move client offset stuff into control.c since only control clients will
need it.


# 1.31 21-May-2020 nicm

Support code for control mode flow control: allow clients to have
separate offsets (used and acknowleged) into the pane buffers; turn off
reading from panes when no clients can accept the data; and add a -A
flag to refresh-client to let clients turn receiving a pane on and off.


Revision tags: OPENBSD_6_7_BASE
# 1.30 13-Apr-2020 nicm

Add helpers for the simple case of parse string and add to command queue.


# 1.29 13-Apr-2020 nicm

When adding a list of commands to the queue, instead of automatically
creating a new state for each group of commands, require the caller to
create one and use it for all the commands in the list. This means the
current target works even with list with multiple groups (which can
happen if they are defined with newlines).


# 1.28 13-Apr-2020 nicm

Move cmdq_state into cmd-queue.c.


# 1.27 13-Apr-2020 nicm

Rename cmdq_shared to cmdq_state which will better reflect what it is
(going to be) used for.


# 1.26 13-Apr-2020 nicm

Also move cmdq_item and cmdq_list into cmd-queue.c (this is to make its
use more clearly defined and preparation for some future work).


# 1.25 12-Dec-2019 nicm

Rewrite the code for reading and writing files. Now, if the client is
not attached, the server process asks it to open the file, similar to
how works for stdin, stdout, stderr. This makes special files like
/dev/fd/X work (used by some shells). stdin, stdout and stderr and
control mode are now just special cases of the same mechanism. This will
also make it easier to use for other commands that read files such as
source-file.


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

Do not leak empty lines, GitHub issue 1824.


# 1.23 31-May-2019 nicm

Allow % strings that are all numbers or %s, and fix a double free. Both
reported by George Nachman, GitHub issues 1765 and 1766.


# 1.22 23-May-2019 nicm

Replace the split parser code (cfg.c and cmd-string.c) with a single
parser using yacc(1). This is a major change but is clearer and simpler
and allows some edge cases to be made more consistent, as well as
tidying up how aliases are handled. It will also allow some further
improvements later.

Entirely the same parser is now used for parsing the configuration file
and for string commands. This means that constructs previously only
available in .tmux.conf, such as %if, can now be used in string commands
(for example, those given to if-shell - not commands invoked from the
shell, they are still parsed by the shell itself).

The only syntax change I am aware of is that #{} outside quotes or a
comment is now considered a format and not a comment, so #{ is now a
syntax error (notably, if it is at the start of a line).

This also adds two new sections to the man page documenting the syntax
and outlining how parsing and command execution works.

Thanks to everyone who sent me test configs (they still all parse
without errors - but this doesn't mean they still work as intended!).

Thanks to Avi Halachmi for testing and man page improvements, also to
jmc@ for reviewing the man page changes.


# 1.21 18-May-2019 nicm

Move the single command flag (CMD_CONTROL) into the shared flags.


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.20 15-Jan-2017 nicm

It is silly for cmd_list_parse to return an integer error when it could
just return NULL.


# 1.19 16-Oct-2016 nicm

Mass rename struct cmd_q to struct cmdq_item and related.


# 1.18 16-Oct-2016 nicm

Rewrite command queue handling. Each client still has a command queue,
but there is also now a global command queue. Instead of command queues
being dispatched on demand from wherever the command happens to be
added, they are now all dispatched from the top level server
loop. Command queues may now also include callbacks as well as commands,
and items may be inserted after the current command as well as at the end.

This all makes command queues significantly more predictable and easier
to use, and avoids the complex multiple nested command queues used by
source-file, if-shell and friends.

A mass rename of struct cmdq to a better name (cmdq_item probably) is
coming.


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.17 19-Jan-2016 nicm

I no longer use my SourceForge address so replace it.


# 1.16 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.15 14-Nov-2015 nicm

Push stdout and stderr to clients more aggressively, and add an event to
continue if the send fails.


Revision tags: OPENBSD_5_8_BASE
# 1.14 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.13 20-Oct-2014 nicm

Better format for printf format attributes.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.12 10-Oct-2013 nicm

Pass flags into cmdq_guard as an argument since sometimes cmdq->cmd can
be NULL. Avoids crash when a command in a command client can't be
parsed.


Revision tags: OPENBSD_5_4_BASE
# 1.11 23-Jun-2013 nicm

Mark control commands specially so the client can identify them, based
on a diff from George Nachman a while back.


# 1.10 26-Mar-2013 nicm

Fix compiler warnings, missing #include. From Thomas Adam.


# 1.9 25-Mar-2013 nicm

Add time and a command count to control mode guards, based on code from
George Nachman.


# 1.8 24-Mar-2013 nicm

Add a command queue to standardize and simplify commands that call other
commands and allow a command to block execution of subsequent
commands. This allows run-shell and if-shell to be synchronous which has
been much requested.

Each client has a default command queue and commands are consumed one at
a time from it. A command may suspend execution from the queue by
returning CMD_RETURN_WAIT and then resume it by calling cmd_continue() -
for example run-shell does this from the callback that is fired after
the job is freed.

When the command queue becomes empty, command clients are automatically
exited (unless attaching). A callback is also fired - this is used for
nested commands in, for example, if-shell which can block execution of
the client's cmdq until a new cmdq becomes empty.

Also merge all the old error/info/print functions together and lose the
old curclient/cmdclient distinction - a cmdq is bound to one client (or
none if in the configuration file), this is a command client if
c->session is NULL otherwise an attached client.


# 1.7 22-Mar-2013 nicm

Need to set clients in context before changing their reference count.


# 1.6 22-Mar-2013 nicm

Remove unnecessary initializers of cmd_ctx.


# 1.5 22-Mar-2013 nicm

Add functions to allocate and free command contexts rather than doing it
all on the stack.


Revision tags: OPENBSD_5_3_BASE
# 1.4 24-Sep-2012 nicm

Add control_write_buffer, from George Nachman.


# 1.3 03-Sep-2012 nicm

Send notifications to control clients. Also don't redraw client when
suspended.


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

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


# 1.1 18-Jun-2012 nicm

Add a skeleton mode to tmux (called "control mode") that let's tmux
commands be sent and output received on stdout. This can be used to
integrate with other terminal emulators and should allow some other
things to be made simpler later. More to come so doesn't do much yet and
deliberately not documented.


# 1.33 24-May-2020 nicm

Give control code its own state struct.


# 1.32 22-May-2020 nicm

Move client offset stuff into control.c since only control clients will
need it.


# 1.31 21-May-2020 nicm

Support code for control mode flow control: allow clients to have
separate offsets (used and acknowleged) into the pane buffers; turn off
reading from panes when no clients can accept the data; and add a -A
flag to refresh-client to let clients turn receiving a pane on and off.


Revision tags: OPENBSD_6_7_BASE
# 1.30 13-Apr-2020 nicm

Add helpers for the simple case of parse string and add to command queue.


# 1.29 13-Apr-2020 nicm

When adding a list of commands to the queue, instead of automatically
creating a new state for each group of commands, require the caller to
create one and use it for all the commands in the list. This means the
current target works even with list with multiple groups (which can
happen if they are defined with newlines).


# 1.28 13-Apr-2020 nicm

Move cmdq_state into cmd-queue.c.


# 1.27 13-Apr-2020 nicm

Rename cmdq_shared to cmdq_state which will better reflect what it is
(going to be) used for.


# 1.26 13-Apr-2020 nicm

Also move cmdq_item and cmdq_list into cmd-queue.c (this is to make its
use more clearly defined and preparation for some future work).


# 1.25 12-Dec-2019 nicm

Rewrite the code for reading and writing files. Now, if the client is
not attached, the server process asks it to open the file, similar to
how works for stdin, stdout, stderr. This makes special files like
/dev/fd/X work (used by some shells). stdin, stdout and stderr and
control mode are now just special cases of the same mechanism. This will
also make it easier to use for other commands that read files such as
source-file.


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

Do not leak empty lines, GitHub issue 1824.


# 1.23 31-May-2019 nicm

Allow % strings that are all numbers or %s, and fix a double free. Both
reported by George Nachman, GitHub issues 1765 and 1766.


# 1.22 23-May-2019 nicm

Replace the split parser code (cfg.c and cmd-string.c) with a single
parser using yacc(1). This is a major change but is clearer and simpler
and allows some edge cases to be made more consistent, as well as
tidying up how aliases are handled. It will also allow some further
improvements later.

Entirely the same parser is now used for parsing the configuration file
and for string commands. This means that constructs previously only
available in .tmux.conf, such as %if, can now be used in string commands
(for example, those given to if-shell - not commands invoked from the
shell, they are still parsed by the shell itself).

The only syntax change I am aware of is that #{} outside quotes or a
comment is now considered a format and not a comment, so #{ is now a
syntax error (notably, if it is at the start of a line).

This also adds two new sections to the man page documenting the syntax
and outlining how parsing and command execution works.

Thanks to everyone who sent me test configs (they still all parse
without errors - but this doesn't mean they still work as intended!).

Thanks to Avi Halachmi for testing and man page improvements, also to
jmc@ for reviewing the man page changes.


# 1.21 18-May-2019 nicm

Move the single command flag (CMD_CONTROL) into the shared flags.


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.20 15-Jan-2017 nicm

It is silly for cmd_list_parse to return an integer error when it could
just return NULL.


# 1.19 16-Oct-2016 nicm

Mass rename struct cmd_q to struct cmdq_item and related.


# 1.18 16-Oct-2016 nicm

Rewrite command queue handling. Each client still has a command queue,
but there is also now a global command queue. Instead of command queues
being dispatched on demand from wherever the command happens to be
added, they are now all dispatched from the top level server
loop. Command queues may now also include callbacks as well as commands,
and items may be inserted after the current command as well as at the end.

This all makes command queues significantly more predictable and easier
to use, and avoids the complex multiple nested command queues used by
source-file, if-shell and friends.

A mass rename of struct cmdq to a better name (cmdq_item probably) is
coming.


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.17 19-Jan-2016 nicm

I no longer use my SourceForge address so replace it.


# 1.16 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.15 14-Nov-2015 nicm

Push stdout and stderr to clients more aggressively, and add an event to
continue if the send fails.


Revision tags: OPENBSD_5_8_BASE
# 1.14 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.13 20-Oct-2014 nicm

Better format for printf format attributes.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.12 10-Oct-2013 nicm

Pass flags into cmdq_guard as an argument since sometimes cmdq->cmd can
be NULL. Avoids crash when a command in a command client can't be
parsed.


Revision tags: OPENBSD_5_4_BASE
# 1.11 23-Jun-2013 nicm

Mark control commands specially so the client can identify them, based
on a diff from George Nachman a while back.


# 1.10 26-Mar-2013 nicm

Fix compiler warnings, missing #include. From Thomas Adam.


# 1.9 25-Mar-2013 nicm

Add time and a command count to control mode guards, based on code from
George Nachman.


# 1.8 24-Mar-2013 nicm

Add a command queue to standardize and simplify commands that call other
commands and allow a command to block execution of subsequent
commands. This allows run-shell and if-shell to be synchronous which has
been much requested.

Each client has a default command queue and commands are consumed one at
a time from it. A command may suspend execution from the queue by
returning CMD_RETURN_WAIT and then resume it by calling cmd_continue() -
for example run-shell does this from the callback that is fired after
the job is freed.

When the command queue becomes empty, command clients are automatically
exited (unless attaching). A callback is also fired - this is used for
nested commands in, for example, if-shell which can block execution of
the client's cmdq until a new cmdq becomes empty.

Also merge all the old error/info/print functions together and lose the
old curclient/cmdclient distinction - a cmdq is bound to one client (or
none if in the configuration file), this is a command client if
c->session is NULL otherwise an attached client.


# 1.7 22-Mar-2013 nicm

Need to set clients in context before changing their reference count.


# 1.6 22-Mar-2013 nicm

Remove unnecessary initializers of cmd_ctx.


# 1.5 22-Mar-2013 nicm

Add functions to allocate and free command contexts rather than doing it
all on the stack.


Revision tags: OPENBSD_5_3_BASE
# 1.4 24-Sep-2012 nicm

Add control_write_buffer, from George Nachman.


# 1.3 03-Sep-2012 nicm

Send notifications to control clients. Also don't redraw client when
suspended.


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

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


# 1.1 18-Jun-2012 nicm

Add a skeleton mode to tmux (called "control mode") that let's tmux
commands be sent and output received on stdout. This can be used to
integrate with other terminal emulators and should allow some other
things to be made simpler later. More to come so doesn't do much yet and
deliberately not documented.


# 1.32 22-May-2020 nicm

Move client offset stuff into control.c since only control clients will
need it.


# 1.31 21-May-2020 nicm

Support code for control mode flow control: allow clients to have
separate offsets (used and acknowleged) into the pane buffers; turn off
reading from panes when no clients can accept the data; and add a -A
flag to refresh-client to let clients turn receiving a pane on and off.


Revision tags: OPENBSD_6_7_BASE
# 1.30 13-Apr-2020 nicm

Add helpers for the simple case of parse string and add to command queue.


# 1.29 13-Apr-2020 nicm

When adding a list of commands to the queue, instead of automatically
creating a new state for each group of commands, require the caller to
create one and use it for all the commands in the list. This means the
current target works even with list with multiple groups (which can
happen if they are defined with newlines).


# 1.28 13-Apr-2020 nicm

Move cmdq_state into cmd-queue.c.


# 1.27 13-Apr-2020 nicm

Rename cmdq_shared to cmdq_state which will better reflect what it is
(going to be) used for.


# 1.26 13-Apr-2020 nicm

Also move cmdq_item and cmdq_list into cmd-queue.c (this is to make its
use more clearly defined and preparation for some future work).


# 1.25 12-Dec-2019 nicm

Rewrite the code for reading and writing files. Now, if the client is
not attached, the server process asks it to open the file, similar to
how works for stdin, stdout, stderr. This makes special files like
/dev/fd/X work (used by some shells). stdin, stdout and stderr and
control mode are now just special cases of the same mechanism. This will
also make it easier to use for other commands that read files such as
source-file.


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

Do not leak empty lines, GitHub issue 1824.


# 1.23 31-May-2019 nicm

Allow % strings that are all numbers or %s, and fix a double free. Both
reported by George Nachman, GitHub issues 1765 and 1766.


# 1.22 23-May-2019 nicm

Replace the split parser code (cfg.c and cmd-string.c) with a single
parser using yacc(1). This is a major change but is clearer and simpler
and allows some edge cases to be made more consistent, as well as
tidying up how aliases are handled. It will also allow some further
improvements later.

Entirely the same parser is now used for parsing the configuration file
and for string commands. This means that constructs previously only
available in .tmux.conf, such as %if, can now be used in string commands
(for example, those given to if-shell - not commands invoked from the
shell, they are still parsed by the shell itself).

The only syntax change I am aware of is that #{} outside quotes or a
comment is now considered a format and not a comment, so #{ is now a
syntax error (notably, if it is at the start of a line).

This also adds two new sections to the man page documenting the syntax
and outlining how parsing and command execution works.

Thanks to everyone who sent me test configs (they still all parse
without errors - but this doesn't mean they still work as intended!).

Thanks to Avi Halachmi for testing and man page improvements, also to
jmc@ for reviewing the man page changes.


# 1.21 18-May-2019 nicm

Move the single command flag (CMD_CONTROL) into the shared flags.


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.20 15-Jan-2017 nicm

It is silly for cmd_list_parse to return an integer error when it could
just return NULL.


# 1.19 16-Oct-2016 nicm

Mass rename struct cmd_q to struct cmdq_item and related.


# 1.18 16-Oct-2016 nicm

Rewrite command queue handling. Each client still has a command queue,
but there is also now a global command queue. Instead of command queues
being dispatched on demand from wherever the command happens to be
added, they are now all dispatched from the top level server
loop. Command queues may now also include callbacks as well as commands,
and items may be inserted after the current command as well as at the end.

This all makes command queues significantly more predictable and easier
to use, and avoids the complex multiple nested command queues used by
source-file, if-shell and friends.

A mass rename of struct cmdq to a better name (cmdq_item probably) is
coming.


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.17 19-Jan-2016 nicm

I no longer use my SourceForge address so replace it.


# 1.16 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.15 14-Nov-2015 nicm

Push stdout and stderr to clients more aggressively, and add an event to
continue if the send fails.


Revision tags: OPENBSD_5_8_BASE
# 1.14 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.13 20-Oct-2014 nicm

Better format for printf format attributes.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.12 10-Oct-2013 nicm

Pass flags into cmdq_guard as an argument since sometimes cmdq->cmd can
be NULL. Avoids crash when a command in a command client can't be
parsed.


Revision tags: OPENBSD_5_4_BASE
# 1.11 23-Jun-2013 nicm

Mark control commands specially so the client can identify them, based
on a diff from George Nachman a while back.


# 1.10 26-Mar-2013 nicm

Fix compiler warnings, missing #include. From Thomas Adam.


# 1.9 25-Mar-2013 nicm

Add time and a command count to control mode guards, based on code from
George Nachman.


# 1.8 24-Mar-2013 nicm

Add a command queue to standardize and simplify commands that call other
commands and allow a command to block execution of subsequent
commands. This allows run-shell and if-shell to be synchronous which has
been much requested.

Each client has a default command queue and commands are consumed one at
a time from it. A command may suspend execution from the queue by
returning CMD_RETURN_WAIT and then resume it by calling cmd_continue() -
for example run-shell does this from the callback that is fired after
the job is freed.

When the command queue becomes empty, command clients are automatically
exited (unless attaching). A callback is also fired - this is used for
nested commands in, for example, if-shell which can block execution of
the client's cmdq until a new cmdq becomes empty.

Also merge all the old error/info/print functions together and lose the
old curclient/cmdclient distinction - a cmdq is bound to one client (or
none if in the configuration file), this is a command client if
c->session is NULL otherwise an attached client.


# 1.7 22-Mar-2013 nicm

Need to set clients in context before changing their reference count.


# 1.6 22-Mar-2013 nicm

Remove unnecessary initializers of cmd_ctx.


# 1.5 22-Mar-2013 nicm

Add functions to allocate and free command contexts rather than doing it
all on the stack.


Revision tags: OPENBSD_5_3_BASE
# 1.4 24-Sep-2012 nicm

Add control_write_buffer, from George Nachman.


# 1.3 03-Sep-2012 nicm

Send notifications to control clients. Also don't redraw client when
suspended.


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

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


# 1.1 18-Jun-2012 nicm

Add a skeleton mode to tmux (called "control mode") that let's tmux
commands be sent and output received on stdout. This can be used to
integrate with other terminal emulators and should allow some other
things to be made simpler later. More to come so doesn't do much yet and
deliberately not documented.


# 1.31 21-May-2020 nicm

Support code for control mode flow control: allow clients to have
separate offsets (used and acknowleged) into the pane buffers; turn off
reading from panes when no clients can accept the data; and add a -A
flag to refresh-client to let clients turn receiving a pane on and off.


Revision tags: OPENBSD_6_7_BASE
# 1.30 13-Apr-2020 nicm

Add helpers for the simple case of parse string and add to command queue.


# 1.29 13-Apr-2020 nicm

When adding a list of commands to the queue, instead of automatically
creating a new state for each group of commands, require the caller to
create one and use it for all the commands in the list. This means the
current target works even with list with multiple groups (which can
happen if they are defined with newlines).


# 1.28 13-Apr-2020 nicm

Move cmdq_state into cmd-queue.c.


# 1.27 13-Apr-2020 nicm

Rename cmdq_shared to cmdq_state which will better reflect what it is
(going to be) used for.


# 1.26 13-Apr-2020 nicm

Also move cmdq_item and cmdq_list into cmd-queue.c (this is to make its
use more clearly defined and preparation for some future work).


# 1.25 12-Dec-2019 nicm

Rewrite the code for reading and writing files. Now, if the client is
not attached, the server process asks it to open the file, similar to
how works for stdin, stdout, stderr. This makes special files like
/dev/fd/X work (used by some shells). stdin, stdout and stderr and
control mode are now just special cases of the same mechanism. This will
also make it easier to use for other commands that read files such as
source-file.


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

Do not leak empty lines, GitHub issue 1824.


# 1.23 31-May-2019 nicm

Allow % strings that are all numbers or %s, and fix a double free. Both
reported by George Nachman, GitHub issues 1765 and 1766.


# 1.22 23-May-2019 nicm

Replace the split parser code (cfg.c and cmd-string.c) with a single
parser using yacc(1). This is a major change but is clearer and simpler
and allows some edge cases to be made more consistent, as well as
tidying up how aliases are handled. It will also allow some further
improvements later.

Entirely the same parser is now used for parsing the configuration file
and for string commands. This means that constructs previously only
available in .tmux.conf, such as %if, can now be used in string commands
(for example, those given to if-shell - not commands invoked from the
shell, they are still parsed by the shell itself).

The only syntax change I am aware of is that #{} outside quotes or a
comment is now considered a format and not a comment, so #{ is now a
syntax error (notably, if it is at the start of a line).

This also adds two new sections to the man page documenting the syntax
and outlining how parsing and command execution works.

Thanks to everyone who sent me test configs (they still all parse
without errors - but this doesn't mean they still work as intended!).

Thanks to Avi Halachmi for testing and man page improvements, also to
jmc@ for reviewing the man page changes.


# 1.21 18-May-2019 nicm

Move the single command flag (CMD_CONTROL) into the shared flags.


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.20 15-Jan-2017 nicm

It is silly for cmd_list_parse to return an integer error when it could
just return NULL.


# 1.19 16-Oct-2016 nicm

Mass rename struct cmd_q to struct cmdq_item and related.


# 1.18 16-Oct-2016 nicm

Rewrite command queue handling. Each client still has a command queue,
but there is also now a global command queue. Instead of command queues
being dispatched on demand from wherever the command happens to be
added, they are now all dispatched from the top level server
loop. Command queues may now also include callbacks as well as commands,
and items may be inserted after the current command as well as at the end.

This all makes command queues significantly more predictable and easier
to use, and avoids the complex multiple nested command queues used by
source-file, if-shell and friends.

A mass rename of struct cmdq to a better name (cmdq_item probably) is
coming.


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.17 19-Jan-2016 nicm

I no longer use my SourceForge address so replace it.


# 1.16 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.15 14-Nov-2015 nicm

Push stdout and stderr to clients more aggressively, and add an event to
continue if the send fails.


Revision tags: OPENBSD_5_8_BASE
# 1.14 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.13 20-Oct-2014 nicm

Better format for printf format attributes.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.12 10-Oct-2013 nicm

Pass flags into cmdq_guard as an argument since sometimes cmdq->cmd can
be NULL. Avoids crash when a command in a command client can't be
parsed.


Revision tags: OPENBSD_5_4_BASE
# 1.11 23-Jun-2013 nicm

Mark control commands specially so the client can identify them, based
on a diff from George Nachman a while back.


# 1.10 26-Mar-2013 nicm

Fix compiler warnings, missing #include. From Thomas Adam.


# 1.9 25-Mar-2013 nicm

Add time and a command count to control mode guards, based on code from
George Nachman.


# 1.8 24-Mar-2013 nicm

Add a command queue to standardize and simplify commands that call other
commands and allow a command to block execution of subsequent
commands. This allows run-shell and if-shell to be synchronous which has
been much requested.

Each client has a default command queue and commands are consumed one at
a time from it. A command may suspend execution from the queue by
returning CMD_RETURN_WAIT and then resume it by calling cmd_continue() -
for example run-shell does this from the callback that is fired after
the job is freed.

When the command queue becomes empty, command clients are automatically
exited (unless attaching). A callback is also fired - this is used for
nested commands in, for example, if-shell which can block execution of
the client's cmdq until a new cmdq becomes empty.

Also merge all the old error/info/print functions together and lose the
old curclient/cmdclient distinction - a cmdq is bound to one client (or
none if in the configuration file), this is a command client if
c->session is NULL otherwise an attached client.


# 1.7 22-Mar-2013 nicm

Need to set clients in context before changing their reference count.


# 1.6 22-Mar-2013 nicm

Remove unnecessary initializers of cmd_ctx.


# 1.5 22-Mar-2013 nicm

Add functions to allocate and free command contexts rather than doing it
all on the stack.


Revision tags: OPENBSD_5_3_BASE
# 1.4 24-Sep-2012 nicm

Add control_write_buffer, from George Nachman.


# 1.3 03-Sep-2012 nicm

Send notifications to control clients. Also don't redraw client when
suspended.


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

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


# 1.1 18-Jun-2012 nicm

Add a skeleton mode to tmux (called "control mode") that let's tmux
commands be sent and output received on stdout. This can be used to
integrate with other terminal emulators and should allow some other
things to be made simpler later. More to come so doesn't do much yet and
deliberately not documented.


# 1.30 13-Apr-2020 nicm

Add helpers for the simple case of parse string and add to command queue.


# 1.29 13-Apr-2020 nicm

When adding a list of commands to the queue, instead of automatically
creating a new state for each group of commands, require the caller to
create one and use it for all the commands in the list. This means the
current target works even with list with multiple groups (which can
happen if they are defined with newlines).


# 1.28 13-Apr-2020 nicm

Move cmdq_state into cmd-queue.c.


# 1.27 13-Apr-2020 nicm

Rename cmdq_shared to cmdq_state which will better reflect what it is
(going to be) used for.


# 1.26 13-Apr-2020 nicm

Also move cmdq_item and cmdq_list into cmd-queue.c (this is to make its
use more clearly defined and preparation for some future work).


# 1.25 12-Dec-2019 nicm

Rewrite the code for reading and writing files. Now, if the client is
not attached, the server process asks it to open the file, similar to
how works for stdin, stdout, stderr. This makes special files like
/dev/fd/X work (used by some shells). stdin, stdout and stderr and
control mode are now just special cases of the same mechanism. This will
also make it easier to use for other commands that read files such as
source-file.


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

Do not leak empty lines, GitHub issue 1824.


# 1.23 31-May-2019 nicm

Allow % strings that are all numbers or %s, and fix a double free. Both
reported by George Nachman, GitHub issues 1765 and 1766.


# 1.22 23-May-2019 nicm

Replace the split parser code (cfg.c and cmd-string.c) with a single
parser using yacc(1). This is a major change but is clearer and simpler
and allows some edge cases to be made more consistent, as well as
tidying up how aliases are handled. It will also allow some further
improvements later.

Entirely the same parser is now used for parsing the configuration file
and for string commands. This means that constructs previously only
available in .tmux.conf, such as %if, can now be used in string commands
(for example, those given to if-shell - not commands invoked from the
shell, they are still parsed by the shell itself).

The only syntax change I am aware of is that #{} outside quotes or a
comment is now considered a format and not a comment, so #{ is now a
syntax error (notably, if it is at the start of a line).

This also adds two new sections to the man page documenting the syntax
and outlining how parsing and command execution works.

Thanks to everyone who sent me test configs (they still all parse
without errors - but this doesn't mean they still work as intended!).

Thanks to Avi Halachmi for testing and man page improvements, also to
jmc@ for reviewing the man page changes.


# 1.21 18-May-2019 nicm

Move the single command flag (CMD_CONTROL) into the shared flags.


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.20 15-Jan-2017 nicm

It is silly for cmd_list_parse to return an integer error when it could
just return NULL.


# 1.19 16-Oct-2016 nicm

Mass rename struct cmd_q to struct cmdq_item and related.


# 1.18 16-Oct-2016 nicm

Rewrite command queue handling. Each client still has a command queue,
but there is also now a global command queue. Instead of command queues
being dispatched on demand from wherever the command happens to be
added, they are now all dispatched from the top level server
loop. Command queues may now also include callbacks as well as commands,
and items may be inserted after the current command as well as at the end.

This all makes command queues significantly more predictable and easier
to use, and avoids the complex multiple nested command queues used by
source-file, if-shell and friends.

A mass rename of struct cmdq to a better name (cmdq_item probably) is
coming.


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.17 19-Jan-2016 nicm

I no longer use my SourceForge address so replace it.


# 1.16 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.15 14-Nov-2015 nicm

Push stdout and stderr to clients more aggressively, and add an event to
continue if the send fails.


Revision tags: OPENBSD_5_8_BASE
# 1.14 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.13 20-Oct-2014 nicm

Better format for printf format attributes.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.12 10-Oct-2013 nicm

Pass flags into cmdq_guard as an argument since sometimes cmdq->cmd can
be NULL. Avoids crash when a command in a command client can't be
parsed.


Revision tags: OPENBSD_5_4_BASE
# 1.11 23-Jun-2013 nicm

Mark control commands specially so the client can identify them, based
on a diff from George Nachman a while back.


# 1.10 26-Mar-2013 nicm

Fix compiler warnings, missing #include. From Thomas Adam.


# 1.9 25-Mar-2013 nicm

Add time and a command count to control mode guards, based on code from
George Nachman.


# 1.8 24-Mar-2013 nicm

Add a command queue to standardize and simplify commands that call other
commands and allow a command to block execution of subsequent
commands. This allows run-shell and if-shell to be synchronous which has
been much requested.

Each client has a default command queue and commands are consumed one at
a time from it. A command may suspend execution from the queue by
returning CMD_RETURN_WAIT and then resume it by calling cmd_continue() -
for example run-shell does this from the callback that is fired after
the job is freed.

When the command queue becomes empty, command clients are automatically
exited (unless attaching). A callback is also fired - this is used for
nested commands in, for example, if-shell which can block execution of
the client's cmdq until a new cmdq becomes empty.

Also merge all the old error/info/print functions together and lose the
old curclient/cmdclient distinction - a cmdq is bound to one client (or
none if in the configuration file), this is a command client if
c->session is NULL otherwise an attached client.


# 1.7 22-Mar-2013 nicm

Need to set clients in context before changing their reference count.


# 1.6 22-Mar-2013 nicm

Remove unnecessary initializers of cmd_ctx.


# 1.5 22-Mar-2013 nicm

Add functions to allocate and free command contexts rather than doing it
all on the stack.


Revision tags: OPENBSD_5_3_BASE
# 1.4 24-Sep-2012 nicm

Add control_write_buffer, from George Nachman.


# 1.3 03-Sep-2012 nicm

Send notifications to control clients. Also don't redraw client when
suspended.


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

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


# 1.1 18-Jun-2012 nicm

Add a skeleton mode to tmux (called "control mode") that let's tmux
commands be sent and output received on stdout. This can be used to
integrate with other terminal emulators and should allow some other
things to be made simpler later. More to come so doesn't do much yet and
deliberately not documented.


# 1.26 13-Apr-2020 nicm

Also move cmdq_item and cmdq_list into cmd-queue.c (this is to make its
use more clearly defined and preparation for some future work).


# 1.25 12-Dec-2019 nicm

Rewrite the code for reading and writing files. Now, if the client is
not attached, the server process asks it to open the file, similar to
how works for stdin, stdout, stderr. This makes special files like
/dev/fd/X work (used by some shells). stdin, stdout and stderr and
control mode are now just special cases of the same mechanism. This will
also make it easier to use for other commands that read files such as
source-file.


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

Do not leak empty lines, GitHub issue 1824.


# 1.23 31-May-2019 nicm

Allow % strings that are all numbers or %s, and fix a double free. Both
reported by George Nachman, GitHub issues 1765 and 1766.


# 1.22 23-May-2019 nicm

Replace the split parser code (cfg.c and cmd-string.c) with a single
parser using yacc(1). This is a major change but is clearer and simpler
and allows some edge cases to be made more consistent, as well as
tidying up how aliases are handled. It will also allow some further
improvements later.

Entirely the same parser is now used for parsing the configuration file
and for string commands. This means that constructs previously only
available in .tmux.conf, such as %if, can now be used in string commands
(for example, those given to if-shell - not commands invoked from the
shell, they are still parsed by the shell itself).

The only syntax change I am aware of is that #{} outside quotes or a
comment is now considered a format and not a comment, so #{ is now a
syntax error (notably, if it is at the start of a line).

This also adds two new sections to the man page documenting the syntax
and outlining how parsing and command execution works.

Thanks to everyone who sent me test configs (they still all parse
without errors - but this doesn't mean they still work as intended!).

Thanks to Avi Halachmi for testing and man page improvements, also to
jmc@ for reviewing the man page changes.


# 1.21 18-May-2019 nicm

Move the single command flag (CMD_CONTROL) into the shared flags.


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.20 15-Jan-2017 nicm

It is silly for cmd_list_parse to return an integer error when it could
just return NULL.


# 1.19 16-Oct-2016 nicm

Mass rename struct cmd_q to struct cmdq_item and related.


# 1.18 16-Oct-2016 nicm

Rewrite command queue handling. Each client still has a command queue,
but there is also now a global command queue. Instead of command queues
being dispatched on demand from wherever the command happens to be
added, they are now all dispatched from the top level server
loop. Command queues may now also include callbacks as well as commands,
and items may be inserted after the current command as well as at the end.

This all makes command queues significantly more predictable and easier
to use, and avoids the complex multiple nested command queues used by
source-file, if-shell and friends.

A mass rename of struct cmdq to a better name (cmdq_item probably) is
coming.


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.17 19-Jan-2016 nicm

I no longer use my SourceForge address so replace it.


# 1.16 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.15 14-Nov-2015 nicm

Push stdout and stderr to clients more aggressively, and add an event to
continue if the send fails.


Revision tags: OPENBSD_5_8_BASE
# 1.14 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.13 20-Oct-2014 nicm

Better format for printf format attributes.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.12 10-Oct-2013 nicm

Pass flags into cmdq_guard as an argument since sometimes cmdq->cmd can
be NULL. Avoids crash when a command in a command client can't be
parsed.


Revision tags: OPENBSD_5_4_BASE
# 1.11 23-Jun-2013 nicm

Mark control commands specially so the client can identify them, based
on a diff from George Nachman a while back.


# 1.10 26-Mar-2013 nicm

Fix compiler warnings, missing #include. From Thomas Adam.


# 1.9 25-Mar-2013 nicm

Add time and a command count to control mode guards, based on code from
George Nachman.


# 1.8 24-Mar-2013 nicm

Add a command queue to standardize and simplify commands that call other
commands and allow a command to block execution of subsequent
commands. This allows run-shell and if-shell to be synchronous which has
been much requested.

Each client has a default command queue and commands are consumed one at
a time from it. A command may suspend execution from the queue by
returning CMD_RETURN_WAIT and then resume it by calling cmd_continue() -
for example run-shell does this from the callback that is fired after
the job is freed.

When the command queue becomes empty, command clients are automatically
exited (unless attaching). A callback is also fired - this is used for
nested commands in, for example, if-shell which can block execution of
the client's cmdq until a new cmdq becomes empty.

Also merge all the old error/info/print functions together and lose the
old curclient/cmdclient distinction - a cmdq is bound to one client (or
none if in the configuration file), this is a command client if
c->session is NULL otherwise an attached client.


# 1.7 22-Mar-2013 nicm

Need to set clients in context before changing their reference count.


# 1.6 22-Mar-2013 nicm

Remove unnecessary initializers of cmd_ctx.


# 1.5 22-Mar-2013 nicm

Add functions to allocate and free command contexts rather than doing it
all on the stack.


Revision tags: OPENBSD_5_3_BASE
# 1.4 24-Sep-2012 nicm

Add control_write_buffer, from George Nachman.


# 1.3 03-Sep-2012 nicm

Send notifications to control clients. Also don't redraw client when
suspended.


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

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


# 1.1 18-Jun-2012 nicm

Add a skeleton mode to tmux (called "control mode") that let's tmux
commands be sent and output received on stdout. This can be used to
integrate with other terminal emulators and should allow some other
things to be made simpler later. More to come so doesn't do much yet and
deliberately not documented.


# 1.25 12-Dec-2019 nicm

Rewrite the code for reading and writing files. Now, if the client is
not attached, the server process asks it to open the file, similar to
how works for stdin, stdout, stderr. This makes special files like
/dev/fd/X work (used by some shells). stdin, stdout and stderr and
control mode are now just special cases of the same mechanism. This will
also make it easier to use for other commands that read files such as
source-file.


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

Do not leak empty lines, GitHub issue 1824.


# 1.23 31-May-2019 nicm

Allow % strings that are all numbers or %s, and fix a double free. Both
reported by George Nachman, GitHub issues 1765 and 1766.


# 1.22 23-May-2019 nicm

Replace the split parser code (cfg.c and cmd-string.c) with a single
parser using yacc(1). This is a major change but is clearer and simpler
and allows some edge cases to be made more consistent, as well as
tidying up how aliases are handled. It will also allow some further
improvements later.

Entirely the same parser is now used for parsing the configuration file
and for string commands. This means that constructs previously only
available in .tmux.conf, such as %if, can now be used in string commands
(for example, those given to if-shell - not commands invoked from the
shell, they are still parsed by the shell itself).

The only syntax change I am aware of is that #{} outside quotes or a
comment is now considered a format and not a comment, so #{ is now a
syntax error (notably, if it is at the start of a line).

This also adds two new sections to the man page documenting the syntax
and outlining how parsing and command execution works.

Thanks to everyone who sent me test configs (they still all parse
without errors - but this doesn't mean they still work as intended!).

Thanks to Avi Halachmi for testing and man page improvements, also to
jmc@ for reviewing the man page changes.


# 1.21 18-May-2019 nicm

Move the single command flag (CMD_CONTROL) into the shared flags.


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.20 15-Jan-2017 nicm

It is silly for cmd_list_parse to return an integer error when it could
just return NULL.


# 1.19 16-Oct-2016 nicm

Mass rename struct cmd_q to struct cmdq_item and related.


# 1.18 16-Oct-2016 nicm

Rewrite command queue handling. Each client still has a command queue,
but there is also now a global command queue. Instead of command queues
being dispatched on demand from wherever the command happens to be
added, they are now all dispatched from the top level server
loop. Command queues may now also include callbacks as well as commands,
and items may be inserted after the current command as well as at the end.

This all makes command queues significantly more predictable and easier
to use, and avoids the complex multiple nested command queues used by
source-file, if-shell and friends.

A mass rename of struct cmdq to a better name (cmdq_item probably) is
coming.


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.17 19-Jan-2016 nicm

I no longer use my SourceForge address so replace it.


# 1.16 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.15 14-Nov-2015 nicm

Push stdout and stderr to clients more aggressively, and add an event to
continue if the send fails.


Revision tags: OPENBSD_5_8_BASE
# 1.14 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.13 20-Oct-2014 nicm

Better format for printf format attributes.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.12 10-Oct-2013 nicm

Pass flags into cmdq_guard as an argument since sometimes cmdq->cmd can
be NULL. Avoids crash when a command in a command client can't be
parsed.


Revision tags: OPENBSD_5_4_BASE
# 1.11 23-Jun-2013 nicm

Mark control commands specially so the client can identify them, based
on a diff from George Nachman a while back.


# 1.10 26-Mar-2013 nicm

Fix compiler warnings, missing #include. From Thomas Adam.


# 1.9 25-Mar-2013 nicm

Add time and a command count to control mode guards, based on code from
George Nachman.


# 1.8 24-Mar-2013 nicm

Add a command queue to standardize and simplify commands that call other
commands and allow a command to block execution of subsequent
commands. This allows run-shell and if-shell to be synchronous which has
been much requested.

Each client has a default command queue and commands are consumed one at
a time from it. A command may suspend execution from the queue by
returning CMD_RETURN_WAIT and then resume it by calling cmd_continue() -
for example run-shell does this from the callback that is fired after
the job is freed.

When the command queue becomes empty, command clients are automatically
exited (unless attaching). A callback is also fired - this is used for
nested commands in, for example, if-shell which can block execution of
the client's cmdq until a new cmdq becomes empty.

Also merge all the old error/info/print functions together and lose the
old curclient/cmdclient distinction - a cmdq is bound to one client (or
none if in the configuration file), this is a command client if
c->session is NULL otherwise an attached client.


# 1.7 22-Mar-2013 nicm

Need to set clients in context before changing their reference count.


# 1.6 22-Mar-2013 nicm

Remove unnecessary initializers of cmd_ctx.


# 1.5 22-Mar-2013 nicm

Add functions to allocate and free command contexts rather than doing it
all on the stack.


Revision tags: OPENBSD_5_3_BASE
# 1.4 24-Sep-2012 nicm

Add control_write_buffer, from George Nachman.


# 1.3 03-Sep-2012 nicm

Send notifications to control clients. Also don't redraw client when
suspended.


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

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


# 1.1 18-Jun-2012 nicm

Add a skeleton mode to tmux (called "control mode") that let's tmux
commands be sent and output received on stdout. This can be used to
integrate with other terminal emulators and should allow some other
things to be made simpler later. More to come so doesn't do much yet and
deliberately not documented.


# 1.24 09-Jul-2019 nicm

Do not leak empty lines, GitHub issue 1824.


# 1.23 31-May-2019 nicm

Allow % strings that are all numbers or %s, and fix a double free. Both
reported by George Nachman, GitHub issues 1765 and 1766.


# 1.22 23-May-2019 nicm

Replace the split parser code (cfg.c and cmd-string.c) with a single
parser using yacc(1). This is a major change but is clearer and simpler
and allows some edge cases to be made more consistent, as well as
tidying up how aliases are handled. It will also allow some further
improvements later.

Entirely the same parser is now used for parsing the configuration file
and for string commands. This means that constructs previously only
available in .tmux.conf, such as %if, can now be used in string commands
(for example, those given to if-shell - not commands invoked from the
shell, they are still parsed by the shell itself).

The only syntax change I am aware of is that #{} outside quotes or a
comment is now considered a format and not a comment, so #{ is now a
syntax error (notably, if it is at the start of a line).

This also adds two new sections to the man page documenting the syntax
and outlining how parsing and command execution works.

Thanks to everyone who sent me test configs (they still all parse
without errors - but this doesn't mean they still work as intended!).

Thanks to Avi Halachmi for testing and man page improvements, also to
jmc@ for reviewing the man page changes.


# 1.21 18-May-2019 nicm

Move the single command flag (CMD_CONTROL) into the shared flags.


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.20 15-Jan-2017 nicm

It is silly for cmd_list_parse to return an integer error when it could
just return NULL.


# 1.19 16-Oct-2016 nicm

Mass rename struct cmd_q to struct cmdq_item and related.


# 1.18 16-Oct-2016 nicm

Rewrite command queue handling. Each client still has a command queue,
but there is also now a global command queue. Instead of command queues
being dispatched on demand from wherever the command happens to be
added, they are now all dispatched from the top level server
loop. Command queues may now also include callbacks as well as commands,
and items may be inserted after the current command as well as at the end.

This all makes command queues significantly more predictable and easier
to use, and avoids the complex multiple nested command queues used by
source-file, if-shell and friends.

A mass rename of struct cmdq to a better name (cmdq_item probably) is
coming.


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.17 19-Jan-2016 nicm

I no longer use my SourceForge address so replace it.


# 1.16 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.15 14-Nov-2015 nicm

Push stdout and stderr to clients more aggressively, and add an event to
continue if the send fails.


Revision tags: OPENBSD_5_8_BASE
# 1.14 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.13 20-Oct-2014 nicm

Better format for printf format attributes.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.12 10-Oct-2013 nicm

Pass flags into cmdq_guard as an argument since sometimes cmdq->cmd can
be NULL. Avoids crash when a command in a command client can't be
parsed.


Revision tags: OPENBSD_5_4_BASE
# 1.11 23-Jun-2013 nicm

Mark control commands specially so the client can identify them, based
on a diff from George Nachman a while back.


# 1.10 26-Mar-2013 nicm

Fix compiler warnings, missing #include. From Thomas Adam.


# 1.9 25-Mar-2013 nicm

Add time and a command count to control mode guards, based on code from
George Nachman.


# 1.8 24-Mar-2013 nicm

Add a command queue to standardize and simplify commands that call other
commands and allow a command to block execution of subsequent
commands. This allows run-shell and if-shell to be synchronous which has
been much requested.

Each client has a default command queue and commands are consumed one at
a time from it. A command may suspend execution from the queue by
returning CMD_RETURN_WAIT and then resume it by calling cmd_continue() -
for example run-shell does this from the callback that is fired after
the job is freed.

When the command queue becomes empty, command clients are automatically
exited (unless attaching). A callback is also fired - this is used for
nested commands in, for example, if-shell which can block execution of
the client's cmdq until a new cmdq becomes empty.

Also merge all the old error/info/print functions together and lose the
old curclient/cmdclient distinction - a cmdq is bound to one client (or
none if in the configuration file), this is a command client if
c->session is NULL otherwise an attached client.


# 1.7 22-Mar-2013 nicm

Need to set clients in context before changing their reference count.


# 1.6 22-Mar-2013 nicm

Remove unnecessary initializers of cmd_ctx.


# 1.5 22-Mar-2013 nicm

Add functions to allocate and free command contexts rather than doing it
all on the stack.


Revision tags: OPENBSD_5_3_BASE
# 1.4 24-Sep-2012 nicm

Add control_write_buffer, from George Nachman.


# 1.3 03-Sep-2012 nicm

Send notifications to control clients. Also don't redraw client when
suspended.


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

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


# 1.1 18-Jun-2012 nicm

Add a skeleton mode to tmux (called "control mode") that let's tmux
commands be sent and output received on stdout. This can be used to
integrate with other terminal emulators and should allow some other
things to be made simpler later. More to come so doesn't do much yet and
deliberately not documented.


# 1.23 31-May-2019 nicm

Allow % strings that are all numbers or %s, and fix a double free. Both
reported by George Nachman, GitHub issues 1765 and 1766.


# 1.22 23-May-2019 nicm

Replace the split parser code (cfg.c and cmd-string.c) with a single
parser using yacc(1). This is a major change but is clearer and simpler
and allows some edge cases to be made more consistent, as well as
tidying up how aliases are handled. It will also allow some further
improvements later.

Entirely the same parser is now used for parsing the configuration file
and for string commands. This means that constructs previously only
available in .tmux.conf, such as %if, can now be used in string commands
(for example, those given to if-shell - not commands invoked from the
shell, they are still parsed by the shell itself).

The only syntax change I am aware of is that #{} outside quotes or a
comment is now considered a format and not a comment, so #{ is now a
syntax error (notably, if it is at the start of a line).

This also adds two new sections to the man page documenting the syntax
and outlining how parsing and command execution works.

Thanks to everyone who sent me test configs (they still all parse
without errors - but this doesn't mean they still work as intended!).

Thanks to Avi Halachmi for testing and man page improvements, also to
jmc@ for reviewing the man page changes.


# 1.21 18-May-2019 nicm

Move the single command flag (CMD_CONTROL) into the shared flags.


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.20 15-Jan-2017 nicm

It is silly for cmd_list_parse to return an integer error when it could
just return NULL.


# 1.19 16-Oct-2016 nicm

Mass rename struct cmd_q to struct cmdq_item and related.


# 1.18 16-Oct-2016 nicm

Rewrite command queue handling. Each client still has a command queue,
but there is also now a global command queue. Instead of command queues
being dispatched on demand from wherever the command happens to be
added, they are now all dispatched from the top level server
loop. Command queues may now also include callbacks as well as commands,
and items may be inserted after the current command as well as at the end.

This all makes command queues significantly more predictable and easier
to use, and avoids the complex multiple nested command queues used by
source-file, if-shell and friends.

A mass rename of struct cmdq to a better name (cmdq_item probably) is
coming.


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.17 19-Jan-2016 nicm

I no longer use my SourceForge address so replace it.


# 1.16 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.15 14-Nov-2015 nicm

Push stdout and stderr to clients more aggressively, and add an event to
continue if the send fails.


Revision tags: OPENBSD_5_8_BASE
# 1.14 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.13 20-Oct-2014 nicm

Better format for printf format attributes.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.12 10-Oct-2013 nicm

Pass flags into cmdq_guard as an argument since sometimes cmdq->cmd can
be NULL. Avoids crash when a command in a command client can't be
parsed.


Revision tags: OPENBSD_5_4_BASE
# 1.11 23-Jun-2013 nicm

Mark control commands specially so the client can identify them, based
on a diff from George Nachman a while back.


# 1.10 26-Mar-2013 nicm

Fix compiler warnings, missing #include. From Thomas Adam.


# 1.9 25-Mar-2013 nicm

Add time and a command count to control mode guards, based on code from
George Nachman.


# 1.8 24-Mar-2013 nicm

Add a command queue to standardize and simplify commands that call other
commands and allow a command to block execution of subsequent
commands. This allows run-shell and if-shell to be synchronous which has
been much requested.

Each client has a default command queue and commands are consumed one at
a time from it. A command may suspend execution from the queue by
returning CMD_RETURN_WAIT and then resume it by calling cmd_continue() -
for example run-shell does this from the callback that is fired after
the job is freed.

When the command queue becomes empty, command clients are automatically
exited (unless attaching). A callback is also fired - this is used for
nested commands in, for example, if-shell which can block execution of
the client's cmdq until a new cmdq becomes empty.

Also merge all the old error/info/print functions together and lose the
old curclient/cmdclient distinction - a cmdq is bound to one client (or
none if in the configuration file), this is a command client if
c->session is NULL otherwise an attached client.


# 1.7 22-Mar-2013 nicm

Need to set clients in context before changing their reference count.


# 1.6 22-Mar-2013 nicm

Remove unnecessary initializers of cmd_ctx.


# 1.5 22-Mar-2013 nicm

Add functions to allocate and free command contexts rather than doing it
all on the stack.


Revision tags: OPENBSD_5_3_BASE
# 1.4 24-Sep-2012 nicm

Add control_write_buffer, from George Nachman.


# 1.3 03-Sep-2012 nicm

Send notifications to control clients. Also don't redraw client when
suspended.


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

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


# 1.1 18-Jun-2012 nicm

Add a skeleton mode to tmux (called "control mode") that let's tmux
commands be sent and output received on stdout. This can be used to
integrate with other terminal emulators and should allow some other
things to be made simpler later. More to come so doesn't do much yet and
deliberately not documented.


# 1.22 23-May-2019 nicm

Replace the split parser code (cfg.c and cmd-string.c) with a single
parser using yacc(1). This is a major change but is clearer and simpler
and allows some edge cases to be made more consistent, as well as
tidying up how aliases are handled. It will also allow some further
improvements later.

Entirely the same parser is now used for parsing the configuration file
and for string commands. This means that constructs previously only
available in .tmux.conf, such as %if, can now be used in string commands
(for example, those given to if-shell - not commands invoked from the
shell, they are still parsed by the shell itself).

The only syntax change I am aware of is that #{} outside quotes or a
comment is now considered a format and not a comment, so #{ is now a
syntax error (notably, if it is at the start of a line).

This also adds two new sections to the man page documenting the syntax
and outlining how parsing and command execution works.

Thanks to everyone who sent me test configs (they still all parse
without errors - but this doesn't mean they still work as intended!).

Thanks to Avi Halachmi for testing and man page improvements, also to
jmc@ for reviewing the man page changes.


# 1.21 18-May-2019 nicm

Move the single command flag (CMD_CONTROL) into the shared flags.


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.20 15-Jan-2017 nicm

It is silly for cmd_list_parse to return an integer error when it could
just return NULL.


# 1.19 16-Oct-2016 nicm

Mass rename struct cmd_q to struct cmdq_item and related.


# 1.18 16-Oct-2016 nicm

Rewrite command queue handling. Each client still has a command queue,
but there is also now a global command queue. Instead of command queues
being dispatched on demand from wherever the command happens to be
added, they are now all dispatched from the top level server
loop. Command queues may now also include callbacks as well as commands,
and items may be inserted after the current command as well as at the end.

This all makes command queues significantly more predictable and easier
to use, and avoids the complex multiple nested command queues used by
source-file, if-shell and friends.

A mass rename of struct cmdq to a better name (cmdq_item probably) is
coming.


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.17 19-Jan-2016 nicm

I no longer use my SourceForge address so replace it.


# 1.16 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.15 14-Nov-2015 nicm

Push stdout and stderr to clients more aggressively, and add an event to
continue if the send fails.


Revision tags: OPENBSD_5_8_BASE
# 1.14 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.13 20-Oct-2014 nicm

Better format for printf format attributes.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.12 10-Oct-2013 nicm

Pass flags into cmdq_guard as an argument since sometimes cmdq->cmd can
be NULL. Avoids crash when a command in a command client can't be
parsed.


Revision tags: OPENBSD_5_4_BASE
# 1.11 23-Jun-2013 nicm

Mark control commands specially so the client can identify them, based
on a diff from George Nachman a while back.


# 1.10 26-Mar-2013 nicm

Fix compiler warnings, missing #include. From Thomas Adam.


# 1.9 25-Mar-2013 nicm

Add time and a command count to control mode guards, based on code from
George Nachman.


# 1.8 24-Mar-2013 nicm

Add a command queue to standardize and simplify commands that call other
commands and allow a command to block execution of subsequent
commands. This allows run-shell and if-shell to be synchronous which has
been much requested.

Each client has a default command queue and commands are consumed one at
a time from it. A command may suspend execution from the queue by
returning CMD_RETURN_WAIT and then resume it by calling cmd_continue() -
for example run-shell does this from the callback that is fired after
the job is freed.

When the command queue becomes empty, command clients are automatically
exited (unless attaching). A callback is also fired - this is used for
nested commands in, for example, if-shell which can block execution of
the client's cmdq until a new cmdq becomes empty.

Also merge all the old error/info/print functions together and lose the
old curclient/cmdclient distinction - a cmdq is bound to one client (or
none if in the configuration file), this is a command client if
c->session is NULL otherwise an attached client.


# 1.7 22-Mar-2013 nicm

Need to set clients in context before changing their reference count.


# 1.6 22-Mar-2013 nicm

Remove unnecessary initializers of cmd_ctx.


# 1.5 22-Mar-2013 nicm

Add functions to allocate and free command contexts rather than doing it
all on the stack.


Revision tags: OPENBSD_5_3_BASE
# 1.4 24-Sep-2012 nicm

Add control_write_buffer, from George Nachman.


# 1.3 03-Sep-2012 nicm

Send notifications to control clients. Also don't redraw client when
suspended.


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

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


# 1.1 18-Jun-2012 nicm

Add a skeleton mode to tmux (called "control mode") that let's tmux
commands be sent and output received on stdout. This can be used to
integrate with other terminal emulators and should allow some other
things to be made simpler later. More to come so doesn't do much yet and
deliberately not documented.


# 1.21 18-May-2019 nicm

Move the single command flag (CMD_CONTROL) into the shared flags.


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.20 15-Jan-2017 nicm

It is silly for cmd_list_parse to return an integer error when it could
just return NULL.


# 1.19 16-Oct-2016 nicm

Mass rename struct cmd_q to struct cmdq_item and related.


# 1.18 16-Oct-2016 nicm

Rewrite command queue handling. Each client still has a command queue,
but there is also now a global command queue. Instead of command queues
being dispatched on demand from wherever the command happens to be
added, they are now all dispatched from the top level server
loop. Command queues may now also include callbacks as well as commands,
and items may be inserted after the current command as well as at the end.

This all makes command queues significantly more predictable and easier
to use, and avoids the complex multiple nested command queues used by
source-file, if-shell and friends.

A mass rename of struct cmdq to a better name (cmdq_item probably) is
coming.


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.17 19-Jan-2016 nicm

I no longer use my SourceForge address so replace it.


# 1.16 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.15 14-Nov-2015 nicm

Push stdout and stderr to clients more aggressively, and add an event to
continue if the send fails.


Revision tags: OPENBSD_5_8_BASE
# 1.14 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.13 20-Oct-2014 nicm

Better format for printf format attributes.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.12 10-Oct-2013 nicm

Pass flags into cmdq_guard as an argument since sometimes cmdq->cmd can
be NULL. Avoids crash when a command in a command client can't be
parsed.


Revision tags: OPENBSD_5_4_BASE
# 1.11 23-Jun-2013 nicm

Mark control commands specially so the client can identify them, based
on a diff from George Nachman a while back.


# 1.10 26-Mar-2013 nicm

Fix compiler warnings, missing #include. From Thomas Adam.


# 1.9 25-Mar-2013 nicm

Add time and a command count to control mode guards, based on code from
George Nachman.


# 1.8 24-Mar-2013 nicm

Add a command queue to standardize and simplify commands that call other
commands and allow a command to block execution of subsequent
commands. This allows run-shell and if-shell to be synchronous which has
been much requested.

Each client has a default command queue and commands are consumed one at
a time from it. A command may suspend execution from the queue by
returning CMD_RETURN_WAIT and then resume it by calling cmd_continue() -
for example run-shell does this from the callback that is fired after
the job is freed.

When the command queue becomes empty, command clients are automatically
exited (unless attaching). A callback is also fired - this is used for
nested commands in, for example, if-shell which can block execution of
the client's cmdq until a new cmdq becomes empty.

Also merge all the old error/info/print functions together and lose the
old curclient/cmdclient distinction - a cmdq is bound to one client (or
none if in the configuration file), this is a command client if
c->session is NULL otherwise an attached client.


# 1.7 22-Mar-2013 nicm

Need to set clients in context before changing their reference count.


# 1.6 22-Mar-2013 nicm

Remove unnecessary initializers of cmd_ctx.


# 1.5 22-Mar-2013 nicm

Add functions to allocate and free command contexts rather than doing it
all on the stack.


Revision tags: OPENBSD_5_3_BASE
# 1.4 24-Sep-2012 nicm

Add control_write_buffer, from George Nachman.


# 1.3 03-Sep-2012 nicm

Send notifications to control clients. Also don't redraw client when
suspended.


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

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


# 1.1 18-Jun-2012 nicm

Add a skeleton mode to tmux (called "control mode") that let's tmux
commands be sent and output received on stdout. This can be used to
integrate with other terminal emulators and should allow some other
things to be made simpler later. More to come so doesn't do much yet and
deliberately not documented.


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.20 15-Jan-2017 nicm

It is silly for cmd_list_parse to return an integer error when it could
just return NULL.


# 1.19 16-Oct-2016 nicm

Mass rename struct cmd_q to struct cmdq_item and related.


# 1.18 16-Oct-2016 nicm

Rewrite command queue handling. Each client still has a command queue,
but there is also now a global command queue. Instead of command queues
being dispatched on demand from wherever the command happens to be
added, they are now all dispatched from the top level server
loop. Command queues may now also include callbacks as well as commands,
and items may be inserted after the current command as well as at the end.

This all makes command queues significantly more predictable and easier
to use, and avoids the complex multiple nested command queues used by
source-file, if-shell and friends.

A mass rename of struct cmdq to a better name (cmdq_item probably) is
coming.


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.17 19-Jan-2016 nicm

I no longer use my SourceForge address so replace it.


# 1.16 18-Nov-2015 nicm

Use __unused rather than rolling our own.


# 1.15 14-Nov-2015 nicm

Push stdout and stderr to clients more aggressively, and add an event to
continue if the send fails.


Revision tags: OPENBSD_5_8_BASE
# 1.14 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.13 20-Oct-2014 nicm

Better format for printf format attributes.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.12 10-Oct-2013 nicm

Pass flags into cmdq_guard as an argument since sometimes cmdq->cmd can
be NULL. Avoids crash when a command in a command client can't be
parsed.


Revision tags: OPENBSD_5_4_BASE
# 1.11 23-Jun-2013 nicm

Mark control commands specially so the client can identify them, based
on a diff from George Nachman a while back.


# 1.10 26-Mar-2013 nicm

Fix compiler warnings, missing #include. From Thomas Adam.


# 1.9 25-Mar-2013 nicm

Add time and a command count to control mode guards, based on code from
George Nachman.


# 1.8 24-Mar-2013 nicm

Add a command queue to standardize and simplify commands that call other
commands and allow a command to block execution of subsequent
commands. This allows run-shell and if-shell to be synchronous which has
been much requested.

Each client has a default command queue and commands are consumed one at
a time from it. A command may suspend execution from the queue by
returning CMD_RETURN_WAIT and then resume it by calling cmd_continue() -
for example run-shell does this from the callback that is fired after
the job is freed.

When the command queue becomes empty, command clients are automatically
exited (unless attaching). A callback is also fired - this is used for
nested commands in, for example, if-shell which can block execution of
the client's cmdq until a new cmdq becomes empty.

Also merge all the old error/info/print functions together and lose the
old curclient/cmdclient distinction - a cmdq is bound to one client (or
none if in the configuration file), this is a command client if
c->session is NULL otherwise an attached client.


# 1.7 22-Mar-2013 nicm

Need to set clients in context before changing their reference count.


# 1.6 22-Mar-2013 nicm

Remove unnecessary initializers of cmd_ctx.


# 1.5 22-Mar-2013 nicm

Add functions to allocate and free command contexts rather than doing it
all on the stack.


Revision tags: OPENBSD_5_3_BASE
# 1.4 24-Sep-2012 nicm

Add control_write_buffer, from George Nachman.


# 1.3 03-Sep-2012 nicm

Send notifications to control clients. Also don't redraw client when
suspended.


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

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


# 1.1 18-Jun-2012 nicm

Add a skeleton mode to tmux (called "control mode") that let's tmux
commands be sent and output received on stdout. This can be used to
integrate with other terminal emulators and should allow some other
things to be made simpler later. More to come so doesn't do much yet and
deliberately not documented.