History log of /openbsd-current/usr.bin/tmux/options.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.69 17-Jun-2022 nicm

Check cursor options when a pane is created, not just when they are changed.


Revision tags: OPENBSD_7_1_BASE
# 1.68 16-Mar-2022 nicm

Add an option to set the character used for unused areas of the
terminal, GitHub issue 3110.


# 1.67 03-Nov-2021 nicm

Add a cursor-style option, from Alexis Hildebrandt in GitHub issue 2960.


# 1.66 01-Nov-2021 nicm

Add a cursor-colour option, from Alexis Hildebrandt in GitHub issue
2959.


# 1.65 14-Oct-2021 nicm

Add popup-border-lines option to set popup line style, from Alexis
Hildebrandt, GitHub issue 2930.


Revision tags: OPENBSD_7_0_BASE
# 1.64 21-Aug-2021 nicm

Stop caring about empty commands, just treat as a null command.


# 1.63 11-Aug-2021 nicm

Break the colour palette into a struct rather than just a single array
and use that to support the OSC palette-setting sequences in popups.
Also add a pane-colours array option to specify the defaults. GitHub
issue 2815.


Revision tags: OPENBSD_6_9_BASE
# 1.62 11-Mar-2021 nicm

Add split-window -Z to start the pane zoomed, GitHub issue 2591.


# 1.61 18-Jan-2021 nicm

Hide some warnings on newer GCC versions, GitHUb issue 2525.


Revision tags: OPENBSD_6_8_BASE
# 1.60 25-Aug-2020 nicm

Allow colour to be spelt as color, from Boris Verkhovsky. GitHub issue
2317.


# 1.59 16-Jun-2020 nicm

d and D keys to reset to default in customize mode.


# 1.58 16-May-2020 nicm

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


# 1.57 16-May-2020 nicm

Add a customize mode where keys and options may be browsed and changed,
includes adding a brief description of each option. Bound to "C" by
default.


# 1.56 16-May-2020 nicm

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

To make this work, a few other changes:

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

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

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


Revision tags: OPENBSD_6_7_BASE
# 1.55 03-Dec-2019 nicm

Style nits in function arguments.


# 1.54 15-Oct-2019 nicm

Rewrite options_array_set to be clearer and remove a spurious warning
with newer GCC. From Ben Boeckel.


# 1.53 14-Oct-2019 nicm

Memory leaks, from Igor Wong in GitHub issue 1934.


Revision tags: OPENBSD_6_6_BASE
# 1.52 23-Jun-2019 nicm

Do not always set scope for panes because the window check might fail,
GitHub issue 1810.


# 1.51 20-Jun-2019 nicm

FIx return of options_scope_from_name on error.


# 1.50 20-Jun-2019 nicm

Add a per-pane option set. Pane options inherit from window options (so
there should be no change to existing behaviour) and are set and shown
with set-option -p and show-options -p.

Change remain-on-exit and window-style/window-active-style to be pane
options (some others will be changed later).

This makes select-pane -P and -g unnecessary so no longer document them
(they still work) and no longer document set-window-option and
show-window-options in favour of set-option -w and show-options -w.


# 1.49 20-Jun-2019 nicm

Add a helper function to work out option table from name.


# 1.48 08-Jun-2019 nicm

Do not try to parse command when unsetting, GitHub issue 1788.


# 1.47 30-May-2019 nicm

Remove a leftover abort and some fixes from cppcheck.


# 1.46 23-May-2019 nicm

Break the argument escaping code into a separate function and use it to
escape key bindings in list-keys. Also escape ~ and ; and $ properly.


# 1.45 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.44 12-May-2019 nicm

Fix some indentation and dead assignments.


# 1.43 26-Apr-2019 nicm

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


# 1.42 25-Apr-2019 nicm

Make options_tostring allocate its result instead of using a stack
buffer (needed for something in the future).


# 1.41 23-Apr-2019 nicm

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


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

The individual -fg, -bg and -attr options have been deprecated (in
favour of -style), undocumented and hidden from show-options since
2014. Remove them, except for status-fg and status-bg.


# 1.39 18-Mar-2019 nicm

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


# 1.38 15-Mar-2019 nicm

Add a way to set individual defaults for an array option.


# 1.37 14-Mar-2019 nicm

Add a wrapper (struct style) around styles rather than using the
grid_cell directly. There will be some non-cell members soon.


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.36 09-Aug-2017 nicm

Fix filtering so it works after the change to only show windows if they
have multiple panes.


# 1.35 31-May-2017 nicm

Style and spacing nits.


# 1.34 22-Apr-2017 nicm

Memory leaks, from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.33 08-Mar-2017 nicm

Handle empty options correctly.


# 1.32 30-Jan-2017 nicm

When a flag option is used in a format, it should use the number form
not string.


# 1.31 24-Jan-2017 nicm

If given an array option without an index either show or set all items,
and support -a for array options. Allow the separator for set to be
specified in the options table (will be used for backwards compatibility
later).


# 1.30 18-Jan-2017 nicm

Do not reset idx, it has just been set.


# 1.29 18-Jan-2017 nicm

options_match needs to explicitly check for user options.


# 1.28 16-Jan-2017 nicm

Correctly handle -style options without all of a corresponding -fg/-bg/-attr.


# 1.27 16-Jan-2017 nicm

getopt() has a struct option so just return to using options_entry.


# 1.26 15-Jan-2017 nicm

Major tidy up and rework of options tree and set-option/show-options
commands this pushes more of the code into options.c and ties it more
closely to the options table rather than having an unnecessary
split. Also add support for array options (will be used later). Only
(intentional) user visible change is that show-options output is now
passed through vis(3) with VIS_DQ so quotes are escaped.


# 1.25 15-Jan-2017 nicm

Append needs to go old,new not new,old...


# 1.24 13-Jan-2017 nicm

options_get_style return const too.


# 1.23 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.22 12-Jan-2017 nicm

Simplify appending to string options.


# 1.21 11-Jan-2017 nicm

Some tidying and tweaks to options code.


# 1.20 10-Oct-2016 nicm

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


# 1.19 26-Sep-2016 nicm

Support set -a (append) with user options, suggested by Xandor Schiefer.


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

I no longer use my SourceForge address so replace it.


# 1.17 11-Dec-2015 nicm

We cannot do hooks_find and then hooks_remove because it might have come
from the parent (global) tree, instead make it remove by name like options.

While here, also tidy up a few bits of options and hooks handling (use
RB_FOREACH_SAFE, and a helper function for the free).


# 1.16 08-Dec-2015 nicm

Spacing nits.


# 1.15 18-Nov-2015 nicm

Sync the entire xmalloc.[ch] with the other users, but with the addition
of xrealloc, xvasprintf, xvsnprintf.


# 1.14 13-Nov-2015 nicm

Log option names in fatal() for missing option.


# 1.13 27-Oct-2015 nicm

Move struct options into options.c.


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.12 18-Feb-2015 nicm

When given an invalid style, don't set the option to the default. Fix
from J Raynor. Also make style_parse not alter the grid_cell when it
fails.


# 1.11 20-Oct-2014 nicm

Better format for printf format attributes.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.10 28-Jan-2014 nicm

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

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

Becomes:

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

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

set -g status-bg red

Becomes:

set -ag status-style bg=red

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

From Tiago Cunha.


# 1.9 09-Jan-2014 nicm

Style and comment fixes from Tiago Cunha.


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.8 10-Jul-2012 nicm

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


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

Use RB trees not SPLAY.


# 1.6 21-Jan-2012 nicm

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

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

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


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.5 22-Sep-2009 nicm

Permit multiple prefix keys to be defined, separated by commas, for example:

set -g prefix ^a,^b

Any key in the list acts as the prefix. The send-prefix command always sends
the first key in the list.


# 1.4 21-Sep-2009 nicm

Use option print function for info messages as well.


# 1.3 21-Sep-2009 nicm

Drop tiny union from option struct.


# 1.2 21-Jul-2009 nicm

Make some functions which return unused values void (mostly found by lint) and
tweak a redundant expression in window_pane_set_mode.


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

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

ok deraadt pirofti


# 1.68 16-Mar-2022 nicm

Add an option to set the character used for unused areas of the
terminal, GitHub issue 3110.


# 1.67 03-Nov-2021 nicm

Add a cursor-style option, from Alexis Hildebrandt in GitHub issue 2960.


# 1.66 01-Nov-2021 nicm

Add a cursor-colour option, from Alexis Hildebrandt in GitHub issue
2959.


# 1.65 14-Oct-2021 nicm

Add popup-border-lines option to set popup line style, from Alexis
Hildebrandt, GitHub issue 2930.


Revision tags: OPENBSD_7_0_BASE
# 1.64 21-Aug-2021 nicm

Stop caring about empty commands, just treat as a null command.


# 1.63 11-Aug-2021 nicm

Break the colour palette into a struct rather than just a single array
and use that to support the OSC palette-setting sequences in popups.
Also add a pane-colours array option to specify the defaults. GitHub
issue 2815.


Revision tags: OPENBSD_6_9_BASE
# 1.62 11-Mar-2021 nicm

Add split-window -Z to start the pane zoomed, GitHub issue 2591.


# 1.61 18-Jan-2021 nicm

Hide some warnings on newer GCC versions, GitHUb issue 2525.


Revision tags: OPENBSD_6_8_BASE
# 1.60 25-Aug-2020 nicm

Allow colour to be spelt as color, from Boris Verkhovsky. GitHub issue
2317.


# 1.59 16-Jun-2020 nicm

d and D keys to reset to default in customize mode.


# 1.58 16-May-2020 nicm

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


# 1.57 16-May-2020 nicm

Add a customize mode where keys and options may be browsed and changed,
includes adding a brief description of each option. Bound to "C" by
default.


# 1.56 16-May-2020 nicm

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

To make this work, a few other changes:

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

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

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


Revision tags: OPENBSD_6_7_BASE
# 1.55 03-Dec-2019 nicm

Style nits in function arguments.


# 1.54 15-Oct-2019 nicm

Rewrite options_array_set to be clearer and remove a spurious warning
with newer GCC. From Ben Boeckel.


# 1.53 14-Oct-2019 nicm

Memory leaks, from Igor Wong in GitHub issue 1934.


Revision tags: OPENBSD_6_6_BASE
# 1.52 23-Jun-2019 nicm

Do not always set scope for panes because the window check might fail,
GitHub issue 1810.


# 1.51 20-Jun-2019 nicm

FIx return of options_scope_from_name on error.


# 1.50 20-Jun-2019 nicm

Add a per-pane option set. Pane options inherit from window options (so
there should be no change to existing behaviour) and are set and shown
with set-option -p and show-options -p.

Change remain-on-exit and window-style/window-active-style to be pane
options (some others will be changed later).

This makes select-pane -P and -g unnecessary so no longer document them
(they still work) and no longer document set-window-option and
show-window-options in favour of set-option -w and show-options -w.


# 1.49 20-Jun-2019 nicm

Add a helper function to work out option table from name.


# 1.48 08-Jun-2019 nicm

Do not try to parse command when unsetting, GitHub issue 1788.


# 1.47 30-May-2019 nicm

Remove a leftover abort and some fixes from cppcheck.


# 1.46 23-May-2019 nicm

Break the argument escaping code into a separate function and use it to
escape key bindings in list-keys. Also escape ~ and ; and $ properly.


# 1.45 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.44 12-May-2019 nicm

Fix some indentation and dead assignments.


# 1.43 26-Apr-2019 nicm

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


# 1.42 25-Apr-2019 nicm

Make options_tostring allocate its result instead of using a stack
buffer (needed for something in the future).


# 1.41 23-Apr-2019 nicm

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


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

The individual -fg, -bg and -attr options have been deprecated (in
favour of -style), undocumented and hidden from show-options since
2014. Remove them, except for status-fg and status-bg.


# 1.39 18-Mar-2019 nicm

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


# 1.38 15-Mar-2019 nicm

Add a way to set individual defaults for an array option.


# 1.37 14-Mar-2019 nicm

Add a wrapper (struct style) around styles rather than using the
grid_cell directly. There will be some non-cell members soon.


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.36 09-Aug-2017 nicm

Fix filtering so it works after the change to only show windows if they
have multiple panes.


# 1.35 31-May-2017 nicm

Style and spacing nits.


# 1.34 22-Apr-2017 nicm

Memory leaks, from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.33 08-Mar-2017 nicm

Handle empty options correctly.


# 1.32 30-Jan-2017 nicm

When a flag option is used in a format, it should use the number form
not string.


# 1.31 24-Jan-2017 nicm

If given an array option without an index either show or set all items,
and support -a for array options. Allow the separator for set to be
specified in the options table (will be used for backwards compatibility
later).


# 1.30 18-Jan-2017 nicm

Do not reset idx, it has just been set.


# 1.29 18-Jan-2017 nicm

options_match needs to explicitly check for user options.


# 1.28 16-Jan-2017 nicm

Correctly handle -style options without all of a corresponding -fg/-bg/-attr.


# 1.27 16-Jan-2017 nicm

getopt() has a struct option so just return to using options_entry.


# 1.26 15-Jan-2017 nicm

Major tidy up and rework of options tree and set-option/show-options
commands this pushes more of the code into options.c and ties it more
closely to the options table rather than having an unnecessary
split. Also add support for array options (will be used later). Only
(intentional) user visible change is that show-options output is now
passed through vis(3) with VIS_DQ so quotes are escaped.


# 1.25 15-Jan-2017 nicm

Append needs to go old,new not new,old...


# 1.24 13-Jan-2017 nicm

options_get_style return const too.


# 1.23 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.22 12-Jan-2017 nicm

Simplify appending to string options.


# 1.21 11-Jan-2017 nicm

Some tidying and tweaks to options code.


# 1.20 10-Oct-2016 nicm

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


# 1.19 26-Sep-2016 nicm

Support set -a (append) with user options, suggested by Xandor Schiefer.


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

I no longer use my SourceForge address so replace it.


# 1.17 11-Dec-2015 nicm

We cannot do hooks_find and then hooks_remove because it might have come
from the parent (global) tree, instead make it remove by name like options.

While here, also tidy up a few bits of options and hooks handling (use
RB_FOREACH_SAFE, and a helper function for the free).


# 1.16 08-Dec-2015 nicm

Spacing nits.


# 1.15 18-Nov-2015 nicm

Sync the entire xmalloc.[ch] with the other users, but with the addition
of xrealloc, xvasprintf, xvsnprintf.


# 1.14 13-Nov-2015 nicm

Log option names in fatal() for missing option.


# 1.13 27-Oct-2015 nicm

Move struct options into options.c.


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.12 18-Feb-2015 nicm

When given an invalid style, don't set the option to the default. Fix
from J Raynor. Also make style_parse not alter the grid_cell when it
fails.


# 1.11 20-Oct-2014 nicm

Better format for printf format attributes.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.10 28-Jan-2014 nicm

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

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

Becomes:

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

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

set -g status-bg red

Becomes:

set -ag status-style bg=red

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

From Tiago Cunha.


# 1.9 09-Jan-2014 nicm

Style and comment fixes from Tiago Cunha.


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.8 10-Jul-2012 nicm

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


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

Use RB trees not SPLAY.


# 1.6 21-Jan-2012 nicm

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

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

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


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.5 22-Sep-2009 nicm

Permit multiple prefix keys to be defined, separated by commas, for example:

set -g prefix ^a,^b

Any key in the list acts as the prefix. The send-prefix command always sends
the first key in the list.


# 1.4 21-Sep-2009 nicm

Use option print function for info messages as well.


# 1.3 21-Sep-2009 nicm

Drop tiny union from option struct.


# 1.2 21-Jul-2009 nicm

Make some functions which return unused values void (mostly found by lint) and
tweak a redundant expression in window_pane_set_mode.


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

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

ok deraadt pirofti


# 1.67 03-Nov-2021 nicm

Add a cursor-style option, from Alexis Hildebrandt in GitHub issue 2960.


# 1.66 01-Nov-2021 nicm

Add a cursor-colour option, from Alexis Hildebrandt in GitHub issue
2959.


# 1.65 14-Oct-2021 nicm

Add popup-border-lines option to set popup line style, from Alexis
Hildebrandt, GitHub issue 2930.


Revision tags: OPENBSD_7_0_BASE
# 1.64 21-Aug-2021 nicm

Stop caring about empty commands, just treat as a null command.


# 1.63 11-Aug-2021 nicm

Break the colour palette into a struct rather than just a single array
and use that to support the OSC palette-setting sequences in popups.
Also add a pane-colours array option to specify the defaults. GitHub
issue 2815.


Revision tags: OPENBSD_6_9_BASE
# 1.62 11-Mar-2021 nicm

Add split-window -Z to start the pane zoomed, GitHub issue 2591.


# 1.61 18-Jan-2021 nicm

Hide some warnings on newer GCC versions, GitHUb issue 2525.


Revision tags: OPENBSD_6_8_BASE
# 1.60 25-Aug-2020 nicm

Allow colour to be spelt as color, from Boris Verkhovsky. GitHub issue
2317.


# 1.59 16-Jun-2020 nicm

d and D keys to reset to default in customize mode.


# 1.58 16-May-2020 nicm

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


# 1.57 16-May-2020 nicm

Add a customize mode where keys and options may be browsed and changed,
includes adding a brief description of each option. Bound to "C" by
default.


# 1.56 16-May-2020 nicm

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

To make this work, a few other changes:

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

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

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


Revision tags: OPENBSD_6_7_BASE
# 1.55 03-Dec-2019 nicm

Style nits in function arguments.


# 1.54 15-Oct-2019 nicm

Rewrite options_array_set to be clearer and remove a spurious warning
with newer GCC. From Ben Boeckel.


# 1.53 14-Oct-2019 nicm

Memory leaks, from Igor Wong in GitHub issue 1934.


Revision tags: OPENBSD_6_6_BASE
# 1.52 23-Jun-2019 nicm

Do not always set scope for panes because the window check might fail,
GitHub issue 1810.


# 1.51 20-Jun-2019 nicm

FIx return of options_scope_from_name on error.


# 1.50 20-Jun-2019 nicm

Add a per-pane option set. Pane options inherit from window options (so
there should be no change to existing behaviour) and are set and shown
with set-option -p and show-options -p.

Change remain-on-exit and window-style/window-active-style to be pane
options (some others will be changed later).

This makes select-pane -P and -g unnecessary so no longer document them
(they still work) and no longer document set-window-option and
show-window-options in favour of set-option -w and show-options -w.


# 1.49 20-Jun-2019 nicm

Add a helper function to work out option table from name.


# 1.48 08-Jun-2019 nicm

Do not try to parse command when unsetting, GitHub issue 1788.


# 1.47 30-May-2019 nicm

Remove a leftover abort and some fixes from cppcheck.


# 1.46 23-May-2019 nicm

Break the argument escaping code into a separate function and use it to
escape key bindings in list-keys. Also escape ~ and ; and $ properly.


# 1.45 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.44 12-May-2019 nicm

Fix some indentation and dead assignments.


# 1.43 26-Apr-2019 nicm

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


# 1.42 25-Apr-2019 nicm

Make options_tostring allocate its result instead of using a stack
buffer (needed for something in the future).


# 1.41 23-Apr-2019 nicm

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


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

The individual -fg, -bg and -attr options have been deprecated (in
favour of -style), undocumented and hidden from show-options since
2014. Remove them, except for status-fg and status-bg.


# 1.39 18-Mar-2019 nicm

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


# 1.38 15-Mar-2019 nicm

Add a way to set individual defaults for an array option.


# 1.37 14-Mar-2019 nicm

Add a wrapper (struct style) around styles rather than using the
grid_cell directly. There will be some non-cell members soon.


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.36 09-Aug-2017 nicm

Fix filtering so it works after the change to only show windows if they
have multiple panes.


# 1.35 31-May-2017 nicm

Style and spacing nits.


# 1.34 22-Apr-2017 nicm

Memory leaks, from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.33 08-Mar-2017 nicm

Handle empty options correctly.


# 1.32 30-Jan-2017 nicm

When a flag option is used in a format, it should use the number form
not string.


# 1.31 24-Jan-2017 nicm

If given an array option without an index either show or set all items,
and support -a for array options. Allow the separator for set to be
specified in the options table (will be used for backwards compatibility
later).


# 1.30 18-Jan-2017 nicm

Do not reset idx, it has just been set.


# 1.29 18-Jan-2017 nicm

options_match needs to explicitly check for user options.


# 1.28 16-Jan-2017 nicm

Correctly handle -style options without all of a corresponding -fg/-bg/-attr.


# 1.27 16-Jan-2017 nicm

getopt() has a struct option so just return to using options_entry.


# 1.26 15-Jan-2017 nicm

Major tidy up and rework of options tree and set-option/show-options
commands this pushes more of the code into options.c and ties it more
closely to the options table rather than having an unnecessary
split. Also add support for array options (will be used later). Only
(intentional) user visible change is that show-options output is now
passed through vis(3) with VIS_DQ so quotes are escaped.


# 1.25 15-Jan-2017 nicm

Append needs to go old,new not new,old...


# 1.24 13-Jan-2017 nicm

options_get_style return const too.


# 1.23 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.22 12-Jan-2017 nicm

Simplify appending to string options.


# 1.21 11-Jan-2017 nicm

Some tidying and tweaks to options code.


# 1.20 10-Oct-2016 nicm

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


# 1.19 26-Sep-2016 nicm

Support set -a (append) with user options, suggested by Xandor Schiefer.


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

I no longer use my SourceForge address so replace it.


# 1.17 11-Dec-2015 nicm

We cannot do hooks_find and then hooks_remove because it might have come
from the parent (global) tree, instead make it remove by name like options.

While here, also tidy up a few bits of options and hooks handling (use
RB_FOREACH_SAFE, and a helper function for the free).


# 1.16 08-Dec-2015 nicm

Spacing nits.


# 1.15 18-Nov-2015 nicm

Sync the entire xmalloc.[ch] with the other users, but with the addition
of xrealloc, xvasprintf, xvsnprintf.


# 1.14 13-Nov-2015 nicm

Log option names in fatal() for missing option.


# 1.13 27-Oct-2015 nicm

Move struct options into options.c.


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.12 18-Feb-2015 nicm

When given an invalid style, don't set the option to the default. Fix
from J Raynor. Also make style_parse not alter the grid_cell when it
fails.


# 1.11 20-Oct-2014 nicm

Better format for printf format attributes.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.10 28-Jan-2014 nicm

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

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

Becomes:

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

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

set -g status-bg red

Becomes:

set -ag status-style bg=red

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

From Tiago Cunha.


# 1.9 09-Jan-2014 nicm

Style and comment fixes from Tiago Cunha.


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.8 10-Jul-2012 nicm

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


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

Use RB trees not SPLAY.


# 1.6 21-Jan-2012 nicm

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

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

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


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.5 22-Sep-2009 nicm

Permit multiple prefix keys to be defined, separated by commas, for example:

set -g prefix ^a,^b

Any key in the list acts as the prefix. The send-prefix command always sends
the first key in the list.


# 1.4 21-Sep-2009 nicm

Use option print function for info messages as well.


# 1.3 21-Sep-2009 nicm

Drop tiny union from option struct.


# 1.2 21-Jul-2009 nicm

Make some functions which return unused values void (mostly found by lint) and
tweak a redundant expression in window_pane_set_mode.


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

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

ok deraadt pirofti


# 1.66 01-Nov-2021 nicm

Add a cursor-colour option, from Alexis Hildebrandt in GitHub issue
2959.


# 1.65 14-Oct-2021 nicm

Add popup-border-lines option to set popup line style, from Alexis
Hildebrandt, GitHub issue 2930.


Revision tags: OPENBSD_7_0_BASE
# 1.64 21-Aug-2021 nicm

Stop caring about empty commands, just treat as a null command.


# 1.63 11-Aug-2021 nicm

Break the colour palette into a struct rather than just a single array
and use that to support the OSC palette-setting sequences in popups.
Also add a pane-colours array option to specify the defaults. GitHub
issue 2815.


Revision tags: OPENBSD_6_9_BASE
# 1.62 11-Mar-2021 nicm

Add split-window -Z to start the pane zoomed, GitHub issue 2591.


# 1.61 18-Jan-2021 nicm

Hide some warnings on newer GCC versions, GitHUb issue 2525.


Revision tags: OPENBSD_6_8_BASE
# 1.60 25-Aug-2020 nicm

Allow colour to be spelt as color, from Boris Verkhovsky. GitHub issue
2317.


# 1.59 16-Jun-2020 nicm

d and D keys to reset to default in customize mode.


# 1.58 16-May-2020 nicm

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


# 1.57 16-May-2020 nicm

Add a customize mode where keys and options may be browsed and changed,
includes adding a brief description of each option. Bound to "C" by
default.


# 1.56 16-May-2020 nicm

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

To make this work, a few other changes:

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

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

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


Revision tags: OPENBSD_6_7_BASE
# 1.55 03-Dec-2019 nicm

Style nits in function arguments.


# 1.54 15-Oct-2019 nicm

Rewrite options_array_set to be clearer and remove a spurious warning
with newer GCC. From Ben Boeckel.


# 1.53 14-Oct-2019 nicm

Memory leaks, from Igor Wong in GitHub issue 1934.


Revision tags: OPENBSD_6_6_BASE
# 1.52 23-Jun-2019 nicm

Do not always set scope for panes because the window check might fail,
GitHub issue 1810.


# 1.51 20-Jun-2019 nicm

FIx return of options_scope_from_name on error.


# 1.50 20-Jun-2019 nicm

Add a per-pane option set. Pane options inherit from window options (so
there should be no change to existing behaviour) and are set and shown
with set-option -p and show-options -p.

Change remain-on-exit and window-style/window-active-style to be pane
options (some others will be changed later).

This makes select-pane -P and -g unnecessary so no longer document them
(they still work) and no longer document set-window-option and
show-window-options in favour of set-option -w and show-options -w.


# 1.49 20-Jun-2019 nicm

Add a helper function to work out option table from name.


# 1.48 08-Jun-2019 nicm

Do not try to parse command when unsetting, GitHub issue 1788.


# 1.47 30-May-2019 nicm

Remove a leftover abort and some fixes from cppcheck.


# 1.46 23-May-2019 nicm

Break the argument escaping code into a separate function and use it to
escape key bindings in list-keys. Also escape ~ and ; and $ properly.


# 1.45 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.44 12-May-2019 nicm

Fix some indentation and dead assignments.


# 1.43 26-Apr-2019 nicm

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


# 1.42 25-Apr-2019 nicm

Make options_tostring allocate its result instead of using a stack
buffer (needed for something in the future).


# 1.41 23-Apr-2019 nicm

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


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

The individual -fg, -bg and -attr options have been deprecated (in
favour of -style), undocumented and hidden from show-options since
2014. Remove them, except for status-fg and status-bg.


# 1.39 18-Mar-2019 nicm

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


# 1.38 15-Mar-2019 nicm

Add a way to set individual defaults for an array option.


# 1.37 14-Mar-2019 nicm

Add a wrapper (struct style) around styles rather than using the
grid_cell directly. There will be some non-cell members soon.


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.36 09-Aug-2017 nicm

Fix filtering so it works after the change to only show windows if they
have multiple panes.


# 1.35 31-May-2017 nicm

Style and spacing nits.


# 1.34 22-Apr-2017 nicm

Memory leaks, from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.33 08-Mar-2017 nicm

Handle empty options correctly.


# 1.32 30-Jan-2017 nicm

When a flag option is used in a format, it should use the number form
not string.


# 1.31 24-Jan-2017 nicm

If given an array option without an index either show or set all items,
and support -a for array options. Allow the separator for set to be
specified in the options table (will be used for backwards compatibility
later).


# 1.30 18-Jan-2017 nicm

Do not reset idx, it has just been set.


# 1.29 18-Jan-2017 nicm

options_match needs to explicitly check for user options.


# 1.28 16-Jan-2017 nicm

Correctly handle -style options without all of a corresponding -fg/-bg/-attr.


# 1.27 16-Jan-2017 nicm

getopt() has a struct option so just return to using options_entry.


# 1.26 15-Jan-2017 nicm

Major tidy up and rework of options tree and set-option/show-options
commands this pushes more of the code into options.c and ties it more
closely to the options table rather than having an unnecessary
split. Also add support for array options (will be used later). Only
(intentional) user visible change is that show-options output is now
passed through vis(3) with VIS_DQ so quotes are escaped.


# 1.25 15-Jan-2017 nicm

Append needs to go old,new not new,old...


# 1.24 13-Jan-2017 nicm

options_get_style return const too.


# 1.23 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.22 12-Jan-2017 nicm

Simplify appending to string options.


# 1.21 11-Jan-2017 nicm

Some tidying and tweaks to options code.


# 1.20 10-Oct-2016 nicm

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


# 1.19 26-Sep-2016 nicm

Support set -a (append) with user options, suggested by Xandor Schiefer.


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

I no longer use my SourceForge address so replace it.


# 1.17 11-Dec-2015 nicm

We cannot do hooks_find and then hooks_remove because it might have come
from the parent (global) tree, instead make it remove by name like options.

While here, also tidy up a few bits of options and hooks handling (use
RB_FOREACH_SAFE, and a helper function for the free).


# 1.16 08-Dec-2015 nicm

Spacing nits.


# 1.15 18-Nov-2015 nicm

Sync the entire xmalloc.[ch] with the other users, but with the addition
of xrealloc, xvasprintf, xvsnprintf.


# 1.14 13-Nov-2015 nicm

Log option names in fatal() for missing option.


# 1.13 27-Oct-2015 nicm

Move struct options into options.c.


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.12 18-Feb-2015 nicm

When given an invalid style, don't set the option to the default. Fix
from J Raynor. Also make style_parse not alter the grid_cell when it
fails.


# 1.11 20-Oct-2014 nicm

Better format for printf format attributes.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.10 28-Jan-2014 nicm

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

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

Becomes:

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

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

set -g status-bg red

Becomes:

set -ag status-style bg=red

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

From Tiago Cunha.


# 1.9 09-Jan-2014 nicm

Style and comment fixes from Tiago Cunha.


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.8 10-Jul-2012 nicm

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


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

Use RB trees not SPLAY.


# 1.6 21-Jan-2012 nicm

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

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

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


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.5 22-Sep-2009 nicm

Permit multiple prefix keys to be defined, separated by commas, for example:

set -g prefix ^a,^b

Any key in the list acts as the prefix. The send-prefix command always sends
the first key in the list.


# 1.4 21-Sep-2009 nicm

Use option print function for info messages as well.


# 1.3 21-Sep-2009 nicm

Drop tiny union from option struct.


# 1.2 21-Jul-2009 nicm

Make some functions which return unused values void (mostly found by lint) and
tweak a redundant expression in window_pane_set_mode.


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

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

ok deraadt pirofti


# 1.65 14-Oct-2021 nicm

Add popup-border-lines option to set popup line style, from Alexis
Hildebrandt, GitHub issue 2930.


Revision tags: OPENBSD_7_0_BASE
# 1.64 21-Aug-2021 nicm

Stop caring about empty commands, just treat as a null command.


# 1.63 11-Aug-2021 nicm

Break the colour palette into a struct rather than just a single array
and use that to support the OSC palette-setting sequences in popups.
Also add a pane-colours array option to specify the defaults. GitHub
issue 2815.


Revision tags: OPENBSD_6_9_BASE
# 1.62 11-Mar-2021 nicm

Add split-window -Z to start the pane zoomed, GitHub issue 2591.


# 1.61 18-Jan-2021 nicm

Hide some warnings on newer GCC versions, GitHUb issue 2525.


Revision tags: OPENBSD_6_8_BASE
# 1.60 25-Aug-2020 nicm

Allow colour to be spelt as color, from Boris Verkhovsky. GitHub issue
2317.


# 1.59 16-Jun-2020 nicm

d and D keys to reset to default in customize mode.


# 1.58 16-May-2020 nicm

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


# 1.57 16-May-2020 nicm

Add a customize mode where keys and options may be browsed and changed,
includes adding a brief description of each option. Bound to "C" by
default.


# 1.56 16-May-2020 nicm

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

To make this work, a few other changes:

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

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

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


Revision tags: OPENBSD_6_7_BASE
# 1.55 03-Dec-2019 nicm

Style nits in function arguments.


# 1.54 15-Oct-2019 nicm

Rewrite options_array_set to be clearer and remove a spurious warning
with newer GCC. From Ben Boeckel.


# 1.53 14-Oct-2019 nicm

Memory leaks, from Igor Wong in GitHub issue 1934.


Revision tags: OPENBSD_6_6_BASE
# 1.52 23-Jun-2019 nicm

Do not always set scope for panes because the window check might fail,
GitHub issue 1810.


# 1.51 20-Jun-2019 nicm

FIx return of options_scope_from_name on error.


# 1.50 20-Jun-2019 nicm

Add a per-pane option set. Pane options inherit from window options (so
there should be no change to existing behaviour) and are set and shown
with set-option -p and show-options -p.

Change remain-on-exit and window-style/window-active-style to be pane
options (some others will be changed later).

This makes select-pane -P and -g unnecessary so no longer document them
(they still work) and no longer document set-window-option and
show-window-options in favour of set-option -w and show-options -w.


# 1.49 20-Jun-2019 nicm

Add a helper function to work out option table from name.


# 1.48 08-Jun-2019 nicm

Do not try to parse command when unsetting, GitHub issue 1788.


# 1.47 30-May-2019 nicm

Remove a leftover abort and some fixes from cppcheck.


# 1.46 23-May-2019 nicm

Break the argument escaping code into a separate function and use it to
escape key bindings in list-keys. Also escape ~ and ; and $ properly.


# 1.45 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.44 12-May-2019 nicm

Fix some indentation and dead assignments.


# 1.43 26-Apr-2019 nicm

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


# 1.42 25-Apr-2019 nicm

Make options_tostring allocate its result instead of using a stack
buffer (needed for something in the future).


# 1.41 23-Apr-2019 nicm

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


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

The individual -fg, -bg and -attr options have been deprecated (in
favour of -style), undocumented and hidden from show-options since
2014. Remove them, except for status-fg and status-bg.


# 1.39 18-Mar-2019 nicm

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


# 1.38 15-Mar-2019 nicm

Add a way to set individual defaults for an array option.


# 1.37 14-Mar-2019 nicm

Add a wrapper (struct style) around styles rather than using the
grid_cell directly. There will be some non-cell members soon.


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.36 09-Aug-2017 nicm

Fix filtering so it works after the change to only show windows if they
have multiple panes.


# 1.35 31-May-2017 nicm

Style and spacing nits.


# 1.34 22-Apr-2017 nicm

Memory leaks, from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.33 08-Mar-2017 nicm

Handle empty options correctly.


# 1.32 30-Jan-2017 nicm

When a flag option is used in a format, it should use the number form
not string.


# 1.31 24-Jan-2017 nicm

If given an array option without an index either show or set all items,
and support -a for array options. Allow the separator for set to be
specified in the options table (will be used for backwards compatibility
later).


# 1.30 18-Jan-2017 nicm

Do not reset idx, it has just been set.


# 1.29 18-Jan-2017 nicm

options_match needs to explicitly check for user options.


# 1.28 16-Jan-2017 nicm

Correctly handle -style options without all of a corresponding -fg/-bg/-attr.


# 1.27 16-Jan-2017 nicm

getopt() has a struct option so just return to using options_entry.


# 1.26 15-Jan-2017 nicm

Major tidy up and rework of options tree and set-option/show-options
commands this pushes more of the code into options.c and ties it more
closely to the options table rather than having an unnecessary
split. Also add support for array options (will be used later). Only
(intentional) user visible change is that show-options output is now
passed through vis(3) with VIS_DQ so quotes are escaped.


# 1.25 15-Jan-2017 nicm

Append needs to go old,new not new,old...


# 1.24 13-Jan-2017 nicm

options_get_style return const too.


# 1.23 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.22 12-Jan-2017 nicm

Simplify appending to string options.


# 1.21 11-Jan-2017 nicm

Some tidying and tweaks to options code.


# 1.20 10-Oct-2016 nicm

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


# 1.19 26-Sep-2016 nicm

Support set -a (append) with user options, suggested by Xandor Schiefer.


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

I no longer use my SourceForge address so replace it.


# 1.17 11-Dec-2015 nicm

We cannot do hooks_find and then hooks_remove because it might have come
from the parent (global) tree, instead make it remove by name like options.

While here, also tidy up a few bits of options and hooks handling (use
RB_FOREACH_SAFE, and a helper function for the free).


# 1.16 08-Dec-2015 nicm

Spacing nits.


# 1.15 18-Nov-2015 nicm

Sync the entire xmalloc.[ch] with the other users, but with the addition
of xrealloc, xvasprintf, xvsnprintf.


# 1.14 13-Nov-2015 nicm

Log option names in fatal() for missing option.


# 1.13 27-Oct-2015 nicm

Move struct options into options.c.


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.12 18-Feb-2015 nicm

When given an invalid style, don't set the option to the default. Fix
from J Raynor. Also make style_parse not alter the grid_cell when it
fails.


# 1.11 20-Oct-2014 nicm

Better format for printf format attributes.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.10 28-Jan-2014 nicm

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

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

Becomes:

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

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

set -g status-bg red

Becomes:

set -ag status-style bg=red

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

From Tiago Cunha.


# 1.9 09-Jan-2014 nicm

Style and comment fixes from Tiago Cunha.


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.8 10-Jul-2012 nicm

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


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

Use RB trees not SPLAY.


# 1.6 21-Jan-2012 nicm

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

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

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


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.5 22-Sep-2009 nicm

Permit multiple prefix keys to be defined, separated by commas, for example:

set -g prefix ^a,^b

Any key in the list acts as the prefix. The send-prefix command always sends
the first key in the list.


# 1.4 21-Sep-2009 nicm

Use option print function for info messages as well.


# 1.3 21-Sep-2009 nicm

Drop tiny union from option struct.


# 1.2 21-Jul-2009 nicm

Make some functions which return unused values void (mostly found by lint) and
tweak a redundant expression in window_pane_set_mode.


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

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

ok deraadt pirofti


# 1.64 21-Aug-2021 nicm

Stop caring about empty commands, just treat as a null command.


# 1.63 11-Aug-2021 nicm

Break the colour palette into a struct rather than just a single array
and use that to support the OSC palette-setting sequences in popups.
Also add a pane-colours array option to specify the defaults. GitHub
issue 2815.


Revision tags: OPENBSD_6_9_BASE
# 1.62 11-Mar-2021 nicm

Add split-window -Z to start the pane zoomed, GitHub issue 2591.


# 1.61 18-Jan-2021 nicm

Hide some warnings on newer GCC versions, GitHUb issue 2525.


Revision tags: OPENBSD_6_8_BASE
# 1.60 25-Aug-2020 nicm

Allow colour to be spelt as color, from Boris Verkhovsky. GitHub issue
2317.


# 1.59 16-Jun-2020 nicm

d and D keys to reset to default in customize mode.


# 1.58 16-May-2020 nicm

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


# 1.57 16-May-2020 nicm

Add a customize mode where keys and options may be browsed and changed,
includes adding a brief description of each option. Bound to "C" by
default.


# 1.56 16-May-2020 nicm

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

To make this work, a few other changes:

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

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

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


Revision tags: OPENBSD_6_7_BASE
# 1.55 03-Dec-2019 nicm

Style nits in function arguments.


# 1.54 15-Oct-2019 nicm

Rewrite options_array_set to be clearer and remove a spurious warning
with newer GCC. From Ben Boeckel.


# 1.53 14-Oct-2019 nicm

Memory leaks, from Igor Wong in GitHub issue 1934.


Revision tags: OPENBSD_6_6_BASE
# 1.52 23-Jun-2019 nicm

Do not always set scope for panes because the window check might fail,
GitHub issue 1810.


# 1.51 20-Jun-2019 nicm

FIx return of options_scope_from_name on error.


# 1.50 20-Jun-2019 nicm

Add a per-pane option set. Pane options inherit from window options (so
there should be no change to existing behaviour) and are set and shown
with set-option -p and show-options -p.

Change remain-on-exit and window-style/window-active-style to be pane
options (some others will be changed later).

This makes select-pane -P and -g unnecessary so no longer document them
(they still work) and no longer document set-window-option and
show-window-options in favour of set-option -w and show-options -w.


# 1.49 20-Jun-2019 nicm

Add a helper function to work out option table from name.


# 1.48 08-Jun-2019 nicm

Do not try to parse command when unsetting, GitHub issue 1788.


# 1.47 30-May-2019 nicm

Remove a leftover abort and some fixes from cppcheck.


# 1.46 23-May-2019 nicm

Break the argument escaping code into a separate function and use it to
escape key bindings in list-keys. Also escape ~ and ; and $ properly.


# 1.45 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.44 12-May-2019 nicm

Fix some indentation and dead assignments.


# 1.43 26-Apr-2019 nicm

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


# 1.42 25-Apr-2019 nicm

Make options_tostring allocate its result instead of using a stack
buffer (needed for something in the future).


# 1.41 23-Apr-2019 nicm

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


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

The individual -fg, -bg and -attr options have been deprecated (in
favour of -style), undocumented and hidden from show-options since
2014. Remove them, except for status-fg and status-bg.


# 1.39 18-Mar-2019 nicm

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


# 1.38 15-Mar-2019 nicm

Add a way to set individual defaults for an array option.


# 1.37 14-Mar-2019 nicm

Add a wrapper (struct style) around styles rather than using the
grid_cell directly. There will be some non-cell members soon.


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.36 09-Aug-2017 nicm

Fix filtering so it works after the change to only show windows if they
have multiple panes.


# 1.35 31-May-2017 nicm

Style and spacing nits.


# 1.34 22-Apr-2017 nicm

Memory leaks, from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.33 08-Mar-2017 nicm

Handle empty options correctly.


# 1.32 30-Jan-2017 nicm

When a flag option is used in a format, it should use the number form
not string.


# 1.31 24-Jan-2017 nicm

If given an array option without an index either show or set all items,
and support -a for array options. Allow the separator for set to be
specified in the options table (will be used for backwards compatibility
later).


# 1.30 18-Jan-2017 nicm

Do not reset idx, it has just been set.


# 1.29 18-Jan-2017 nicm

options_match needs to explicitly check for user options.


# 1.28 16-Jan-2017 nicm

Correctly handle -style options without all of a corresponding -fg/-bg/-attr.


# 1.27 16-Jan-2017 nicm

getopt() has a struct option so just return to using options_entry.


# 1.26 15-Jan-2017 nicm

Major tidy up and rework of options tree and set-option/show-options
commands this pushes more of the code into options.c and ties it more
closely to the options table rather than having an unnecessary
split. Also add support for array options (will be used later). Only
(intentional) user visible change is that show-options output is now
passed through vis(3) with VIS_DQ so quotes are escaped.


# 1.25 15-Jan-2017 nicm

Append needs to go old,new not new,old...


# 1.24 13-Jan-2017 nicm

options_get_style return const too.


# 1.23 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.22 12-Jan-2017 nicm

Simplify appending to string options.


# 1.21 11-Jan-2017 nicm

Some tidying and tweaks to options code.


# 1.20 10-Oct-2016 nicm

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


# 1.19 26-Sep-2016 nicm

Support set -a (append) with user options, suggested by Xandor Schiefer.


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

I no longer use my SourceForge address so replace it.


# 1.17 11-Dec-2015 nicm

We cannot do hooks_find and then hooks_remove because it might have come
from the parent (global) tree, instead make it remove by name like options.

While here, also tidy up a few bits of options and hooks handling (use
RB_FOREACH_SAFE, and a helper function for the free).


# 1.16 08-Dec-2015 nicm

Spacing nits.


# 1.15 18-Nov-2015 nicm

Sync the entire xmalloc.[ch] with the other users, but with the addition
of xrealloc, xvasprintf, xvsnprintf.


# 1.14 13-Nov-2015 nicm

Log option names in fatal() for missing option.


# 1.13 27-Oct-2015 nicm

Move struct options into options.c.


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.12 18-Feb-2015 nicm

When given an invalid style, don't set the option to the default. Fix
from J Raynor. Also make style_parse not alter the grid_cell when it
fails.


# 1.11 20-Oct-2014 nicm

Better format for printf format attributes.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.10 28-Jan-2014 nicm

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

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

Becomes:

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

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

set -g status-bg red

Becomes:

set -ag status-style bg=red

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

From Tiago Cunha.


# 1.9 09-Jan-2014 nicm

Style and comment fixes from Tiago Cunha.


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.8 10-Jul-2012 nicm

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


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

Use RB trees not SPLAY.


# 1.6 21-Jan-2012 nicm

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

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

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


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.5 22-Sep-2009 nicm

Permit multiple prefix keys to be defined, separated by commas, for example:

set -g prefix ^a,^b

Any key in the list acts as the prefix. The send-prefix command always sends
the first key in the list.


# 1.4 21-Sep-2009 nicm

Use option print function for info messages as well.


# 1.3 21-Sep-2009 nicm

Drop tiny union from option struct.


# 1.2 21-Jul-2009 nicm

Make some functions which return unused values void (mostly found by lint) and
tweak a redundant expression in window_pane_set_mode.


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

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

ok deraadt pirofti


# 1.63 11-Aug-2021 nicm

Break the colour palette into a struct rather than just a single array
and use that to support the OSC palette-setting sequences in popups.
Also add a pane-colours array option to specify the defaults. GitHub
issue 2815.


Revision tags: OPENBSD_6_9_BASE
# 1.62 11-Mar-2021 nicm

Add split-window -Z to start the pane zoomed, GitHub issue 2591.


# 1.61 18-Jan-2021 nicm

Hide some warnings on newer GCC versions, GitHUb issue 2525.


Revision tags: OPENBSD_6_8_BASE
# 1.60 25-Aug-2020 nicm

Allow colour to be spelt as color, from Boris Verkhovsky. GitHub issue
2317.


# 1.59 16-Jun-2020 nicm

d and D keys to reset to default in customize mode.


# 1.58 16-May-2020 nicm

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


# 1.57 16-May-2020 nicm

Add a customize mode where keys and options may be browsed and changed,
includes adding a brief description of each option. Bound to "C" by
default.


# 1.56 16-May-2020 nicm

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

To make this work, a few other changes:

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

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

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


Revision tags: OPENBSD_6_7_BASE
# 1.55 03-Dec-2019 nicm

Style nits in function arguments.


# 1.54 15-Oct-2019 nicm

Rewrite options_array_set to be clearer and remove a spurious warning
with newer GCC. From Ben Boeckel.


# 1.53 14-Oct-2019 nicm

Memory leaks, from Igor Wong in GitHub issue 1934.


Revision tags: OPENBSD_6_6_BASE
# 1.52 23-Jun-2019 nicm

Do not always set scope for panes because the window check might fail,
GitHub issue 1810.


# 1.51 20-Jun-2019 nicm

FIx return of options_scope_from_name on error.


# 1.50 20-Jun-2019 nicm

Add a per-pane option set. Pane options inherit from window options (so
there should be no change to existing behaviour) and are set and shown
with set-option -p and show-options -p.

Change remain-on-exit and window-style/window-active-style to be pane
options (some others will be changed later).

This makes select-pane -P and -g unnecessary so no longer document them
(they still work) and no longer document set-window-option and
show-window-options in favour of set-option -w and show-options -w.


# 1.49 20-Jun-2019 nicm

Add a helper function to work out option table from name.


# 1.48 08-Jun-2019 nicm

Do not try to parse command when unsetting, GitHub issue 1788.


# 1.47 30-May-2019 nicm

Remove a leftover abort and some fixes from cppcheck.


# 1.46 23-May-2019 nicm

Break the argument escaping code into a separate function and use it to
escape key bindings in list-keys. Also escape ~ and ; and $ properly.


# 1.45 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.44 12-May-2019 nicm

Fix some indentation and dead assignments.


# 1.43 26-Apr-2019 nicm

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


# 1.42 25-Apr-2019 nicm

Make options_tostring allocate its result instead of using a stack
buffer (needed for something in the future).


# 1.41 23-Apr-2019 nicm

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


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

The individual -fg, -bg and -attr options have been deprecated (in
favour of -style), undocumented and hidden from show-options since
2014. Remove them, except for status-fg and status-bg.


# 1.39 18-Mar-2019 nicm

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


# 1.38 15-Mar-2019 nicm

Add a way to set individual defaults for an array option.


# 1.37 14-Mar-2019 nicm

Add a wrapper (struct style) around styles rather than using the
grid_cell directly. There will be some non-cell members soon.


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.36 09-Aug-2017 nicm

Fix filtering so it works after the change to only show windows if they
have multiple panes.


# 1.35 31-May-2017 nicm

Style and spacing nits.


# 1.34 22-Apr-2017 nicm

Memory leaks, from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.33 08-Mar-2017 nicm

Handle empty options correctly.


# 1.32 30-Jan-2017 nicm

When a flag option is used in a format, it should use the number form
not string.


# 1.31 24-Jan-2017 nicm

If given an array option without an index either show or set all items,
and support -a for array options. Allow the separator for set to be
specified in the options table (will be used for backwards compatibility
later).


# 1.30 18-Jan-2017 nicm

Do not reset idx, it has just been set.


# 1.29 18-Jan-2017 nicm

options_match needs to explicitly check for user options.


# 1.28 16-Jan-2017 nicm

Correctly handle -style options without all of a corresponding -fg/-bg/-attr.


# 1.27 16-Jan-2017 nicm

getopt() has a struct option so just return to using options_entry.


# 1.26 15-Jan-2017 nicm

Major tidy up and rework of options tree and set-option/show-options
commands this pushes more of the code into options.c and ties it more
closely to the options table rather than having an unnecessary
split. Also add support for array options (will be used later). Only
(intentional) user visible change is that show-options output is now
passed through vis(3) with VIS_DQ so quotes are escaped.


# 1.25 15-Jan-2017 nicm

Append needs to go old,new not new,old...


# 1.24 13-Jan-2017 nicm

options_get_style return const too.


# 1.23 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.22 12-Jan-2017 nicm

Simplify appending to string options.


# 1.21 11-Jan-2017 nicm

Some tidying and tweaks to options code.


# 1.20 10-Oct-2016 nicm

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


# 1.19 26-Sep-2016 nicm

Support set -a (append) with user options, suggested by Xandor Schiefer.


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

I no longer use my SourceForge address so replace it.


# 1.17 11-Dec-2015 nicm

We cannot do hooks_find and then hooks_remove because it might have come
from the parent (global) tree, instead make it remove by name like options.

While here, also tidy up a few bits of options and hooks handling (use
RB_FOREACH_SAFE, and a helper function for the free).


# 1.16 08-Dec-2015 nicm

Spacing nits.


# 1.15 18-Nov-2015 nicm

Sync the entire xmalloc.[ch] with the other users, but with the addition
of xrealloc, xvasprintf, xvsnprintf.


# 1.14 13-Nov-2015 nicm

Log option names in fatal() for missing option.


# 1.13 27-Oct-2015 nicm

Move struct options into options.c.


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.12 18-Feb-2015 nicm

When given an invalid style, don't set the option to the default. Fix
from J Raynor. Also make style_parse not alter the grid_cell when it
fails.


# 1.11 20-Oct-2014 nicm

Better format for printf format attributes.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.10 28-Jan-2014 nicm

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

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

Becomes:

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

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

set -g status-bg red

Becomes:

set -ag status-style bg=red

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

From Tiago Cunha.


# 1.9 09-Jan-2014 nicm

Style and comment fixes from Tiago Cunha.


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.8 10-Jul-2012 nicm

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


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

Use RB trees not SPLAY.


# 1.6 21-Jan-2012 nicm

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

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

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


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.5 22-Sep-2009 nicm

Permit multiple prefix keys to be defined, separated by commas, for example:

set -g prefix ^a,^b

Any key in the list acts as the prefix. The send-prefix command always sends
the first key in the list.


# 1.4 21-Sep-2009 nicm

Use option print function for info messages as well.


# 1.3 21-Sep-2009 nicm

Drop tiny union from option struct.


# 1.2 21-Jul-2009 nicm

Make some functions which return unused values void (mostly found by lint) and
tweak a redundant expression in window_pane_set_mode.


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

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

ok deraadt pirofti


# 1.62 11-Mar-2021 nicm

Add split-window -Z to start the pane zoomed, GitHub issue 2591.


# 1.61 18-Jan-2021 nicm

Hide some warnings on newer GCC versions, GitHUb issue 2525.


Revision tags: OPENBSD_6_8_BASE
# 1.60 25-Aug-2020 nicm

Allow colour to be spelt as color, from Boris Verkhovsky. GitHub issue
2317.


# 1.59 16-Jun-2020 nicm

d and D keys to reset to default in customize mode.


# 1.58 16-May-2020 nicm

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


# 1.57 16-May-2020 nicm

Add a customize mode where keys and options may be browsed and changed,
includes adding a brief description of each option. Bound to "C" by
default.


# 1.56 16-May-2020 nicm

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

To make this work, a few other changes:

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

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

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


Revision tags: OPENBSD_6_7_BASE
# 1.55 03-Dec-2019 nicm

Style nits in function arguments.


# 1.54 15-Oct-2019 nicm

Rewrite options_array_set to be clearer and remove a spurious warning
with newer GCC. From Ben Boeckel.


# 1.53 14-Oct-2019 nicm

Memory leaks, from Igor Wong in GitHub issue 1934.


Revision tags: OPENBSD_6_6_BASE
# 1.52 23-Jun-2019 nicm

Do not always set scope for panes because the window check might fail,
GitHub issue 1810.


# 1.51 20-Jun-2019 nicm

FIx return of options_scope_from_name on error.


# 1.50 20-Jun-2019 nicm

Add a per-pane option set. Pane options inherit from window options (so
there should be no change to existing behaviour) and are set and shown
with set-option -p and show-options -p.

Change remain-on-exit and window-style/window-active-style to be pane
options (some others will be changed later).

This makes select-pane -P and -g unnecessary so no longer document them
(they still work) and no longer document set-window-option and
show-window-options in favour of set-option -w and show-options -w.


# 1.49 20-Jun-2019 nicm

Add a helper function to work out option table from name.


# 1.48 08-Jun-2019 nicm

Do not try to parse command when unsetting, GitHub issue 1788.


# 1.47 30-May-2019 nicm

Remove a leftover abort and some fixes from cppcheck.


# 1.46 23-May-2019 nicm

Break the argument escaping code into a separate function and use it to
escape key bindings in list-keys. Also escape ~ and ; and $ properly.


# 1.45 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.44 12-May-2019 nicm

Fix some indentation and dead assignments.


# 1.43 26-Apr-2019 nicm

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


# 1.42 25-Apr-2019 nicm

Make options_tostring allocate its result instead of using a stack
buffer (needed for something in the future).


# 1.41 23-Apr-2019 nicm

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


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

The individual -fg, -bg and -attr options have been deprecated (in
favour of -style), undocumented and hidden from show-options since
2014. Remove them, except for status-fg and status-bg.


# 1.39 18-Mar-2019 nicm

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


# 1.38 15-Mar-2019 nicm

Add a way to set individual defaults for an array option.


# 1.37 14-Mar-2019 nicm

Add a wrapper (struct style) around styles rather than using the
grid_cell directly. There will be some non-cell members soon.


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.36 09-Aug-2017 nicm

Fix filtering so it works after the change to only show windows if they
have multiple panes.


# 1.35 31-May-2017 nicm

Style and spacing nits.


# 1.34 22-Apr-2017 nicm

Memory leaks, from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.33 08-Mar-2017 nicm

Handle empty options correctly.


# 1.32 30-Jan-2017 nicm

When a flag option is used in a format, it should use the number form
not string.


# 1.31 24-Jan-2017 nicm

If given an array option without an index either show or set all items,
and support -a for array options. Allow the separator for set to be
specified in the options table (will be used for backwards compatibility
later).


# 1.30 18-Jan-2017 nicm

Do not reset idx, it has just been set.


# 1.29 18-Jan-2017 nicm

options_match needs to explicitly check for user options.


# 1.28 16-Jan-2017 nicm

Correctly handle -style options without all of a corresponding -fg/-bg/-attr.


# 1.27 16-Jan-2017 nicm

getopt() has a struct option so just return to using options_entry.


# 1.26 15-Jan-2017 nicm

Major tidy up and rework of options tree and set-option/show-options
commands this pushes more of the code into options.c and ties it more
closely to the options table rather than having an unnecessary
split. Also add support for array options (will be used later). Only
(intentional) user visible change is that show-options output is now
passed through vis(3) with VIS_DQ so quotes are escaped.


# 1.25 15-Jan-2017 nicm

Append needs to go old,new not new,old...


# 1.24 13-Jan-2017 nicm

options_get_style return const too.


# 1.23 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.22 12-Jan-2017 nicm

Simplify appending to string options.


# 1.21 11-Jan-2017 nicm

Some tidying and tweaks to options code.


# 1.20 10-Oct-2016 nicm

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


# 1.19 26-Sep-2016 nicm

Support set -a (append) with user options, suggested by Xandor Schiefer.


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

I no longer use my SourceForge address so replace it.


# 1.17 11-Dec-2015 nicm

We cannot do hooks_find and then hooks_remove because it might have come
from the parent (global) tree, instead make it remove by name like options.

While here, also tidy up a few bits of options and hooks handling (use
RB_FOREACH_SAFE, and a helper function for the free).


# 1.16 08-Dec-2015 nicm

Spacing nits.


# 1.15 18-Nov-2015 nicm

Sync the entire xmalloc.[ch] with the other users, but with the addition
of xrealloc, xvasprintf, xvsnprintf.


# 1.14 13-Nov-2015 nicm

Log option names in fatal() for missing option.


# 1.13 27-Oct-2015 nicm

Move struct options into options.c.


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.12 18-Feb-2015 nicm

When given an invalid style, don't set the option to the default. Fix
from J Raynor. Also make style_parse not alter the grid_cell when it
fails.


# 1.11 20-Oct-2014 nicm

Better format for printf format attributes.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.10 28-Jan-2014 nicm

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

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

Becomes:

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

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

set -g status-bg red

Becomes:

set -ag status-style bg=red

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

From Tiago Cunha.


# 1.9 09-Jan-2014 nicm

Style and comment fixes from Tiago Cunha.


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.8 10-Jul-2012 nicm

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


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

Use RB trees not SPLAY.


# 1.6 21-Jan-2012 nicm

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

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

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


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.5 22-Sep-2009 nicm

Permit multiple prefix keys to be defined, separated by commas, for example:

set -g prefix ^a,^b

Any key in the list acts as the prefix. The send-prefix command always sends
the first key in the list.


# 1.4 21-Sep-2009 nicm

Use option print function for info messages as well.


# 1.3 21-Sep-2009 nicm

Drop tiny union from option struct.


# 1.2 21-Jul-2009 nicm

Make some functions which return unused values void (mostly found by lint) and
tweak a redundant expression in window_pane_set_mode.


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

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

ok deraadt pirofti


# 1.61 18-Jan-2021 nicm

Hide some warnings on newer GCC versions, GitHUb issue 2525.


Revision tags: OPENBSD_6_8_BASE
# 1.60 25-Aug-2020 nicm

Allow colour to be spelt as color, from Boris Verkhovsky. GitHub issue
2317.


# 1.59 16-Jun-2020 nicm

d and D keys to reset to default in customize mode.


# 1.58 16-May-2020 nicm

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


# 1.57 16-May-2020 nicm

Add a customize mode where keys and options may be browsed and changed,
includes adding a brief description of each option. Bound to "C" by
default.


# 1.56 16-May-2020 nicm

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

To make this work, a few other changes:

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

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

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


Revision tags: OPENBSD_6_7_BASE
# 1.55 03-Dec-2019 nicm

Style nits in function arguments.


# 1.54 15-Oct-2019 nicm

Rewrite options_array_set to be clearer and remove a spurious warning
with newer GCC. From Ben Boeckel.


# 1.53 14-Oct-2019 nicm

Memory leaks, from Igor Wong in GitHub issue 1934.


Revision tags: OPENBSD_6_6_BASE
# 1.52 23-Jun-2019 nicm

Do not always set scope for panes because the window check might fail,
GitHub issue 1810.


# 1.51 20-Jun-2019 nicm

FIx return of options_scope_from_name on error.


# 1.50 20-Jun-2019 nicm

Add a per-pane option set. Pane options inherit from window options (so
there should be no change to existing behaviour) and are set and shown
with set-option -p and show-options -p.

Change remain-on-exit and window-style/window-active-style to be pane
options (some others will be changed later).

This makes select-pane -P and -g unnecessary so no longer document them
(they still work) and no longer document set-window-option and
show-window-options in favour of set-option -w and show-options -w.


# 1.49 20-Jun-2019 nicm

Add a helper function to work out option table from name.


# 1.48 08-Jun-2019 nicm

Do not try to parse command when unsetting, GitHub issue 1788.


# 1.47 30-May-2019 nicm

Remove a leftover abort and some fixes from cppcheck.


# 1.46 23-May-2019 nicm

Break the argument escaping code into a separate function and use it to
escape key bindings in list-keys. Also escape ~ and ; and $ properly.


# 1.45 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.44 12-May-2019 nicm

Fix some indentation and dead assignments.


# 1.43 26-Apr-2019 nicm

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


# 1.42 25-Apr-2019 nicm

Make options_tostring allocate its result instead of using a stack
buffer (needed for something in the future).


# 1.41 23-Apr-2019 nicm

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


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

The individual -fg, -bg and -attr options have been deprecated (in
favour of -style), undocumented and hidden from show-options since
2014. Remove them, except for status-fg and status-bg.


# 1.39 18-Mar-2019 nicm

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


# 1.38 15-Mar-2019 nicm

Add a way to set individual defaults for an array option.


# 1.37 14-Mar-2019 nicm

Add a wrapper (struct style) around styles rather than using the
grid_cell directly. There will be some non-cell members soon.


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.36 09-Aug-2017 nicm

Fix filtering so it works after the change to only show windows if they
have multiple panes.


# 1.35 31-May-2017 nicm

Style and spacing nits.


# 1.34 22-Apr-2017 nicm

Memory leaks, from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.33 08-Mar-2017 nicm

Handle empty options correctly.


# 1.32 30-Jan-2017 nicm

When a flag option is used in a format, it should use the number form
not string.


# 1.31 24-Jan-2017 nicm

If given an array option without an index either show or set all items,
and support -a for array options. Allow the separator for set to be
specified in the options table (will be used for backwards compatibility
later).


# 1.30 18-Jan-2017 nicm

Do not reset idx, it has just been set.


# 1.29 18-Jan-2017 nicm

options_match needs to explicitly check for user options.


# 1.28 16-Jan-2017 nicm

Correctly handle -style options without all of a corresponding -fg/-bg/-attr.


# 1.27 16-Jan-2017 nicm

getopt() has a struct option so just return to using options_entry.


# 1.26 15-Jan-2017 nicm

Major tidy up and rework of options tree and set-option/show-options
commands this pushes more of the code into options.c and ties it more
closely to the options table rather than having an unnecessary
split. Also add support for array options (will be used later). Only
(intentional) user visible change is that show-options output is now
passed through vis(3) with VIS_DQ so quotes are escaped.


# 1.25 15-Jan-2017 nicm

Append needs to go old,new not new,old...


# 1.24 13-Jan-2017 nicm

options_get_style return const too.


# 1.23 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.22 12-Jan-2017 nicm

Simplify appending to string options.


# 1.21 11-Jan-2017 nicm

Some tidying and tweaks to options code.


# 1.20 10-Oct-2016 nicm

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


# 1.19 26-Sep-2016 nicm

Support set -a (append) with user options, suggested by Xandor Schiefer.


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

I no longer use my SourceForge address so replace it.


# 1.17 11-Dec-2015 nicm

We cannot do hooks_find and then hooks_remove because it might have come
from the parent (global) tree, instead make it remove by name like options.

While here, also tidy up a few bits of options and hooks handling (use
RB_FOREACH_SAFE, and a helper function for the free).


# 1.16 08-Dec-2015 nicm

Spacing nits.


# 1.15 18-Nov-2015 nicm

Sync the entire xmalloc.[ch] with the other users, but with the addition
of xrealloc, xvasprintf, xvsnprintf.


# 1.14 13-Nov-2015 nicm

Log option names in fatal() for missing option.


# 1.13 27-Oct-2015 nicm

Move struct options into options.c.


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.12 18-Feb-2015 nicm

When given an invalid style, don't set the option to the default. Fix
from J Raynor. Also make style_parse not alter the grid_cell when it
fails.


# 1.11 20-Oct-2014 nicm

Better format for printf format attributes.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.10 28-Jan-2014 nicm

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

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

Becomes:

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

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

set -g status-bg red

Becomes:

set -ag status-style bg=red

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

From Tiago Cunha.


# 1.9 09-Jan-2014 nicm

Style and comment fixes from Tiago Cunha.


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.8 10-Jul-2012 nicm

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


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

Use RB trees not SPLAY.


# 1.6 21-Jan-2012 nicm

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

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

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


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.5 22-Sep-2009 nicm

Permit multiple prefix keys to be defined, separated by commas, for example:

set -g prefix ^a,^b

Any key in the list acts as the prefix. The send-prefix command always sends
the first key in the list.


# 1.4 21-Sep-2009 nicm

Use option print function for info messages as well.


# 1.3 21-Sep-2009 nicm

Drop tiny union from option struct.


# 1.2 21-Jul-2009 nicm

Make some functions which return unused values void (mostly found by lint) and
tweak a redundant expression in window_pane_set_mode.


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

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

ok deraadt pirofti


# 1.60 25-Aug-2020 nicm

Allow colour to be spelt as color, from Boris Verkhovsky. GitHub issue
2317.


# 1.59 16-Jun-2020 nicm

d and D keys to reset to default in customize mode.


# 1.58 16-May-2020 nicm

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


# 1.57 16-May-2020 nicm

Add a customize mode where keys and options may be browsed and changed,
includes adding a brief description of each option. Bound to "C" by
default.


# 1.56 16-May-2020 nicm

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

To make this work, a few other changes:

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

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

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


Revision tags: OPENBSD_6_7_BASE
# 1.55 03-Dec-2019 nicm

Style nits in function arguments.


# 1.54 15-Oct-2019 nicm

Rewrite options_array_set to be clearer and remove a spurious warning
with newer GCC. From Ben Boeckel.


# 1.53 14-Oct-2019 nicm

Memory leaks, from Igor Wong in GitHub issue 1934.


Revision tags: OPENBSD_6_6_BASE
# 1.52 23-Jun-2019 nicm

Do not always set scope for panes because the window check might fail,
GitHub issue 1810.


# 1.51 20-Jun-2019 nicm

FIx return of options_scope_from_name on error.


# 1.50 20-Jun-2019 nicm

Add a per-pane option set. Pane options inherit from window options (so
there should be no change to existing behaviour) and are set and shown
with set-option -p and show-options -p.

Change remain-on-exit and window-style/window-active-style to be pane
options (some others will be changed later).

This makes select-pane -P and -g unnecessary so no longer document them
(they still work) and no longer document set-window-option and
show-window-options in favour of set-option -w and show-options -w.


# 1.49 20-Jun-2019 nicm

Add a helper function to work out option table from name.


# 1.48 08-Jun-2019 nicm

Do not try to parse command when unsetting, GitHub issue 1788.


# 1.47 30-May-2019 nicm

Remove a leftover abort and some fixes from cppcheck.


# 1.46 23-May-2019 nicm

Break the argument escaping code into a separate function and use it to
escape key bindings in list-keys. Also escape ~ and ; and $ properly.


# 1.45 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.44 12-May-2019 nicm

Fix some indentation and dead assignments.


# 1.43 26-Apr-2019 nicm

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


# 1.42 25-Apr-2019 nicm

Make options_tostring allocate its result instead of using a stack
buffer (needed for something in the future).


# 1.41 23-Apr-2019 nicm

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


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

The individual -fg, -bg and -attr options have been deprecated (in
favour of -style), undocumented and hidden from show-options since
2014. Remove them, except for status-fg and status-bg.


# 1.39 18-Mar-2019 nicm

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


# 1.38 15-Mar-2019 nicm

Add a way to set individual defaults for an array option.


# 1.37 14-Mar-2019 nicm

Add a wrapper (struct style) around styles rather than using the
grid_cell directly. There will be some non-cell members soon.


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.36 09-Aug-2017 nicm

Fix filtering so it works after the change to only show windows if they
have multiple panes.


# 1.35 31-May-2017 nicm

Style and spacing nits.


# 1.34 22-Apr-2017 nicm

Memory leaks, from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.33 08-Mar-2017 nicm

Handle empty options correctly.


# 1.32 30-Jan-2017 nicm

When a flag option is used in a format, it should use the number form
not string.


# 1.31 24-Jan-2017 nicm

If given an array option without an index either show or set all items,
and support -a for array options. Allow the separator for set to be
specified in the options table (will be used for backwards compatibility
later).


# 1.30 18-Jan-2017 nicm

Do not reset idx, it has just been set.


# 1.29 18-Jan-2017 nicm

options_match needs to explicitly check for user options.


# 1.28 16-Jan-2017 nicm

Correctly handle -style options without all of a corresponding -fg/-bg/-attr.


# 1.27 16-Jan-2017 nicm

getopt() has a struct option so just return to using options_entry.


# 1.26 15-Jan-2017 nicm

Major tidy up and rework of options tree and set-option/show-options
commands this pushes more of the code into options.c and ties it more
closely to the options table rather than having an unnecessary
split. Also add support for array options (will be used later). Only
(intentional) user visible change is that show-options output is now
passed through vis(3) with VIS_DQ so quotes are escaped.


# 1.25 15-Jan-2017 nicm

Append needs to go old,new not new,old...


# 1.24 13-Jan-2017 nicm

options_get_style return const too.


# 1.23 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.22 12-Jan-2017 nicm

Simplify appending to string options.


# 1.21 11-Jan-2017 nicm

Some tidying and tweaks to options code.


# 1.20 10-Oct-2016 nicm

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


# 1.19 26-Sep-2016 nicm

Support set -a (append) with user options, suggested by Xandor Schiefer.


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

I no longer use my SourceForge address so replace it.


# 1.17 11-Dec-2015 nicm

We cannot do hooks_find and then hooks_remove because it might have come
from the parent (global) tree, instead make it remove by name like options.

While here, also tidy up a few bits of options and hooks handling (use
RB_FOREACH_SAFE, and a helper function for the free).


# 1.16 08-Dec-2015 nicm

Spacing nits.


# 1.15 18-Nov-2015 nicm

Sync the entire xmalloc.[ch] with the other users, but with the addition
of xrealloc, xvasprintf, xvsnprintf.


# 1.14 13-Nov-2015 nicm

Log option names in fatal() for missing option.


# 1.13 27-Oct-2015 nicm

Move struct options into options.c.


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.12 18-Feb-2015 nicm

When given an invalid style, don't set the option to the default. Fix
from J Raynor. Also make style_parse not alter the grid_cell when it
fails.


# 1.11 20-Oct-2014 nicm

Better format for printf format attributes.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.10 28-Jan-2014 nicm

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

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

Becomes:

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

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

set -g status-bg red

Becomes:

set -ag status-style bg=red

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

From Tiago Cunha.


# 1.9 09-Jan-2014 nicm

Style and comment fixes from Tiago Cunha.


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.8 10-Jul-2012 nicm

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


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

Use RB trees not SPLAY.


# 1.6 21-Jan-2012 nicm

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

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

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


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.5 22-Sep-2009 nicm

Permit multiple prefix keys to be defined, separated by commas, for example:

set -g prefix ^a,^b

Any key in the list acts as the prefix. The send-prefix command always sends
the first key in the list.


# 1.4 21-Sep-2009 nicm

Use option print function for info messages as well.


# 1.3 21-Sep-2009 nicm

Drop tiny union from option struct.


# 1.2 21-Jul-2009 nicm

Make some functions which return unused values void (mostly found by lint) and
tweak a redundant expression in window_pane_set_mode.


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

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

ok deraadt pirofti


# 1.59 16-Jun-2020 nicm

d and D keys to reset to default in customize mode.


# 1.58 16-May-2020 nicm

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


# 1.57 16-May-2020 nicm

Add a customize mode where keys and options may be browsed and changed,
includes adding a brief description of each option. Bound to "C" by
default.


# 1.56 16-May-2020 nicm

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

To make this work, a few other changes:

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

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

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


Revision tags: OPENBSD_6_7_BASE
# 1.55 03-Dec-2019 nicm

Style nits in function arguments.


# 1.54 15-Oct-2019 nicm

Rewrite options_array_set to be clearer and remove a spurious warning
with newer GCC. From Ben Boeckel.


# 1.53 14-Oct-2019 nicm

Memory leaks, from Igor Wong in GitHub issue 1934.


Revision tags: OPENBSD_6_6_BASE
# 1.52 23-Jun-2019 nicm

Do not always set scope for panes because the window check might fail,
GitHub issue 1810.


# 1.51 20-Jun-2019 nicm

FIx return of options_scope_from_name on error.


# 1.50 20-Jun-2019 nicm

Add a per-pane option set. Pane options inherit from window options (so
there should be no change to existing behaviour) and are set and shown
with set-option -p and show-options -p.

Change remain-on-exit and window-style/window-active-style to be pane
options (some others will be changed later).

This makes select-pane -P and -g unnecessary so no longer document them
(they still work) and no longer document set-window-option and
show-window-options in favour of set-option -w and show-options -w.


# 1.49 20-Jun-2019 nicm

Add a helper function to work out option table from name.


# 1.48 08-Jun-2019 nicm

Do not try to parse command when unsetting, GitHub issue 1788.


# 1.47 30-May-2019 nicm

Remove a leftover abort and some fixes from cppcheck.


# 1.46 23-May-2019 nicm

Break the argument escaping code into a separate function and use it to
escape key bindings in list-keys. Also escape ~ and ; and $ properly.


# 1.45 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.44 12-May-2019 nicm

Fix some indentation and dead assignments.


# 1.43 26-Apr-2019 nicm

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


# 1.42 25-Apr-2019 nicm

Make options_tostring allocate its result instead of using a stack
buffer (needed for something in the future).


# 1.41 23-Apr-2019 nicm

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


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

The individual -fg, -bg and -attr options have been deprecated (in
favour of -style), undocumented and hidden from show-options since
2014. Remove them, except for status-fg and status-bg.


# 1.39 18-Mar-2019 nicm

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


# 1.38 15-Mar-2019 nicm

Add a way to set individual defaults for an array option.


# 1.37 14-Mar-2019 nicm

Add a wrapper (struct style) around styles rather than using the
grid_cell directly. There will be some non-cell members soon.


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.36 09-Aug-2017 nicm

Fix filtering so it works after the change to only show windows if they
have multiple panes.


# 1.35 31-May-2017 nicm

Style and spacing nits.


# 1.34 22-Apr-2017 nicm

Memory leaks, from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.33 08-Mar-2017 nicm

Handle empty options correctly.


# 1.32 30-Jan-2017 nicm

When a flag option is used in a format, it should use the number form
not string.


# 1.31 24-Jan-2017 nicm

If given an array option without an index either show or set all items,
and support -a for array options. Allow the separator for set to be
specified in the options table (will be used for backwards compatibility
later).


# 1.30 18-Jan-2017 nicm

Do not reset idx, it has just been set.


# 1.29 18-Jan-2017 nicm

options_match needs to explicitly check for user options.


# 1.28 16-Jan-2017 nicm

Correctly handle -style options without all of a corresponding -fg/-bg/-attr.


# 1.27 16-Jan-2017 nicm

getopt() has a struct option so just return to using options_entry.


# 1.26 15-Jan-2017 nicm

Major tidy up and rework of options tree and set-option/show-options
commands this pushes more of the code into options.c and ties it more
closely to the options table rather than having an unnecessary
split. Also add support for array options (will be used later). Only
(intentional) user visible change is that show-options output is now
passed through vis(3) with VIS_DQ so quotes are escaped.


# 1.25 15-Jan-2017 nicm

Append needs to go old,new not new,old...


# 1.24 13-Jan-2017 nicm

options_get_style return const too.


# 1.23 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.22 12-Jan-2017 nicm

Simplify appending to string options.


# 1.21 11-Jan-2017 nicm

Some tidying and tweaks to options code.


# 1.20 10-Oct-2016 nicm

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


# 1.19 26-Sep-2016 nicm

Support set -a (append) with user options, suggested by Xandor Schiefer.


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

I no longer use my SourceForge address so replace it.


# 1.17 11-Dec-2015 nicm

We cannot do hooks_find and then hooks_remove because it might have come
from the parent (global) tree, instead make it remove by name like options.

While here, also tidy up a few bits of options and hooks handling (use
RB_FOREACH_SAFE, and a helper function for the free).


# 1.16 08-Dec-2015 nicm

Spacing nits.


# 1.15 18-Nov-2015 nicm

Sync the entire xmalloc.[ch] with the other users, but with the addition
of xrealloc, xvasprintf, xvsnprintf.


# 1.14 13-Nov-2015 nicm

Log option names in fatal() for missing option.


# 1.13 27-Oct-2015 nicm

Move struct options into options.c.


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.12 18-Feb-2015 nicm

When given an invalid style, don't set the option to the default. Fix
from J Raynor. Also make style_parse not alter the grid_cell when it
fails.


# 1.11 20-Oct-2014 nicm

Better format for printf format attributes.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.10 28-Jan-2014 nicm

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

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

Becomes:

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

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

set -g status-bg red

Becomes:

set -ag status-style bg=red

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

From Tiago Cunha.


# 1.9 09-Jan-2014 nicm

Style and comment fixes from Tiago Cunha.


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.8 10-Jul-2012 nicm

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


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

Use RB trees not SPLAY.


# 1.6 21-Jan-2012 nicm

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

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

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


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.5 22-Sep-2009 nicm

Permit multiple prefix keys to be defined, separated by commas, for example:

set -g prefix ^a,^b

Any key in the list acts as the prefix. The send-prefix command always sends
the first key in the list.


# 1.4 21-Sep-2009 nicm

Use option print function for info messages as well.


# 1.3 21-Sep-2009 nicm

Drop tiny union from option struct.


# 1.2 21-Jul-2009 nicm

Make some functions which return unused values void (mostly found by lint) and
tweak a redundant expression in window_pane_set_mode.


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

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

ok deraadt pirofti


# 1.58 16-May-2020 nicm

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


# 1.57 16-May-2020 nicm

Add a customize mode where keys and options may be browsed and changed,
includes adding a brief description of each option. Bound to "C" by
default.


# 1.56 16-May-2020 nicm

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

To make this work, a few other changes:

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

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

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


Revision tags: OPENBSD_6_7_BASE
# 1.55 03-Dec-2019 nicm

Style nits in function arguments.


# 1.54 15-Oct-2019 nicm

Rewrite options_array_set to be clearer and remove a spurious warning
with newer GCC. From Ben Boeckel.


# 1.53 14-Oct-2019 nicm

Memory leaks, from Igor Wong in GitHub issue 1934.


Revision tags: OPENBSD_6_6_BASE
# 1.52 23-Jun-2019 nicm

Do not always set scope for panes because the window check might fail,
GitHub issue 1810.


# 1.51 20-Jun-2019 nicm

FIx return of options_scope_from_name on error.


# 1.50 20-Jun-2019 nicm

Add a per-pane option set. Pane options inherit from window options (so
there should be no change to existing behaviour) and are set and shown
with set-option -p and show-options -p.

Change remain-on-exit and window-style/window-active-style to be pane
options (some others will be changed later).

This makes select-pane -P and -g unnecessary so no longer document them
(they still work) and no longer document set-window-option and
show-window-options in favour of set-option -w and show-options -w.


# 1.49 20-Jun-2019 nicm

Add a helper function to work out option table from name.


# 1.48 08-Jun-2019 nicm

Do not try to parse command when unsetting, GitHub issue 1788.


# 1.47 30-May-2019 nicm

Remove a leftover abort and some fixes from cppcheck.


# 1.46 23-May-2019 nicm

Break the argument escaping code into a separate function and use it to
escape key bindings in list-keys. Also escape ~ and ; and $ properly.


# 1.45 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.44 12-May-2019 nicm

Fix some indentation and dead assignments.


# 1.43 26-Apr-2019 nicm

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


# 1.42 25-Apr-2019 nicm

Make options_tostring allocate its result instead of using a stack
buffer (needed for something in the future).


# 1.41 23-Apr-2019 nicm

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


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

The individual -fg, -bg and -attr options have been deprecated (in
favour of -style), undocumented and hidden from show-options since
2014. Remove them, except for status-fg and status-bg.


# 1.39 18-Mar-2019 nicm

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


# 1.38 15-Mar-2019 nicm

Add a way to set individual defaults for an array option.


# 1.37 14-Mar-2019 nicm

Add a wrapper (struct style) around styles rather than using the
grid_cell directly. There will be some non-cell members soon.


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.36 09-Aug-2017 nicm

Fix filtering so it works after the change to only show windows if they
have multiple panes.


# 1.35 31-May-2017 nicm

Style and spacing nits.


# 1.34 22-Apr-2017 nicm

Memory leaks, from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.33 08-Mar-2017 nicm

Handle empty options correctly.


# 1.32 30-Jan-2017 nicm

When a flag option is used in a format, it should use the number form
not string.


# 1.31 24-Jan-2017 nicm

If given an array option without an index either show or set all items,
and support -a for array options. Allow the separator for set to be
specified in the options table (will be used for backwards compatibility
later).


# 1.30 18-Jan-2017 nicm

Do not reset idx, it has just been set.


# 1.29 18-Jan-2017 nicm

options_match needs to explicitly check for user options.


# 1.28 16-Jan-2017 nicm

Correctly handle -style options without all of a corresponding -fg/-bg/-attr.


# 1.27 16-Jan-2017 nicm

getopt() has a struct option so just return to using options_entry.


# 1.26 15-Jan-2017 nicm

Major tidy up and rework of options tree and set-option/show-options
commands this pushes more of the code into options.c and ties it more
closely to the options table rather than having an unnecessary
split. Also add support for array options (will be used later). Only
(intentional) user visible change is that show-options output is now
passed through vis(3) with VIS_DQ so quotes are escaped.


# 1.25 15-Jan-2017 nicm

Append needs to go old,new not new,old...


# 1.24 13-Jan-2017 nicm

options_get_style return const too.


# 1.23 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.22 12-Jan-2017 nicm

Simplify appending to string options.


# 1.21 11-Jan-2017 nicm

Some tidying and tweaks to options code.


# 1.20 10-Oct-2016 nicm

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


# 1.19 26-Sep-2016 nicm

Support set -a (append) with user options, suggested by Xandor Schiefer.


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

I no longer use my SourceForge address so replace it.


# 1.17 11-Dec-2015 nicm

We cannot do hooks_find and then hooks_remove because it might have come
from the parent (global) tree, instead make it remove by name like options.

While here, also tidy up a few bits of options and hooks handling (use
RB_FOREACH_SAFE, and a helper function for the free).


# 1.16 08-Dec-2015 nicm

Spacing nits.


# 1.15 18-Nov-2015 nicm

Sync the entire xmalloc.[ch] with the other users, but with the addition
of xrealloc, xvasprintf, xvsnprintf.


# 1.14 13-Nov-2015 nicm

Log option names in fatal() for missing option.


# 1.13 27-Oct-2015 nicm

Move struct options into options.c.


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.12 18-Feb-2015 nicm

When given an invalid style, don't set the option to the default. Fix
from J Raynor. Also make style_parse not alter the grid_cell when it
fails.


# 1.11 20-Oct-2014 nicm

Better format for printf format attributes.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.10 28-Jan-2014 nicm

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

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

Becomes:

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

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

set -g status-bg red

Becomes:

set -ag status-style bg=red

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

From Tiago Cunha.


# 1.9 09-Jan-2014 nicm

Style and comment fixes from Tiago Cunha.


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.8 10-Jul-2012 nicm

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


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

Use RB trees not SPLAY.


# 1.6 21-Jan-2012 nicm

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

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

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


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.5 22-Sep-2009 nicm

Permit multiple prefix keys to be defined, separated by commas, for example:

set -g prefix ^a,^b

Any key in the list acts as the prefix. The send-prefix command always sends
the first key in the list.


# 1.4 21-Sep-2009 nicm

Use option print function for info messages as well.


# 1.3 21-Sep-2009 nicm

Drop tiny union from option struct.


# 1.2 21-Jul-2009 nicm

Make some functions which return unused values void (mostly found by lint) and
tweak a redundant expression in window_pane_set_mode.


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

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

ok deraadt pirofti


# 1.55 03-Dec-2019 nicm

Style nits in function arguments.


# 1.54 15-Oct-2019 nicm

Rewrite options_array_set to be clearer and remove a spurious warning
with newer GCC. From Ben Boeckel.


# 1.53 14-Oct-2019 nicm

Memory leaks, from Igor Wong in GitHub issue 1934.


Revision tags: OPENBSD_6_6_BASE
# 1.52 23-Jun-2019 nicm

Do not always set scope for panes because the window check might fail,
GitHub issue 1810.


# 1.51 20-Jun-2019 nicm

FIx return of options_scope_from_name on error.


# 1.50 20-Jun-2019 nicm

Add a per-pane option set. Pane options inherit from window options (so
there should be no change to existing behaviour) and are set and shown
with set-option -p and show-options -p.

Change remain-on-exit and window-style/window-active-style to be pane
options (some others will be changed later).

This makes select-pane -P and -g unnecessary so no longer document them
(they still work) and no longer document set-window-option and
show-window-options in favour of set-option -w and show-options -w.


# 1.49 20-Jun-2019 nicm

Add a helper function to work out option table from name.


# 1.48 08-Jun-2019 nicm

Do not try to parse command when unsetting, GitHub issue 1788.


# 1.47 30-May-2019 nicm

Remove a leftover abort and some fixes from cppcheck.


# 1.46 23-May-2019 nicm

Break the argument escaping code into a separate function and use it to
escape key bindings in list-keys. Also escape ~ and ; and $ properly.


# 1.45 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.44 12-May-2019 nicm

Fix some indentation and dead assignments.


# 1.43 26-Apr-2019 nicm

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


# 1.42 25-Apr-2019 nicm

Make options_tostring allocate its result instead of using a stack
buffer (needed for something in the future).


# 1.41 23-Apr-2019 nicm

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


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

The individual -fg, -bg and -attr options have been deprecated (in
favour of -style), undocumented and hidden from show-options since
2014. Remove them, except for status-fg and status-bg.


# 1.39 18-Mar-2019 nicm

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


# 1.38 15-Mar-2019 nicm

Add a way to set individual defaults for an array option.


# 1.37 14-Mar-2019 nicm

Add a wrapper (struct style) around styles rather than using the
grid_cell directly. There will be some non-cell members soon.


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.36 09-Aug-2017 nicm

Fix filtering so it works after the change to only show windows if they
have multiple panes.


# 1.35 31-May-2017 nicm

Style and spacing nits.


# 1.34 22-Apr-2017 nicm

Memory leaks, from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.33 08-Mar-2017 nicm

Handle empty options correctly.


# 1.32 30-Jan-2017 nicm

When a flag option is used in a format, it should use the number form
not string.


# 1.31 24-Jan-2017 nicm

If given an array option without an index either show or set all items,
and support -a for array options. Allow the separator for set to be
specified in the options table (will be used for backwards compatibility
later).


# 1.30 18-Jan-2017 nicm

Do not reset idx, it has just been set.


# 1.29 18-Jan-2017 nicm

options_match needs to explicitly check for user options.


# 1.28 16-Jan-2017 nicm

Correctly handle -style options without all of a corresponding -fg/-bg/-attr.


# 1.27 16-Jan-2017 nicm

getopt() has a struct option so just return to using options_entry.


# 1.26 15-Jan-2017 nicm

Major tidy up and rework of options tree and set-option/show-options
commands this pushes more of the code into options.c and ties it more
closely to the options table rather than having an unnecessary
split. Also add support for array options (will be used later). Only
(intentional) user visible change is that show-options output is now
passed through vis(3) with VIS_DQ so quotes are escaped.


# 1.25 15-Jan-2017 nicm

Append needs to go old,new not new,old...


# 1.24 13-Jan-2017 nicm

options_get_style return const too.


# 1.23 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.22 12-Jan-2017 nicm

Simplify appending to string options.


# 1.21 11-Jan-2017 nicm

Some tidying and tweaks to options code.


# 1.20 10-Oct-2016 nicm

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


# 1.19 26-Sep-2016 nicm

Support set -a (append) with user options, suggested by Xandor Schiefer.


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

I no longer use my SourceForge address so replace it.


# 1.17 11-Dec-2015 nicm

We cannot do hooks_find and then hooks_remove because it might have come
from the parent (global) tree, instead make it remove by name like options.

While here, also tidy up a few bits of options and hooks handling (use
RB_FOREACH_SAFE, and a helper function for the free).


# 1.16 08-Dec-2015 nicm

Spacing nits.


# 1.15 18-Nov-2015 nicm

Sync the entire xmalloc.[ch] with the other users, but with the addition
of xrealloc, xvasprintf, xvsnprintf.


# 1.14 13-Nov-2015 nicm

Log option names in fatal() for missing option.


# 1.13 27-Oct-2015 nicm

Move struct options into options.c.


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.12 18-Feb-2015 nicm

When given an invalid style, don't set the option to the default. Fix
from J Raynor. Also make style_parse not alter the grid_cell when it
fails.


# 1.11 20-Oct-2014 nicm

Better format for printf format attributes.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.10 28-Jan-2014 nicm

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

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

Becomes:

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

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

set -g status-bg red

Becomes:

set -ag status-style bg=red

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

From Tiago Cunha.


# 1.9 09-Jan-2014 nicm

Style and comment fixes from Tiago Cunha.


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.8 10-Jul-2012 nicm

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


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

Use RB trees not SPLAY.


# 1.6 21-Jan-2012 nicm

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

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

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


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.5 22-Sep-2009 nicm

Permit multiple prefix keys to be defined, separated by commas, for example:

set -g prefix ^a,^b

Any key in the list acts as the prefix. The send-prefix command always sends
the first key in the list.


# 1.4 21-Sep-2009 nicm

Use option print function for info messages as well.


# 1.3 21-Sep-2009 nicm

Drop tiny union from option struct.


# 1.2 21-Jul-2009 nicm

Make some functions which return unused values void (mostly found by lint) and
tweak a redundant expression in window_pane_set_mode.


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

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

ok deraadt pirofti


# 1.54 15-Oct-2019 nicm

Rewrite options_array_set to be clearer and remove a spurious warning
with newer GCC. From Ben Boeckel.


# 1.53 14-Oct-2019 nicm

Memory leaks, from Igor Wong in GitHub issue 1934.


Revision tags: OPENBSD_6_6_BASE
# 1.52 23-Jun-2019 nicm

Do not always set scope for panes because the window check might fail,
GitHub issue 1810.


# 1.51 20-Jun-2019 nicm

FIx return of options_scope_from_name on error.


# 1.50 20-Jun-2019 nicm

Add a per-pane option set. Pane options inherit from window options (so
there should be no change to existing behaviour) and are set and shown
with set-option -p and show-options -p.

Change remain-on-exit and window-style/window-active-style to be pane
options (some others will be changed later).

This makes select-pane -P and -g unnecessary so no longer document them
(they still work) and no longer document set-window-option and
show-window-options in favour of set-option -w and show-options -w.


# 1.49 20-Jun-2019 nicm

Add a helper function to work out option table from name.


# 1.48 08-Jun-2019 nicm

Do not try to parse command when unsetting, GitHub issue 1788.


# 1.47 30-May-2019 nicm

Remove a leftover abort and some fixes from cppcheck.


# 1.46 23-May-2019 nicm

Break the argument escaping code into a separate function and use it to
escape key bindings in list-keys. Also escape ~ and ; and $ properly.


# 1.45 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.44 12-May-2019 nicm

Fix some indentation and dead assignments.


# 1.43 26-Apr-2019 nicm

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


# 1.42 25-Apr-2019 nicm

Make options_tostring allocate its result instead of using a stack
buffer (needed for something in the future).


# 1.41 23-Apr-2019 nicm

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


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

The individual -fg, -bg and -attr options have been deprecated (in
favour of -style), undocumented and hidden from show-options since
2014. Remove them, except for status-fg and status-bg.


# 1.39 18-Mar-2019 nicm

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


# 1.38 15-Mar-2019 nicm

Add a way to set individual defaults for an array option.


# 1.37 14-Mar-2019 nicm

Add a wrapper (struct style) around styles rather than using the
grid_cell directly. There will be some non-cell members soon.


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.36 09-Aug-2017 nicm

Fix filtering so it works after the change to only show windows if they
have multiple panes.


# 1.35 31-May-2017 nicm

Style and spacing nits.


# 1.34 22-Apr-2017 nicm

Memory leaks, from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.33 08-Mar-2017 nicm

Handle empty options correctly.


# 1.32 30-Jan-2017 nicm

When a flag option is used in a format, it should use the number form
not string.


# 1.31 24-Jan-2017 nicm

If given an array option without an index either show or set all items,
and support -a for array options. Allow the separator for set to be
specified in the options table (will be used for backwards compatibility
later).


# 1.30 18-Jan-2017 nicm

Do not reset idx, it has just been set.


# 1.29 18-Jan-2017 nicm

options_match needs to explicitly check for user options.


# 1.28 16-Jan-2017 nicm

Correctly handle -style options without all of a corresponding -fg/-bg/-attr.


# 1.27 16-Jan-2017 nicm

getopt() has a struct option so just return to using options_entry.


# 1.26 15-Jan-2017 nicm

Major tidy up and rework of options tree and set-option/show-options
commands this pushes more of the code into options.c and ties it more
closely to the options table rather than having an unnecessary
split. Also add support for array options (will be used later). Only
(intentional) user visible change is that show-options output is now
passed through vis(3) with VIS_DQ so quotes are escaped.


# 1.25 15-Jan-2017 nicm

Append needs to go old,new not new,old...


# 1.24 13-Jan-2017 nicm

options_get_style return const too.


# 1.23 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.22 12-Jan-2017 nicm

Simplify appending to string options.


# 1.21 11-Jan-2017 nicm

Some tidying and tweaks to options code.


# 1.20 10-Oct-2016 nicm

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


# 1.19 26-Sep-2016 nicm

Support set -a (append) with user options, suggested by Xandor Schiefer.


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

I no longer use my SourceForge address so replace it.


# 1.17 11-Dec-2015 nicm

We cannot do hooks_find and then hooks_remove because it might have come
from the parent (global) tree, instead make it remove by name like options.

While here, also tidy up a few bits of options and hooks handling (use
RB_FOREACH_SAFE, and a helper function for the free).


# 1.16 08-Dec-2015 nicm

Spacing nits.


# 1.15 18-Nov-2015 nicm

Sync the entire xmalloc.[ch] with the other users, but with the addition
of xrealloc, xvasprintf, xvsnprintf.


# 1.14 13-Nov-2015 nicm

Log option names in fatal() for missing option.


# 1.13 27-Oct-2015 nicm

Move struct options into options.c.


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.12 18-Feb-2015 nicm

When given an invalid style, don't set the option to the default. Fix
from J Raynor. Also make style_parse not alter the grid_cell when it
fails.


# 1.11 20-Oct-2014 nicm

Better format for printf format attributes.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.10 28-Jan-2014 nicm

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

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

Becomes:

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

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

set -g status-bg red

Becomes:

set -ag status-style bg=red

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

From Tiago Cunha.


# 1.9 09-Jan-2014 nicm

Style and comment fixes from Tiago Cunha.


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.8 10-Jul-2012 nicm

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


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

Use RB trees not SPLAY.


# 1.6 21-Jan-2012 nicm

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

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

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


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.5 22-Sep-2009 nicm

Permit multiple prefix keys to be defined, separated by commas, for example:

set -g prefix ^a,^b

Any key in the list acts as the prefix. The send-prefix command always sends
the first key in the list.


# 1.4 21-Sep-2009 nicm

Use option print function for info messages as well.


# 1.3 21-Sep-2009 nicm

Drop tiny union from option struct.


# 1.2 21-Jul-2009 nicm

Make some functions which return unused values void (mostly found by lint) and
tweak a redundant expression in window_pane_set_mode.


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

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

ok deraadt pirofti


# 1.53 14-Oct-2019 nicm

Memory leaks, from Igor Wong in GitHub issue 1934.


Revision tags: OPENBSD_6_6_BASE
# 1.52 23-Jun-2019 nicm

Do not always set scope for panes because the window check might fail,
GitHub issue 1810.


# 1.51 20-Jun-2019 nicm

FIx return of options_scope_from_name on error.


# 1.50 20-Jun-2019 nicm

Add a per-pane option set. Pane options inherit from window options (so
there should be no change to existing behaviour) and are set and shown
with set-option -p and show-options -p.

Change remain-on-exit and window-style/window-active-style to be pane
options (some others will be changed later).

This makes select-pane -P and -g unnecessary so no longer document them
(they still work) and no longer document set-window-option and
show-window-options in favour of set-option -w and show-options -w.


# 1.49 20-Jun-2019 nicm

Add a helper function to work out option table from name.


# 1.48 08-Jun-2019 nicm

Do not try to parse command when unsetting, GitHub issue 1788.


# 1.47 30-May-2019 nicm

Remove a leftover abort and some fixes from cppcheck.


# 1.46 23-May-2019 nicm

Break the argument escaping code into a separate function and use it to
escape key bindings in list-keys. Also escape ~ and ; and $ properly.


# 1.45 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.44 12-May-2019 nicm

Fix some indentation and dead assignments.


# 1.43 26-Apr-2019 nicm

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


# 1.42 25-Apr-2019 nicm

Make options_tostring allocate its result instead of using a stack
buffer (needed for something in the future).


# 1.41 23-Apr-2019 nicm

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


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

The individual -fg, -bg and -attr options have been deprecated (in
favour of -style), undocumented and hidden from show-options since
2014. Remove them, except for status-fg and status-bg.


# 1.39 18-Mar-2019 nicm

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


# 1.38 15-Mar-2019 nicm

Add a way to set individual defaults for an array option.


# 1.37 14-Mar-2019 nicm

Add a wrapper (struct style) around styles rather than using the
grid_cell directly. There will be some non-cell members soon.


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.36 09-Aug-2017 nicm

Fix filtering so it works after the change to only show windows if they
have multiple panes.


# 1.35 31-May-2017 nicm

Style and spacing nits.


# 1.34 22-Apr-2017 nicm

Memory leaks, from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.33 08-Mar-2017 nicm

Handle empty options correctly.


# 1.32 30-Jan-2017 nicm

When a flag option is used in a format, it should use the number form
not string.


# 1.31 24-Jan-2017 nicm

If given an array option without an index either show or set all items,
and support -a for array options. Allow the separator for set to be
specified in the options table (will be used for backwards compatibility
later).


# 1.30 18-Jan-2017 nicm

Do not reset idx, it has just been set.


# 1.29 18-Jan-2017 nicm

options_match needs to explicitly check for user options.


# 1.28 16-Jan-2017 nicm

Correctly handle -style options without all of a corresponding -fg/-bg/-attr.


# 1.27 16-Jan-2017 nicm

getopt() has a struct option so just return to using options_entry.


# 1.26 15-Jan-2017 nicm

Major tidy up and rework of options tree and set-option/show-options
commands this pushes more of the code into options.c and ties it more
closely to the options table rather than having an unnecessary
split. Also add support for array options (will be used later). Only
(intentional) user visible change is that show-options output is now
passed through vis(3) with VIS_DQ so quotes are escaped.


# 1.25 15-Jan-2017 nicm

Append needs to go old,new not new,old...


# 1.24 13-Jan-2017 nicm

options_get_style return const too.


# 1.23 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.22 12-Jan-2017 nicm

Simplify appending to string options.


# 1.21 11-Jan-2017 nicm

Some tidying and tweaks to options code.


# 1.20 10-Oct-2016 nicm

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


# 1.19 26-Sep-2016 nicm

Support set -a (append) with user options, suggested by Xandor Schiefer.


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

I no longer use my SourceForge address so replace it.


# 1.17 11-Dec-2015 nicm

We cannot do hooks_find and then hooks_remove because it might have come
from the parent (global) tree, instead make it remove by name like options.

While here, also tidy up a few bits of options and hooks handling (use
RB_FOREACH_SAFE, and a helper function for the free).


# 1.16 08-Dec-2015 nicm

Spacing nits.


# 1.15 18-Nov-2015 nicm

Sync the entire xmalloc.[ch] with the other users, but with the addition
of xrealloc, xvasprintf, xvsnprintf.


# 1.14 13-Nov-2015 nicm

Log option names in fatal() for missing option.


# 1.13 27-Oct-2015 nicm

Move struct options into options.c.


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.12 18-Feb-2015 nicm

When given an invalid style, don't set the option to the default. Fix
from J Raynor. Also make style_parse not alter the grid_cell when it
fails.


# 1.11 20-Oct-2014 nicm

Better format for printf format attributes.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.10 28-Jan-2014 nicm

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

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

Becomes:

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

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

set -g status-bg red

Becomes:

set -ag status-style bg=red

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

From Tiago Cunha.


# 1.9 09-Jan-2014 nicm

Style and comment fixes from Tiago Cunha.


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.8 10-Jul-2012 nicm

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


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

Use RB trees not SPLAY.


# 1.6 21-Jan-2012 nicm

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

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

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


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.5 22-Sep-2009 nicm

Permit multiple prefix keys to be defined, separated by commas, for example:

set -g prefix ^a,^b

Any key in the list acts as the prefix. The send-prefix command always sends
the first key in the list.


# 1.4 21-Sep-2009 nicm

Use option print function for info messages as well.


# 1.3 21-Sep-2009 nicm

Drop tiny union from option struct.


# 1.2 21-Jul-2009 nicm

Make some functions which return unused values void (mostly found by lint) and
tweak a redundant expression in window_pane_set_mode.


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

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

ok deraadt pirofti


# 1.52 23-Jun-2019 nicm

Do not always set scope for panes because the window check might fail,
GitHub issue 1810.


# 1.51 20-Jun-2019 nicm

FIx return of options_scope_from_name on error.


# 1.50 20-Jun-2019 nicm

Add a per-pane option set. Pane options inherit from window options (so
there should be no change to existing behaviour) and are set and shown
with set-option -p and show-options -p.

Change remain-on-exit and window-style/window-active-style to be pane
options (some others will be changed later).

This makes select-pane -P and -g unnecessary so no longer document them
(they still work) and no longer document set-window-option and
show-window-options in favour of set-option -w and show-options -w.


# 1.49 20-Jun-2019 nicm

Add a helper function to work out option table from name.


# 1.48 08-Jun-2019 nicm

Do not try to parse command when unsetting, GitHub issue 1788.


# 1.47 30-May-2019 nicm

Remove a leftover abort and some fixes from cppcheck.


# 1.46 23-May-2019 nicm

Break the argument escaping code into a separate function and use it to
escape key bindings in list-keys. Also escape ~ and ; and $ properly.


# 1.45 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.44 12-May-2019 nicm

Fix some indentation and dead assignments.


# 1.43 26-Apr-2019 nicm

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


# 1.42 25-Apr-2019 nicm

Make options_tostring allocate its result instead of using a stack
buffer (needed for something in the future).


# 1.41 23-Apr-2019 nicm

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


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

The individual -fg, -bg and -attr options have been deprecated (in
favour of -style), undocumented and hidden from show-options since
2014. Remove them, except for status-fg and status-bg.


# 1.39 18-Mar-2019 nicm

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


# 1.38 15-Mar-2019 nicm

Add a way to set individual defaults for an array option.


# 1.37 14-Mar-2019 nicm

Add a wrapper (struct style) around styles rather than using the
grid_cell directly. There will be some non-cell members soon.


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.36 09-Aug-2017 nicm

Fix filtering so it works after the change to only show windows if they
have multiple panes.


# 1.35 31-May-2017 nicm

Style and spacing nits.


# 1.34 22-Apr-2017 nicm

Memory leaks, from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.33 08-Mar-2017 nicm

Handle empty options correctly.


# 1.32 30-Jan-2017 nicm

When a flag option is used in a format, it should use the number form
not string.


# 1.31 24-Jan-2017 nicm

If given an array option without an index either show or set all items,
and support -a for array options. Allow the separator for set to be
specified in the options table (will be used for backwards compatibility
later).


# 1.30 18-Jan-2017 nicm

Do not reset idx, it has just been set.


# 1.29 18-Jan-2017 nicm

options_match needs to explicitly check for user options.


# 1.28 16-Jan-2017 nicm

Correctly handle -style options without all of a corresponding -fg/-bg/-attr.


# 1.27 16-Jan-2017 nicm

getopt() has a struct option so just return to using options_entry.


# 1.26 15-Jan-2017 nicm

Major tidy up and rework of options tree and set-option/show-options
commands this pushes more of the code into options.c and ties it more
closely to the options table rather than having an unnecessary
split. Also add support for array options (will be used later). Only
(intentional) user visible change is that show-options output is now
passed through vis(3) with VIS_DQ so quotes are escaped.


# 1.25 15-Jan-2017 nicm

Append needs to go old,new not new,old...


# 1.24 13-Jan-2017 nicm

options_get_style return const too.


# 1.23 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.22 12-Jan-2017 nicm

Simplify appending to string options.


# 1.21 11-Jan-2017 nicm

Some tidying and tweaks to options code.


# 1.20 10-Oct-2016 nicm

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


# 1.19 26-Sep-2016 nicm

Support set -a (append) with user options, suggested by Xandor Schiefer.


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

I no longer use my SourceForge address so replace it.


# 1.17 11-Dec-2015 nicm

We cannot do hooks_find and then hooks_remove because it might have come
from the parent (global) tree, instead make it remove by name like options.

While here, also tidy up a few bits of options and hooks handling (use
RB_FOREACH_SAFE, and a helper function for the free).


# 1.16 08-Dec-2015 nicm

Spacing nits.


# 1.15 18-Nov-2015 nicm

Sync the entire xmalloc.[ch] with the other users, but with the addition
of xrealloc, xvasprintf, xvsnprintf.


# 1.14 13-Nov-2015 nicm

Log option names in fatal() for missing option.


# 1.13 27-Oct-2015 nicm

Move struct options into options.c.


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.12 18-Feb-2015 nicm

When given an invalid style, don't set the option to the default. Fix
from J Raynor. Also make style_parse not alter the grid_cell when it
fails.


# 1.11 20-Oct-2014 nicm

Better format for printf format attributes.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.10 28-Jan-2014 nicm

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

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

Becomes:

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

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

set -g status-bg red

Becomes:

set -ag status-style bg=red

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

From Tiago Cunha.


# 1.9 09-Jan-2014 nicm

Style and comment fixes from Tiago Cunha.


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.8 10-Jul-2012 nicm

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


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

Use RB trees not SPLAY.


# 1.6 21-Jan-2012 nicm

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

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

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


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.5 22-Sep-2009 nicm

Permit multiple prefix keys to be defined, separated by commas, for example:

set -g prefix ^a,^b

Any key in the list acts as the prefix. The send-prefix command always sends
the first key in the list.


# 1.4 21-Sep-2009 nicm

Use option print function for info messages as well.


# 1.3 21-Sep-2009 nicm

Drop tiny union from option struct.


# 1.2 21-Jul-2009 nicm

Make some functions which return unused values void (mostly found by lint) and
tweak a redundant expression in window_pane_set_mode.


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

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

ok deraadt pirofti


# 1.51 20-Jun-2019 nicm

FIx return of options_scope_from_name on error.


# 1.50 20-Jun-2019 nicm

Add a per-pane option set. Pane options inherit from window options (so
there should be no change to existing behaviour) and are set and shown
with set-option -p and show-options -p.

Change remain-on-exit and window-style/window-active-style to be pane
options (some others will be changed later).

This makes select-pane -P and -g unnecessary so no longer document them
(they still work) and no longer document set-window-option and
show-window-options in favour of set-option -w and show-options -w.


# 1.49 20-Jun-2019 nicm

Add a helper function to work out option table from name.


# 1.48 08-Jun-2019 nicm

Do not try to parse command when unsetting, GitHub issue 1788.


# 1.47 30-May-2019 nicm

Remove a leftover abort and some fixes from cppcheck.


# 1.46 23-May-2019 nicm

Break the argument escaping code into a separate function and use it to
escape key bindings in list-keys. Also escape ~ and ; and $ properly.


# 1.45 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.44 12-May-2019 nicm

Fix some indentation and dead assignments.


# 1.43 26-Apr-2019 nicm

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


# 1.42 25-Apr-2019 nicm

Make options_tostring allocate its result instead of using a stack
buffer (needed for something in the future).


# 1.41 23-Apr-2019 nicm

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


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

The individual -fg, -bg and -attr options have been deprecated (in
favour of -style), undocumented and hidden from show-options since
2014. Remove them, except for status-fg and status-bg.


# 1.39 18-Mar-2019 nicm

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


# 1.38 15-Mar-2019 nicm

Add a way to set individual defaults for an array option.


# 1.37 14-Mar-2019 nicm

Add a wrapper (struct style) around styles rather than using the
grid_cell directly. There will be some non-cell members soon.


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.36 09-Aug-2017 nicm

Fix filtering so it works after the change to only show windows if they
have multiple panes.


# 1.35 31-May-2017 nicm

Style and spacing nits.


# 1.34 22-Apr-2017 nicm

Memory leaks, from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.33 08-Mar-2017 nicm

Handle empty options correctly.


# 1.32 30-Jan-2017 nicm

When a flag option is used in a format, it should use the number form
not string.


# 1.31 24-Jan-2017 nicm

If given an array option without an index either show or set all items,
and support -a for array options. Allow the separator for set to be
specified in the options table (will be used for backwards compatibility
later).


# 1.30 18-Jan-2017 nicm

Do not reset idx, it has just been set.


# 1.29 18-Jan-2017 nicm

options_match needs to explicitly check for user options.


# 1.28 16-Jan-2017 nicm

Correctly handle -style options without all of a corresponding -fg/-bg/-attr.


# 1.27 16-Jan-2017 nicm

getopt() has a struct option so just return to using options_entry.


# 1.26 15-Jan-2017 nicm

Major tidy up and rework of options tree and set-option/show-options
commands this pushes more of the code into options.c and ties it more
closely to the options table rather than having an unnecessary
split. Also add support for array options (will be used later). Only
(intentional) user visible change is that show-options output is now
passed through vis(3) with VIS_DQ so quotes are escaped.


# 1.25 15-Jan-2017 nicm

Append needs to go old,new not new,old...


# 1.24 13-Jan-2017 nicm

options_get_style return const too.


# 1.23 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.22 12-Jan-2017 nicm

Simplify appending to string options.


# 1.21 11-Jan-2017 nicm

Some tidying and tweaks to options code.


# 1.20 10-Oct-2016 nicm

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


# 1.19 26-Sep-2016 nicm

Support set -a (append) with user options, suggested by Xandor Schiefer.


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

I no longer use my SourceForge address so replace it.


# 1.17 11-Dec-2015 nicm

We cannot do hooks_find and then hooks_remove because it might have come
from the parent (global) tree, instead make it remove by name like options.

While here, also tidy up a few bits of options and hooks handling (use
RB_FOREACH_SAFE, and a helper function for the free).


# 1.16 08-Dec-2015 nicm

Spacing nits.


# 1.15 18-Nov-2015 nicm

Sync the entire xmalloc.[ch] with the other users, but with the addition
of xrealloc, xvasprintf, xvsnprintf.


# 1.14 13-Nov-2015 nicm

Log option names in fatal() for missing option.


# 1.13 27-Oct-2015 nicm

Move struct options into options.c.


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.12 18-Feb-2015 nicm

When given an invalid style, don't set the option to the default. Fix
from J Raynor. Also make style_parse not alter the grid_cell when it
fails.


# 1.11 20-Oct-2014 nicm

Better format for printf format attributes.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.10 28-Jan-2014 nicm

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

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

Becomes:

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

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

set -g status-bg red

Becomes:

set -ag status-style bg=red

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

From Tiago Cunha.


# 1.9 09-Jan-2014 nicm

Style and comment fixes from Tiago Cunha.


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.8 10-Jul-2012 nicm

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


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

Use RB trees not SPLAY.


# 1.6 21-Jan-2012 nicm

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

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

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


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.5 22-Sep-2009 nicm

Permit multiple prefix keys to be defined, separated by commas, for example:

set -g prefix ^a,^b

Any key in the list acts as the prefix. The send-prefix command always sends
the first key in the list.


# 1.4 21-Sep-2009 nicm

Use option print function for info messages as well.


# 1.3 21-Sep-2009 nicm

Drop tiny union from option struct.


# 1.2 21-Jul-2009 nicm

Make some functions which return unused values void (mostly found by lint) and
tweak a redundant expression in window_pane_set_mode.


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

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

ok deraadt pirofti


# 1.49 20-Jun-2019 nicm

Add a helper function to work out option table from name.


# 1.48 08-Jun-2019 nicm

Do not try to parse command when unsetting, GitHub issue 1788.


# 1.47 30-May-2019 nicm

Remove a leftover abort and some fixes from cppcheck.


# 1.46 23-May-2019 nicm

Break the argument escaping code into a separate function and use it to
escape key bindings in list-keys. Also escape ~ and ; and $ properly.


# 1.45 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.44 12-May-2019 nicm

Fix some indentation and dead assignments.


# 1.43 26-Apr-2019 nicm

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


# 1.42 25-Apr-2019 nicm

Make options_tostring allocate its result instead of using a stack
buffer (needed for something in the future).


# 1.41 23-Apr-2019 nicm

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


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

The individual -fg, -bg and -attr options have been deprecated (in
favour of -style), undocumented and hidden from show-options since
2014. Remove them, except for status-fg and status-bg.


# 1.39 18-Mar-2019 nicm

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


# 1.38 15-Mar-2019 nicm

Add a way to set individual defaults for an array option.


# 1.37 14-Mar-2019 nicm

Add a wrapper (struct style) around styles rather than using the
grid_cell directly. There will be some non-cell members soon.


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.36 09-Aug-2017 nicm

Fix filtering so it works after the change to only show windows if they
have multiple panes.


# 1.35 31-May-2017 nicm

Style and spacing nits.


# 1.34 22-Apr-2017 nicm

Memory leaks, from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.33 08-Mar-2017 nicm

Handle empty options correctly.


# 1.32 30-Jan-2017 nicm

When a flag option is used in a format, it should use the number form
not string.


# 1.31 24-Jan-2017 nicm

If given an array option without an index either show or set all items,
and support -a for array options. Allow the separator for set to be
specified in the options table (will be used for backwards compatibility
later).


# 1.30 18-Jan-2017 nicm

Do not reset idx, it has just been set.


# 1.29 18-Jan-2017 nicm

options_match needs to explicitly check for user options.


# 1.28 16-Jan-2017 nicm

Correctly handle -style options without all of a corresponding -fg/-bg/-attr.


# 1.27 16-Jan-2017 nicm

getopt() has a struct option so just return to using options_entry.


# 1.26 15-Jan-2017 nicm

Major tidy up and rework of options tree and set-option/show-options
commands this pushes more of the code into options.c and ties it more
closely to the options table rather than having an unnecessary
split. Also add support for array options (will be used later). Only
(intentional) user visible change is that show-options output is now
passed through vis(3) with VIS_DQ so quotes are escaped.


# 1.25 15-Jan-2017 nicm

Append needs to go old,new not new,old...


# 1.24 13-Jan-2017 nicm

options_get_style return const too.


# 1.23 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.22 12-Jan-2017 nicm

Simplify appending to string options.


# 1.21 11-Jan-2017 nicm

Some tidying and tweaks to options code.


# 1.20 10-Oct-2016 nicm

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


# 1.19 26-Sep-2016 nicm

Support set -a (append) with user options, suggested by Xandor Schiefer.


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

I no longer use my SourceForge address so replace it.


# 1.17 11-Dec-2015 nicm

We cannot do hooks_find and then hooks_remove because it might have come
from the parent (global) tree, instead make it remove by name like options.

While here, also tidy up a few bits of options and hooks handling (use
RB_FOREACH_SAFE, and a helper function for the free).


# 1.16 08-Dec-2015 nicm

Spacing nits.


# 1.15 18-Nov-2015 nicm

Sync the entire xmalloc.[ch] with the other users, but with the addition
of xrealloc, xvasprintf, xvsnprintf.


# 1.14 13-Nov-2015 nicm

Log option names in fatal() for missing option.


# 1.13 27-Oct-2015 nicm

Move struct options into options.c.


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.12 18-Feb-2015 nicm

When given an invalid style, don't set the option to the default. Fix
from J Raynor. Also make style_parse not alter the grid_cell when it
fails.


# 1.11 20-Oct-2014 nicm

Better format for printf format attributes.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.10 28-Jan-2014 nicm

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

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

Becomes:

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

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

set -g status-bg red

Becomes:

set -ag status-style bg=red

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

From Tiago Cunha.


# 1.9 09-Jan-2014 nicm

Style and comment fixes from Tiago Cunha.


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.8 10-Jul-2012 nicm

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


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

Use RB trees not SPLAY.


# 1.6 21-Jan-2012 nicm

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

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

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


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.5 22-Sep-2009 nicm

Permit multiple prefix keys to be defined, separated by commas, for example:

set -g prefix ^a,^b

Any key in the list acts as the prefix. The send-prefix command always sends
the first key in the list.


# 1.4 21-Sep-2009 nicm

Use option print function for info messages as well.


# 1.3 21-Sep-2009 nicm

Drop tiny union from option struct.


# 1.2 21-Jul-2009 nicm

Make some functions which return unused values void (mostly found by lint) and
tweak a redundant expression in window_pane_set_mode.


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

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

ok deraadt pirofti


# 1.48 08-Jun-2019 nicm

Do not try to parse command when unsetting, GitHub issue 1788.


# 1.47 30-May-2019 nicm

Remove a leftover abort and some fixes from cppcheck.


# 1.46 23-May-2019 nicm

Break the argument escaping code into a separate function and use it to
escape key bindings in list-keys. Also escape ~ and ; and $ properly.


# 1.45 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.44 12-May-2019 nicm

Fix some indentation and dead assignments.


# 1.43 26-Apr-2019 nicm

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


# 1.42 25-Apr-2019 nicm

Make options_tostring allocate its result instead of using a stack
buffer (needed for something in the future).


# 1.41 23-Apr-2019 nicm

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


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

The individual -fg, -bg and -attr options have been deprecated (in
favour of -style), undocumented and hidden from show-options since
2014. Remove them, except for status-fg and status-bg.


# 1.39 18-Mar-2019 nicm

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


# 1.38 15-Mar-2019 nicm

Add a way to set individual defaults for an array option.


# 1.37 14-Mar-2019 nicm

Add a wrapper (struct style) around styles rather than using the
grid_cell directly. There will be some non-cell members soon.


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.36 09-Aug-2017 nicm

Fix filtering so it works after the change to only show windows if they
have multiple panes.


# 1.35 31-May-2017 nicm

Style and spacing nits.


# 1.34 22-Apr-2017 nicm

Memory leaks, from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.33 08-Mar-2017 nicm

Handle empty options correctly.


# 1.32 30-Jan-2017 nicm

When a flag option is used in a format, it should use the number form
not string.


# 1.31 24-Jan-2017 nicm

If given an array option without an index either show or set all items,
and support -a for array options. Allow the separator for set to be
specified in the options table (will be used for backwards compatibility
later).


# 1.30 18-Jan-2017 nicm

Do not reset idx, it has just been set.


# 1.29 18-Jan-2017 nicm

options_match needs to explicitly check for user options.


# 1.28 16-Jan-2017 nicm

Correctly handle -style options without all of a corresponding -fg/-bg/-attr.


# 1.27 16-Jan-2017 nicm

getopt() has a struct option so just return to using options_entry.


# 1.26 15-Jan-2017 nicm

Major tidy up and rework of options tree and set-option/show-options
commands this pushes more of the code into options.c and ties it more
closely to the options table rather than having an unnecessary
split. Also add support for array options (will be used later). Only
(intentional) user visible change is that show-options output is now
passed through vis(3) with VIS_DQ so quotes are escaped.


# 1.25 15-Jan-2017 nicm

Append needs to go old,new not new,old...


# 1.24 13-Jan-2017 nicm

options_get_style return const too.


# 1.23 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.22 12-Jan-2017 nicm

Simplify appending to string options.


# 1.21 11-Jan-2017 nicm

Some tidying and tweaks to options code.


# 1.20 10-Oct-2016 nicm

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


# 1.19 26-Sep-2016 nicm

Support set -a (append) with user options, suggested by Xandor Schiefer.


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

I no longer use my SourceForge address so replace it.


# 1.17 11-Dec-2015 nicm

We cannot do hooks_find and then hooks_remove because it might have come
from the parent (global) tree, instead make it remove by name like options.

While here, also tidy up a few bits of options and hooks handling (use
RB_FOREACH_SAFE, and a helper function for the free).


# 1.16 08-Dec-2015 nicm

Spacing nits.


# 1.15 18-Nov-2015 nicm

Sync the entire xmalloc.[ch] with the other users, but with the addition
of xrealloc, xvasprintf, xvsnprintf.


# 1.14 13-Nov-2015 nicm

Log option names in fatal() for missing option.


# 1.13 27-Oct-2015 nicm

Move struct options into options.c.


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.12 18-Feb-2015 nicm

When given an invalid style, don't set the option to the default. Fix
from J Raynor. Also make style_parse not alter the grid_cell when it
fails.


# 1.11 20-Oct-2014 nicm

Better format for printf format attributes.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.10 28-Jan-2014 nicm

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

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

Becomes:

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

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

set -g status-bg red

Becomes:

set -ag status-style bg=red

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

From Tiago Cunha.


# 1.9 09-Jan-2014 nicm

Style and comment fixes from Tiago Cunha.


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.8 10-Jul-2012 nicm

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


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

Use RB trees not SPLAY.


# 1.6 21-Jan-2012 nicm

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

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

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


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.5 22-Sep-2009 nicm

Permit multiple prefix keys to be defined, separated by commas, for example:

set -g prefix ^a,^b

Any key in the list acts as the prefix. The send-prefix command always sends
the first key in the list.


# 1.4 21-Sep-2009 nicm

Use option print function for info messages as well.


# 1.3 21-Sep-2009 nicm

Drop tiny union from option struct.


# 1.2 21-Jul-2009 nicm

Make some functions which return unused values void (mostly found by lint) and
tweak a redundant expression in window_pane_set_mode.


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

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

ok deraadt pirofti


# 1.47 30-May-2019 nicm

Remove a leftover abort and some fixes from cppcheck.


# 1.46 23-May-2019 nicm

Break the argument escaping code into a separate function and use it to
escape key bindings in list-keys. Also escape ~ and ; and $ properly.


# 1.45 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.44 12-May-2019 nicm

Fix some indentation and dead assignments.


# 1.43 26-Apr-2019 nicm

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


# 1.42 25-Apr-2019 nicm

Make options_tostring allocate its result instead of using a stack
buffer (needed for something in the future).


# 1.41 23-Apr-2019 nicm

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


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

The individual -fg, -bg and -attr options have been deprecated (in
favour of -style), undocumented and hidden from show-options since
2014. Remove them, except for status-fg and status-bg.


# 1.39 18-Mar-2019 nicm

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


# 1.38 15-Mar-2019 nicm

Add a way to set individual defaults for an array option.


# 1.37 14-Mar-2019 nicm

Add a wrapper (struct style) around styles rather than using the
grid_cell directly. There will be some non-cell members soon.


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.36 09-Aug-2017 nicm

Fix filtering so it works after the change to only show windows if they
have multiple panes.


# 1.35 31-May-2017 nicm

Style and spacing nits.


# 1.34 22-Apr-2017 nicm

Memory leaks, from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.33 08-Mar-2017 nicm

Handle empty options correctly.


# 1.32 30-Jan-2017 nicm

When a flag option is used in a format, it should use the number form
not string.


# 1.31 24-Jan-2017 nicm

If given an array option without an index either show or set all items,
and support -a for array options. Allow the separator for set to be
specified in the options table (will be used for backwards compatibility
later).


# 1.30 18-Jan-2017 nicm

Do not reset idx, it has just been set.


# 1.29 18-Jan-2017 nicm

options_match needs to explicitly check for user options.


# 1.28 16-Jan-2017 nicm

Correctly handle -style options without all of a corresponding -fg/-bg/-attr.


# 1.27 16-Jan-2017 nicm

getopt() has a struct option so just return to using options_entry.


# 1.26 15-Jan-2017 nicm

Major tidy up and rework of options tree and set-option/show-options
commands this pushes more of the code into options.c and ties it more
closely to the options table rather than having an unnecessary
split. Also add support for array options (will be used later). Only
(intentional) user visible change is that show-options output is now
passed through vis(3) with VIS_DQ so quotes are escaped.


# 1.25 15-Jan-2017 nicm

Append needs to go old,new not new,old...


# 1.24 13-Jan-2017 nicm

options_get_style return const too.


# 1.23 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.22 12-Jan-2017 nicm

Simplify appending to string options.


# 1.21 11-Jan-2017 nicm

Some tidying and tweaks to options code.


# 1.20 10-Oct-2016 nicm

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


# 1.19 26-Sep-2016 nicm

Support set -a (append) with user options, suggested by Xandor Schiefer.


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

I no longer use my SourceForge address so replace it.


# 1.17 11-Dec-2015 nicm

We cannot do hooks_find and then hooks_remove because it might have come
from the parent (global) tree, instead make it remove by name like options.

While here, also tidy up a few bits of options and hooks handling (use
RB_FOREACH_SAFE, and a helper function for the free).


# 1.16 08-Dec-2015 nicm

Spacing nits.


# 1.15 18-Nov-2015 nicm

Sync the entire xmalloc.[ch] with the other users, but with the addition
of xrealloc, xvasprintf, xvsnprintf.


# 1.14 13-Nov-2015 nicm

Log option names in fatal() for missing option.


# 1.13 27-Oct-2015 nicm

Move struct options into options.c.


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.12 18-Feb-2015 nicm

When given an invalid style, don't set the option to the default. Fix
from J Raynor. Also make style_parse not alter the grid_cell when it
fails.


# 1.11 20-Oct-2014 nicm

Better format for printf format attributes.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.10 28-Jan-2014 nicm

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

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

Becomes:

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

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

set -g status-bg red

Becomes:

set -ag status-style bg=red

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

From Tiago Cunha.


# 1.9 09-Jan-2014 nicm

Style and comment fixes from Tiago Cunha.


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.8 10-Jul-2012 nicm

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


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

Use RB trees not SPLAY.


# 1.6 21-Jan-2012 nicm

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

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

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


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.5 22-Sep-2009 nicm

Permit multiple prefix keys to be defined, separated by commas, for example:

set -g prefix ^a,^b

Any key in the list acts as the prefix. The send-prefix command always sends
the first key in the list.


# 1.4 21-Sep-2009 nicm

Use option print function for info messages as well.


# 1.3 21-Sep-2009 nicm

Drop tiny union from option struct.


# 1.2 21-Jul-2009 nicm

Make some functions which return unused values void (mostly found by lint) and
tweak a redundant expression in window_pane_set_mode.


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

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

ok deraadt pirofti


# 1.46 23-May-2019 nicm

Break the argument escaping code into a separate function and use it to
escape key bindings in list-keys. Also escape ~ and ; and $ properly.


# 1.45 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.44 12-May-2019 nicm

Fix some indentation and dead assignments.


# 1.43 26-Apr-2019 nicm

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


# 1.42 25-Apr-2019 nicm

Make options_tostring allocate its result instead of using a stack
buffer (needed for something in the future).


# 1.41 23-Apr-2019 nicm

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


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

The individual -fg, -bg and -attr options have been deprecated (in
favour of -style), undocumented and hidden from show-options since
2014. Remove them, except for status-fg and status-bg.


# 1.39 18-Mar-2019 nicm

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


# 1.38 15-Mar-2019 nicm

Add a way to set individual defaults for an array option.


# 1.37 14-Mar-2019 nicm

Add a wrapper (struct style) around styles rather than using the
grid_cell directly. There will be some non-cell members soon.


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.36 09-Aug-2017 nicm

Fix filtering so it works after the change to only show windows if they
have multiple panes.


# 1.35 31-May-2017 nicm

Style and spacing nits.


# 1.34 22-Apr-2017 nicm

Memory leaks, from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.33 08-Mar-2017 nicm

Handle empty options correctly.


# 1.32 30-Jan-2017 nicm

When a flag option is used in a format, it should use the number form
not string.


# 1.31 24-Jan-2017 nicm

If given an array option without an index either show or set all items,
and support -a for array options. Allow the separator for set to be
specified in the options table (will be used for backwards compatibility
later).


# 1.30 18-Jan-2017 nicm

Do not reset idx, it has just been set.


# 1.29 18-Jan-2017 nicm

options_match needs to explicitly check for user options.


# 1.28 16-Jan-2017 nicm

Correctly handle -style options without all of a corresponding -fg/-bg/-attr.


# 1.27 16-Jan-2017 nicm

getopt() has a struct option so just return to using options_entry.


# 1.26 15-Jan-2017 nicm

Major tidy up and rework of options tree and set-option/show-options
commands this pushes more of the code into options.c and ties it more
closely to the options table rather than having an unnecessary
split. Also add support for array options (will be used later). Only
(intentional) user visible change is that show-options output is now
passed through vis(3) with VIS_DQ so quotes are escaped.


# 1.25 15-Jan-2017 nicm

Append needs to go old,new not new,old...


# 1.24 13-Jan-2017 nicm

options_get_style return const too.


# 1.23 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.22 12-Jan-2017 nicm

Simplify appending to string options.


# 1.21 11-Jan-2017 nicm

Some tidying and tweaks to options code.


# 1.20 10-Oct-2016 nicm

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


# 1.19 26-Sep-2016 nicm

Support set -a (append) with user options, suggested by Xandor Schiefer.


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

I no longer use my SourceForge address so replace it.


# 1.17 11-Dec-2015 nicm

We cannot do hooks_find and then hooks_remove because it might have come
from the parent (global) tree, instead make it remove by name like options.

While here, also tidy up a few bits of options and hooks handling (use
RB_FOREACH_SAFE, and a helper function for the free).


# 1.16 08-Dec-2015 nicm

Spacing nits.


# 1.15 18-Nov-2015 nicm

Sync the entire xmalloc.[ch] with the other users, but with the addition
of xrealloc, xvasprintf, xvsnprintf.


# 1.14 13-Nov-2015 nicm

Log option names in fatal() for missing option.


# 1.13 27-Oct-2015 nicm

Move struct options into options.c.


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.12 18-Feb-2015 nicm

When given an invalid style, don't set the option to the default. Fix
from J Raynor. Also make style_parse not alter the grid_cell when it
fails.


# 1.11 20-Oct-2014 nicm

Better format for printf format attributes.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.10 28-Jan-2014 nicm

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

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

Becomes:

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

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

set -g status-bg red

Becomes:

set -ag status-style bg=red

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

From Tiago Cunha.


# 1.9 09-Jan-2014 nicm

Style and comment fixes from Tiago Cunha.


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.8 10-Jul-2012 nicm

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


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

Use RB trees not SPLAY.


# 1.6 21-Jan-2012 nicm

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

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

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


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.5 22-Sep-2009 nicm

Permit multiple prefix keys to be defined, separated by commas, for example:

set -g prefix ^a,^b

Any key in the list acts as the prefix. The send-prefix command always sends
the first key in the list.


# 1.4 21-Sep-2009 nicm

Use option print function for info messages as well.


# 1.3 21-Sep-2009 nicm

Drop tiny union from option struct.


# 1.2 21-Jul-2009 nicm

Make some functions which return unused values void (mostly found by lint) and
tweak a redundant expression in window_pane_set_mode.


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

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

ok deraadt pirofti


# 1.44 12-May-2019 nicm

Fix some indentation and dead assignments.


# 1.43 26-Apr-2019 nicm

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


# 1.42 25-Apr-2019 nicm

Make options_tostring allocate its result instead of using a stack
buffer (needed for something in the future).


# 1.41 23-Apr-2019 nicm

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


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

The individual -fg, -bg and -attr options have been deprecated (in
favour of -style), undocumented and hidden from show-options since
2014. Remove them, except for status-fg and status-bg.


# 1.39 18-Mar-2019 nicm

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


# 1.38 15-Mar-2019 nicm

Add a way to set individual defaults for an array option.


# 1.37 14-Mar-2019 nicm

Add a wrapper (struct style) around styles rather than using the
grid_cell directly. There will be some non-cell members soon.


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.36 09-Aug-2017 nicm

Fix filtering so it works after the change to only show windows if they
have multiple panes.


# 1.35 31-May-2017 nicm

Style and spacing nits.


# 1.34 22-Apr-2017 nicm

Memory leaks, from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.33 08-Mar-2017 nicm

Handle empty options correctly.


# 1.32 30-Jan-2017 nicm

When a flag option is used in a format, it should use the number form
not string.


# 1.31 24-Jan-2017 nicm

If given an array option without an index either show or set all items,
and support -a for array options. Allow the separator for set to be
specified in the options table (will be used for backwards compatibility
later).


# 1.30 18-Jan-2017 nicm

Do not reset idx, it has just been set.


# 1.29 18-Jan-2017 nicm

options_match needs to explicitly check for user options.


# 1.28 16-Jan-2017 nicm

Correctly handle -style options without all of a corresponding -fg/-bg/-attr.


# 1.27 16-Jan-2017 nicm

getopt() has a struct option so just return to using options_entry.


# 1.26 15-Jan-2017 nicm

Major tidy up and rework of options tree and set-option/show-options
commands this pushes more of the code into options.c and ties it more
closely to the options table rather than having an unnecessary
split. Also add support for array options (will be used later). Only
(intentional) user visible change is that show-options output is now
passed through vis(3) with VIS_DQ so quotes are escaped.


# 1.25 15-Jan-2017 nicm

Append needs to go old,new not new,old...


# 1.24 13-Jan-2017 nicm

options_get_style return const too.


# 1.23 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.22 12-Jan-2017 nicm

Simplify appending to string options.


# 1.21 11-Jan-2017 nicm

Some tidying and tweaks to options code.


# 1.20 10-Oct-2016 nicm

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


# 1.19 26-Sep-2016 nicm

Support set -a (append) with user options, suggested by Xandor Schiefer.


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

I no longer use my SourceForge address so replace it.


# 1.17 11-Dec-2015 nicm

We cannot do hooks_find and then hooks_remove because it might have come
from the parent (global) tree, instead make it remove by name like options.

While here, also tidy up a few bits of options and hooks handling (use
RB_FOREACH_SAFE, and a helper function for the free).


# 1.16 08-Dec-2015 nicm

Spacing nits.


# 1.15 18-Nov-2015 nicm

Sync the entire xmalloc.[ch] with the other users, but with the addition
of xrealloc, xvasprintf, xvsnprintf.


# 1.14 13-Nov-2015 nicm

Log option names in fatal() for missing option.


# 1.13 27-Oct-2015 nicm

Move struct options into options.c.


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.12 18-Feb-2015 nicm

When given an invalid style, don't set the option to the default. Fix
from J Raynor. Also make style_parse not alter the grid_cell when it
fails.


# 1.11 20-Oct-2014 nicm

Better format for printf format attributes.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.10 28-Jan-2014 nicm

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

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

Becomes:

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

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

set -g status-bg red

Becomes:

set -ag status-style bg=red

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

From Tiago Cunha.


# 1.9 09-Jan-2014 nicm

Style and comment fixes from Tiago Cunha.


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.8 10-Jul-2012 nicm

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


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

Use RB trees not SPLAY.


# 1.6 21-Jan-2012 nicm

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

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

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


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.5 22-Sep-2009 nicm

Permit multiple prefix keys to be defined, separated by commas, for example:

set -g prefix ^a,^b

Any key in the list acts as the prefix. The send-prefix command always sends
the first key in the list.


# 1.4 21-Sep-2009 nicm

Use option print function for info messages as well.


# 1.3 21-Sep-2009 nicm

Drop tiny union from option struct.


# 1.2 21-Jul-2009 nicm

Make some functions which return unused values void (mostly found by lint) and
tweak a redundant expression in window_pane_set_mode.


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

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

ok deraadt pirofti


# 1.43 26-Apr-2019 nicm

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


# 1.42 25-Apr-2019 nicm

Make options_tostring allocate its result instead of using a stack
buffer (needed for something in the future).


# 1.41 23-Apr-2019 nicm

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


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

The individual -fg, -bg and -attr options have been deprecated (in
favour of -style), undocumented and hidden from show-options since
2014. Remove them, except for status-fg and status-bg.


# 1.39 18-Mar-2019 nicm

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


# 1.38 15-Mar-2019 nicm

Add a way to set individual defaults for an array option.


# 1.37 14-Mar-2019 nicm

Add a wrapper (struct style) around styles rather than using the
grid_cell directly. There will be some non-cell members soon.


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.36 09-Aug-2017 nicm

Fix filtering so it works after the change to only show windows if they
have multiple panes.


# 1.35 31-May-2017 nicm

Style and spacing nits.


# 1.34 22-Apr-2017 nicm

Memory leaks, from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.33 08-Mar-2017 nicm

Handle empty options correctly.


# 1.32 30-Jan-2017 nicm

When a flag option is used in a format, it should use the number form
not string.


# 1.31 24-Jan-2017 nicm

If given an array option without an index either show or set all items,
and support -a for array options. Allow the separator for set to be
specified in the options table (will be used for backwards compatibility
later).


# 1.30 18-Jan-2017 nicm

Do not reset idx, it has just been set.


# 1.29 18-Jan-2017 nicm

options_match needs to explicitly check for user options.


# 1.28 16-Jan-2017 nicm

Correctly handle -style options without all of a corresponding -fg/-bg/-attr.


# 1.27 16-Jan-2017 nicm

getopt() has a struct option so just return to using options_entry.


# 1.26 15-Jan-2017 nicm

Major tidy up and rework of options tree and set-option/show-options
commands this pushes more of the code into options.c and ties it more
closely to the options table rather than having an unnecessary
split. Also add support for array options (will be used later). Only
(intentional) user visible change is that show-options output is now
passed through vis(3) with VIS_DQ so quotes are escaped.


# 1.25 15-Jan-2017 nicm

Append needs to go old,new not new,old...


# 1.24 13-Jan-2017 nicm

options_get_style return const too.


# 1.23 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.22 12-Jan-2017 nicm

Simplify appending to string options.


# 1.21 11-Jan-2017 nicm

Some tidying and tweaks to options code.


# 1.20 10-Oct-2016 nicm

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


# 1.19 26-Sep-2016 nicm

Support set -a (append) with user options, suggested by Xandor Schiefer.


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

I no longer use my SourceForge address so replace it.


# 1.17 11-Dec-2015 nicm

We cannot do hooks_find and then hooks_remove because it might have come
from the parent (global) tree, instead make it remove by name like options.

While here, also tidy up a few bits of options and hooks handling (use
RB_FOREACH_SAFE, and a helper function for the free).


# 1.16 08-Dec-2015 nicm

Spacing nits.


# 1.15 18-Nov-2015 nicm

Sync the entire xmalloc.[ch] with the other users, but with the addition
of xrealloc, xvasprintf, xvsnprintf.


# 1.14 13-Nov-2015 nicm

Log option names in fatal() for missing option.


# 1.13 27-Oct-2015 nicm

Move struct options into options.c.


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.12 18-Feb-2015 nicm

When given an invalid style, don't set the option to the default. Fix
from J Raynor. Also make style_parse not alter the grid_cell when it
fails.


# 1.11 20-Oct-2014 nicm

Better format for printf format attributes.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.10 28-Jan-2014 nicm

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

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

Becomes:

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

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

set -g status-bg red

Becomes:

set -ag status-style bg=red

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

From Tiago Cunha.


# 1.9 09-Jan-2014 nicm

Style and comment fixes from Tiago Cunha.


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.8 10-Jul-2012 nicm

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


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

Use RB trees not SPLAY.


# 1.6 21-Jan-2012 nicm

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

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

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


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.5 22-Sep-2009 nicm

Permit multiple prefix keys to be defined, separated by commas, for example:

set -g prefix ^a,^b

Any key in the list acts as the prefix. The send-prefix command always sends
the first key in the list.


# 1.4 21-Sep-2009 nicm

Use option print function for info messages as well.


# 1.3 21-Sep-2009 nicm

Drop tiny union from option struct.


# 1.2 21-Jul-2009 nicm

Make some functions which return unused values void (mostly found by lint) and
tweak a redundant expression in window_pane_set_mode.


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

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

ok deraadt pirofti


Revision tags: OPENBSD_6_2_BASE
# 1.36 09-Aug-2017 nicm

Fix filtering so it works after the change to only show windows if they
have multiple panes.


# 1.35 31-May-2017 nicm

Style and spacing nits.


# 1.34 22-Apr-2017 nicm

Memory leaks, from David CARLIER.


Revision tags: OPENBSD_6_1_BASE
# 1.33 08-Mar-2017 nicm

Handle empty options correctly.


# 1.32 30-Jan-2017 nicm

When a flag option is used in a format, it should use the number form
not string.


# 1.31 24-Jan-2017 nicm

If given an array option without an index either show or set all items,
and support -a for array options. Allow the separator for set to be
specified in the options table (will be used for backwards compatibility
later).


# 1.30 18-Jan-2017 nicm

Do not reset idx, it has just been set.


# 1.29 18-Jan-2017 nicm

options_match needs to explicitly check for user options.


# 1.28 16-Jan-2017 nicm

Correctly handle -style options without all of a corresponding -fg/-bg/-attr.


# 1.27 16-Jan-2017 nicm

getopt() has a struct option so just return to using options_entry.


# 1.26 15-Jan-2017 nicm

Major tidy up and rework of options tree and set-option/show-options
commands this pushes more of the code into options.c and ties it more
closely to the options table rather than having an unnecessary
split. Also add support for array options (will be used later). Only
(intentional) user visible change is that show-options output is now
passed through vis(3) with VIS_DQ so quotes are escaped.


# 1.25 15-Jan-2017 nicm

Append needs to go old,new not new,old...


# 1.24 13-Jan-2017 nicm

options_get_style return const too.


# 1.23 13-Jan-2017 nicm

Make options_get_string return const string.


# 1.22 12-Jan-2017 nicm

Simplify appending to string options.


# 1.21 11-Jan-2017 nicm

Some tidying and tweaks to options code.


# 1.20 10-Oct-2016 nicm

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


# 1.19 26-Sep-2016 nicm

Support set -a (append) with user options, suggested by Xandor Schiefer.


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

I no longer use my SourceForge address so replace it.


# 1.17 11-Dec-2015 nicm

We cannot do hooks_find and then hooks_remove because it might have come
from the parent (global) tree, instead make it remove by name like options.

While here, also tidy up a few bits of options and hooks handling (use
RB_FOREACH_SAFE, and a helper function for the free).


# 1.16 08-Dec-2015 nicm

Spacing nits.


# 1.15 18-Nov-2015 nicm

Sync the entire xmalloc.[ch] with the other users, but with the addition
of xrealloc, xvasprintf, xvsnprintf.


# 1.14 13-Nov-2015 nicm

Log option names in fatal() for missing option.


# 1.13 27-Oct-2015 nicm

Move struct options into options.c.


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.12 18-Feb-2015 nicm

When given an invalid style, don't set the option to the default. Fix
from J Raynor. Also make style_parse not alter the grid_cell when it
fails.


# 1.11 20-Oct-2014 nicm

Better format for printf format attributes.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.10 28-Jan-2014 nicm

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

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

Becomes:

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

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

set -g status-bg red

Becomes:

set -ag status-style bg=red

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

From Tiago Cunha.


# 1.9 09-Jan-2014 nicm

Style and comment fixes from Tiago Cunha.


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.8 10-Jul-2012 nicm

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


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

Use RB trees not SPLAY.


# 1.6 21-Jan-2012 nicm

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

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

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


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.5 22-Sep-2009 nicm

Permit multiple prefix keys to be defined, separated by commas, for example:

set -g prefix ^a,^b

Any key in the list acts as the prefix. The send-prefix command always sends
the first key in the list.


# 1.4 21-Sep-2009 nicm

Use option print function for info messages as well.


# 1.3 21-Sep-2009 nicm

Drop tiny union from option struct.


# 1.2 21-Jul-2009 nicm

Make some functions which return unused values void (mostly found by lint) and
tweak a redundant expression in window_pane_set_mode.


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

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

ok deraadt pirofti