History log of /openbsd-current/usr.bin/tmux/window-tree.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.63 30-Jun-2023 nicm

Change a few types to fix warnings, from Thomas Klausner.


Revision tags: OPENBSD_7_2_BASE OPENBSD_7_3_BASE
# 1.62 04-Jul-2022 nicm

Sort panes by index not by ID, GitHub issue 3249.


# 1.61 04-Jul-2022 nicm

Mouse clicks could change current item, so work it out again. GitHub
issue 3242.


# 1.60 30-May-2022 nicm

Spacing/style nits.


Revision tags: OPENBSD_7_1_BASE
# 1.59 20-Oct-2021 nicm

Add -T to set a popup title, from Alexis Hildebrandt in GitHub issue 2941.


# 1.58 14-Oct-2021 nicm

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


# 1.57 13-Oct-2021 nicm

Add popup-style and popup-border-style options, from Alexis Hildebrandt
in GitHub issue 2927.


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

Hide struct args behind a couple of accessor functions.


# 1.55 10-Jun-2021 nicm

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


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

Permit shortcut keys in buffer, client, tree modes to be configured with
a format; the default remains the line number. GitHub issue 2636.


# 1.53 03-Dec-2020 nicm

Redraw any visible modes when status line changes so that formats like
the pane title are updated. GitHub issue 2487. Also a man page fix from
jmc.


Revision tags: OPENBSD_6_8_BASE
# 1.52 15-Jul-2020 nicm

Renumber after killing windows for choose-tree.


# 1.51 04-Jul-2020 nicm

kill-window -a cannot just walk the list of windows because if
renumber-windows is on, the window it wants to keep could be moved.
Change to renumber afterwards and also behave better if the window is
linked into the session twice. GitHub issue 2287.


# 1.50 16-May-2020 nicm

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


# 1.49 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.48 16-May-2020 nicm

Tweak the default choose modes formats:

- Only show pane title if it is not default and not empty.
- Add a prettier time format and use that instead of long ctime().
- Remove clutter and change the order.


Revision tags: OPENBSD_6_7_BASE
# 1.47 22-Apr-2020 nicm

Indicate the marked pane in choose mode in reverse and add key to set
and clear it (m and M) and a key to jump to the starting pane (H).


# 1.46 09-Apr-2020 nicm

More style nits.


# 1.45 20-Mar-2020 nicm

Fix positioning of menu in choose modes and a couple of keys in tree mode.


# 1.44 08-Jan-2020 nicm

Add -Z to default switch-client command in tree mode, matches previous
behaviour.


# 1.43 03-Dec-2019 nicm

Style nits in function arguments.


# 1.42 15-Oct-2019 nicm

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


Revision tags: OPENBSD_6_6_BASE
# 1.41 25-Sep-2019 nicm

Style and line length nits.


# 1.40 16-Aug-2019 nicm

Add a flag to reverse sort in the various choose modes, from Benjamin
Poirier in GitHub issue 1875.


# 1.39 28-May-2019 nicm

Change display-menu from taking a single string to a set of arguments,
which is much easier to work with. Based on a diff from Avi Halachmi.


# 1.38 12-May-2019 nicm

Add simple menus to tree, client, buffer modes.


# 1.37 30-Apr-2019 nicm

Fix memory leak in window tree search, from Amos Bird.


# 1.36 17-Apr-2019 nicm

Break new window and pane creation common code from various commands and
window.c into a separate file spawn.c.


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

Add format variables for the default formats for the various modes
(tree_mode_format and so on) and add a -a flag to display-message to
list variables with values.


# 1.34 12-Mar-2019 nicm

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


# 1.33 07-Mar-2019 nicm

Add a separate mode struct for the active window mode if any.


# 1.32 18-Dec-2018 nicm

Pass window into mode functions.


Revision tags: OPENBSD_6_4_BASE
# 1.31 19-Aug-2018 nicm

Expand \u and \U escape sequences in command strings, from Christopher
Hunt in GitHub issue 1443.


# 1.30 10-Apr-2018 nicm

Add x and X to choose-tree (with a confirmation prompt) to kill an
item. Suggested by Matt Zagrabelny.


# 1.29 29-Mar-2018 nicm

Do not crash on empty window, reported by Jamie Macdonald in GitHub
issue 1299. Patch from Thomas Adam.


Revision tags: OPENBSD_6_3_BASE
# 1.28 28-Feb-2018 nicm

Add -Z flag to choose-tree, choose-client, choose-buffer to
automatically zoom the pane when the mode is entered and unzoom when it
exits, assuming the pane is not already zoomed. Add -Z to the default
key bindings.


# 1.27 03-Nov-2017 nicm

Support mouse on preview in tree mode.


# 1.26 02-Nov-2017 nicm

Make the mode draw function use the parent screen directly rather than
its own to avoid copying twice.


# 1.25 02-Nov-2017 nicm

Format for group list of "other sessions" is a bit weird, just list all
the sessions in the group.


# 1.24 02-Nov-2017 nicm

Tweak previous slightly so that current session is chosen if it is in
the group rather than first.


# 1.23 02-Nov-2017 nicm

Only show the first member of session groups in tree mode (-G flag
disables).


# 1.22 26-Oct-2017 nicm

Fix crash exiting command prompt (from Alex Maese in GitHub issue 1139)
and a man page tweak from jmc.


# 1.21 25-Oct-2017 nicm

Add P key to paste tagged in buffer mode, and trim some code that should
no longer be necessary.


# 1.20 22-Oct-2017 nicm

Use window_pane_index() when drawing pane numbers (so pane-base-index is
applied), from Thomas Adam. GitHub issue 1125.


# 1.19 11-Oct-2017 nicm

Box around label in preview.


# 1.18 11-Oct-2017 nicm

Add C-n and C-p keys for tree mode, and choose the right initial line
when no panes.


Revision tags: OPENBSD_6_2_BASE
# 1.17 30-Aug-2017 nicm

Pass flags into cmd_find_from_* to fix prefer-unattached, reported by
Thomas Sattler.


# 1.16 09-Aug-2017 nicm

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


# 1.15 09-Aug-2017 nicm

Add -F to choose-tree, choose-client, choose-buffer to specify the
format of each line, as well as adding a couple of formats needed for
the default display.


# 1.14 28-Jul-2017 nicm

Show pane title in window list for windows with only one pane.


# 1.13 12-Jul-2017 nicm

Line up keys in tree mode, and don't expand windows with one pane. From
Thomas Adam.


# 1.12 07-Jul-2017 nicm

Fix size of rightmost preview section.


# 1.11 04-Jul-2017 nicm

< and > keys to scroll preview list left and right in tree mode.


# 1.10 04-Jul-2017 nicm

Handle 0 size of preview box in caller.


# 1.9 03-Jul-2017 nicm

Change session and window preview so that the current window or pane is
always shown.


# 1.8 30-Jun-2017 nicm

Don't write over right border.


# 1.7 30-Jun-2017 nicm

Fix previous when we end up able to show no panes.


# 1.6 30-Jun-2017 nicm

Try to show a better preview of sessions and windows in tree mode.


# 1.5 09-Jun-2017 nicm

Extend filters (f key) to buffer and client mode and add -f flag to
specify to command.


# 1.4 09-Jun-2017 nicm

Add -O option to choose-* to set initial sort order.


# 1.3 07-Jun-2017 nicm

Add simple searching (C-s and n) to the various choose modes: by name
for client and tree, and by name and content for buffer.


# 1.2 06-Jun-2017 nicm

Do not pass a state into commands when fired on individual items in tree
mode, rely on the %% target substitution in the command for the chosen
pane and leave the default target as the current pane (where the mode
is). Otherwise, joinp and similar end up with -t and -s the
same. Reported by Jacob Niehus in GitHub issue 960.


# 1.1 30-May-2017 nicm

Rewrite of choose mode, both to simplify and tidy the code and to add
some modern features.

Now the common code is in mode-tree.c, which provides an API used by the
three modes now separated into window-{buffer,client,tree}.c. Buffer
mode shows buffers, client mode clients and tree mode a tree of
sessions, windows and panes.

Each mode has a common set of key bindings plus a few that are specific
to the mode. Other changes are:

- each mode has a preview pane: for buffers this is the buffer content
(very useful), for others it is a preview of the pane;

- items may be sorted in different ways ('O' key);

- multiple items may be tagged and an operation applied to all of them
(for example, to delete multiple buffers at once);

- in tree mode a command may be run on the selected item (session,
window, pane) or on tagged items (key ':');

- displayed items may be filtered in tree mode by using a format (this
is used to implement find-window) (key 'f');

- the custom format (-F) for the display is no longer available;

- shortcut keys change from 0-9, a-z, A-Z which was always a bit weird
with keys used for other uses to 0-9, M-a to M-z.

Now that the code is simpler, other improvements will come later.

Primary key bindings for each mode are documented under the commands in
the man page (choose-buffer, choose-client, choose-tree).

Parts written by Thomas Adam.


# 1.62 04-Jul-2022 nicm

Sort panes by index not by ID, GitHub issue 3249.


# 1.61 04-Jul-2022 nicm

Mouse clicks could change current item, so work it out again. GitHub
issue 3242.


# 1.60 30-May-2022 nicm

Spacing/style nits.


Revision tags: OPENBSD_7_1_BASE
# 1.59 20-Oct-2021 nicm

Add -T to set a popup title, from Alexis Hildebrandt in GitHub issue 2941.


# 1.58 14-Oct-2021 nicm

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


# 1.57 13-Oct-2021 nicm

Add popup-style and popup-border-style options, from Alexis Hildebrandt
in GitHub issue 2927.


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

Hide struct args behind a couple of accessor functions.


# 1.55 10-Jun-2021 nicm

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


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

Permit shortcut keys in buffer, client, tree modes to be configured with
a format; the default remains the line number. GitHub issue 2636.


# 1.53 03-Dec-2020 nicm

Redraw any visible modes when status line changes so that formats like
the pane title are updated. GitHub issue 2487. Also a man page fix from
jmc.


Revision tags: OPENBSD_6_8_BASE
# 1.52 15-Jul-2020 nicm

Renumber after killing windows for choose-tree.


# 1.51 04-Jul-2020 nicm

kill-window -a cannot just walk the list of windows because if
renumber-windows is on, the window it wants to keep could be moved.
Change to renumber afterwards and also behave better if the window is
linked into the session twice. GitHub issue 2287.


# 1.50 16-May-2020 nicm

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


# 1.49 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.48 16-May-2020 nicm

Tweak the default choose modes formats:

- Only show pane title if it is not default and not empty.
- Add a prettier time format and use that instead of long ctime().
- Remove clutter and change the order.


Revision tags: OPENBSD_6_7_BASE
# 1.47 22-Apr-2020 nicm

Indicate the marked pane in choose mode in reverse and add key to set
and clear it (m and M) and a key to jump to the starting pane (H).


# 1.46 09-Apr-2020 nicm

More style nits.


# 1.45 20-Mar-2020 nicm

Fix positioning of menu in choose modes and a couple of keys in tree mode.


# 1.44 08-Jan-2020 nicm

Add -Z to default switch-client command in tree mode, matches previous
behaviour.


# 1.43 03-Dec-2019 nicm

Style nits in function arguments.


# 1.42 15-Oct-2019 nicm

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


Revision tags: OPENBSD_6_6_BASE
# 1.41 25-Sep-2019 nicm

Style and line length nits.


# 1.40 16-Aug-2019 nicm

Add a flag to reverse sort in the various choose modes, from Benjamin
Poirier in GitHub issue 1875.


# 1.39 28-May-2019 nicm

Change display-menu from taking a single string to a set of arguments,
which is much easier to work with. Based on a diff from Avi Halachmi.


# 1.38 12-May-2019 nicm

Add simple menus to tree, client, buffer modes.


# 1.37 30-Apr-2019 nicm

Fix memory leak in window tree search, from Amos Bird.


# 1.36 17-Apr-2019 nicm

Break new window and pane creation common code from various commands and
window.c into a separate file spawn.c.


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

Add format variables for the default formats for the various modes
(tree_mode_format and so on) and add a -a flag to display-message to
list variables with values.


# 1.34 12-Mar-2019 nicm

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


# 1.33 07-Mar-2019 nicm

Add a separate mode struct for the active window mode if any.


# 1.32 18-Dec-2018 nicm

Pass window into mode functions.


Revision tags: OPENBSD_6_4_BASE
# 1.31 19-Aug-2018 nicm

Expand \u and \U escape sequences in command strings, from Christopher
Hunt in GitHub issue 1443.


# 1.30 10-Apr-2018 nicm

Add x and X to choose-tree (with a confirmation prompt) to kill an
item. Suggested by Matt Zagrabelny.


# 1.29 29-Mar-2018 nicm

Do not crash on empty window, reported by Jamie Macdonald in GitHub
issue 1299. Patch from Thomas Adam.


Revision tags: OPENBSD_6_3_BASE
# 1.28 28-Feb-2018 nicm

Add -Z flag to choose-tree, choose-client, choose-buffer to
automatically zoom the pane when the mode is entered and unzoom when it
exits, assuming the pane is not already zoomed. Add -Z to the default
key bindings.


# 1.27 03-Nov-2017 nicm

Support mouse on preview in tree mode.


# 1.26 02-Nov-2017 nicm

Make the mode draw function use the parent screen directly rather than
its own to avoid copying twice.


# 1.25 02-Nov-2017 nicm

Format for group list of "other sessions" is a bit weird, just list all
the sessions in the group.


# 1.24 02-Nov-2017 nicm

Tweak previous slightly so that current session is chosen if it is in
the group rather than first.


# 1.23 02-Nov-2017 nicm

Only show the first member of session groups in tree mode (-G flag
disables).


# 1.22 26-Oct-2017 nicm

Fix crash exiting command prompt (from Alex Maese in GitHub issue 1139)
and a man page tweak from jmc.


# 1.21 25-Oct-2017 nicm

Add P key to paste tagged in buffer mode, and trim some code that should
no longer be necessary.


# 1.20 22-Oct-2017 nicm

Use window_pane_index() when drawing pane numbers (so pane-base-index is
applied), from Thomas Adam. GitHub issue 1125.


# 1.19 11-Oct-2017 nicm

Box around label in preview.


# 1.18 11-Oct-2017 nicm

Add C-n and C-p keys for tree mode, and choose the right initial line
when no panes.


Revision tags: OPENBSD_6_2_BASE
# 1.17 30-Aug-2017 nicm

Pass flags into cmd_find_from_* to fix prefer-unattached, reported by
Thomas Sattler.


# 1.16 09-Aug-2017 nicm

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


# 1.15 09-Aug-2017 nicm

Add -F to choose-tree, choose-client, choose-buffer to specify the
format of each line, as well as adding a couple of formats needed for
the default display.


# 1.14 28-Jul-2017 nicm

Show pane title in window list for windows with only one pane.


# 1.13 12-Jul-2017 nicm

Line up keys in tree mode, and don't expand windows with one pane. From
Thomas Adam.


# 1.12 07-Jul-2017 nicm

Fix size of rightmost preview section.


# 1.11 04-Jul-2017 nicm

< and > keys to scroll preview list left and right in tree mode.


# 1.10 04-Jul-2017 nicm

Handle 0 size of preview box in caller.


# 1.9 03-Jul-2017 nicm

Change session and window preview so that the current window or pane is
always shown.


# 1.8 30-Jun-2017 nicm

Don't write over right border.


# 1.7 30-Jun-2017 nicm

Fix previous when we end up able to show no panes.


# 1.6 30-Jun-2017 nicm

Try to show a better preview of sessions and windows in tree mode.


# 1.5 09-Jun-2017 nicm

Extend filters (f key) to buffer and client mode and add -f flag to
specify to command.


# 1.4 09-Jun-2017 nicm

Add -O option to choose-* to set initial sort order.


# 1.3 07-Jun-2017 nicm

Add simple searching (C-s and n) to the various choose modes: by name
for client and tree, and by name and content for buffer.


# 1.2 06-Jun-2017 nicm

Do not pass a state into commands when fired on individual items in tree
mode, rely on the %% target substitution in the command for the chosen
pane and leave the default target as the current pane (where the mode
is). Otherwise, joinp and similar end up with -t and -s the
same. Reported by Jacob Niehus in GitHub issue 960.


# 1.1 30-May-2017 nicm

Rewrite of choose mode, both to simplify and tidy the code and to add
some modern features.

Now the common code is in mode-tree.c, which provides an API used by the
three modes now separated into window-{buffer,client,tree}.c. Buffer
mode shows buffers, client mode clients and tree mode a tree of
sessions, windows and panes.

Each mode has a common set of key bindings plus a few that are specific
to the mode. Other changes are:

- each mode has a preview pane: for buffers this is the buffer content
(very useful), for others it is a preview of the pane;

- items may be sorted in different ways ('O' key);

- multiple items may be tagged and an operation applied to all of them
(for example, to delete multiple buffers at once);

- in tree mode a command may be run on the selected item (session,
window, pane) or on tagged items (key ':');

- displayed items may be filtered in tree mode by using a format (this
is used to implement find-window) (key 'f');

- the custom format (-F) for the display is no longer available;

- shortcut keys change from 0-9, a-z, A-Z which was always a bit weird
with keys used for other uses to 0-9, M-a to M-z.

Now that the code is simpler, other improvements will come later.

Primary key bindings for each mode are documented under the commands in
the man page (choose-buffer, choose-client, choose-tree).

Parts written by Thomas Adam.


# 1.60 30-May-2022 nicm

Spacing/style nits.


Revision tags: OPENBSD_7_1_BASE
# 1.59 20-Oct-2021 nicm

Add -T to set a popup title, from Alexis Hildebrandt in GitHub issue 2941.


# 1.58 14-Oct-2021 nicm

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


# 1.57 13-Oct-2021 nicm

Add popup-style and popup-border-style options, from Alexis Hildebrandt
in GitHub issue 2927.


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

Hide struct args behind a couple of accessor functions.


# 1.55 10-Jun-2021 nicm

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


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

Permit shortcut keys in buffer, client, tree modes to be configured with
a format; the default remains the line number. GitHub issue 2636.


# 1.53 03-Dec-2020 nicm

Redraw any visible modes when status line changes so that formats like
the pane title are updated. GitHub issue 2487. Also a man page fix from
jmc.


Revision tags: OPENBSD_6_8_BASE
# 1.52 15-Jul-2020 nicm

Renumber after killing windows for choose-tree.


# 1.51 04-Jul-2020 nicm

kill-window -a cannot just walk the list of windows because if
renumber-windows is on, the window it wants to keep could be moved.
Change to renumber afterwards and also behave better if the window is
linked into the session twice. GitHub issue 2287.


# 1.50 16-May-2020 nicm

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


# 1.49 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.48 16-May-2020 nicm

Tweak the default choose modes formats:

- Only show pane title if it is not default and not empty.
- Add a prettier time format and use that instead of long ctime().
- Remove clutter and change the order.


Revision tags: OPENBSD_6_7_BASE
# 1.47 22-Apr-2020 nicm

Indicate the marked pane in choose mode in reverse and add key to set
and clear it (m and M) and a key to jump to the starting pane (H).


# 1.46 09-Apr-2020 nicm

More style nits.


# 1.45 20-Mar-2020 nicm

Fix positioning of menu in choose modes and a couple of keys in tree mode.


# 1.44 08-Jan-2020 nicm

Add -Z to default switch-client command in tree mode, matches previous
behaviour.


# 1.43 03-Dec-2019 nicm

Style nits in function arguments.


# 1.42 15-Oct-2019 nicm

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


Revision tags: OPENBSD_6_6_BASE
# 1.41 25-Sep-2019 nicm

Style and line length nits.


# 1.40 16-Aug-2019 nicm

Add a flag to reverse sort in the various choose modes, from Benjamin
Poirier in GitHub issue 1875.


# 1.39 28-May-2019 nicm

Change display-menu from taking a single string to a set of arguments,
which is much easier to work with. Based on a diff from Avi Halachmi.


# 1.38 12-May-2019 nicm

Add simple menus to tree, client, buffer modes.


# 1.37 30-Apr-2019 nicm

Fix memory leak in window tree search, from Amos Bird.


# 1.36 17-Apr-2019 nicm

Break new window and pane creation common code from various commands and
window.c into a separate file spawn.c.


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

Add format variables for the default formats for the various modes
(tree_mode_format and so on) and add a -a flag to display-message to
list variables with values.


# 1.34 12-Mar-2019 nicm

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


# 1.33 07-Mar-2019 nicm

Add a separate mode struct for the active window mode if any.


# 1.32 18-Dec-2018 nicm

Pass window into mode functions.


Revision tags: OPENBSD_6_4_BASE
# 1.31 19-Aug-2018 nicm

Expand \u and \U escape sequences in command strings, from Christopher
Hunt in GitHub issue 1443.


# 1.30 10-Apr-2018 nicm

Add x and X to choose-tree (with a confirmation prompt) to kill an
item. Suggested by Matt Zagrabelny.


# 1.29 29-Mar-2018 nicm

Do not crash on empty window, reported by Jamie Macdonald in GitHub
issue 1299. Patch from Thomas Adam.


Revision tags: OPENBSD_6_3_BASE
# 1.28 28-Feb-2018 nicm

Add -Z flag to choose-tree, choose-client, choose-buffer to
automatically zoom the pane when the mode is entered and unzoom when it
exits, assuming the pane is not already zoomed. Add -Z to the default
key bindings.


# 1.27 03-Nov-2017 nicm

Support mouse on preview in tree mode.


# 1.26 02-Nov-2017 nicm

Make the mode draw function use the parent screen directly rather than
its own to avoid copying twice.


# 1.25 02-Nov-2017 nicm

Format for group list of "other sessions" is a bit weird, just list all
the sessions in the group.


# 1.24 02-Nov-2017 nicm

Tweak previous slightly so that current session is chosen if it is in
the group rather than first.


# 1.23 02-Nov-2017 nicm

Only show the first member of session groups in tree mode (-G flag
disables).


# 1.22 26-Oct-2017 nicm

Fix crash exiting command prompt (from Alex Maese in GitHub issue 1139)
and a man page tweak from jmc.


# 1.21 25-Oct-2017 nicm

Add P key to paste tagged in buffer mode, and trim some code that should
no longer be necessary.


# 1.20 22-Oct-2017 nicm

Use window_pane_index() when drawing pane numbers (so pane-base-index is
applied), from Thomas Adam. GitHub issue 1125.


# 1.19 11-Oct-2017 nicm

Box around label in preview.


# 1.18 11-Oct-2017 nicm

Add C-n and C-p keys for tree mode, and choose the right initial line
when no panes.


Revision tags: OPENBSD_6_2_BASE
# 1.17 30-Aug-2017 nicm

Pass flags into cmd_find_from_* to fix prefer-unattached, reported by
Thomas Sattler.


# 1.16 09-Aug-2017 nicm

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


# 1.15 09-Aug-2017 nicm

Add -F to choose-tree, choose-client, choose-buffer to specify the
format of each line, as well as adding a couple of formats needed for
the default display.


# 1.14 28-Jul-2017 nicm

Show pane title in window list for windows with only one pane.


# 1.13 12-Jul-2017 nicm

Line up keys in tree mode, and don't expand windows with one pane. From
Thomas Adam.


# 1.12 07-Jul-2017 nicm

Fix size of rightmost preview section.


# 1.11 04-Jul-2017 nicm

< and > keys to scroll preview list left and right in tree mode.


# 1.10 04-Jul-2017 nicm

Handle 0 size of preview box in caller.


# 1.9 03-Jul-2017 nicm

Change session and window preview so that the current window or pane is
always shown.


# 1.8 30-Jun-2017 nicm

Don't write over right border.


# 1.7 30-Jun-2017 nicm

Fix previous when we end up able to show no panes.


# 1.6 30-Jun-2017 nicm

Try to show a better preview of sessions and windows in tree mode.


# 1.5 09-Jun-2017 nicm

Extend filters (f key) to buffer and client mode and add -f flag to
specify to command.


# 1.4 09-Jun-2017 nicm

Add -O option to choose-* to set initial sort order.


# 1.3 07-Jun-2017 nicm

Add simple searching (C-s and n) to the various choose modes: by name
for client and tree, and by name and content for buffer.


# 1.2 06-Jun-2017 nicm

Do not pass a state into commands when fired on individual items in tree
mode, rely on the %% target substitution in the command for the chosen
pane and leave the default target as the current pane (where the mode
is). Otherwise, joinp and similar end up with -t and -s the
same. Reported by Jacob Niehus in GitHub issue 960.


# 1.1 30-May-2017 nicm

Rewrite of choose mode, both to simplify and tidy the code and to add
some modern features.

Now the common code is in mode-tree.c, which provides an API used by the
three modes now separated into window-{buffer,client,tree}.c. Buffer
mode shows buffers, client mode clients and tree mode a tree of
sessions, windows and panes.

Each mode has a common set of key bindings plus a few that are specific
to the mode. Other changes are:

- each mode has a preview pane: for buffers this is the buffer content
(very useful), for others it is a preview of the pane;

- items may be sorted in different ways ('O' key);

- multiple items may be tagged and an operation applied to all of them
(for example, to delete multiple buffers at once);

- in tree mode a command may be run on the selected item (session,
window, pane) or on tagged items (key ':');

- displayed items may be filtered in tree mode by using a format (this
is used to implement find-window) (key 'f');

- the custom format (-F) for the display is no longer available;

- shortcut keys change from 0-9, a-z, A-Z which was always a bit weird
with keys used for other uses to 0-9, M-a to M-z.

Now that the code is simpler, other improvements will come later.

Primary key bindings for each mode are documented under the commands in
the man page (choose-buffer, choose-client, choose-tree).

Parts written by Thomas Adam.


# 1.59 20-Oct-2021 nicm

Add -T to set a popup title, from Alexis Hildebrandt in GitHub issue 2941.


# 1.58 14-Oct-2021 nicm

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


# 1.57 13-Oct-2021 nicm

Add popup-style and popup-border-style options, from Alexis Hildebrandt
in GitHub issue 2927.


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

Hide struct args behind a couple of accessor functions.


# 1.55 10-Jun-2021 nicm

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


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

Permit shortcut keys in buffer, client, tree modes to be configured with
a format; the default remains the line number. GitHub issue 2636.


# 1.53 03-Dec-2020 nicm

Redraw any visible modes when status line changes so that formats like
the pane title are updated. GitHub issue 2487. Also a man page fix from
jmc.


Revision tags: OPENBSD_6_8_BASE
# 1.52 15-Jul-2020 nicm

Renumber after killing windows for choose-tree.


# 1.51 04-Jul-2020 nicm

kill-window -a cannot just walk the list of windows because if
renumber-windows is on, the window it wants to keep could be moved.
Change to renumber afterwards and also behave better if the window is
linked into the session twice. GitHub issue 2287.


# 1.50 16-May-2020 nicm

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


# 1.49 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.48 16-May-2020 nicm

Tweak the default choose modes formats:

- Only show pane title if it is not default and not empty.
- Add a prettier time format and use that instead of long ctime().
- Remove clutter and change the order.


Revision tags: OPENBSD_6_7_BASE
# 1.47 22-Apr-2020 nicm

Indicate the marked pane in choose mode in reverse and add key to set
and clear it (m and M) and a key to jump to the starting pane (H).


# 1.46 09-Apr-2020 nicm

More style nits.


# 1.45 20-Mar-2020 nicm

Fix positioning of menu in choose modes and a couple of keys in tree mode.


# 1.44 08-Jan-2020 nicm

Add -Z to default switch-client command in tree mode, matches previous
behaviour.


# 1.43 03-Dec-2019 nicm

Style nits in function arguments.


# 1.42 15-Oct-2019 nicm

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


Revision tags: OPENBSD_6_6_BASE
# 1.41 25-Sep-2019 nicm

Style and line length nits.


# 1.40 16-Aug-2019 nicm

Add a flag to reverse sort in the various choose modes, from Benjamin
Poirier in GitHub issue 1875.


# 1.39 28-May-2019 nicm

Change display-menu from taking a single string to a set of arguments,
which is much easier to work with. Based on a diff from Avi Halachmi.


# 1.38 12-May-2019 nicm

Add simple menus to tree, client, buffer modes.


# 1.37 30-Apr-2019 nicm

Fix memory leak in window tree search, from Amos Bird.


# 1.36 17-Apr-2019 nicm

Break new window and pane creation common code from various commands and
window.c into a separate file spawn.c.


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

Add format variables for the default formats for the various modes
(tree_mode_format and so on) and add a -a flag to display-message to
list variables with values.


# 1.34 12-Mar-2019 nicm

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


# 1.33 07-Mar-2019 nicm

Add a separate mode struct for the active window mode if any.


# 1.32 18-Dec-2018 nicm

Pass window into mode functions.


Revision tags: OPENBSD_6_4_BASE
# 1.31 19-Aug-2018 nicm

Expand \u and \U escape sequences in command strings, from Christopher
Hunt in GitHub issue 1443.


# 1.30 10-Apr-2018 nicm

Add x and X to choose-tree (with a confirmation prompt) to kill an
item. Suggested by Matt Zagrabelny.


# 1.29 29-Mar-2018 nicm

Do not crash on empty window, reported by Jamie Macdonald in GitHub
issue 1299. Patch from Thomas Adam.


Revision tags: OPENBSD_6_3_BASE
# 1.28 28-Feb-2018 nicm

Add -Z flag to choose-tree, choose-client, choose-buffer to
automatically zoom the pane when the mode is entered and unzoom when it
exits, assuming the pane is not already zoomed. Add -Z to the default
key bindings.


# 1.27 03-Nov-2017 nicm

Support mouse on preview in tree mode.


# 1.26 02-Nov-2017 nicm

Make the mode draw function use the parent screen directly rather than
its own to avoid copying twice.


# 1.25 02-Nov-2017 nicm

Format for group list of "other sessions" is a bit weird, just list all
the sessions in the group.


# 1.24 02-Nov-2017 nicm

Tweak previous slightly so that current session is chosen if it is in
the group rather than first.


# 1.23 02-Nov-2017 nicm

Only show the first member of session groups in tree mode (-G flag
disables).


# 1.22 26-Oct-2017 nicm

Fix crash exiting command prompt (from Alex Maese in GitHub issue 1139)
and a man page tweak from jmc.


# 1.21 25-Oct-2017 nicm

Add P key to paste tagged in buffer mode, and trim some code that should
no longer be necessary.


# 1.20 22-Oct-2017 nicm

Use window_pane_index() when drawing pane numbers (so pane-base-index is
applied), from Thomas Adam. GitHub issue 1125.


# 1.19 11-Oct-2017 nicm

Box around label in preview.


# 1.18 11-Oct-2017 nicm

Add C-n and C-p keys for tree mode, and choose the right initial line
when no panes.


Revision tags: OPENBSD_6_2_BASE
# 1.17 30-Aug-2017 nicm

Pass flags into cmd_find_from_* to fix prefer-unattached, reported by
Thomas Sattler.


# 1.16 09-Aug-2017 nicm

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


# 1.15 09-Aug-2017 nicm

Add -F to choose-tree, choose-client, choose-buffer to specify the
format of each line, as well as adding a couple of formats needed for
the default display.


# 1.14 28-Jul-2017 nicm

Show pane title in window list for windows with only one pane.


# 1.13 12-Jul-2017 nicm

Line up keys in tree mode, and don't expand windows with one pane. From
Thomas Adam.


# 1.12 07-Jul-2017 nicm

Fix size of rightmost preview section.


# 1.11 04-Jul-2017 nicm

< and > keys to scroll preview list left and right in tree mode.


# 1.10 04-Jul-2017 nicm

Handle 0 size of preview box in caller.


# 1.9 03-Jul-2017 nicm

Change session and window preview so that the current window or pane is
always shown.


# 1.8 30-Jun-2017 nicm

Don't write over right border.


# 1.7 30-Jun-2017 nicm

Fix previous when we end up able to show no panes.


# 1.6 30-Jun-2017 nicm

Try to show a better preview of sessions and windows in tree mode.


# 1.5 09-Jun-2017 nicm

Extend filters (f key) to buffer and client mode and add -f flag to
specify to command.


# 1.4 09-Jun-2017 nicm

Add -O option to choose-* to set initial sort order.


# 1.3 07-Jun-2017 nicm

Add simple searching (C-s and n) to the various choose modes: by name
for client and tree, and by name and content for buffer.


# 1.2 06-Jun-2017 nicm

Do not pass a state into commands when fired on individual items in tree
mode, rely on the %% target substitution in the command for the chosen
pane and leave the default target as the current pane (where the mode
is). Otherwise, joinp and similar end up with -t and -s the
same. Reported by Jacob Niehus in GitHub issue 960.


# 1.1 30-May-2017 nicm

Rewrite of choose mode, both to simplify and tidy the code and to add
some modern features.

Now the common code is in mode-tree.c, which provides an API used by the
three modes now separated into window-{buffer,client,tree}.c. Buffer
mode shows buffers, client mode clients and tree mode a tree of
sessions, windows and panes.

Each mode has a common set of key bindings plus a few that are specific
to the mode. Other changes are:

- each mode has a preview pane: for buffers this is the buffer content
(very useful), for others it is a preview of the pane;

- items may be sorted in different ways ('O' key);

- multiple items may be tagged and an operation applied to all of them
(for example, to delete multiple buffers at once);

- in tree mode a command may be run on the selected item (session,
window, pane) or on tagged items (key ':');

- displayed items may be filtered in tree mode by using a format (this
is used to implement find-window) (key 'f');

- the custom format (-F) for the display is no longer available;

- shortcut keys change from 0-9, a-z, A-Z which was always a bit weird
with keys used for other uses to 0-9, M-a to M-z.

Now that the code is simpler, other improvements will come later.

Primary key bindings for each mode are documented under the commands in
the man page (choose-buffer, choose-client, choose-tree).

Parts written by Thomas Adam.


# 1.58 14-Oct-2021 nicm

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


# 1.57 13-Oct-2021 nicm

Add popup-style and popup-border-style options, from Alexis Hildebrandt
in GitHub issue 2927.


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

Hide struct args behind a couple of accessor functions.


# 1.55 10-Jun-2021 nicm

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


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

Permit shortcut keys in buffer, client, tree modes to be configured with
a format; the default remains the line number. GitHub issue 2636.


# 1.53 03-Dec-2020 nicm

Redraw any visible modes when status line changes so that formats like
the pane title are updated. GitHub issue 2487. Also a man page fix from
jmc.


Revision tags: OPENBSD_6_8_BASE
# 1.52 15-Jul-2020 nicm

Renumber after killing windows for choose-tree.


# 1.51 04-Jul-2020 nicm

kill-window -a cannot just walk the list of windows because if
renumber-windows is on, the window it wants to keep could be moved.
Change to renumber afterwards and also behave better if the window is
linked into the session twice. GitHub issue 2287.


# 1.50 16-May-2020 nicm

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


# 1.49 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.48 16-May-2020 nicm

Tweak the default choose modes formats:

- Only show pane title if it is not default and not empty.
- Add a prettier time format and use that instead of long ctime().
- Remove clutter and change the order.


Revision tags: OPENBSD_6_7_BASE
# 1.47 22-Apr-2020 nicm

Indicate the marked pane in choose mode in reverse and add key to set
and clear it (m and M) and a key to jump to the starting pane (H).


# 1.46 09-Apr-2020 nicm

More style nits.


# 1.45 20-Mar-2020 nicm

Fix positioning of menu in choose modes and a couple of keys in tree mode.


# 1.44 08-Jan-2020 nicm

Add -Z to default switch-client command in tree mode, matches previous
behaviour.


# 1.43 03-Dec-2019 nicm

Style nits in function arguments.


# 1.42 15-Oct-2019 nicm

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


Revision tags: OPENBSD_6_6_BASE
# 1.41 25-Sep-2019 nicm

Style and line length nits.


# 1.40 16-Aug-2019 nicm

Add a flag to reverse sort in the various choose modes, from Benjamin
Poirier in GitHub issue 1875.


# 1.39 28-May-2019 nicm

Change display-menu from taking a single string to a set of arguments,
which is much easier to work with. Based on a diff from Avi Halachmi.


# 1.38 12-May-2019 nicm

Add simple menus to tree, client, buffer modes.


# 1.37 30-Apr-2019 nicm

Fix memory leak in window tree search, from Amos Bird.


# 1.36 17-Apr-2019 nicm

Break new window and pane creation common code from various commands and
window.c into a separate file spawn.c.


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

Add format variables for the default formats for the various modes
(tree_mode_format and so on) and add a -a flag to display-message to
list variables with values.


# 1.34 12-Mar-2019 nicm

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


# 1.33 07-Mar-2019 nicm

Add a separate mode struct for the active window mode if any.


# 1.32 18-Dec-2018 nicm

Pass window into mode functions.


Revision tags: OPENBSD_6_4_BASE
# 1.31 19-Aug-2018 nicm

Expand \u and \U escape sequences in command strings, from Christopher
Hunt in GitHub issue 1443.


# 1.30 10-Apr-2018 nicm

Add x and X to choose-tree (with a confirmation prompt) to kill an
item. Suggested by Matt Zagrabelny.


# 1.29 29-Mar-2018 nicm

Do not crash on empty window, reported by Jamie Macdonald in GitHub
issue 1299. Patch from Thomas Adam.


Revision tags: OPENBSD_6_3_BASE
# 1.28 28-Feb-2018 nicm

Add -Z flag to choose-tree, choose-client, choose-buffer to
automatically zoom the pane when the mode is entered and unzoom when it
exits, assuming the pane is not already zoomed. Add -Z to the default
key bindings.


# 1.27 03-Nov-2017 nicm

Support mouse on preview in tree mode.


# 1.26 02-Nov-2017 nicm

Make the mode draw function use the parent screen directly rather than
its own to avoid copying twice.


# 1.25 02-Nov-2017 nicm

Format for group list of "other sessions" is a bit weird, just list all
the sessions in the group.


# 1.24 02-Nov-2017 nicm

Tweak previous slightly so that current session is chosen if it is in
the group rather than first.


# 1.23 02-Nov-2017 nicm

Only show the first member of session groups in tree mode (-G flag
disables).


# 1.22 26-Oct-2017 nicm

Fix crash exiting command prompt (from Alex Maese in GitHub issue 1139)
and a man page tweak from jmc.


# 1.21 25-Oct-2017 nicm

Add P key to paste tagged in buffer mode, and trim some code that should
no longer be necessary.


# 1.20 22-Oct-2017 nicm

Use window_pane_index() when drawing pane numbers (so pane-base-index is
applied), from Thomas Adam. GitHub issue 1125.


# 1.19 11-Oct-2017 nicm

Box around label in preview.


# 1.18 11-Oct-2017 nicm

Add C-n and C-p keys for tree mode, and choose the right initial line
when no panes.


Revision tags: OPENBSD_6_2_BASE
# 1.17 30-Aug-2017 nicm

Pass flags into cmd_find_from_* to fix prefer-unattached, reported by
Thomas Sattler.


# 1.16 09-Aug-2017 nicm

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


# 1.15 09-Aug-2017 nicm

Add -F to choose-tree, choose-client, choose-buffer to specify the
format of each line, as well as adding a couple of formats needed for
the default display.


# 1.14 28-Jul-2017 nicm

Show pane title in window list for windows with only one pane.


# 1.13 12-Jul-2017 nicm

Line up keys in tree mode, and don't expand windows with one pane. From
Thomas Adam.


# 1.12 07-Jul-2017 nicm

Fix size of rightmost preview section.


# 1.11 04-Jul-2017 nicm

< and > keys to scroll preview list left and right in tree mode.


# 1.10 04-Jul-2017 nicm

Handle 0 size of preview box in caller.


# 1.9 03-Jul-2017 nicm

Change session and window preview so that the current window or pane is
always shown.


# 1.8 30-Jun-2017 nicm

Don't write over right border.


# 1.7 30-Jun-2017 nicm

Fix previous when we end up able to show no panes.


# 1.6 30-Jun-2017 nicm

Try to show a better preview of sessions and windows in tree mode.


# 1.5 09-Jun-2017 nicm

Extend filters (f key) to buffer and client mode and add -f flag to
specify to command.


# 1.4 09-Jun-2017 nicm

Add -O option to choose-* to set initial sort order.


# 1.3 07-Jun-2017 nicm

Add simple searching (C-s and n) to the various choose modes: by name
for client and tree, and by name and content for buffer.


# 1.2 06-Jun-2017 nicm

Do not pass a state into commands when fired on individual items in tree
mode, rely on the %% target substitution in the command for the chosen
pane and leave the default target as the current pane (where the mode
is). Otherwise, joinp and similar end up with -t and -s the
same. Reported by Jacob Niehus in GitHub issue 960.


# 1.1 30-May-2017 nicm

Rewrite of choose mode, both to simplify and tidy the code and to add
some modern features.

Now the common code is in mode-tree.c, which provides an API used by the
three modes now separated into window-{buffer,client,tree}.c. Buffer
mode shows buffers, client mode clients and tree mode a tree of
sessions, windows and panes.

Each mode has a common set of key bindings plus a few that are specific
to the mode. Other changes are:

- each mode has a preview pane: for buffers this is the buffer content
(very useful), for others it is a preview of the pane;

- items may be sorted in different ways ('O' key);

- multiple items may be tagged and an operation applied to all of them
(for example, to delete multiple buffers at once);

- in tree mode a command may be run on the selected item (session,
window, pane) or on tagged items (key ':');

- displayed items may be filtered in tree mode by using a format (this
is used to implement find-window) (key 'f');

- the custom format (-F) for the display is no longer available;

- shortcut keys change from 0-9, a-z, A-Z which was always a bit weird
with keys used for other uses to 0-9, M-a to M-z.

Now that the code is simpler, other improvements will come later.

Primary key bindings for each mode are documented under the commands in
the man page (choose-buffer, choose-client, choose-tree).

Parts written by Thomas Adam.


# 1.56 20-Aug-2021 nicm

Hide struct args behind a couple of accessor functions.


# 1.55 10-Jun-2021 nicm

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


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

Permit shortcut keys in buffer, client, tree modes to be configured with
a format; the default remains the line number. GitHub issue 2636.


# 1.53 03-Dec-2020 nicm

Redraw any visible modes when status line changes so that formats like
the pane title are updated. GitHub issue 2487. Also a man page fix from
jmc.


Revision tags: OPENBSD_6_8_BASE
# 1.52 15-Jul-2020 nicm

Renumber after killing windows for choose-tree.


# 1.51 04-Jul-2020 nicm

kill-window -a cannot just walk the list of windows because if
renumber-windows is on, the window it wants to keep could be moved.
Change to renumber afterwards and also behave better if the window is
linked into the session twice. GitHub issue 2287.


# 1.50 16-May-2020 nicm

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


# 1.49 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.48 16-May-2020 nicm

Tweak the default choose modes formats:

- Only show pane title if it is not default and not empty.
- Add a prettier time format and use that instead of long ctime().
- Remove clutter and change the order.


Revision tags: OPENBSD_6_7_BASE
# 1.47 22-Apr-2020 nicm

Indicate the marked pane in choose mode in reverse and add key to set
and clear it (m and M) and a key to jump to the starting pane (H).


# 1.46 09-Apr-2020 nicm

More style nits.


# 1.45 20-Mar-2020 nicm

Fix positioning of menu in choose modes and a couple of keys in tree mode.


# 1.44 08-Jan-2020 nicm

Add -Z to default switch-client command in tree mode, matches previous
behaviour.


# 1.43 03-Dec-2019 nicm

Style nits in function arguments.


# 1.42 15-Oct-2019 nicm

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


Revision tags: OPENBSD_6_6_BASE
# 1.41 25-Sep-2019 nicm

Style and line length nits.


# 1.40 16-Aug-2019 nicm

Add a flag to reverse sort in the various choose modes, from Benjamin
Poirier in GitHub issue 1875.


# 1.39 28-May-2019 nicm

Change display-menu from taking a single string to a set of arguments,
which is much easier to work with. Based on a diff from Avi Halachmi.


# 1.38 12-May-2019 nicm

Add simple menus to tree, client, buffer modes.


# 1.37 30-Apr-2019 nicm

Fix memory leak in window tree search, from Amos Bird.


# 1.36 17-Apr-2019 nicm

Break new window and pane creation common code from various commands and
window.c into a separate file spawn.c.


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

Add format variables for the default formats for the various modes
(tree_mode_format and so on) and add a -a flag to display-message to
list variables with values.


# 1.34 12-Mar-2019 nicm

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


# 1.33 07-Mar-2019 nicm

Add a separate mode struct for the active window mode if any.


# 1.32 18-Dec-2018 nicm

Pass window into mode functions.


Revision tags: OPENBSD_6_4_BASE
# 1.31 19-Aug-2018 nicm

Expand \u and \U escape sequences in command strings, from Christopher
Hunt in GitHub issue 1443.


# 1.30 10-Apr-2018 nicm

Add x and X to choose-tree (with a confirmation prompt) to kill an
item. Suggested by Matt Zagrabelny.


# 1.29 29-Mar-2018 nicm

Do not crash on empty window, reported by Jamie Macdonald in GitHub
issue 1299. Patch from Thomas Adam.


Revision tags: OPENBSD_6_3_BASE
# 1.28 28-Feb-2018 nicm

Add -Z flag to choose-tree, choose-client, choose-buffer to
automatically zoom the pane when the mode is entered and unzoom when it
exits, assuming the pane is not already zoomed. Add -Z to the default
key bindings.


# 1.27 03-Nov-2017 nicm

Support mouse on preview in tree mode.


# 1.26 02-Nov-2017 nicm

Make the mode draw function use the parent screen directly rather than
its own to avoid copying twice.


# 1.25 02-Nov-2017 nicm

Format for group list of "other sessions" is a bit weird, just list all
the sessions in the group.


# 1.24 02-Nov-2017 nicm

Tweak previous slightly so that current session is chosen if it is in
the group rather than first.


# 1.23 02-Nov-2017 nicm

Only show the first member of session groups in tree mode (-G flag
disables).


# 1.22 26-Oct-2017 nicm

Fix crash exiting command prompt (from Alex Maese in GitHub issue 1139)
and a man page tweak from jmc.


# 1.21 25-Oct-2017 nicm

Add P key to paste tagged in buffer mode, and trim some code that should
no longer be necessary.


# 1.20 22-Oct-2017 nicm

Use window_pane_index() when drawing pane numbers (so pane-base-index is
applied), from Thomas Adam. GitHub issue 1125.


# 1.19 11-Oct-2017 nicm

Box around label in preview.


# 1.18 11-Oct-2017 nicm

Add C-n and C-p keys for tree mode, and choose the right initial line
when no panes.


Revision tags: OPENBSD_6_2_BASE
# 1.17 30-Aug-2017 nicm

Pass flags into cmd_find_from_* to fix prefer-unattached, reported by
Thomas Sattler.


# 1.16 09-Aug-2017 nicm

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


# 1.15 09-Aug-2017 nicm

Add -F to choose-tree, choose-client, choose-buffer to specify the
format of each line, as well as adding a couple of formats needed for
the default display.


# 1.14 28-Jul-2017 nicm

Show pane title in window list for windows with only one pane.


# 1.13 12-Jul-2017 nicm

Line up keys in tree mode, and don't expand windows with one pane. From
Thomas Adam.


# 1.12 07-Jul-2017 nicm

Fix size of rightmost preview section.


# 1.11 04-Jul-2017 nicm

< and > keys to scroll preview list left and right in tree mode.


# 1.10 04-Jul-2017 nicm

Handle 0 size of preview box in caller.


# 1.9 03-Jul-2017 nicm

Change session and window preview so that the current window or pane is
always shown.


# 1.8 30-Jun-2017 nicm

Don't write over right border.


# 1.7 30-Jun-2017 nicm

Fix previous when we end up able to show no panes.


# 1.6 30-Jun-2017 nicm

Try to show a better preview of sessions and windows in tree mode.


# 1.5 09-Jun-2017 nicm

Extend filters (f key) to buffer and client mode and add -f flag to
specify to command.


# 1.4 09-Jun-2017 nicm

Add -O option to choose-* to set initial sort order.


# 1.3 07-Jun-2017 nicm

Add simple searching (C-s and n) to the various choose modes: by name
for client and tree, and by name and content for buffer.


# 1.2 06-Jun-2017 nicm

Do not pass a state into commands when fired on individual items in tree
mode, rely on the %% target substitution in the command for the chosen
pane and leave the default target as the current pane (where the mode
is). Otherwise, joinp and similar end up with -t and -s the
same. Reported by Jacob Niehus in GitHub issue 960.


# 1.1 30-May-2017 nicm

Rewrite of choose mode, both to simplify and tidy the code and to add
some modern features.

Now the common code is in mode-tree.c, which provides an API used by the
three modes now separated into window-{buffer,client,tree}.c. Buffer
mode shows buffers, client mode clients and tree mode a tree of
sessions, windows and panes.

Each mode has a common set of key bindings plus a few that are specific
to the mode. Other changes are:

- each mode has a preview pane: for buffers this is the buffer content
(very useful), for others it is a preview of the pane;

- items may be sorted in different ways ('O' key);

- multiple items may be tagged and an operation applied to all of them
(for example, to delete multiple buffers at once);

- in tree mode a command may be run on the selected item (session,
window, pane) or on tagged items (key ':');

- displayed items may be filtered in tree mode by using a format (this
is used to implement find-window) (key 'f');

- the custom format (-F) for the display is no longer available;

- shortcut keys change from 0-9, a-z, A-Z which was always a bit weird
with keys used for other uses to 0-9, M-a to M-z.

Now that the code is simpler, other improvements will come later.

Primary key bindings for each mode are documented under the commands in
the man page (choose-buffer, choose-client, choose-tree).

Parts written by Thomas Adam.


# 1.55 10-Jun-2021 nicm

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


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

Permit shortcut keys in buffer, client, tree modes to be configured with
a format; the default remains the line number. GitHub issue 2636.


# 1.53 03-Dec-2020 nicm

Redraw any visible modes when status line changes so that formats like
the pane title are updated. GitHub issue 2487. Also a man page fix from
jmc.


Revision tags: OPENBSD_6_8_BASE
# 1.52 15-Jul-2020 nicm

Renumber after killing windows for choose-tree.


# 1.51 04-Jul-2020 nicm

kill-window -a cannot just walk the list of windows because if
renumber-windows is on, the window it wants to keep could be moved.
Change to renumber afterwards and also behave better if the window is
linked into the session twice. GitHub issue 2287.


# 1.50 16-May-2020 nicm

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


# 1.49 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.48 16-May-2020 nicm

Tweak the default choose modes formats:

- Only show pane title if it is not default and not empty.
- Add a prettier time format and use that instead of long ctime().
- Remove clutter and change the order.


Revision tags: OPENBSD_6_7_BASE
# 1.47 22-Apr-2020 nicm

Indicate the marked pane in choose mode in reverse and add key to set
and clear it (m and M) and a key to jump to the starting pane (H).


# 1.46 09-Apr-2020 nicm

More style nits.


# 1.45 20-Mar-2020 nicm

Fix positioning of menu in choose modes and a couple of keys in tree mode.


# 1.44 08-Jan-2020 nicm

Add -Z to default switch-client command in tree mode, matches previous
behaviour.


# 1.43 03-Dec-2019 nicm

Style nits in function arguments.


# 1.42 15-Oct-2019 nicm

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


Revision tags: OPENBSD_6_6_BASE
# 1.41 25-Sep-2019 nicm

Style and line length nits.


# 1.40 16-Aug-2019 nicm

Add a flag to reverse sort in the various choose modes, from Benjamin
Poirier in GitHub issue 1875.


# 1.39 28-May-2019 nicm

Change display-menu from taking a single string to a set of arguments,
which is much easier to work with. Based on a diff from Avi Halachmi.


# 1.38 12-May-2019 nicm

Add simple menus to tree, client, buffer modes.


# 1.37 30-Apr-2019 nicm

Fix memory leak in window tree search, from Amos Bird.


# 1.36 17-Apr-2019 nicm

Break new window and pane creation common code from various commands and
window.c into a separate file spawn.c.


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

Add format variables for the default formats for the various modes
(tree_mode_format and so on) and add a -a flag to display-message to
list variables with values.


# 1.34 12-Mar-2019 nicm

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


# 1.33 07-Mar-2019 nicm

Add a separate mode struct for the active window mode if any.


# 1.32 18-Dec-2018 nicm

Pass window into mode functions.


Revision tags: OPENBSD_6_4_BASE
# 1.31 19-Aug-2018 nicm

Expand \u and \U escape sequences in command strings, from Christopher
Hunt in GitHub issue 1443.


# 1.30 10-Apr-2018 nicm

Add x and X to choose-tree (with a confirmation prompt) to kill an
item. Suggested by Matt Zagrabelny.


# 1.29 29-Mar-2018 nicm

Do not crash on empty window, reported by Jamie Macdonald in GitHub
issue 1299. Patch from Thomas Adam.


Revision tags: OPENBSD_6_3_BASE
# 1.28 28-Feb-2018 nicm

Add -Z flag to choose-tree, choose-client, choose-buffer to
automatically zoom the pane when the mode is entered and unzoom when it
exits, assuming the pane is not already zoomed. Add -Z to the default
key bindings.


# 1.27 03-Nov-2017 nicm

Support mouse on preview in tree mode.


# 1.26 02-Nov-2017 nicm

Make the mode draw function use the parent screen directly rather than
its own to avoid copying twice.


# 1.25 02-Nov-2017 nicm

Format for group list of "other sessions" is a bit weird, just list all
the sessions in the group.


# 1.24 02-Nov-2017 nicm

Tweak previous slightly so that current session is chosen if it is in
the group rather than first.


# 1.23 02-Nov-2017 nicm

Only show the first member of session groups in tree mode (-G flag
disables).


# 1.22 26-Oct-2017 nicm

Fix crash exiting command prompt (from Alex Maese in GitHub issue 1139)
and a man page tweak from jmc.


# 1.21 25-Oct-2017 nicm

Add P key to paste tagged in buffer mode, and trim some code that should
no longer be necessary.


# 1.20 22-Oct-2017 nicm

Use window_pane_index() when drawing pane numbers (so pane-base-index is
applied), from Thomas Adam. GitHub issue 1125.


# 1.19 11-Oct-2017 nicm

Box around label in preview.


# 1.18 11-Oct-2017 nicm

Add C-n and C-p keys for tree mode, and choose the right initial line
when no panes.


Revision tags: OPENBSD_6_2_BASE
# 1.17 30-Aug-2017 nicm

Pass flags into cmd_find_from_* to fix prefer-unattached, reported by
Thomas Sattler.


# 1.16 09-Aug-2017 nicm

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


# 1.15 09-Aug-2017 nicm

Add -F to choose-tree, choose-client, choose-buffer to specify the
format of each line, as well as adding a couple of formats needed for
the default display.


# 1.14 28-Jul-2017 nicm

Show pane title in window list for windows with only one pane.


# 1.13 12-Jul-2017 nicm

Line up keys in tree mode, and don't expand windows with one pane. From
Thomas Adam.


# 1.12 07-Jul-2017 nicm

Fix size of rightmost preview section.


# 1.11 04-Jul-2017 nicm

< and > keys to scroll preview list left and right in tree mode.


# 1.10 04-Jul-2017 nicm

Handle 0 size of preview box in caller.


# 1.9 03-Jul-2017 nicm

Change session and window preview so that the current window or pane is
always shown.


# 1.8 30-Jun-2017 nicm

Don't write over right border.


# 1.7 30-Jun-2017 nicm

Fix previous when we end up able to show no panes.


# 1.6 30-Jun-2017 nicm

Try to show a better preview of sessions and windows in tree mode.


# 1.5 09-Jun-2017 nicm

Extend filters (f key) to buffer and client mode and add -f flag to
specify to command.


# 1.4 09-Jun-2017 nicm

Add -O option to choose-* to set initial sort order.


# 1.3 07-Jun-2017 nicm

Add simple searching (C-s and n) to the various choose modes: by name
for client and tree, and by name and content for buffer.


# 1.2 06-Jun-2017 nicm

Do not pass a state into commands when fired on individual items in tree
mode, rely on the %% target substitution in the command for the chosen
pane and leave the default target as the current pane (where the mode
is). Otherwise, joinp and similar end up with -t and -s the
same. Reported by Jacob Niehus in GitHub issue 960.


# 1.1 30-May-2017 nicm

Rewrite of choose mode, both to simplify and tidy the code and to add
some modern features.

Now the common code is in mode-tree.c, which provides an API used by the
three modes now separated into window-{buffer,client,tree}.c. Buffer
mode shows buffers, client mode clients and tree mode a tree of
sessions, windows and panes.

Each mode has a common set of key bindings plus a few that are specific
to the mode. Other changes are:

- each mode has a preview pane: for buffers this is the buffer content
(very useful), for others it is a preview of the pane;

- items may be sorted in different ways ('O' key);

- multiple items may be tagged and an operation applied to all of them
(for example, to delete multiple buffers at once);

- in tree mode a command may be run on the selected item (session,
window, pane) or on tagged items (key ':');

- displayed items may be filtered in tree mode by using a format (this
is used to implement find-window) (key 'f');

- the custom format (-F) for the display is no longer available;

- shortcut keys change from 0-9, a-z, A-Z which was always a bit weird
with keys used for other uses to 0-9, M-a to M-z.

Now that the code is simpler, other improvements will come later.

Primary key bindings for each mode are documented under the commands in
the man page (choose-buffer, choose-client, choose-tree).

Parts written by Thomas Adam.


# 1.54 12-Apr-2021 nicm

Permit shortcut keys in buffer, client, tree modes to be configured with
a format; the default remains the line number. GitHub issue 2636.


# 1.53 03-Dec-2020 nicm

Redraw any visible modes when status line changes so that formats like
the pane title are updated. GitHub issue 2487. Also a man page fix from
jmc.


Revision tags: OPENBSD_6_8_BASE
# 1.52 15-Jul-2020 nicm

Renumber after killing windows for choose-tree.


# 1.51 04-Jul-2020 nicm

kill-window -a cannot just walk the list of windows because if
renumber-windows is on, the window it wants to keep could be moved.
Change to renumber afterwards and also behave better if the window is
linked into the session twice. GitHub issue 2287.


# 1.50 16-May-2020 nicm

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


# 1.49 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.48 16-May-2020 nicm

Tweak the default choose modes formats:

- Only show pane title if it is not default and not empty.
- Add a prettier time format and use that instead of long ctime().
- Remove clutter and change the order.


Revision tags: OPENBSD_6_7_BASE
# 1.47 22-Apr-2020 nicm

Indicate the marked pane in choose mode in reverse and add key to set
and clear it (m and M) and a key to jump to the starting pane (H).


# 1.46 09-Apr-2020 nicm

More style nits.


# 1.45 20-Mar-2020 nicm

Fix positioning of menu in choose modes and a couple of keys in tree mode.


# 1.44 08-Jan-2020 nicm

Add -Z to default switch-client command in tree mode, matches previous
behaviour.


# 1.43 03-Dec-2019 nicm

Style nits in function arguments.


# 1.42 15-Oct-2019 nicm

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


Revision tags: OPENBSD_6_6_BASE
# 1.41 25-Sep-2019 nicm

Style and line length nits.


# 1.40 16-Aug-2019 nicm

Add a flag to reverse sort in the various choose modes, from Benjamin
Poirier in GitHub issue 1875.


# 1.39 28-May-2019 nicm

Change display-menu from taking a single string to a set of arguments,
which is much easier to work with. Based on a diff from Avi Halachmi.


# 1.38 12-May-2019 nicm

Add simple menus to tree, client, buffer modes.


# 1.37 30-Apr-2019 nicm

Fix memory leak in window tree search, from Amos Bird.


# 1.36 17-Apr-2019 nicm

Break new window and pane creation common code from various commands and
window.c into a separate file spawn.c.


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

Add format variables for the default formats for the various modes
(tree_mode_format and so on) and add a -a flag to display-message to
list variables with values.


# 1.34 12-Mar-2019 nicm

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


# 1.33 07-Mar-2019 nicm

Add a separate mode struct for the active window mode if any.


# 1.32 18-Dec-2018 nicm

Pass window into mode functions.


Revision tags: OPENBSD_6_4_BASE
# 1.31 19-Aug-2018 nicm

Expand \u and \U escape sequences in command strings, from Christopher
Hunt in GitHub issue 1443.


# 1.30 10-Apr-2018 nicm

Add x and X to choose-tree (with a confirmation prompt) to kill an
item. Suggested by Matt Zagrabelny.


# 1.29 29-Mar-2018 nicm

Do not crash on empty window, reported by Jamie Macdonald in GitHub
issue 1299. Patch from Thomas Adam.


Revision tags: OPENBSD_6_3_BASE
# 1.28 28-Feb-2018 nicm

Add -Z flag to choose-tree, choose-client, choose-buffer to
automatically zoom the pane when the mode is entered and unzoom when it
exits, assuming the pane is not already zoomed. Add -Z to the default
key bindings.


# 1.27 03-Nov-2017 nicm

Support mouse on preview in tree mode.


# 1.26 02-Nov-2017 nicm

Make the mode draw function use the parent screen directly rather than
its own to avoid copying twice.


# 1.25 02-Nov-2017 nicm

Format for group list of "other sessions" is a bit weird, just list all
the sessions in the group.


# 1.24 02-Nov-2017 nicm

Tweak previous slightly so that current session is chosen if it is in
the group rather than first.


# 1.23 02-Nov-2017 nicm

Only show the first member of session groups in tree mode (-G flag
disables).


# 1.22 26-Oct-2017 nicm

Fix crash exiting command prompt (from Alex Maese in GitHub issue 1139)
and a man page tweak from jmc.


# 1.21 25-Oct-2017 nicm

Add P key to paste tagged in buffer mode, and trim some code that should
no longer be necessary.


# 1.20 22-Oct-2017 nicm

Use window_pane_index() when drawing pane numbers (so pane-base-index is
applied), from Thomas Adam. GitHub issue 1125.


# 1.19 11-Oct-2017 nicm

Box around label in preview.


# 1.18 11-Oct-2017 nicm

Add C-n and C-p keys for tree mode, and choose the right initial line
when no panes.


Revision tags: OPENBSD_6_2_BASE
# 1.17 30-Aug-2017 nicm

Pass flags into cmd_find_from_* to fix prefer-unattached, reported by
Thomas Sattler.


# 1.16 09-Aug-2017 nicm

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


# 1.15 09-Aug-2017 nicm

Add -F to choose-tree, choose-client, choose-buffer to specify the
format of each line, as well as adding a couple of formats needed for
the default display.


# 1.14 28-Jul-2017 nicm

Show pane title in window list for windows with only one pane.


# 1.13 12-Jul-2017 nicm

Line up keys in tree mode, and don't expand windows with one pane. From
Thomas Adam.


# 1.12 07-Jul-2017 nicm

Fix size of rightmost preview section.


# 1.11 04-Jul-2017 nicm

< and > keys to scroll preview list left and right in tree mode.


# 1.10 04-Jul-2017 nicm

Handle 0 size of preview box in caller.


# 1.9 03-Jul-2017 nicm

Change session and window preview so that the current window or pane is
always shown.


# 1.8 30-Jun-2017 nicm

Don't write over right border.


# 1.7 30-Jun-2017 nicm

Fix previous when we end up able to show no panes.


# 1.6 30-Jun-2017 nicm

Try to show a better preview of sessions and windows in tree mode.


# 1.5 09-Jun-2017 nicm

Extend filters (f key) to buffer and client mode and add -f flag to
specify to command.


# 1.4 09-Jun-2017 nicm

Add -O option to choose-* to set initial sort order.


# 1.3 07-Jun-2017 nicm

Add simple searching (C-s and n) to the various choose modes: by name
for client and tree, and by name and content for buffer.


# 1.2 06-Jun-2017 nicm

Do not pass a state into commands when fired on individual items in tree
mode, rely on the %% target substitution in the command for the chosen
pane and leave the default target as the current pane (where the mode
is). Otherwise, joinp and similar end up with -t and -s the
same. Reported by Jacob Niehus in GitHub issue 960.


# 1.1 30-May-2017 nicm

Rewrite of choose mode, both to simplify and tidy the code and to add
some modern features.

Now the common code is in mode-tree.c, which provides an API used by the
three modes now separated into window-{buffer,client,tree}.c. Buffer
mode shows buffers, client mode clients and tree mode a tree of
sessions, windows and panes.

Each mode has a common set of key bindings plus a few that are specific
to the mode. Other changes are:

- each mode has a preview pane: for buffers this is the buffer content
(very useful), for others it is a preview of the pane;

- items may be sorted in different ways ('O' key);

- multiple items may be tagged and an operation applied to all of them
(for example, to delete multiple buffers at once);

- in tree mode a command may be run on the selected item (session,
window, pane) or on tagged items (key ':');

- displayed items may be filtered in tree mode by using a format (this
is used to implement find-window) (key 'f');

- the custom format (-F) for the display is no longer available;

- shortcut keys change from 0-9, a-z, A-Z which was always a bit weird
with keys used for other uses to 0-9, M-a to M-z.

Now that the code is simpler, other improvements will come later.

Primary key bindings for each mode are documented under the commands in
the man page (choose-buffer, choose-client, choose-tree).

Parts written by Thomas Adam.


# 1.53 03-Dec-2020 nicm

Redraw any visible modes when status line changes so that formats like
the pane title are updated. GitHub issue 2487. Also a man page fix from
jmc.


Revision tags: OPENBSD_6_8_BASE
# 1.52 15-Jul-2020 nicm

Renumber after killing windows for choose-tree.


# 1.51 04-Jul-2020 nicm

kill-window -a cannot just walk the list of windows because if
renumber-windows is on, the window it wants to keep could be moved.
Change to renumber afterwards and also behave better if the window is
linked into the session twice. GitHub issue 2287.


# 1.50 16-May-2020 nicm

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


# 1.49 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.48 16-May-2020 nicm

Tweak the default choose modes formats:

- Only show pane title if it is not default and not empty.
- Add a prettier time format and use that instead of long ctime().
- Remove clutter and change the order.


Revision tags: OPENBSD_6_7_BASE
# 1.47 22-Apr-2020 nicm

Indicate the marked pane in choose mode in reverse and add key to set
and clear it (m and M) and a key to jump to the starting pane (H).


# 1.46 09-Apr-2020 nicm

More style nits.


# 1.45 20-Mar-2020 nicm

Fix positioning of menu in choose modes and a couple of keys in tree mode.


# 1.44 08-Jan-2020 nicm

Add -Z to default switch-client command in tree mode, matches previous
behaviour.


# 1.43 03-Dec-2019 nicm

Style nits in function arguments.


# 1.42 15-Oct-2019 nicm

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


Revision tags: OPENBSD_6_6_BASE
# 1.41 25-Sep-2019 nicm

Style and line length nits.


# 1.40 16-Aug-2019 nicm

Add a flag to reverse sort in the various choose modes, from Benjamin
Poirier in GitHub issue 1875.


# 1.39 28-May-2019 nicm

Change display-menu from taking a single string to a set of arguments,
which is much easier to work with. Based on a diff from Avi Halachmi.


# 1.38 12-May-2019 nicm

Add simple menus to tree, client, buffer modes.


# 1.37 30-Apr-2019 nicm

Fix memory leak in window tree search, from Amos Bird.


# 1.36 17-Apr-2019 nicm

Break new window and pane creation common code from various commands and
window.c into a separate file spawn.c.


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

Add format variables for the default formats for the various modes
(tree_mode_format and so on) and add a -a flag to display-message to
list variables with values.


# 1.34 12-Mar-2019 nicm

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


# 1.33 07-Mar-2019 nicm

Add a separate mode struct for the active window mode if any.


# 1.32 18-Dec-2018 nicm

Pass window into mode functions.


Revision tags: OPENBSD_6_4_BASE
# 1.31 19-Aug-2018 nicm

Expand \u and \U escape sequences in command strings, from Christopher
Hunt in GitHub issue 1443.


# 1.30 10-Apr-2018 nicm

Add x and X to choose-tree (with a confirmation prompt) to kill an
item. Suggested by Matt Zagrabelny.


# 1.29 29-Mar-2018 nicm

Do not crash on empty window, reported by Jamie Macdonald in GitHub
issue 1299. Patch from Thomas Adam.


Revision tags: OPENBSD_6_3_BASE
# 1.28 28-Feb-2018 nicm

Add -Z flag to choose-tree, choose-client, choose-buffer to
automatically zoom the pane when the mode is entered and unzoom when it
exits, assuming the pane is not already zoomed. Add -Z to the default
key bindings.


# 1.27 03-Nov-2017 nicm

Support mouse on preview in tree mode.


# 1.26 02-Nov-2017 nicm

Make the mode draw function use the parent screen directly rather than
its own to avoid copying twice.


# 1.25 02-Nov-2017 nicm

Format for group list of "other sessions" is a bit weird, just list all
the sessions in the group.


# 1.24 02-Nov-2017 nicm

Tweak previous slightly so that current session is chosen if it is in
the group rather than first.


# 1.23 02-Nov-2017 nicm

Only show the first member of session groups in tree mode (-G flag
disables).


# 1.22 26-Oct-2017 nicm

Fix crash exiting command prompt (from Alex Maese in GitHub issue 1139)
and a man page tweak from jmc.


# 1.21 25-Oct-2017 nicm

Add P key to paste tagged in buffer mode, and trim some code that should
no longer be necessary.


# 1.20 22-Oct-2017 nicm

Use window_pane_index() when drawing pane numbers (so pane-base-index is
applied), from Thomas Adam. GitHub issue 1125.


# 1.19 11-Oct-2017 nicm

Box around label in preview.


# 1.18 11-Oct-2017 nicm

Add C-n and C-p keys for tree mode, and choose the right initial line
when no panes.


Revision tags: OPENBSD_6_2_BASE
# 1.17 30-Aug-2017 nicm

Pass flags into cmd_find_from_* to fix prefer-unattached, reported by
Thomas Sattler.


# 1.16 09-Aug-2017 nicm

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


# 1.15 09-Aug-2017 nicm

Add -F to choose-tree, choose-client, choose-buffer to specify the
format of each line, as well as adding a couple of formats needed for
the default display.


# 1.14 28-Jul-2017 nicm

Show pane title in window list for windows with only one pane.


# 1.13 12-Jul-2017 nicm

Line up keys in tree mode, and don't expand windows with one pane. From
Thomas Adam.


# 1.12 07-Jul-2017 nicm

Fix size of rightmost preview section.


# 1.11 04-Jul-2017 nicm

< and > keys to scroll preview list left and right in tree mode.


# 1.10 04-Jul-2017 nicm

Handle 0 size of preview box in caller.


# 1.9 03-Jul-2017 nicm

Change session and window preview so that the current window or pane is
always shown.


# 1.8 30-Jun-2017 nicm

Don't write over right border.


# 1.7 30-Jun-2017 nicm

Fix previous when we end up able to show no panes.


# 1.6 30-Jun-2017 nicm

Try to show a better preview of sessions and windows in tree mode.


# 1.5 09-Jun-2017 nicm

Extend filters (f key) to buffer and client mode and add -f flag to
specify to command.


# 1.4 09-Jun-2017 nicm

Add -O option to choose-* to set initial sort order.


# 1.3 07-Jun-2017 nicm

Add simple searching (C-s and n) to the various choose modes: by name
for client and tree, and by name and content for buffer.


# 1.2 06-Jun-2017 nicm

Do not pass a state into commands when fired on individual items in tree
mode, rely on the %% target substitution in the command for the chosen
pane and leave the default target as the current pane (where the mode
is). Otherwise, joinp and similar end up with -t and -s the
same. Reported by Jacob Niehus in GitHub issue 960.


# 1.1 30-May-2017 nicm

Rewrite of choose mode, both to simplify and tidy the code and to add
some modern features.

Now the common code is in mode-tree.c, which provides an API used by the
three modes now separated into window-{buffer,client,tree}.c. Buffer
mode shows buffers, client mode clients and tree mode a tree of
sessions, windows and panes.

Each mode has a common set of key bindings plus a few that are specific
to the mode. Other changes are:

- each mode has a preview pane: for buffers this is the buffer content
(very useful), for others it is a preview of the pane;

- items may be sorted in different ways ('O' key);

- multiple items may be tagged and an operation applied to all of them
(for example, to delete multiple buffers at once);

- in tree mode a command may be run on the selected item (session,
window, pane) or on tagged items (key ':');

- displayed items may be filtered in tree mode by using a format (this
is used to implement find-window) (key 'f');

- the custom format (-F) for the display is no longer available;

- shortcut keys change from 0-9, a-z, A-Z which was always a bit weird
with keys used for other uses to 0-9, M-a to M-z.

Now that the code is simpler, other improvements will come later.

Primary key bindings for each mode are documented under the commands in
the man page (choose-buffer, choose-client, choose-tree).

Parts written by Thomas Adam.


# 1.52 15-Jul-2020 nicm

Renumber after killing windows for choose-tree.


# 1.51 04-Jul-2020 nicm

kill-window -a cannot just walk the list of windows because if
renumber-windows is on, the window it wants to keep could be moved.
Change to renumber afterwards and also behave better if the window is
linked into the session twice. GitHub issue 2287.


# 1.50 16-May-2020 nicm

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


# 1.49 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.48 16-May-2020 nicm

Tweak the default choose modes formats:

- Only show pane title if it is not default and not empty.
- Add a prettier time format and use that instead of long ctime().
- Remove clutter and change the order.


Revision tags: OPENBSD_6_7_BASE
# 1.47 22-Apr-2020 nicm

Indicate the marked pane in choose mode in reverse and add key to set
and clear it (m and M) and a key to jump to the starting pane (H).


# 1.46 09-Apr-2020 nicm

More style nits.


# 1.45 20-Mar-2020 nicm

Fix positioning of menu in choose modes and a couple of keys in tree mode.


# 1.44 08-Jan-2020 nicm

Add -Z to default switch-client command in tree mode, matches previous
behaviour.


# 1.43 03-Dec-2019 nicm

Style nits in function arguments.


# 1.42 15-Oct-2019 nicm

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


Revision tags: OPENBSD_6_6_BASE
# 1.41 25-Sep-2019 nicm

Style and line length nits.


# 1.40 16-Aug-2019 nicm

Add a flag to reverse sort in the various choose modes, from Benjamin
Poirier in GitHub issue 1875.


# 1.39 28-May-2019 nicm

Change display-menu from taking a single string to a set of arguments,
which is much easier to work with. Based on a diff from Avi Halachmi.


# 1.38 12-May-2019 nicm

Add simple menus to tree, client, buffer modes.


# 1.37 30-Apr-2019 nicm

Fix memory leak in window tree search, from Amos Bird.


# 1.36 17-Apr-2019 nicm

Break new window and pane creation common code from various commands and
window.c into a separate file spawn.c.


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

Add format variables for the default formats for the various modes
(tree_mode_format and so on) and add a -a flag to display-message to
list variables with values.


# 1.34 12-Mar-2019 nicm

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


# 1.33 07-Mar-2019 nicm

Add a separate mode struct for the active window mode if any.


# 1.32 18-Dec-2018 nicm

Pass window into mode functions.


Revision tags: OPENBSD_6_4_BASE
# 1.31 19-Aug-2018 nicm

Expand \u and \U escape sequences in command strings, from Christopher
Hunt in GitHub issue 1443.


# 1.30 10-Apr-2018 nicm

Add x and X to choose-tree (with a confirmation prompt) to kill an
item. Suggested by Matt Zagrabelny.


# 1.29 29-Mar-2018 nicm

Do not crash on empty window, reported by Jamie Macdonald in GitHub
issue 1299. Patch from Thomas Adam.


Revision tags: OPENBSD_6_3_BASE
# 1.28 28-Feb-2018 nicm

Add -Z flag to choose-tree, choose-client, choose-buffer to
automatically zoom the pane when the mode is entered and unzoom when it
exits, assuming the pane is not already zoomed. Add -Z to the default
key bindings.


# 1.27 03-Nov-2017 nicm

Support mouse on preview in tree mode.


# 1.26 02-Nov-2017 nicm

Make the mode draw function use the parent screen directly rather than
its own to avoid copying twice.


# 1.25 02-Nov-2017 nicm

Format for group list of "other sessions" is a bit weird, just list all
the sessions in the group.


# 1.24 02-Nov-2017 nicm

Tweak previous slightly so that current session is chosen if it is in
the group rather than first.


# 1.23 02-Nov-2017 nicm

Only show the first member of session groups in tree mode (-G flag
disables).


# 1.22 26-Oct-2017 nicm

Fix crash exiting command prompt (from Alex Maese in GitHub issue 1139)
and a man page tweak from jmc.


# 1.21 25-Oct-2017 nicm

Add P key to paste tagged in buffer mode, and trim some code that should
no longer be necessary.


# 1.20 22-Oct-2017 nicm

Use window_pane_index() when drawing pane numbers (so pane-base-index is
applied), from Thomas Adam. GitHub issue 1125.


# 1.19 11-Oct-2017 nicm

Box around label in preview.


# 1.18 11-Oct-2017 nicm

Add C-n and C-p keys for tree mode, and choose the right initial line
when no panes.


Revision tags: OPENBSD_6_2_BASE
# 1.17 30-Aug-2017 nicm

Pass flags into cmd_find_from_* to fix prefer-unattached, reported by
Thomas Sattler.


# 1.16 09-Aug-2017 nicm

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


# 1.15 09-Aug-2017 nicm

Add -F to choose-tree, choose-client, choose-buffer to specify the
format of each line, as well as adding a couple of formats needed for
the default display.


# 1.14 28-Jul-2017 nicm

Show pane title in window list for windows with only one pane.


# 1.13 12-Jul-2017 nicm

Line up keys in tree mode, and don't expand windows with one pane. From
Thomas Adam.


# 1.12 07-Jul-2017 nicm

Fix size of rightmost preview section.


# 1.11 04-Jul-2017 nicm

< and > keys to scroll preview list left and right in tree mode.


# 1.10 04-Jul-2017 nicm

Handle 0 size of preview box in caller.


# 1.9 03-Jul-2017 nicm

Change session and window preview so that the current window or pane is
always shown.


# 1.8 30-Jun-2017 nicm

Don't write over right border.


# 1.7 30-Jun-2017 nicm

Fix previous when we end up able to show no panes.


# 1.6 30-Jun-2017 nicm

Try to show a better preview of sessions and windows in tree mode.


# 1.5 09-Jun-2017 nicm

Extend filters (f key) to buffer and client mode and add -f flag to
specify to command.


# 1.4 09-Jun-2017 nicm

Add -O option to choose-* to set initial sort order.


# 1.3 07-Jun-2017 nicm

Add simple searching (C-s and n) to the various choose modes: by name
for client and tree, and by name and content for buffer.


# 1.2 06-Jun-2017 nicm

Do not pass a state into commands when fired on individual items in tree
mode, rely on the %% target substitution in the command for the chosen
pane and leave the default target as the current pane (where the mode
is). Otherwise, joinp and similar end up with -t and -s the
same. Reported by Jacob Niehus in GitHub issue 960.


# 1.1 30-May-2017 nicm

Rewrite of choose mode, both to simplify and tidy the code and to add
some modern features.

Now the common code is in mode-tree.c, which provides an API used by the
three modes now separated into window-{buffer,client,tree}.c. Buffer
mode shows buffers, client mode clients and tree mode a tree of
sessions, windows and panes.

Each mode has a common set of key bindings plus a few that are specific
to the mode. Other changes are:

- each mode has a preview pane: for buffers this is the buffer content
(very useful), for others it is a preview of the pane;

- items may be sorted in different ways ('O' key);

- multiple items may be tagged and an operation applied to all of them
(for example, to delete multiple buffers at once);

- in tree mode a command may be run on the selected item (session,
window, pane) or on tagged items (key ':');

- displayed items may be filtered in tree mode by using a format (this
is used to implement find-window) (key 'f');

- the custom format (-F) for the display is no longer available;

- shortcut keys change from 0-9, a-z, A-Z which was always a bit weird
with keys used for other uses to 0-9, M-a to M-z.

Now that the code is simpler, other improvements will come later.

Primary key bindings for each mode are documented under the commands in
the man page (choose-buffer, choose-client, choose-tree).

Parts written by Thomas Adam.


# 1.51 04-Jul-2020 nicm

kill-window -a cannot just walk the list of windows because if
renumber-windows is on, the window it wants to keep could be moved.
Change to renumber afterwards and also behave better if the window is
linked into the session twice. GitHub issue 2287.


# 1.50 16-May-2020 nicm

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


# 1.49 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.48 16-May-2020 nicm

Tweak the default choose modes formats:

- Only show pane title if it is not default and not empty.
- Add a prettier time format and use that instead of long ctime().
- Remove clutter and change the order.


Revision tags: OPENBSD_6_7_BASE
# 1.47 22-Apr-2020 nicm

Indicate the marked pane in choose mode in reverse and add key to set
and clear it (m and M) and a key to jump to the starting pane (H).


# 1.46 09-Apr-2020 nicm

More style nits.


# 1.45 20-Mar-2020 nicm

Fix positioning of menu in choose modes and a couple of keys in tree mode.


# 1.44 08-Jan-2020 nicm

Add -Z to default switch-client command in tree mode, matches previous
behaviour.


# 1.43 03-Dec-2019 nicm

Style nits in function arguments.


# 1.42 15-Oct-2019 nicm

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


Revision tags: OPENBSD_6_6_BASE
# 1.41 25-Sep-2019 nicm

Style and line length nits.


# 1.40 16-Aug-2019 nicm

Add a flag to reverse sort in the various choose modes, from Benjamin
Poirier in GitHub issue 1875.


# 1.39 28-May-2019 nicm

Change display-menu from taking a single string to a set of arguments,
which is much easier to work with. Based on a diff from Avi Halachmi.


# 1.38 12-May-2019 nicm

Add simple menus to tree, client, buffer modes.


# 1.37 30-Apr-2019 nicm

Fix memory leak in window tree search, from Amos Bird.


# 1.36 17-Apr-2019 nicm

Break new window and pane creation common code from various commands and
window.c into a separate file spawn.c.


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

Add format variables for the default formats for the various modes
(tree_mode_format and so on) and add a -a flag to display-message to
list variables with values.


# 1.34 12-Mar-2019 nicm

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


# 1.33 07-Mar-2019 nicm

Add a separate mode struct for the active window mode if any.


# 1.32 18-Dec-2018 nicm

Pass window into mode functions.


Revision tags: OPENBSD_6_4_BASE
# 1.31 19-Aug-2018 nicm

Expand \u and \U escape sequences in command strings, from Christopher
Hunt in GitHub issue 1443.


# 1.30 10-Apr-2018 nicm

Add x and X to choose-tree (with a confirmation prompt) to kill an
item. Suggested by Matt Zagrabelny.


# 1.29 29-Mar-2018 nicm

Do not crash on empty window, reported by Jamie Macdonald in GitHub
issue 1299. Patch from Thomas Adam.


Revision tags: OPENBSD_6_3_BASE
# 1.28 28-Feb-2018 nicm

Add -Z flag to choose-tree, choose-client, choose-buffer to
automatically zoom the pane when the mode is entered and unzoom when it
exits, assuming the pane is not already zoomed. Add -Z to the default
key bindings.


# 1.27 03-Nov-2017 nicm

Support mouse on preview in tree mode.


# 1.26 02-Nov-2017 nicm

Make the mode draw function use the parent screen directly rather than
its own to avoid copying twice.


# 1.25 02-Nov-2017 nicm

Format for group list of "other sessions" is a bit weird, just list all
the sessions in the group.


# 1.24 02-Nov-2017 nicm

Tweak previous slightly so that current session is chosen if it is in
the group rather than first.


# 1.23 02-Nov-2017 nicm

Only show the first member of session groups in tree mode (-G flag
disables).


# 1.22 26-Oct-2017 nicm

Fix crash exiting command prompt (from Alex Maese in GitHub issue 1139)
and a man page tweak from jmc.


# 1.21 25-Oct-2017 nicm

Add P key to paste tagged in buffer mode, and trim some code that should
no longer be necessary.


# 1.20 22-Oct-2017 nicm

Use window_pane_index() when drawing pane numbers (so pane-base-index is
applied), from Thomas Adam. GitHub issue 1125.


# 1.19 11-Oct-2017 nicm

Box around label in preview.


# 1.18 11-Oct-2017 nicm

Add C-n and C-p keys for tree mode, and choose the right initial line
when no panes.


Revision tags: OPENBSD_6_2_BASE
# 1.17 30-Aug-2017 nicm

Pass flags into cmd_find_from_* to fix prefer-unattached, reported by
Thomas Sattler.


# 1.16 09-Aug-2017 nicm

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


# 1.15 09-Aug-2017 nicm

Add -F to choose-tree, choose-client, choose-buffer to specify the
format of each line, as well as adding a couple of formats needed for
the default display.


# 1.14 28-Jul-2017 nicm

Show pane title in window list for windows with only one pane.


# 1.13 12-Jul-2017 nicm

Line up keys in tree mode, and don't expand windows with one pane. From
Thomas Adam.


# 1.12 07-Jul-2017 nicm

Fix size of rightmost preview section.


# 1.11 04-Jul-2017 nicm

< and > keys to scroll preview list left and right in tree mode.


# 1.10 04-Jul-2017 nicm

Handle 0 size of preview box in caller.


# 1.9 03-Jul-2017 nicm

Change session and window preview so that the current window or pane is
always shown.


# 1.8 30-Jun-2017 nicm

Don't write over right border.


# 1.7 30-Jun-2017 nicm

Fix previous when we end up able to show no panes.


# 1.6 30-Jun-2017 nicm

Try to show a better preview of sessions and windows in tree mode.


# 1.5 09-Jun-2017 nicm

Extend filters (f key) to buffer and client mode and add -f flag to
specify to command.


# 1.4 09-Jun-2017 nicm

Add -O option to choose-* to set initial sort order.


# 1.3 07-Jun-2017 nicm

Add simple searching (C-s and n) to the various choose modes: by name
for client and tree, and by name and content for buffer.


# 1.2 06-Jun-2017 nicm

Do not pass a state into commands when fired on individual items in tree
mode, rely on the %% target substitution in the command for the chosen
pane and leave the default target as the current pane (where the mode
is). Otherwise, joinp and similar end up with -t and -s the
same. Reported by Jacob Niehus in GitHub issue 960.


# 1.1 30-May-2017 nicm

Rewrite of choose mode, both to simplify and tidy the code and to add
some modern features.

Now the common code is in mode-tree.c, which provides an API used by the
three modes now separated into window-{buffer,client,tree}.c. Buffer
mode shows buffers, client mode clients and tree mode a tree of
sessions, windows and panes.

Each mode has a common set of key bindings plus a few that are specific
to the mode. Other changes are:

- each mode has a preview pane: for buffers this is the buffer content
(very useful), for others it is a preview of the pane;

- items may be sorted in different ways ('O' key);

- multiple items may be tagged and an operation applied to all of them
(for example, to delete multiple buffers at once);

- in tree mode a command may be run on the selected item (session,
window, pane) or on tagged items (key ':');

- displayed items may be filtered in tree mode by using a format (this
is used to implement find-window) (key 'f');

- the custom format (-F) for the display is no longer available;

- shortcut keys change from 0-9, a-z, A-Z which was always a bit weird
with keys used for other uses to 0-9, M-a to M-z.

Now that the code is simpler, other improvements will come later.

Primary key bindings for each mode are documented under the commands in
the man page (choose-buffer, choose-client, choose-tree).

Parts written by Thomas Adam.


# 1.50 16-May-2020 nicm

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


# 1.49 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.48 16-May-2020 nicm

Tweak the default choose modes formats:

- Only show pane title if it is not default and not empty.
- Add a prettier time format and use that instead of long ctime().
- Remove clutter and change the order.


Revision tags: OPENBSD_6_7_BASE
# 1.47 22-Apr-2020 nicm

Indicate the marked pane in choose mode in reverse and add key to set
and clear it (m and M) and a key to jump to the starting pane (H).


# 1.46 09-Apr-2020 nicm

More style nits.


# 1.45 20-Mar-2020 nicm

Fix positioning of menu in choose modes and a couple of keys in tree mode.


# 1.44 08-Jan-2020 nicm

Add -Z to default switch-client command in tree mode, matches previous
behaviour.


# 1.43 03-Dec-2019 nicm

Style nits in function arguments.


# 1.42 15-Oct-2019 nicm

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


Revision tags: OPENBSD_6_6_BASE
# 1.41 25-Sep-2019 nicm

Style and line length nits.


# 1.40 16-Aug-2019 nicm

Add a flag to reverse sort in the various choose modes, from Benjamin
Poirier in GitHub issue 1875.


# 1.39 28-May-2019 nicm

Change display-menu from taking a single string to a set of arguments,
which is much easier to work with. Based on a diff from Avi Halachmi.


# 1.38 12-May-2019 nicm

Add simple menus to tree, client, buffer modes.


# 1.37 30-Apr-2019 nicm

Fix memory leak in window tree search, from Amos Bird.


# 1.36 17-Apr-2019 nicm

Break new window and pane creation common code from various commands and
window.c into a separate file spawn.c.


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

Add format variables for the default formats for the various modes
(tree_mode_format and so on) and add a -a flag to display-message to
list variables with values.


# 1.34 12-Mar-2019 nicm

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


# 1.33 07-Mar-2019 nicm

Add a separate mode struct for the active window mode if any.


# 1.32 18-Dec-2018 nicm

Pass window into mode functions.


Revision tags: OPENBSD_6_4_BASE
# 1.31 19-Aug-2018 nicm

Expand \u and \U escape sequences in command strings, from Christopher
Hunt in GitHub issue 1443.


# 1.30 10-Apr-2018 nicm

Add x and X to choose-tree (with a confirmation prompt) to kill an
item. Suggested by Matt Zagrabelny.


# 1.29 29-Mar-2018 nicm

Do not crash on empty window, reported by Jamie Macdonald in GitHub
issue 1299. Patch from Thomas Adam.


Revision tags: OPENBSD_6_3_BASE
# 1.28 28-Feb-2018 nicm

Add -Z flag to choose-tree, choose-client, choose-buffer to
automatically zoom the pane when the mode is entered and unzoom when it
exits, assuming the pane is not already zoomed. Add -Z to the default
key bindings.


# 1.27 03-Nov-2017 nicm

Support mouse on preview in tree mode.


# 1.26 02-Nov-2017 nicm

Make the mode draw function use the parent screen directly rather than
its own to avoid copying twice.


# 1.25 02-Nov-2017 nicm

Format for group list of "other sessions" is a bit weird, just list all
the sessions in the group.


# 1.24 02-Nov-2017 nicm

Tweak previous slightly so that current session is chosen if it is in
the group rather than first.


# 1.23 02-Nov-2017 nicm

Only show the first member of session groups in tree mode (-G flag
disables).


# 1.22 26-Oct-2017 nicm

Fix crash exiting command prompt (from Alex Maese in GitHub issue 1139)
and a man page tweak from jmc.


# 1.21 25-Oct-2017 nicm

Add P key to paste tagged in buffer mode, and trim some code that should
no longer be necessary.


# 1.20 22-Oct-2017 nicm

Use window_pane_index() when drawing pane numbers (so pane-base-index is
applied), from Thomas Adam. GitHub issue 1125.


# 1.19 11-Oct-2017 nicm

Box around label in preview.


# 1.18 11-Oct-2017 nicm

Add C-n and C-p keys for tree mode, and choose the right initial line
when no panes.


Revision tags: OPENBSD_6_2_BASE
# 1.17 30-Aug-2017 nicm

Pass flags into cmd_find_from_* to fix prefer-unattached, reported by
Thomas Sattler.


# 1.16 09-Aug-2017 nicm

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


# 1.15 09-Aug-2017 nicm

Add -F to choose-tree, choose-client, choose-buffer to specify the
format of each line, as well as adding a couple of formats needed for
the default display.


# 1.14 28-Jul-2017 nicm

Show pane title in window list for windows with only one pane.


# 1.13 12-Jul-2017 nicm

Line up keys in tree mode, and don't expand windows with one pane. From
Thomas Adam.


# 1.12 07-Jul-2017 nicm

Fix size of rightmost preview section.


# 1.11 04-Jul-2017 nicm

< and > keys to scroll preview list left and right in tree mode.


# 1.10 04-Jul-2017 nicm

Handle 0 size of preview box in caller.


# 1.9 03-Jul-2017 nicm

Change session and window preview so that the current window or pane is
always shown.


# 1.8 30-Jun-2017 nicm

Don't write over right border.


# 1.7 30-Jun-2017 nicm

Fix previous when we end up able to show no panes.


# 1.6 30-Jun-2017 nicm

Try to show a better preview of sessions and windows in tree mode.


# 1.5 09-Jun-2017 nicm

Extend filters (f key) to buffer and client mode and add -f flag to
specify to command.


# 1.4 09-Jun-2017 nicm

Add -O option to choose-* to set initial sort order.


# 1.3 07-Jun-2017 nicm

Add simple searching (C-s and n) to the various choose modes: by name
for client and tree, and by name and content for buffer.


# 1.2 06-Jun-2017 nicm

Do not pass a state into commands when fired on individual items in tree
mode, rely on the %% target substitution in the command for the chosen
pane and leave the default target as the current pane (where the mode
is). Otherwise, joinp and similar end up with -t and -s the
same. Reported by Jacob Niehus in GitHub issue 960.


# 1.1 30-May-2017 nicm

Rewrite of choose mode, both to simplify and tidy the code and to add
some modern features.

Now the common code is in mode-tree.c, which provides an API used by the
three modes now separated into window-{buffer,client,tree}.c. Buffer
mode shows buffers, client mode clients and tree mode a tree of
sessions, windows and panes.

Each mode has a common set of key bindings plus a few that are specific
to the mode. Other changes are:

- each mode has a preview pane: for buffers this is the buffer content
(very useful), for others it is a preview of the pane;

- items may be sorted in different ways ('O' key);

- multiple items may be tagged and an operation applied to all of them
(for example, to delete multiple buffers at once);

- in tree mode a command may be run on the selected item (session,
window, pane) or on tagged items (key ':');

- displayed items may be filtered in tree mode by using a format (this
is used to implement find-window) (key 'f');

- the custom format (-F) for the display is no longer available;

- shortcut keys change from 0-9, a-z, A-Z which was always a bit weird
with keys used for other uses to 0-9, M-a to M-z.

Now that the code is simpler, other improvements will come later.

Primary key bindings for each mode are documented under the commands in
the man page (choose-buffer, choose-client, choose-tree).

Parts written by Thomas Adam.


# 1.47 22-Apr-2020 nicm

Indicate the marked pane in choose mode in reverse and add key to set
and clear it (m and M) and a key to jump to the starting pane (H).


# 1.46 09-Apr-2020 nicm

More style nits.


# 1.45 20-Mar-2020 nicm

Fix positioning of menu in choose modes and a couple of keys in tree mode.


# 1.44 08-Jan-2020 nicm

Add -Z to default switch-client command in tree mode, matches previous
behaviour.


# 1.43 03-Dec-2019 nicm

Style nits in function arguments.


# 1.42 15-Oct-2019 nicm

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


Revision tags: OPENBSD_6_6_BASE
# 1.41 25-Sep-2019 nicm

Style and line length nits.


# 1.40 16-Aug-2019 nicm

Add a flag to reverse sort in the various choose modes, from Benjamin
Poirier in GitHub issue 1875.


# 1.39 28-May-2019 nicm

Change display-menu from taking a single string to a set of arguments,
which is much easier to work with. Based on a diff from Avi Halachmi.


# 1.38 12-May-2019 nicm

Add simple menus to tree, client, buffer modes.


# 1.37 30-Apr-2019 nicm

Fix memory leak in window tree search, from Amos Bird.


# 1.36 17-Apr-2019 nicm

Break new window and pane creation common code from various commands and
window.c into a separate file spawn.c.


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

Add format variables for the default formats for the various modes
(tree_mode_format and so on) and add a -a flag to display-message to
list variables with values.


# 1.34 12-Mar-2019 nicm

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


# 1.33 07-Mar-2019 nicm

Add a separate mode struct for the active window mode if any.


# 1.32 18-Dec-2018 nicm

Pass window into mode functions.


Revision tags: OPENBSD_6_4_BASE
# 1.31 19-Aug-2018 nicm

Expand \u and \U escape sequences in command strings, from Christopher
Hunt in GitHub issue 1443.


# 1.30 10-Apr-2018 nicm

Add x and X to choose-tree (with a confirmation prompt) to kill an
item. Suggested by Matt Zagrabelny.


# 1.29 29-Mar-2018 nicm

Do not crash on empty window, reported by Jamie Macdonald in GitHub
issue 1299. Patch from Thomas Adam.


Revision tags: OPENBSD_6_3_BASE
# 1.28 28-Feb-2018 nicm

Add -Z flag to choose-tree, choose-client, choose-buffer to
automatically zoom the pane when the mode is entered and unzoom when it
exits, assuming the pane is not already zoomed. Add -Z to the default
key bindings.


# 1.27 03-Nov-2017 nicm

Support mouse on preview in tree mode.


# 1.26 02-Nov-2017 nicm

Make the mode draw function use the parent screen directly rather than
its own to avoid copying twice.


# 1.25 02-Nov-2017 nicm

Format for group list of "other sessions" is a bit weird, just list all
the sessions in the group.


# 1.24 02-Nov-2017 nicm

Tweak previous slightly so that current session is chosen if it is in
the group rather than first.


# 1.23 02-Nov-2017 nicm

Only show the first member of session groups in tree mode (-G flag
disables).


# 1.22 26-Oct-2017 nicm

Fix crash exiting command prompt (from Alex Maese in GitHub issue 1139)
and a man page tweak from jmc.


# 1.21 25-Oct-2017 nicm

Add P key to paste tagged in buffer mode, and trim some code that should
no longer be necessary.


# 1.20 22-Oct-2017 nicm

Use window_pane_index() when drawing pane numbers (so pane-base-index is
applied), from Thomas Adam. GitHub issue 1125.


# 1.19 11-Oct-2017 nicm

Box around label in preview.


# 1.18 11-Oct-2017 nicm

Add C-n and C-p keys for tree mode, and choose the right initial line
when no panes.


Revision tags: OPENBSD_6_2_BASE
# 1.17 30-Aug-2017 nicm

Pass flags into cmd_find_from_* to fix prefer-unattached, reported by
Thomas Sattler.


# 1.16 09-Aug-2017 nicm

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


# 1.15 09-Aug-2017 nicm

Add -F to choose-tree, choose-client, choose-buffer to specify the
format of each line, as well as adding a couple of formats needed for
the default display.


# 1.14 28-Jul-2017 nicm

Show pane title in window list for windows with only one pane.


# 1.13 12-Jul-2017 nicm

Line up keys in tree mode, and don't expand windows with one pane. From
Thomas Adam.


# 1.12 07-Jul-2017 nicm

Fix size of rightmost preview section.


# 1.11 04-Jul-2017 nicm

< and > keys to scroll preview list left and right in tree mode.


# 1.10 04-Jul-2017 nicm

Handle 0 size of preview box in caller.


# 1.9 03-Jul-2017 nicm

Change session and window preview so that the current window or pane is
always shown.


# 1.8 30-Jun-2017 nicm

Don't write over right border.


# 1.7 30-Jun-2017 nicm

Fix previous when we end up able to show no panes.


# 1.6 30-Jun-2017 nicm

Try to show a better preview of sessions and windows in tree mode.


# 1.5 09-Jun-2017 nicm

Extend filters (f key) to buffer and client mode and add -f flag to
specify to command.


# 1.4 09-Jun-2017 nicm

Add -O option to choose-* to set initial sort order.


# 1.3 07-Jun-2017 nicm

Add simple searching (C-s and n) to the various choose modes: by name
for client and tree, and by name and content for buffer.


# 1.2 06-Jun-2017 nicm

Do not pass a state into commands when fired on individual items in tree
mode, rely on the %% target substitution in the command for the chosen
pane and leave the default target as the current pane (where the mode
is). Otherwise, joinp and similar end up with -t and -s the
same. Reported by Jacob Niehus in GitHub issue 960.


# 1.1 30-May-2017 nicm

Rewrite of choose mode, both to simplify and tidy the code and to add
some modern features.

Now the common code is in mode-tree.c, which provides an API used by the
three modes now separated into window-{buffer,client,tree}.c. Buffer
mode shows buffers, client mode clients and tree mode a tree of
sessions, windows and panes.

Each mode has a common set of key bindings plus a few that are specific
to the mode. Other changes are:

- each mode has a preview pane: for buffers this is the buffer content
(very useful), for others it is a preview of the pane;

- items may be sorted in different ways ('O' key);

- multiple items may be tagged and an operation applied to all of them
(for example, to delete multiple buffers at once);

- in tree mode a command may be run on the selected item (session,
window, pane) or on tagged items (key ':');

- displayed items may be filtered in tree mode by using a format (this
is used to implement find-window) (key 'f');

- the custom format (-F) for the display is no longer available;

- shortcut keys change from 0-9, a-z, A-Z which was always a bit weird
with keys used for other uses to 0-9, M-a to M-z.

Now that the code is simpler, other improvements will come later.

Primary key bindings for each mode are documented under the commands in
the man page (choose-buffer, choose-client, choose-tree).

Parts written by Thomas Adam.


# 1.46 09-Apr-2020 nicm

More style nits.


# 1.45 20-Mar-2020 nicm

Fix positioning of menu in choose modes and a couple of keys in tree mode.


# 1.44 08-Jan-2020 nicm

Add -Z to default switch-client command in tree mode, matches previous
behaviour.


# 1.43 03-Dec-2019 nicm

Style nits in function arguments.


# 1.42 15-Oct-2019 nicm

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


Revision tags: OPENBSD_6_6_BASE
# 1.41 25-Sep-2019 nicm

Style and line length nits.


# 1.40 16-Aug-2019 nicm

Add a flag to reverse sort in the various choose modes, from Benjamin
Poirier in GitHub issue 1875.


# 1.39 28-May-2019 nicm

Change display-menu from taking a single string to a set of arguments,
which is much easier to work with. Based on a diff from Avi Halachmi.


# 1.38 12-May-2019 nicm

Add simple menus to tree, client, buffer modes.


# 1.37 30-Apr-2019 nicm

Fix memory leak in window tree search, from Amos Bird.


# 1.36 17-Apr-2019 nicm

Break new window and pane creation common code from various commands and
window.c into a separate file spawn.c.


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

Add format variables for the default formats for the various modes
(tree_mode_format and so on) and add a -a flag to display-message to
list variables with values.


# 1.34 12-Mar-2019 nicm

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


# 1.33 07-Mar-2019 nicm

Add a separate mode struct for the active window mode if any.


# 1.32 18-Dec-2018 nicm

Pass window into mode functions.


Revision tags: OPENBSD_6_4_BASE
# 1.31 19-Aug-2018 nicm

Expand \u and \U escape sequences in command strings, from Christopher
Hunt in GitHub issue 1443.


# 1.30 10-Apr-2018 nicm

Add x and X to choose-tree (with a confirmation prompt) to kill an
item. Suggested by Matt Zagrabelny.


# 1.29 29-Mar-2018 nicm

Do not crash on empty window, reported by Jamie Macdonald in GitHub
issue 1299. Patch from Thomas Adam.


Revision tags: OPENBSD_6_3_BASE
# 1.28 28-Feb-2018 nicm

Add -Z flag to choose-tree, choose-client, choose-buffer to
automatically zoom the pane when the mode is entered and unzoom when it
exits, assuming the pane is not already zoomed. Add -Z to the default
key bindings.


# 1.27 03-Nov-2017 nicm

Support mouse on preview in tree mode.


# 1.26 02-Nov-2017 nicm

Make the mode draw function use the parent screen directly rather than
its own to avoid copying twice.


# 1.25 02-Nov-2017 nicm

Format for group list of "other sessions" is a bit weird, just list all
the sessions in the group.


# 1.24 02-Nov-2017 nicm

Tweak previous slightly so that current session is chosen if it is in
the group rather than first.


# 1.23 02-Nov-2017 nicm

Only show the first member of session groups in tree mode (-G flag
disables).


# 1.22 26-Oct-2017 nicm

Fix crash exiting command prompt (from Alex Maese in GitHub issue 1139)
and a man page tweak from jmc.


# 1.21 25-Oct-2017 nicm

Add P key to paste tagged in buffer mode, and trim some code that should
no longer be necessary.


# 1.20 22-Oct-2017 nicm

Use window_pane_index() when drawing pane numbers (so pane-base-index is
applied), from Thomas Adam. GitHub issue 1125.


# 1.19 11-Oct-2017 nicm

Box around label in preview.


# 1.18 11-Oct-2017 nicm

Add C-n and C-p keys for tree mode, and choose the right initial line
when no panes.


Revision tags: OPENBSD_6_2_BASE
# 1.17 30-Aug-2017 nicm

Pass flags into cmd_find_from_* to fix prefer-unattached, reported by
Thomas Sattler.


# 1.16 09-Aug-2017 nicm

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


# 1.15 09-Aug-2017 nicm

Add -F to choose-tree, choose-client, choose-buffer to specify the
format of each line, as well as adding a couple of formats needed for
the default display.


# 1.14 28-Jul-2017 nicm

Show pane title in window list for windows with only one pane.


# 1.13 12-Jul-2017 nicm

Line up keys in tree mode, and don't expand windows with one pane. From
Thomas Adam.


# 1.12 07-Jul-2017 nicm

Fix size of rightmost preview section.


# 1.11 04-Jul-2017 nicm

< and > keys to scroll preview list left and right in tree mode.


# 1.10 04-Jul-2017 nicm

Handle 0 size of preview box in caller.


# 1.9 03-Jul-2017 nicm

Change session and window preview so that the current window or pane is
always shown.


# 1.8 30-Jun-2017 nicm

Don't write over right border.


# 1.7 30-Jun-2017 nicm

Fix previous when we end up able to show no panes.


# 1.6 30-Jun-2017 nicm

Try to show a better preview of sessions and windows in tree mode.


# 1.5 09-Jun-2017 nicm

Extend filters (f key) to buffer and client mode and add -f flag to
specify to command.


# 1.4 09-Jun-2017 nicm

Add -O option to choose-* to set initial sort order.


# 1.3 07-Jun-2017 nicm

Add simple searching (C-s and n) to the various choose modes: by name
for client and tree, and by name and content for buffer.


# 1.2 06-Jun-2017 nicm

Do not pass a state into commands when fired on individual items in tree
mode, rely on the %% target substitution in the command for the chosen
pane and leave the default target as the current pane (where the mode
is). Otherwise, joinp and similar end up with -t and -s the
same. Reported by Jacob Niehus in GitHub issue 960.


# 1.1 30-May-2017 nicm

Rewrite of choose mode, both to simplify and tidy the code and to add
some modern features.

Now the common code is in mode-tree.c, which provides an API used by the
three modes now separated into window-{buffer,client,tree}.c. Buffer
mode shows buffers, client mode clients and tree mode a tree of
sessions, windows and panes.

Each mode has a common set of key bindings plus a few that are specific
to the mode. Other changes are:

- each mode has a preview pane: for buffers this is the buffer content
(very useful), for others it is a preview of the pane;

- items may be sorted in different ways ('O' key);

- multiple items may be tagged and an operation applied to all of them
(for example, to delete multiple buffers at once);

- in tree mode a command may be run on the selected item (session,
window, pane) or on tagged items (key ':');

- displayed items may be filtered in tree mode by using a format (this
is used to implement find-window) (key 'f');

- the custom format (-F) for the display is no longer available;

- shortcut keys change from 0-9, a-z, A-Z which was always a bit weird
with keys used for other uses to 0-9, M-a to M-z.

Now that the code is simpler, other improvements will come later.

Primary key bindings for each mode are documented under the commands in
the man page (choose-buffer, choose-client, choose-tree).

Parts written by Thomas Adam.


# 1.45 20-Mar-2020 nicm

Fix positioning of menu in choose modes and a couple of keys in tree mode.


# 1.44 08-Jan-2020 nicm

Add -Z to default switch-client command in tree mode, matches previous
behaviour.


# 1.43 03-Dec-2019 nicm

Style nits in function arguments.


# 1.42 15-Oct-2019 nicm

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


Revision tags: OPENBSD_6_6_BASE
# 1.41 25-Sep-2019 nicm

Style and line length nits.


# 1.40 16-Aug-2019 nicm

Add a flag to reverse sort in the various choose modes, from Benjamin
Poirier in GitHub issue 1875.


# 1.39 28-May-2019 nicm

Change display-menu from taking a single string to a set of arguments,
which is much easier to work with. Based on a diff from Avi Halachmi.


# 1.38 12-May-2019 nicm

Add simple menus to tree, client, buffer modes.


# 1.37 30-Apr-2019 nicm

Fix memory leak in window tree search, from Amos Bird.


# 1.36 17-Apr-2019 nicm

Break new window and pane creation common code from various commands and
window.c into a separate file spawn.c.


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

Add format variables for the default formats for the various modes
(tree_mode_format and so on) and add a -a flag to display-message to
list variables with values.


# 1.34 12-Mar-2019 nicm

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


# 1.33 07-Mar-2019 nicm

Add a separate mode struct for the active window mode if any.


# 1.32 18-Dec-2018 nicm

Pass window into mode functions.


Revision tags: OPENBSD_6_4_BASE
# 1.31 19-Aug-2018 nicm

Expand \u and \U escape sequences in command strings, from Christopher
Hunt in GitHub issue 1443.


# 1.30 10-Apr-2018 nicm

Add x and X to choose-tree (with a confirmation prompt) to kill an
item. Suggested by Matt Zagrabelny.


# 1.29 29-Mar-2018 nicm

Do not crash on empty window, reported by Jamie Macdonald in GitHub
issue 1299. Patch from Thomas Adam.


Revision tags: OPENBSD_6_3_BASE
# 1.28 28-Feb-2018 nicm

Add -Z flag to choose-tree, choose-client, choose-buffer to
automatically zoom the pane when the mode is entered and unzoom when it
exits, assuming the pane is not already zoomed. Add -Z to the default
key bindings.


# 1.27 03-Nov-2017 nicm

Support mouse on preview in tree mode.


# 1.26 02-Nov-2017 nicm

Make the mode draw function use the parent screen directly rather than
its own to avoid copying twice.


# 1.25 02-Nov-2017 nicm

Format for group list of "other sessions" is a bit weird, just list all
the sessions in the group.


# 1.24 02-Nov-2017 nicm

Tweak previous slightly so that current session is chosen if it is in
the group rather than first.


# 1.23 02-Nov-2017 nicm

Only show the first member of session groups in tree mode (-G flag
disables).


# 1.22 26-Oct-2017 nicm

Fix crash exiting command prompt (from Alex Maese in GitHub issue 1139)
and a man page tweak from jmc.


# 1.21 25-Oct-2017 nicm

Add P key to paste tagged in buffer mode, and trim some code that should
no longer be necessary.


# 1.20 22-Oct-2017 nicm

Use window_pane_index() when drawing pane numbers (so pane-base-index is
applied), from Thomas Adam. GitHub issue 1125.


# 1.19 11-Oct-2017 nicm

Box around label in preview.


# 1.18 11-Oct-2017 nicm

Add C-n and C-p keys for tree mode, and choose the right initial line
when no panes.


Revision tags: OPENBSD_6_2_BASE
# 1.17 30-Aug-2017 nicm

Pass flags into cmd_find_from_* to fix prefer-unattached, reported by
Thomas Sattler.


# 1.16 09-Aug-2017 nicm

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


# 1.15 09-Aug-2017 nicm

Add -F to choose-tree, choose-client, choose-buffer to specify the
format of each line, as well as adding a couple of formats needed for
the default display.


# 1.14 28-Jul-2017 nicm

Show pane title in window list for windows with only one pane.


# 1.13 12-Jul-2017 nicm

Line up keys in tree mode, and don't expand windows with one pane. From
Thomas Adam.


# 1.12 07-Jul-2017 nicm

Fix size of rightmost preview section.


# 1.11 04-Jul-2017 nicm

< and > keys to scroll preview list left and right in tree mode.


# 1.10 04-Jul-2017 nicm

Handle 0 size of preview box in caller.


# 1.9 03-Jul-2017 nicm

Change session and window preview so that the current window or pane is
always shown.


# 1.8 30-Jun-2017 nicm

Don't write over right border.


# 1.7 30-Jun-2017 nicm

Fix previous when we end up able to show no panes.


# 1.6 30-Jun-2017 nicm

Try to show a better preview of sessions and windows in tree mode.


# 1.5 09-Jun-2017 nicm

Extend filters (f key) to buffer and client mode and add -f flag to
specify to command.


# 1.4 09-Jun-2017 nicm

Add -O option to choose-* to set initial sort order.


# 1.3 07-Jun-2017 nicm

Add simple searching (C-s and n) to the various choose modes: by name
for client and tree, and by name and content for buffer.


# 1.2 06-Jun-2017 nicm

Do not pass a state into commands when fired on individual items in tree
mode, rely on the %% target substitution in the command for the chosen
pane and leave the default target as the current pane (where the mode
is). Otherwise, joinp and similar end up with -t and -s the
same. Reported by Jacob Niehus in GitHub issue 960.


# 1.1 30-May-2017 nicm

Rewrite of choose mode, both to simplify and tidy the code and to add
some modern features.

Now the common code is in mode-tree.c, which provides an API used by the
three modes now separated into window-{buffer,client,tree}.c. Buffer
mode shows buffers, client mode clients and tree mode a tree of
sessions, windows and panes.

Each mode has a common set of key bindings plus a few that are specific
to the mode. Other changes are:

- each mode has a preview pane: for buffers this is the buffer content
(very useful), for others it is a preview of the pane;

- items may be sorted in different ways ('O' key);

- multiple items may be tagged and an operation applied to all of them
(for example, to delete multiple buffers at once);

- in tree mode a command may be run on the selected item (session,
window, pane) or on tagged items (key ':');

- displayed items may be filtered in tree mode by using a format (this
is used to implement find-window) (key 'f');

- the custom format (-F) for the display is no longer available;

- shortcut keys change from 0-9, a-z, A-Z which was always a bit weird
with keys used for other uses to 0-9, M-a to M-z.

Now that the code is simpler, other improvements will come later.

Primary key bindings for each mode are documented under the commands in
the man page (choose-buffer, choose-client, choose-tree).

Parts written by Thomas Adam.


# 1.44 08-Jan-2020 nicm

Add -Z to default switch-client command in tree mode, matches previous
behaviour.


# 1.43 03-Dec-2019 nicm

Style nits in function arguments.


# 1.42 15-Oct-2019 nicm

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


Revision tags: OPENBSD_6_6_BASE
# 1.41 25-Sep-2019 nicm

Style and line length nits.


# 1.40 16-Aug-2019 nicm

Add a flag to reverse sort in the various choose modes, from Benjamin
Poirier in GitHub issue 1875.


# 1.39 28-May-2019 nicm

Change display-menu from taking a single string to a set of arguments,
which is much easier to work with. Based on a diff from Avi Halachmi.


# 1.38 12-May-2019 nicm

Add simple menus to tree, client, buffer modes.


# 1.37 30-Apr-2019 nicm

Fix memory leak in window tree search, from Amos Bird.


# 1.36 17-Apr-2019 nicm

Break new window and pane creation common code from various commands and
window.c into a separate file spawn.c.


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

Add format variables for the default formats for the various modes
(tree_mode_format and so on) and add a -a flag to display-message to
list variables with values.


# 1.34 12-Mar-2019 nicm

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


# 1.33 07-Mar-2019 nicm

Add a separate mode struct for the active window mode if any.


# 1.32 18-Dec-2018 nicm

Pass window into mode functions.


Revision tags: OPENBSD_6_4_BASE
# 1.31 19-Aug-2018 nicm

Expand \u and \U escape sequences in command strings, from Christopher
Hunt in GitHub issue 1443.


# 1.30 10-Apr-2018 nicm

Add x and X to choose-tree (with a confirmation prompt) to kill an
item. Suggested by Matt Zagrabelny.


# 1.29 29-Mar-2018 nicm

Do not crash on empty window, reported by Jamie Macdonald in GitHub
issue 1299. Patch from Thomas Adam.


Revision tags: OPENBSD_6_3_BASE
# 1.28 28-Feb-2018 nicm

Add -Z flag to choose-tree, choose-client, choose-buffer to
automatically zoom the pane when the mode is entered and unzoom when it
exits, assuming the pane is not already zoomed. Add -Z to the default
key bindings.


# 1.27 03-Nov-2017 nicm

Support mouse on preview in tree mode.


# 1.26 02-Nov-2017 nicm

Make the mode draw function use the parent screen directly rather than
its own to avoid copying twice.


# 1.25 02-Nov-2017 nicm

Format for group list of "other sessions" is a bit weird, just list all
the sessions in the group.


# 1.24 02-Nov-2017 nicm

Tweak previous slightly so that current session is chosen if it is in
the group rather than first.


# 1.23 02-Nov-2017 nicm

Only show the first member of session groups in tree mode (-G flag
disables).


# 1.22 26-Oct-2017 nicm

Fix crash exiting command prompt (from Alex Maese in GitHub issue 1139)
and a man page tweak from jmc.


# 1.21 25-Oct-2017 nicm

Add P key to paste tagged in buffer mode, and trim some code that should
no longer be necessary.


# 1.20 22-Oct-2017 nicm

Use window_pane_index() when drawing pane numbers (so pane-base-index is
applied), from Thomas Adam. GitHub issue 1125.


# 1.19 11-Oct-2017 nicm

Box around label in preview.


# 1.18 11-Oct-2017 nicm

Add C-n and C-p keys for tree mode, and choose the right initial line
when no panes.


Revision tags: OPENBSD_6_2_BASE
# 1.17 30-Aug-2017 nicm

Pass flags into cmd_find_from_* to fix prefer-unattached, reported by
Thomas Sattler.


# 1.16 09-Aug-2017 nicm

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


# 1.15 09-Aug-2017 nicm

Add -F to choose-tree, choose-client, choose-buffer to specify the
format of each line, as well as adding a couple of formats needed for
the default display.


# 1.14 28-Jul-2017 nicm

Show pane title in window list for windows with only one pane.


# 1.13 12-Jul-2017 nicm

Line up keys in tree mode, and don't expand windows with one pane. From
Thomas Adam.


# 1.12 07-Jul-2017 nicm

Fix size of rightmost preview section.


# 1.11 04-Jul-2017 nicm

< and > keys to scroll preview list left and right in tree mode.


# 1.10 04-Jul-2017 nicm

Handle 0 size of preview box in caller.


# 1.9 03-Jul-2017 nicm

Change session and window preview so that the current window or pane is
always shown.


# 1.8 30-Jun-2017 nicm

Don't write over right border.


# 1.7 30-Jun-2017 nicm

Fix previous when we end up able to show no panes.


# 1.6 30-Jun-2017 nicm

Try to show a better preview of sessions and windows in tree mode.


# 1.5 09-Jun-2017 nicm

Extend filters (f key) to buffer and client mode and add -f flag to
specify to command.


# 1.4 09-Jun-2017 nicm

Add -O option to choose-* to set initial sort order.


# 1.3 07-Jun-2017 nicm

Add simple searching (C-s and n) to the various choose modes: by name
for client and tree, and by name and content for buffer.


# 1.2 06-Jun-2017 nicm

Do not pass a state into commands when fired on individual items in tree
mode, rely on the %% target substitution in the command for the chosen
pane and leave the default target as the current pane (where the mode
is). Otherwise, joinp and similar end up with -t and -s the
same. Reported by Jacob Niehus in GitHub issue 960.


# 1.1 30-May-2017 nicm

Rewrite of choose mode, both to simplify and tidy the code and to add
some modern features.

Now the common code is in mode-tree.c, which provides an API used by the
three modes now separated into window-{buffer,client,tree}.c. Buffer
mode shows buffers, client mode clients and tree mode a tree of
sessions, windows and panes.

Each mode has a common set of key bindings plus a few that are specific
to the mode. Other changes are:

- each mode has a preview pane: for buffers this is the buffer content
(very useful), for others it is a preview of the pane;

- items may be sorted in different ways ('O' key);

- multiple items may be tagged and an operation applied to all of them
(for example, to delete multiple buffers at once);

- in tree mode a command may be run on the selected item (session,
window, pane) or on tagged items (key ':');

- displayed items may be filtered in tree mode by using a format (this
is used to implement find-window) (key 'f');

- the custom format (-F) for the display is no longer available;

- shortcut keys change from 0-9, a-z, A-Z which was always a bit weird
with keys used for other uses to 0-9, M-a to M-z.

Now that the code is simpler, other improvements will come later.

Primary key bindings for each mode are documented under the commands in
the man page (choose-buffer, choose-client, choose-tree).

Parts written by Thomas Adam.


# 1.43 03-Dec-2019 nicm

Style nits in function arguments.


# 1.42 15-Oct-2019 nicm

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


Revision tags: OPENBSD_6_6_BASE
# 1.41 25-Sep-2019 nicm

Style and line length nits.


# 1.40 16-Aug-2019 nicm

Add a flag to reverse sort in the various choose modes, from Benjamin
Poirier in GitHub issue 1875.


# 1.39 28-May-2019 nicm

Change display-menu from taking a single string to a set of arguments,
which is much easier to work with. Based on a diff from Avi Halachmi.


# 1.38 12-May-2019 nicm

Add simple menus to tree, client, buffer modes.


# 1.37 30-Apr-2019 nicm

Fix memory leak in window tree search, from Amos Bird.


# 1.36 17-Apr-2019 nicm

Break new window and pane creation common code from various commands and
window.c into a separate file spawn.c.


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

Add format variables for the default formats for the various modes
(tree_mode_format and so on) and add a -a flag to display-message to
list variables with values.


# 1.34 12-Mar-2019 nicm

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


# 1.33 07-Mar-2019 nicm

Add a separate mode struct for the active window mode if any.


# 1.32 18-Dec-2018 nicm

Pass window into mode functions.


Revision tags: OPENBSD_6_4_BASE
# 1.31 19-Aug-2018 nicm

Expand \u and \U escape sequences in command strings, from Christopher
Hunt in GitHub issue 1443.


# 1.30 10-Apr-2018 nicm

Add x and X to choose-tree (with a confirmation prompt) to kill an
item. Suggested by Matt Zagrabelny.


# 1.29 29-Mar-2018 nicm

Do not crash on empty window, reported by Jamie Macdonald in GitHub
issue 1299. Patch from Thomas Adam.


Revision tags: OPENBSD_6_3_BASE
# 1.28 28-Feb-2018 nicm

Add -Z flag to choose-tree, choose-client, choose-buffer to
automatically zoom the pane when the mode is entered and unzoom when it
exits, assuming the pane is not already zoomed. Add -Z to the default
key bindings.


# 1.27 03-Nov-2017 nicm

Support mouse on preview in tree mode.


# 1.26 02-Nov-2017 nicm

Make the mode draw function use the parent screen directly rather than
its own to avoid copying twice.


# 1.25 02-Nov-2017 nicm

Format for group list of "other sessions" is a bit weird, just list all
the sessions in the group.


# 1.24 02-Nov-2017 nicm

Tweak previous slightly so that current session is chosen if it is in
the group rather than first.


# 1.23 02-Nov-2017 nicm

Only show the first member of session groups in tree mode (-G flag
disables).


# 1.22 26-Oct-2017 nicm

Fix crash exiting command prompt (from Alex Maese in GitHub issue 1139)
and a man page tweak from jmc.


# 1.21 25-Oct-2017 nicm

Add P key to paste tagged in buffer mode, and trim some code that should
no longer be necessary.


# 1.20 22-Oct-2017 nicm

Use window_pane_index() when drawing pane numbers (so pane-base-index is
applied), from Thomas Adam. GitHub issue 1125.


# 1.19 11-Oct-2017 nicm

Box around label in preview.


# 1.18 11-Oct-2017 nicm

Add C-n and C-p keys for tree mode, and choose the right initial line
when no panes.


Revision tags: OPENBSD_6_2_BASE
# 1.17 30-Aug-2017 nicm

Pass flags into cmd_find_from_* to fix prefer-unattached, reported by
Thomas Sattler.


# 1.16 09-Aug-2017 nicm

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


# 1.15 09-Aug-2017 nicm

Add -F to choose-tree, choose-client, choose-buffer to specify the
format of each line, as well as adding a couple of formats needed for
the default display.


# 1.14 28-Jul-2017 nicm

Show pane title in window list for windows with only one pane.


# 1.13 12-Jul-2017 nicm

Line up keys in tree mode, and don't expand windows with one pane. From
Thomas Adam.


# 1.12 07-Jul-2017 nicm

Fix size of rightmost preview section.


# 1.11 04-Jul-2017 nicm

< and > keys to scroll preview list left and right in tree mode.


# 1.10 04-Jul-2017 nicm

Handle 0 size of preview box in caller.


# 1.9 03-Jul-2017 nicm

Change session and window preview so that the current window or pane is
always shown.


# 1.8 30-Jun-2017 nicm

Don't write over right border.


# 1.7 30-Jun-2017 nicm

Fix previous when we end up able to show no panes.


# 1.6 30-Jun-2017 nicm

Try to show a better preview of sessions and windows in tree mode.


# 1.5 09-Jun-2017 nicm

Extend filters (f key) to buffer and client mode and add -f flag to
specify to command.


# 1.4 09-Jun-2017 nicm

Add -O option to choose-* to set initial sort order.


# 1.3 07-Jun-2017 nicm

Add simple searching (C-s and n) to the various choose modes: by name
for client and tree, and by name and content for buffer.


# 1.2 06-Jun-2017 nicm

Do not pass a state into commands when fired on individual items in tree
mode, rely on the %% target substitution in the command for the chosen
pane and leave the default target as the current pane (where the mode
is). Otherwise, joinp and similar end up with -t and -s the
same. Reported by Jacob Niehus in GitHub issue 960.


# 1.1 30-May-2017 nicm

Rewrite of choose mode, both to simplify and tidy the code and to add
some modern features.

Now the common code is in mode-tree.c, which provides an API used by the
three modes now separated into window-{buffer,client,tree}.c. Buffer
mode shows buffers, client mode clients and tree mode a tree of
sessions, windows and panes.

Each mode has a common set of key bindings plus a few that are specific
to the mode. Other changes are:

- each mode has a preview pane: for buffers this is the buffer content
(very useful), for others it is a preview of the pane;

- items may be sorted in different ways ('O' key);

- multiple items may be tagged and an operation applied to all of them
(for example, to delete multiple buffers at once);

- in tree mode a command may be run on the selected item (session,
window, pane) or on tagged items (key ':');

- displayed items may be filtered in tree mode by using a format (this
is used to implement find-window) (key 'f');

- the custom format (-F) for the display is no longer available;

- shortcut keys change from 0-9, a-z, A-Z which was always a bit weird
with keys used for other uses to 0-9, M-a to M-z.

Now that the code is simpler, other improvements will come later.

Primary key bindings for each mode are documented under the commands in
the man page (choose-buffer, choose-client, choose-tree).

Parts written by Thomas Adam.


# 1.42 15-Oct-2019 nicm

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


Revision tags: OPENBSD_6_6_BASE
# 1.41 25-Sep-2019 nicm

Style and line length nits.


# 1.40 16-Aug-2019 nicm

Add a flag to reverse sort in the various choose modes, from Benjamin
Poirier in GitHub issue 1875.


# 1.39 28-May-2019 nicm

Change display-menu from taking a single string to a set of arguments,
which is much easier to work with. Based on a diff from Avi Halachmi.


# 1.38 12-May-2019 nicm

Add simple menus to tree, client, buffer modes.


# 1.37 30-Apr-2019 nicm

Fix memory leak in window tree search, from Amos Bird.


# 1.36 17-Apr-2019 nicm

Break new window and pane creation common code from various commands and
window.c into a separate file spawn.c.


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

Add format variables for the default formats for the various modes
(tree_mode_format and so on) and add a -a flag to display-message to
list variables with values.


# 1.34 12-Mar-2019 nicm

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


# 1.33 07-Mar-2019 nicm

Add a separate mode struct for the active window mode if any.


# 1.32 18-Dec-2018 nicm

Pass window into mode functions.


Revision tags: OPENBSD_6_4_BASE
# 1.31 19-Aug-2018 nicm

Expand \u and \U escape sequences in command strings, from Christopher
Hunt in GitHub issue 1443.


# 1.30 10-Apr-2018 nicm

Add x and X to choose-tree (with a confirmation prompt) to kill an
item. Suggested by Matt Zagrabelny.


# 1.29 29-Mar-2018 nicm

Do not crash on empty window, reported by Jamie Macdonald in GitHub
issue 1299. Patch from Thomas Adam.


Revision tags: OPENBSD_6_3_BASE
# 1.28 28-Feb-2018 nicm

Add -Z flag to choose-tree, choose-client, choose-buffer to
automatically zoom the pane when the mode is entered and unzoom when it
exits, assuming the pane is not already zoomed. Add -Z to the default
key bindings.


# 1.27 03-Nov-2017 nicm

Support mouse on preview in tree mode.


# 1.26 02-Nov-2017 nicm

Make the mode draw function use the parent screen directly rather than
its own to avoid copying twice.


# 1.25 02-Nov-2017 nicm

Format for group list of "other sessions" is a bit weird, just list all
the sessions in the group.


# 1.24 02-Nov-2017 nicm

Tweak previous slightly so that current session is chosen if it is in
the group rather than first.


# 1.23 02-Nov-2017 nicm

Only show the first member of session groups in tree mode (-G flag
disables).


# 1.22 26-Oct-2017 nicm

Fix crash exiting command prompt (from Alex Maese in GitHub issue 1139)
and a man page tweak from jmc.


# 1.21 25-Oct-2017 nicm

Add P key to paste tagged in buffer mode, and trim some code that should
no longer be necessary.


# 1.20 22-Oct-2017 nicm

Use window_pane_index() when drawing pane numbers (so pane-base-index is
applied), from Thomas Adam. GitHub issue 1125.


# 1.19 11-Oct-2017 nicm

Box around label in preview.


# 1.18 11-Oct-2017 nicm

Add C-n and C-p keys for tree mode, and choose the right initial line
when no panes.


Revision tags: OPENBSD_6_2_BASE
# 1.17 30-Aug-2017 nicm

Pass flags into cmd_find_from_* to fix prefer-unattached, reported by
Thomas Sattler.


# 1.16 09-Aug-2017 nicm

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


# 1.15 09-Aug-2017 nicm

Add -F to choose-tree, choose-client, choose-buffer to specify the
format of each line, as well as adding a couple of formats needed for
the default display.


# 1.14 28-Jul-2017 nicm

Show pane title in window list for windows with only one pane.


# 1.13 12-Jul-2017 nicm

Line up keys in tree mode, and don't expand windows with one pane. From
Thomas Adam.


# 1.12 07-Jul-2017 nicm

Fix size of rightmost preview section.


# 1.11 04-Jul-2017 nicm

< and > keys to scroll preview list left and right in tree mode.


# 1.10 04-Jul-2017 nicm

Handle 0 size of preview box in caller.


# 1.9 03-Jul-2017 nicm

Change session and window preview so that the current window or pane is
always shown.


# 1.8 30-Jun-2017 nicm

Don't write over right border.


# 1.7 30-Jun-2017 nicm

Fix previous when we end up able to show no panes.


# 1.6 30-Jun-2017 nicm

Try to show a better preview of sessions and windows in tree mode.


# 1.5 09-Jun-2017 nicm

Extend filters (f key) to buffer and client mode and add -f flag to
specify to command.


# 1.4 09-Jun-2017 nicm

Add -O option to choose-* to set initial sort order.


# 1.3 07-Jun-2017 nicm

Add simple searching (C-s and n) to the various choose modes: by name
for client and tree, and by name and content for buffer.


# 1.2 06-Jun-2017 nicm

Do not pass a state into commands when fired on individual items in tree
mode, rely on the %% target substitution in the command for the chosen
pane and leave the default target as the current pane (where the mode
is). Otherwise, joinp and similar end up with -t and -s the
same. Reported by Jacob Niehus in GitHub issue 960.


# 1.1 30-May-2017 nicm

Rewrite of choose mode, both to simplify and tidy the code and to add
some modern features.

Now the common code is in mode-tree.c, which provides an API used by the
three modes now separated into window-{buffer,client,tree}.c. Buffer
mode shows buffers, client mode clients and tree mode a tree of
sessions, windows and panes.

Each mode has a common set of key bindings plus a few that are specific
to the mode. Other changes are:

- each mode has a preview pane: for buffers this is the buffer content
(very useful), for others it is a preview of the pane;

- items may be sorted in different ways ('O' key);

- multiple items may be tagged and an operation applied to all of them
(for example, to delete multiple buffers at once);

- in tree mode a command may be run on the selected item (session,
window, pane) or on tagged items (key ':');

- displayed items may be filtered in tree mode by using a format (this
is used to implement find-window) (key 'f');

- the custom format (-F) for the display is no longer available;

- shortcut keys change from 0-9, a-z, A-Z which was always a bit weird
with keys used for other uses to 0-9, M-a to M-z.

Now that the code is simpler, other improvements will come later.

Primary key bindings for each mode are documented under the commands in
the man page (choose-buffer, choose-client, choose-tree).

Parts written by Thomas Adam.


# 1.41 25-Sep-2019 nicm

Style and line length nits.


# 1.40 16-Aug-2019 nicm

Add a flag to reverse sort in the various choose modes, from Benjamin
Poirier in GitHub issue 1875.


# 1.39 28-May-2019 nicm

Change display-menu from taking a single string to a set of arguments,
which is much easier to work with. Based on a diff from Avi Halachmi.


# 1.38 12-May-2019 nicm

Add simple menus to tree, client, buffer modes.


# 1.37 30-Apr-2019 nicm

Fix memory leak in window tree search, from Amos Bird.


# 1.36 17-Apr-2019 nicm

Break new window and pane creation common code from various commands and
window.c into a separate file spawn.c.


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

Add format variables for the default formats for the various modes
(tree_mode_format and so on) and add a -a flag to display-message to
list variables with values.


# 1.34 12-Mar-2019 nicm

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


# 1.33 07-Mar-2019 nicm

Add a separate mode struct for the active window mode if any.


# 1.32 18-Dec-2018 nicm

Pass window into mode functions.


Revision tags: OPENBSD_6_4_BASE
# 1.31 19-Aug-2018 nicm

Expand \u and \U escape sequences in command strings, from Christopher
Hunt in GitHub issue 1443.


# 1.30 10-Apr-2018 nicm

Add x and X to choose-tree (with a confirmation prompt) to kill an
item. Suggested by Matt Zagrabelny.


# 1.29 29-Mar-2018 nicm

Do not crash on empty window, reported by Jamie Macdonald in GitHub
issue 1299. Patch from Thomas Adam.


Revision tags: OPENBSD_6_3_BASE
# 1.28 28-Feb-2018 nicm

Add -Z flag to choose-tree, choose-client, choose-buffer to
automatically zoom the pane when the mode is entered and unzoom when it
exits, assuming the pane is not already zoomed. Add -Z to the default
key bindings.


# 1.27 03-Nov-2017 nicm

Support mouse on preview in tree mode.


# 1.26 02-Nov-2017 nicm

Make the mode draw function use the parent screen directly rather than
its own to avoid copying twice.


# 1.25 02-Nov-2017 nicm

Format for group list of "other sessions" is a bit weird, just list all
the sessions in the group.


# 1.24 02-Nov-2017 nicm

Tweak previous slightly so that current session is chosen if it is in
the group rather than first.


# 1.23 02-Nov-2017 nicm

Only show the first member of session groups in tree mode (-G flag
disables).


# 1.22 26-Oct-2017 nicm

Fix crash exiting command prompt (from Alex Maese in GitHub issue 1139)
and a man page tweak from jmc.


# 1.21 25-Oct-2017 nicm

Add P key to paste tagged in buffer mode, and trim some code that should
no longer be necessary.


# 1.20 22-Oct-2017 nicm

Use window_pane_index() when drawing pane numbers (so pane-base-index is
applied), from Thomas Adam. GitHub issue 1125.


# 1.19 11-Oct-2017 nicm

Box around label in preview.


# 1.18 11-Oct-2017 nicm

Add C-n and C-p keys for tree mode, and choose the right initial line
when no panes.


Revision tags: OPENBSD_6_2_BASE
# 1.17 30-Aug-2017 nicm

Pass flags into cmd_find_from_* to fix prefer-unattached, reported by
Thomas Sattler.


# 1.16 09-Aug-2017 nicm

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


# 1.15 09-Aug-2017 nicm

Add -F to choose-tree, choose-client, choose-buffer to specify the
format of each line, as well as adding a couple of formats needed for
the default display.


# 1.14 28-Jul-2017 nicm

Show pane title in window list for windows with only one pane.


# 1.13 12-Jul-2017 nicm

Line up keys in tree mode, and don't expand windows with one pane. From
Thomas Adam.


# 1.12 07-Jul-2017 nicm

Fix size of rightmost preview section.


# 1.11 04-Jul-2017 nicm

< and > keys to scroll preview list left and right in tree mode.


# 1.10 04-Jul-2017 nicm

Handle 0 size of preview box in caller.


# 1.9 03-Jul-2017 nicm

Change session and window preview so that the current window or pane is
always shown.


# 1.8 30-Jun-2017 nicm

Don't write over right border.


# 1.7 30-Jun-2017 nicm

Fix previous when we end up able to show no panes.


# 1.6 30-Jun-2017 nicm

Try to show a better preview of sessions and windows in tree mode.


# 1.5 09-Jun-2017 nicm

Extend filters (f key) to buffer and client mode and add -f flag to
specify to command.


# 1.4 09-Jun-2017 nicm

Add -O option to choose-* to set initial sort order.


# 1.3 07-Jun-2017 nicm

Add simple searching (C-s and n) to the various choose modes: by name
for client and tree, and by name and content for buffer.


# 1.2 06-Jun-2017 nicm

Do not pass a state into commands when fired on individual items in tree
mode, rely on the %% target substitution in the command for the chosen
pane and leave the default target as the current pane (where the mode
is). Otherwise, joinp and similar end up with -t and -s the
same. Reported by Jacob Niehus in GitHub issue 960.


# 1.1 30-May-2017 nicm

Rewrite of choose mode, both to simplify and tidy the code and to add
some modern features.

Now the common code is in mode-tree.c, which provides an API used by the
three modes now separated into window-{buffer,client,tree}.c. Buffer
mode shows buffers, client mode clients and tree mode a tree of
sessions, windows and panes.

Each mode has a common set of key bindings plus a few that are specific
to the mode. Other changes are:

- each mode has a preview pane: for buffers this is the buffer content
(very useful), for others it is a preview of the pane;

- items may be sorted in different ways ('O' key);

- multiple items may be tagged and an operation applied to all of them
(for example, to delete multiple buffers at once);

- in tree mode a command may be run on the selected item (session,
window, pane) or on tagged items (key ':');

- displayed items may be filtered in tree mode by using a format (this
is used to implement find-window) (key 'f');

- the custom format (-F) for the display is no longer available;

- shortcut keys change from 0-9, a-z, A-Z which was always a bit weird
with keys used for other uses to 0-9, M-a to M-z.

Now that the code is simpler, other improvements will come later.

Primary key bindings for each mode are documented under the commands in
the man page (choose-buffer, choose-client, choose-tree).

Parts written by Thomas Adam.


# 1.40 16-Aug-2019 nicm

Add a flag to reverse sort in the various choose modes, from Benjamin
Poirier in GitHub issue 1875.


# 1.39 28-May-2019 nicm

Change display-menu from taking a single string to a set of arguments,
which is much easier to work with. Based on a diff from Avi Halachmi.


# 1.38 12-May-2019 nicm

Add simple menus to tree, client, buffer modes.


# 1.37 30-Apr-2019 nicm

Fix memory leak in window tree search, from Amos Bird.


# 1.36 17-Apr-2019 nicm

Break new window and pane creation common code from various commands and
window.c into a separate file spawn.c.


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

Add format variables for the default formats for the various modes
(tree_mode_format and so on) and add a -a flag to display-message to
list variables with values.


# 1.34 12-Mar-2019 nicm

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


# 1.33 07-Mar-2019 nicm

Add a separate mode struct for the active window mode if any.


# 1.32 18-Dec-2018 nicm

Pass window into mode functions.


Revision tags: OPENBSD_6_4_BASE
# 1.31 19-Aug-2018 nicm

Expand \u and \U escape sequences in command strings, from Christopher
Hunt in GitHub issue 1443.


# 1.30 10-Apr-2018 nicm

Add x and X to choose-tree (with a confirmation prompt) to kill an
item. Suggested by Matt Zagrabelny.


# 1.29 29-Mar-2018 nicm

Do not crash on empty window, reported by Jamie Macdonald in GitHub
issue 1299. Patch from Thomas Adam.


Revision tags: OPENBSD_6_3_BASE
# 1.28 28-Feb-2018 nicm

Add -Z flag to choose-tree, choose-client, choose-buffer to
automatically zoom the pane when the mode is entered and unzoom when it
exits, assuming the pane is not already zoomed. Add -Z to the default
key bindings.


# 1.27 03-Nov-2017 nicm

Support mouse on preview in tree mode.


# 1.26 02-Nov-2017 nicm

Make the mode draw function use the parent screen directly rather than
its own to avoid copying twice.


# 1.25 02-Nov-2017 nicm

Format for group list of "other sessions" is a bit weird, just list all
the sessions in the group.


# 1.24 02-Nov-2017 nicm

Tweak previous slightly so that current session is chosen if it is in
the group rather than first.


# 1.23 02-Nov-2017 nicm

Only show the first member of session groups in tree mode (-G flag
disables).


# 1.22 26-Oct-2017 nicm

Fix crash exiting command prompt (from Alex Maese in GitHub issue 1139)
and a man page tweak from jmc.


# 1.21 25-Oct-2017 nicm

Add P key to paste tagged in buffer mode, and trim some code that should
no longer be necessary.


# 1.20 22-Oct-2017 nicm

Use window_pane_index() when drawing pane numbers (so pane-base-index is
applied), from Thomas Adam. GitHub issue 1125.


# 1.19 11-Oct-2017 nicm

Box around label in preview.


# 1.18 11-Oct-2017 nicm

Add C-n and C-p keys for tree mode, and choose the right initial line
when no panes.


Revision tags: OPENBSD_6_2_BASE
# 1.17 30-Aug-2017 nicm

Pass flags into cmd_find_from_* to fix prefer-unattached, reported by
Thomas Sattler.


# 1.16 09-Aug-2017 nicm

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


# 1.15 09-Aug-2017 nicm

Add -F to choose-tree, choose-client, choose-buffer to specify the
format of each line, as well as adding a couple of formats needed for
the default display.


# 1.14 28-Jul-2017 nicm

Show pane title in window list for windows with only one pane.


# 1.13 12-Jul-2017 nicm

Line up keys in tree mode, and don't expand windows with one pane. From
Thomas Adam.


# 1.12 07-Jul-2017 nicm

Fix size of rightmost preview section.


# 1.11 04-Jul-2017 nicm

< and > keys to scroll preview list left and right in tree mode.


# 1.10 04-Jul-2017 nicm

Handle 0 size of preview box in caller.


# 1.9 03-Jul-2017 nicm

Change session and window preview so that the current window or pane is
always shown.


# 1.8 30-Jun-2017 nicm

Don't write over right border.


# 1.7 30-Jun-2017 nicm

Fix previous when we end up able to show no panes.


# 1.6 30-Jun-2017 nicm

Try to show a better preview of sessions and windows in tree mode.


# 1.5 09-Jun-2017 nicm

Extend filters (f key) to buffer and client mode and add -f flag to
specify to command.


# 1.4 09-Jun-2017 nicm

Add -O option to choose-* to set initial sort order.


# 1.3 07-Jun-2017 nicm

Add simple searching (C-s and n) to the various choose modes: by name
for client and tree, and by name and content for buffer.


# 1.2 06-Jun-2017 nicm

Do not pass a state into commands when fired on individual items in tree
mode, rely on the %% target substitution in the command for the chosen
pane and leave the default target as the current pane (where the mode
is). Otherwise, joinp and similar end up with -t and -s the
same. Reported by Jacob Niehus in GitHub issue 960.


# 1.1 30-May-2017 nicm

Rewrite of choose mode, both to simplify and tidy the code and to add
some modern features.

Now the common code is in mode-tree.c, which provides an API used by the
three modes now separated into window-{buffer,client,tree}.c. Buffer
mode shows buffers, client mode clients and tree mode a tree of
sessions, windows and panes.

Each mode has a common set of key bindings plus a few that are specific
to the mode. Other changes are:

- each mode has a preview pane: for buffers this is the buffer content
(very useful), for others it is a preview of the pane;

- items may be sorted in different ways ('O' key);

- multiple items may be tagged and an operation applied to all of them
(for example, to delete multiple buffers at once);

- in tree mode a command may be run on the selected item (session,
window, pane) or on tagged items (key ':');

- displayed items may be filtered in tree mode by using a format (this
is used to implement find-window) (key 'f');

- the custom format (-F) for the display is no longer available;

- shortcut keys change from 0-9, a-z, A-Z which was always a bit weird
with keys used for other uses to 0-9, M-a to M-z.

Now that the code is simpler, other improvements will come later.

Primary key bindings for each mode are documented under the commands in
the man page (choose-buffer, choose-client, choose-tree).

Parts written by Thomas Adam.


# 1.39 28-May-2019 nicm

Change display-menu from taking a single string to a set of arguments,
which is much easier to work with. Based on a diff from Avi Halachmi.


# 1.38 12-May-2019 nicm

Add simple menus to tree, client, buffer modes.


# 1.37 30-Apr-2019 nicm

Fix memory leak in window tree search, from Amos Bird.


# 1.36 17-Apr-2019 nicm

Break new window and pane creation common code from various commands and
window.c into a separate file spawn.c.


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

Add format variables for the default formats for the various modes
(tree_mode_format and so on) and add a -a flag to display-message to
list variables with values.


# 1.34 12-Mar-2019 nicm

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


# 1.33 07-Mar-2019 nicm

Add a separate mode struct for the active window mode if any.


# 1.32 18-Dec-2018 nicm

Pass window into mode functions.


Revision tags: OPENBSD_6_4_BASE
# 1.31 19-Aug-2018 nicm

Expand \u and \U escape sequences in command strings, from Christopher
Hunt in GitHub issue 1443.


# 1.30 10-Apr-2018 nicm

Add x and X to choose-tree (with a confirmation prompt) to kill an
item. Suggested by Matt Zagrabelny.


# 1.29 29-Mar-2018 nicm

Do not crash on empty window, reported by Jamie Macdonald in GitHub
issue 1299. Patch from Thomas Adam.


Revision tags: OPENBSD_6_3_BASE
# 1.28 28-Feb-2018 nicm

Add -Z flag to choose-tree, choose-client, choose-buffer to
automatically zoom the pane when the mode is entered and unzoom when it
exits, assuming the pane is not already zoomed. Add -Z to the default
key bindings.


# 1.27 03-Nov-2017 nicm

Support mouse on preview in tree mode.


# 1.26 02-Nov-2017 nicm

Make the mode draw function use the parent screen directly rather than
its own to avoid copying twice.


# 1.25 02-Nov-2017 nicm

Format for group list of "other sessions" is a bit weird, just list all
the sessions in the group.


# 1.24 02-Nov-2017 nicm

Tweak previous slightly so that current session is chosen if it is in
the group rather than first.


# 1.23 02-Nov-2017 nicm

Only show the first member of session groups in tree mode (-G flag
disables).


# 1.22 26-Oct-2017 nicm

Fix crash exiting command prompt (from Alex Maese in GitHub issue 1139)
and a man page tweak from jmc.


# 1.21 25-Oct-2017 nicm

Add P key to paste tagged in buffer mode, and trim some code that should
no longer be necessary.


# 1.20 22-Oct-2017 nicm

Use window_pane_index() when drawing pane numbers (so pane-base-index is
applied), from Thomas Adam. GitHub issue 1125.


# 1.19 11-Oct-2017 nicm

Box around label in preview.


# 1.18 11-Oct-2017 nicm

Add C-n and C-p keys for tree mode, and choose the right initial line
when no panes.


Revision tags: OPENBSD_6_2_BASE
# 1.17 30-Aug-2017 nicm

Pass flags into cmd_find_from_* to fix prefer-unattached, reported by
Thomas Sattler.


# 1.16 09-Aug-2017 nicm

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


# 1.15 09-Aug-2017 nicm

Add -F to choose-tree, choose-client, choose-buffer to specify the
format of each line, as well as adding a couple of formats needed for
the default display.


# 1.14 28-Jul-2017 nicm

Show pane title in window list for windows with only one pane.


# 1.13 12-Jul-2017 nicm

Line up keys in tree mode, and don't expand windows with one pane. From
Thomas Adam.


# 1.12 07-Jul-2017 nicm

Fix size of rightmost preview section.


# 1.11 04-Jul-2017 nicm

< and > keys to scroll preview list left and right in tree mode.


# 1.10 04-Jul-2017 nicm

Handle 0 size of preview box in caller.


# 1.9 03-Jul-2017 nicm

Change session and window preview so that the current window or pane is
always shown.


# 1.8 30-Jun-2017 nicm

Don't write over right border.


# 1.7 30-Jun-2017 nicm

Fix previous when we end up able to show no panes.


# 1.6 30-Jun-2017 nicm

Try to show a better preview of sessions and windows in tree mode.


# 1.5 09-Jun-2017 nicm

Extend filters (f key) to buffer and client mode and add -f flag to
specify to command.


# 1.4 09-Jun-2017 nicm

Add -O option to choose-* to set initial sort order.


# 1.3 07-Jun-2017 nicm

Add simple searching (C-s and n) to the various choose modes: by name
for client and tree, and by name and content for buffer.


# 1.2 06-Jun-2017 nicm

Do not pass a state into commands when fired on individual items in tree
mode, rely on the %% target substitution in the command for the chosen
pane and leave the default target as the current pane (where the mode
is). Otherwise, joinp and similar end up with -t and -s the
same. Reported by Jacob Niehus in GitHub issue 960.


# 1.1 30-May-2017 nicm

Rewrite of choose mode, both to simplify and tidy the code and to add
some modern features.

Now the common code is in mode-tree.c, which provides an API used by the
three modes now separated into window-{buffer,client,tree}.c. Buffer
mode shows buffers, client mode clients and tree mode a tree of
sessions, windows and panes.

Each mode has a common set of key bindings plus a few that are specific
to the mode. Other changes are:

- each mode has a preview pane: for buffers this is the buffer content
(very useful), for others it is a preview of the pane;

- items may be sorted in different ways ('O' key);

- multiple items may be tagged and an operation applied to all of them
(for example, to delete multiple buffers at once);

- in tree mode a command may be run on the selected item (session,
window, pane) or on tagged items (key ':');

- displayed items may be filtered in tree mode by using a format (this
is used to implement find-window) (key 'f');

- the custom format (-F) for the display is no longer available;

- shortcut keys change from 0-9, a-z, A-Z which was always a bit weird
with keys used for other uses to 0-9, M-a to M-z.

Now that the code is simpler, other improvements will come later.

Primary key bindings for each mode are documented under the commands in
the man page (choose-buffer, choose-client, choose-tree).

Parts written by Thomas Adam.


# 1.38 12-May-2019 nicm

Add simple menus to tree, client, buffer modes.


# 1.37 30-Apr-2019 nicm

Fix memory leak in window tree search, from Amos Bird.


# 1.36 17-Apr-2019 nicm

Break new window and pane creation common code from various commands and
window.c into a separate file spawn.c.


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

Add format variables for the default formats for the various modes
(tree_mode_format and so on) and add a -a flag to display-message to
list variables with values.


# 1.34 12-Mar-2019 nicm

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


# 1.33 07-Mar-2019 nicm

Add a separate mode struct for the active window mode if any.


# 1.32 18-Dec-2018 nicm

Pass window into mode functions.


Revision tags: OPENBSD_6_4_BASE
# 1.31 19-Aug-2018 nicm

Expand \u and \U escape sequences in command strings, from Christopher
Hunt in GitHub issue 1443.


# 1.30 10-Apr-2018 nicm

Add x and X to choose-tree (with a confirmation prompt) to kill an
item. Suggested by Matt Zagrabelny.


# 1.29 29-Mar-2018 nicm

Do not crash on empty window, reported by Jamie Macdonald in GitHub
issue 1299. Patch from Thomas Adam.


Revision tags: OPENBSD_6_3_BASE
# 1.28 28-Feb-2018 nicm

Add -Z flag to choose-tree, choose-client, choose-buffer to
automatically zoom the pane when the mode is entered and unzoom when it
exits, assuming the pane is not already zoomed. Add -Z to the default
key bindings.


# 1.27 03-Nov-2017 nicm

Support mouse on preview in tree mode.


# 1.26 02-Nov-2017 nicm

Make the mode draw function use the parent screen directly rather than
its own to avoid copying twice.


# 1.25 02-Nov-2017 nicm

Format for group list of "other sessions" is a bit weird, just list all
the sessions in the group.


# 1.24 02-Nov-2017 nicm

Tweak previous slightly so that current session is chosen if it is in
the group rather than first.


# 1.23 02-Nov-2017 nicm

Only show the first member of session groups in tree mode (-G flag
disables).


# 1.22 26-Oct-2017 nicm

Fix crash exiting command prompt (from Alex Maese in GitHub issue 1139)
and a man page tweak from jmc.


# 1.21 25-Oct-2017 nicm

Add P key to paste tagged in buffer mode, and trim some code that should
no longer be necessary.


# 1.20 22-Oct-2017 nicm

Use window_pane_index() when drawing pane numbers (so pane-base-index is
applied), from Thomas Adam. GitHub issue 1125.


# 1.19 11-Oct-2017 nicm

Box around label in preview.


# 1.18 11-Oct-2017 nicm

Add C-n and C-p keys for tree mode, and choose the right initial line
when no panes.


Revision tags: OPENBSD_6_2_BASE
# 1.17 30-Aug-2017 nicm

Pass flags into cmd_find_from_* to fix prefer-unattached, reported by
Thomas Sattler.


# 1.16 09-Aug-2017 nicm

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


# 1.15 09-Aug-2017 nicm

Add -F to choose-tree, choose-client, choose-buffer to specify the
format of each line, as well as adding a couple of formats needed for
the default display.


# 1.14 28-Jul-2017 nicm

Show pane title in window list for windows with only one pane.


# 1.13 12-Jul-2017 nicm

Line up keys in tree mode, and don't expand windows with one pane. From
Thomas Adam.


# 1.12 07-Jul-2017 nicm

Fix size of rightmost preview section.


# 1.11 04-Jul-2017 nicm

< and > keys to scroll preview list left and right in tree mode.


# 1.10 04-Jul-2017 nicm

Handle 0 size of preview box in caller.


# 1.9 03-Jul-2017 nicm

Change session and window preview so that the current window or pane is
always shown.


# 1.8 30-Jun-2017 nicm

Don't write over right border.


# 1.7 30-Jun-2017 nicm

Fix previous when we end up able to show no panes.


# 1.6 30-Jun-2017 nicm

Try to show a better preview of sessions and windows in tree mode.


# 1.5 09-Jun-2017 nicm

Extend filters (f key) to buffer and client mode and add -f flag to
specify to command.


# 1.4 09-Jun-2017 nicm

Add -O option to choose-* to set initial sort order.


# 1.3 07-Jun-2017 nicm

Add simple searching (C-s and n) to the various choose modes: by name
for client and tree, and by name and content for buffer.


# 1.2 06-Jun-2017 nicm

Do not pass a state into commands when fired on individual items in tree
mode, rely on the %% target substitution in the command for the chosen
pane and leave the default target as the current pane (where the mode
is). Otherwise, joinp and similar end up with -t and -s the
same. Reported by Jacob Niehus in GitHub issue 960.


# 1.1 30-May-2017 nicm

Rewrite of choose mode, both to simplify and tidy the code and to add
some modern features.

Now the common code is in mode-tree.c, which provides an API used by the
three modes now separated into window-{buffer,client,tree}.c. Buffer
mode shows buffers, client mode clients and tree mode a tree of
sessions, windows and panes.

Each mode has a common set of key bindings plus a few that are specific
to the mode. Other changes are:

- each mode has a preview pane: for buffers this is the buffer content
(very useful), for others it is a preview of the pane;

- items may be sorted in different ways ('O' key);

- multiple items may be tagged and an operation applied to all of them
(for example, to delete multiple buffers at once);

- in tree mode a command may be run on the selected item (session,
window, pane) or on tagged items (key ':');

- displayed items may be filtered in tree mode by using a format (this
is used to implement find-window) (key 'f');

- the custom format (-F) for the display is no longer available;

- shortcut keys change from 0-9, a-z, A-Z which was always a bit weird
with keys used for other uses to 0-9, M-a to M-z.

Now that the code is simpler, other improvements will come later.

Primary key bindings for each mode are documented under the commands in
the man page (choose-buffer, choose-client, choose-tree).

Parts written by Thomas Adam.


# 1.37 30-Apr-2019 nicm

Fix memory leak in window tree search, from Amos Bird.


# 1.36 17-Apr-2019 nicm

Break new window and pane creation common code from various commands and
window.c into a separate file spawn.c.


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

Add format variables for the default formats for the various modes
(tree_mode_format and so on) and add a -a flag to display-message to
list variables with values.


# 1.34 12-Mar-2019 nicm

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


# 1.33 07-Mar-2019 nicm

Add a separate mode struct for the active window mode if any.


# 1.32 18-Dec-2018 nicm

Pass window into mode functions.


Revision tags: OPENBSD_6_4_BASE
# 1.31 19-Aug-2018 nicm

Expand \u and \U escape sequences in command strings, from Christopher
Hunt in GitHub issue 1443.


# 1.30 10-Apr-2018 nicm

Add x and X to choose-tree (with a confirmation prompt) to kill an
item. Suggested by Matt Zagrabelny.


# 1.29 29-Mar-2018 nicm

Do not crash on empty window, reported by Jamie Macdonald in GitHub
issue 1299. Patch from Thomas Adam.


Revision tags: OPENBSD_6_3_BASE
# 1.28 28-Feb-2018 nicm

Add -Z flag to choose-tree, choose-client, choose-buffer to
automatically zoom the pane when the mode is entered and unzoom when it
exits, assuming the pane is not already zoomed. Add -Z to the default
key bindings.


# 1.27 03-Nov-2017 nicm

Support mouse on preview in tree mode.


# 1.26 02-Nov-2017 nicm

Make the mode draw function use the parent screen directly rather than
its own to avoid copying twice.


# 1.25 02-Nov-2017 nicm

Format for group list of "other sessions" is a bit weird, just list all
the sessions in the group.


# 1.24 02-Nov-2017 nicm

Tweak previous slightly so that current session is chosen if it is in
the group rather than first.


# 1.23 02-Nov-2017 nicm

Only show the first member of session groups in tree mode (-G flag
disables).


# 1.22 26-Oct-2017 nicm

Fix crash exiting command prompt (from Alex Maese in GitHub issue 1139)
and a man page tweak from jmc.


# 1.21 25-Oct-2017 nicm

Add P key to paste tagged in buffer mode, and trim some code that should
no longer be necessary.


# 1.20 22-Oct-2017 nicm

Use window_pane_index() when drawing pane numbers (so pane-base-index is
applied), from Thomas Adam. GitHub issue 1125.


# 1.19 11-Oct-2017 nicm

Box around label in preview.


# 1.18 11-Oct-2017 nicm

Add C-n and C-p keys for tree mode, and choose the right initial line
when no panes.


Revision tags: OPENBSD_6_2_BASE
# 1.17 30-Aug-2017 nicm

Pass flags into cmd_find_from_* to fix prefer-unattached, reported by
Thomas Sattler.


# 1.16 09-Aug-2017 nicm

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


# 1.15 09-Aug-2017 nicm

Add -F to choose-tree, choose-client, choose-buffer to specify the
format of each line, as well as adding a couple of formats needed for
the default display.


# 1.14 28-Jul-2017 nicm

Show pane title in window list for windows with only one pane.


# 1.13 12-Jul-2017 nicm

Line up keys in tree mode, and don't expand windows with one pane. From
Thomas Adam.


# 1.12 07-Jul-2017 nicm

Fix size of rightmost preview section.


# 1.11 04-Jul-2017 nicm

< and > keys to scroll preview list left and right in tree mode.


# 1.10 04-Jul-2017 nicm

Handle 0 size of preview box in caller.


# 1.9 03-Jul-2017 nicm

Change session and window preview so that the current window or pane is
always shown.


# 1.8 30-Jun-2017 nicm

Don't write over right border.


# 1.7 30-Jun-2017 nicm

Fix previous when we end up able to show no panes.


# 1.6 30-Jun-2017 nicm

Try to show a better preview of sessions and windows in tree mode.


# 1.5 09-Jun-2017 nicm

Extend filters (f key) to buffer and client mode and add -f flag to
specify to command.


# 1.4 09-Jun-2017 nicm

Add -O option to choose-* to set initial sort order.


# 1.3 07-Jun-2017 nicm

Add simple searching (C-s and n) to the various choose modes: by name
for client and tree, and by name and content for buffer.


# 1.2 06-Jun-2017 nicm

Do not pass a state into commands when fired on individual items in tree
mode, rely on the %% target substitution in the command for the chosen
pane and leave the default target as the current pane (where the mode
is). Otherwise, joinp and similar end up with -t and -s the
same. Reported by Jacob Niehus in GitHub issue 960.


# 1.1 30-May-2017 nicm

Rewrite of choose mode, both to simplify and tidy the code and to add
some modern features.

Now the common code is in mode-tree.c, which provides an API used by the
three modes now separated into window-{buffer,client,tree}.c. Buffer
mode shows buffers, client mode clients and tree mode a tree of
sessions, windows and panes.

Each mode has a common set of key bindings plus a few that are specific
to the mode. Other changes are:

- each mode has a preview pane: for buffers this is the buffer content
(very useful), for others it is a preview of the pane;

- items may be sorted in different ways ('O' key);

- multiple items may be tagged and an operation applied to all of them
(for example, to delete multiple buffers at once);

- in tree mode a command may be run on the selected item (session,
window, pane) or on tagged items (key ':');

- displayed items may be filtered in tree mode by using a format (this
is used to implement find-window) (key 'f');

- the custom format (-F) for the display is no longer available;

- shortcut keys change from 0-9, a-z, A-Z which was always a bit weird
with keys used for other uses to 0-9, M-a to M-z.

Now that the code is simpler, other improvements will come later.

Primary key bindings for each mode are documented under the commands in
the man page (choose-buffer, choose-client, choose-tree).

Parts written by Thomas Adam.


# 1.33 07-Mar-2019 nicm

Add a separate mode struct for the active window mode if any.


# 1.32 18-Dec-2018 nicm

Pass window into mode functions.


Revision tags: OPENBSD_6_4_BASE
# 1.31 19-Aug-2018 nicm

Expand \u and \U escape sequences in command strings, from Christopher
Hunt in GitHub issue 1443.


# 1.30 10-Apr-2018 nicm

Add x and X to choose-tree (with a confirmation prompt) to kill an
item. Suggested by Matt Zagrabelny.


# 1.29 29-Mar-2018 nicm

Do not crash on empty window, reported by Jamie Macdonald in GitHub
issue 1299. Patch from Thomas Adam.


Revision tags: OPENBSD_6_3_BASE
# 1.28 28-Feb-2018 nicm

Add -Z flag to choose-tree, choose-client, choose-buffer to
automatically zoom the pane when the mode is entered and unzoom when it
exits, assuming the pane is not already zoomed. Add -Z to the default
key bindings.


# 1.27 03-Nov-2017 nicm

Support mouse on preview in tree mode.


# 1.26 02-Nov-2017 nicm

Make the mode draw function use the parent screen directly rather than
its own to avoid copying twice.


# 1.25 02-Nov-2017 nicm

Format for group list of "other sessions" is a bit weird, just list all
the sessions in the group.


# 1.24 02-Nov-2017 nicm

Tweak previous slightly so that current session is chosen if it is in
the group rather than first.


# 1.23 02-Nov-2017 nicm

Only show the first member of session groups in tree mode (-G flag
disables).


# 1.22 26-Oct-2017 nicm

Fix crash exiting command prompt (from Alex Maese in GitHub issue 1139)
and a man page tweak from jmc.


# 1.21 25-Oct-2017 nicm

Add P key to paste tagged in buffer mode, and trim some code that should
no longer be necessary.


# 1.20 22-Oct-2017 nicm

Use window_pane_index() when drawing pane numbers (so pane-base-index is
applied), from Thomas Adam. GitHub issue 1125.


# 1.19 11-Oct-2017 nicm

Box around label in preview.


# 1.18 11-Oct-2017 nicm

Add C-n and C-p keys for tree mode, and choose the right initial line
when no panes.


Revision tags: OPENBSD_6_2_BASE
# 1.17 30-Aug-2017 nicm

Pass flags into cmd_find_from_* to fix prefer-unattached, reported by
Thomas Sattler.


# 1.16 09-Aug-2017 nicm

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


# 1.15 09-Aug-2017 nicm

Add -F to choose-tree, choose-client, choose-buffer to specify the
format of each line, as well as adding a couple of formats needed for
the default display.


# 1.14 28-Jul-2017 nicm

Show pane title in window list for windows with only one pane.


# 1.13 12-Jul-2017 nicm

Line up keys in tree mode, and don't expand windows with one pane. From
Thomas Adam.


# 1.12 07-Jul-2017 nicm

Fix size of rightmost preview section.


# 1.11 04-Jul-2017 nicm

< and > keys to scroll preview list left and right in tree mode.


# 1.10 04-Jul-2017 nicm

Handle 0 size of preview box in caller.


# 1.9 03-Jul-2017 nicm

Change session and window preview so that the current window or pane is
always shown.


# 1.8 30-Jun-2017 nicm

Don't write over right border.


# 1.7 30-Jun-2017 nicm

Fix previous when we end up able to show no panes.


# 1.6 30-Jun-2017 nicm

Try to show a better preview of sessions and windows in tree mode.


# 1.5 09-Jun-2017 nicm

Extend filters (f key) to buffer and client mode and add -f flag to
specify to command.


# 1.4 09-Jun-2017 nicm

Add -O option to choose-* to set initial sort order.


# 1.3 07-Jun-2017 nicm

Add simple searching (C-s and n) to the various choose modes: by name
for client and tree, and by name and content for buffer.


# 1.2 06-Jun-2017 nicm

Do not pass a state into commands when fired on individual items in tree
mode, rely on the %% target substitution in the command for the chosen
pane and leave the default target as the current pane (where the mode
is). Otherwise, joinp and similar end up with -t and -s the
same. Reported by Jacob Niehus in GitHub issue 960.


# 1.1 30-May-2017 nicm

Rewrite of choose mode, both to simplify and tidy the code and to add
some modern features.

Now the common code is in mode-tree.c, which provides an API used by the
three modes now separated into window-{buffer,client,tree}.c. Buffer
mode shows buffers, client mode clients and tree mode a tree of
sessions, windows and panes.

Each mode has a common set of key bindings plus a few that are specific
to the mode. Other changes are:

- each mode has a preview pane: for buffers this is the buffer content
(very useful), for others it is a preview of the pane;

- items may be sorted in different ways ('O' key);

- multiple items may be tagged and an operation applied to all of them
(for example, to delete multiple buffers at once);

- in tree mode a command may be run on the selected item (session,
window, pane) or on tagged items (key ':');

- displayed items may be filtered in tree mode by using a format (this
is used to implement find-window) (key 'f');

- the custom format (-F) for the display is no longer available;

- shortcut keys change from 0-9, a-z, A-Z which was always a bit weird
with keys used for other uses to 0-9, M-a to M-z.

Now that the code is simpler, other improvements will come later.

Primary key bindings for each mode are documented under the commands in
the man page (choose-buffer, choose-client, choose-tree).

Parts written by Thomas Adam.


# 1.32 18-Dec-2018 nicm

Pass window into mode functions.


Revision tags: OPENBSD_6_4_BASE
# 1.31 19-Aug-2018 nicm

Expand \u and \U escape sequences in command strings, from Christopher
Hunt in GitHub issue 1443.


# 1.30 10-Apr-2018 nicm

Add x and X to choose-tree (with a confirmation prompt) to kill an
item. Suggested by Matt Zagrabelny.


# 1.29 29-Mar-2018 nicm

Do not crash on empty window, reported by Jamie Macdonald in GitHub
issue 1299. Patch from Thomas Adam.


Revision tags: OPENBSD_6_3_BASE
# 1.28 28-Feb-2018 nicm

Add -Z flag to choose-tree, choose-client, choose-buffer to
automatically zoom the pane when the mode is entered and unzoom when it
exits, assuming the pane is not already zoomed. Add -Z to the default
key bindings.


# 1.27 03-Nov-2017 nicm

Support mouse on preview in tree mode.


# 1.26 02-Nov-2017 nicm

Make the mode draw function use the parent screen directly rather than
its own to avoid copying twice.


# 1.25 02-Nov-2017 nicm

Format for group list of "other sessions" is a bit weird, just list all
the sessions in the group.


# 1.24 02-Nov-2017 nicm

Tweak previous slightly so that current session is chosen if it is in
the group rather than first.


# 1.23 02-Nov-2017 nicm

Only show the first member of session groups in tree mode (-G flag
disables).


# 1.22 26-Oct-2017 nicm

Fix crash exiting command prompt (from Alex Maese in GitHub issue 1139)
and a man page tweak from jmc.


# 1.21 25-Oct-2017 nicm

Add P key to paste tagged in buffer mode, and trim some code that should
no longer be necessary.


# 1.20 22-Oct-2017 nicm

Use window_pane_index() when drawing pane numbers (so pane-base-index is
applied), from Thomas Adam. GitHub issue 1125.


# 1.19 11-Oct-2017 nicm

Box around label in preview.


# 1.18 11-Oct-2017 nicm

Add C-n and C-p keys for tree mode, and choose the right initial line
when no panes.


Revision tags: OPENBSD_6_2_BASE
# 1.17 30-Aug-2017 nicm

Pass flags into cmd_find_from_* to fix prefer-unattached, reported by
Thomas Sattler.


# 1.16 09-Aug-2017 nicm

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


# 1.15 09-Aug-2017 nicm

Add -F to choose-tree, choose-client, choose-buffer to specify the
format of each line, as well as adding a couple of formats needed for
the default display.


# 1.14 28-Jul-2017 nicm

Show pane title in window list for windows with only one pane.


# 1.13 12-Jul-2017 nicm

Line up keys in tree mode, and don't expand windows with one pane. From
Thomas Adam.


# 1.12 07-Jul-2017 nicm

Fix size of rightmost preview section.


# 1.11 04-Jul-2017 nicm

< and > keys to scroll preview list left and right in tree mode.


# 1.10 04-Jul-2017 nicm

Handle 0 size of preview box in caller.


# 1.9 03-Jul-2017 nicm

Change session and window preview so that the current window or pane is
always shown.


# 1.8 30-Jun-2017 nicm

Don't write over right border.


# 1.7 30-Jun-2017 nicm

Fix previous when we end up able to show no panes.


# 1.6 30-Jun-2017 nicm

Try to show a better preview of sessions and windows in tree mode.


# 1.5 09-Jun-2017 nicm

Extend filters (f key) to buffer and client mode and add -f flag to
specify to command.


# 1.4 09-Jun-2017 nicm

Add -O option to choose-* to set initial sort order.


# 1.3 07-Jun-2017 nicm

Add simple searching (C-s and n) to the various choose modes: by name
for client and tree, and by name and content for buffer.


# 1.2 06-Jun-2017 nicm

Do not pass a state into commands when fired on individual items in tree
mode, rely on the %% target substitution in the command for the chosen
pane and leave the default target as the current pane (where the mode
is). Otherwise, joinp and similar end up with -t and -s the
same. Reported by Jacob Niehus in GitHub issue 960.


# 1.1 30-May-2017 nicm

Rewrite of choose mode, both to simplify and tidy the code and to add
some modern features.

Now the common code is in mode-tree.c, which provides an API used by the
three modes now separated into window-{buffer,client,tree}.c. Buffer
mode shows buffers, client mode clients and tree mode a tree of
sessions, windows and panes.

Each mode has a common set of key bindings plus a few that are specific
to the mode. Other changes are:

- each mode has a preview pane: for buffers this is the buffer content
(very useful), for others it is a preview of the pane;

- items may be sorted in different ways ('O' key);

- multiple items may be tagged and an operation applied to all of them
(for example, to delete multiple buffers at once);

- in tree mode a command may be run on the selected item (session,
window, pane) or on tagged items (key ':');

- displayed items may be filtered in tree mode by using a format (this
is used to implement find-window) (key 'f');

- the custom format (-F) for the display is no longer available;

- shortcut keys change from 0-9, a-z, A-Z which was always a bit weird
with keys used for other uses to 0-9, M-a to M-z.

Now that the code is simpler, other improvements will come later.

Primary key bindings for each mode are documented under the commands in
the man page (choose-buffer, choose-client, choose-tree).

Parts written by Thomas Adam.


# 1.31 19-Aug-2018 nicm

Expand \u and \U escape sequences in command strings, from Christopher
Hunt in GitHub issue 1443.


# 1.30 10-Apr-2018 nicm

Add x and X to choose-tree (with a confirmation prompt) to kill an
item. Suggested by Matt Zagrabelny.


# 1.29 29-Mar-2018 nicm

Do not crash on empty window, reported by Jamie Macdonald in GitHub
issue 1299. Patch from Thomas Adam.


Revision tags: OPENBSD_6_3_BASE
# 1.28 28-Feb-2018 nicm

Add -Z flag to choose-tree, choose-client, choose-buffer to
automatically zoom the pane when the mode is entered and unzoom when it
exits, assuming the pane is not already zoomed. Add -Z to the default
key bindings.


# 1.27 03-Nov-2017 nicm

Support mouse on preview in tree mode.


# 1.26 02-Nov-2017 nicm

Make the mode draw function use the parent screen directly rather than
its own to avoid copying twice.


# 1.25 02-Nov-2017 nicm

Format for group list of "other sessions" is a bit weird, just list all
the sessions in the group.


# 1.24 02-Nov-2017 nicm

Tweak previous slightly so that current session is chosen if it is in
the group rather than first.


# 1.23 02-Nov-2017 nicm

Only show the first member of session groups in tree mode (-G flag
disables).


# 1.22 26-Oct-2017 nicm

Fix crash exiting command prompt (from Alex Maese in GitHub issue 1139)
and a man page tweak from jmc.


# 1.21 25-Oct-2017 nicm

Add P key to paste tagged in buffer mode, and trim some code that should
no longer be necessary.


# 1.20 22-Oct-2017 nicm

Use window_pane_index() when drawing pane numbers (so pane-base-index is
applied), from Thomas Adam. GitHub issue 1125.


# 1.19 11-Oct-2017 nicm

Box around label in preview.


# 1.18 11-Oct-2017 nicm

Add C-n and C-p keys for tree mode, and choose the right initial line
when no panes.


Revision tags: OPENBSD_6_2_BASE
# 1.17 30-Aug-2017 nicm

Pass flags into cmd_find_from_* to fix prefer-unattached, reported by
Thomas Sattler.


# 1.16 09-Aug-2017 nicm

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


# 1.15 09-Aug-2017 nicm

Add -F to choose-tree, choose-client, choose-buffer to specify the
format of each line, as well as adding a couple of formats needed for
the default display.


# 1.14 28-Jul-2017 nicm

Show pane title in window list for windows with only one pane.


# 1.13 12-Jul-2017 nicm

Line up keys in tree mode, and don't expand windows with one pane. From
Thomas Adam.


# 1.12 07-Jul-2017 nicm

Fix size of rightmost preview section.


# 1.11 04-Jul-2017 nicm

< and > keys to scroll preview list left and right in tree mode.


# 1.10 04-Jul-2017 nicm

Handle 0 size of preview box in caller.


# 1.9 03-Jul-2017 nicm

Change session and window preview so that the current window or pane is
always shown.


# 1.8 30-Jun-2017 nicm

Don't write over right border.


# 1.7 30-Jun-2017 nicm

Fix previous when we end up able to show no panes.


# 1.6 30-Jun-2017 nicm

Try to show a better preview of sessions and windows in tree mode.


# 1.5 09-Jun-2017 nicm

Extend filters (f key) to buffer and client mode and add -f flag to
specify to command.


# 1.4 09-Jun-2017 nicm

Add -O option to choose-* to set initial sort order.


# 1.3 07-Jun-2017 nicm

Add simple searching (C-s and n) to the various choose modes: by name
for client and tree, and by name and content for buffer.


# 1.2 06-Jun-2017 nicm

Do not pass a state into commands when fired on individual items in tree
mode, rely on the %% target substitution in the command for the chosen
pane and leave the default target as the current pane (where the mode
is). Otherwise, joinp and similar end up with -t and -s the
same. Reported by Jacob Niehus in GitHub issue 960.


# 1.1 30-May-2017 nicm

Rewrite of choose mode, both to simplify and tidy the code and to add
some modern features.

Now the common code is in mode-tree.c, which provides an API used by the
three modes now separated into window-{buffer,client,tree}.c. Buffer
mode shows buffers, client mode clients and tree mode a tree of
sessions, windows and panes.

Each mode has a common set of key bindings plus a few that are specific
to the mode. Other changes are:

- each mode has a preview pane: for buffers this is the buffer content
(very useful), for others it is a preview of the pane;

- items may be sorted in different ways ('O' key);

- multiple items may be tagged and an operation applied to all of them
(for example, to delete multiple buffers at once);

- in tree mode a command may be run on the selected item (session,
window, pane) or on tagged items (key ':');

- displayed items may be filtered in tree mode by using a format (this
is used to implement find-window) (key 'f');

- the custom format (-F) for the display is no longer available;

- shortcut keys change from 0-9, a-z, A-Z which was always a bit weird
with keys used for other uses to 0-9, M-a to M-z.

Now that the code is simpler, other improvements will come later.

Primary key bindings for each mode are documented under the commands in
the man page (choose-buffer, choose-client, choose-tree).

Parts written by Thomas Adam.


# 1.30 10-Apr-2018 nicm

Add x and X to choose-tree (with a confirmation prompt) to kill an
item. Suggested by Matt Zagrabelny.


# 1.29 29-Mar-2018 nicm

Do not crash on empty window, reported by Jamie Macdonald in GitHub
issue 1299. Patch from Thomas Adam.


Revision tags: OPENBSD_6_3_BASE
# 1.28 28-Feb-2018 nicm

Add -Z flag to choose-tree, choose-client, choose-buffer to
automatically zoom the pane when the mode is entered and unzoom when it
exits, assuming the pane is not already zoomed. Add -Z to the default
key bindings.


# 1.27 03-Nov-2017 nicm

Support mouse on preview in tree mode.


# 1.26 02-Nov-2017 nicm

Make the mode draw function use the parent screen directly rather than
its own to avoid copying twice.


# 1.25 02-Nov-2017 nicm

Format for group list of "other sessions" is a bit weird, just list all
the sessions in the group.


# 1.24 02-Nov-2017 nicm

Tweak previous slightly so that current session is chosen if it is in
the group rather than first.


# 1.23 02-Nov-2017 nicm

Only show the first member of session groups in tree mode (-G flag
disables).


# 1.22 26-Oct-2017 nicm

Fix crash exiting command prompt (from Alex Maese in GitHub issue 1139)
and a man page tweak from jmc.


# 1.21 25-Oct-2017 nicm

Add P key to paste tagged in buffer mode, and trim some code that should
no longer be necessary.


# 1.20 22-Oct-2017 nicm

Use window_pane_index() when drawing pane numbers (so pane-base-index is
applied), from Thomas Adam. GitHub issue 1125.


# 1.19 11-Oct-2017 nicm

Box around label in preview.


# 1.18 11-Oct-2017 nicm

Add C-n and C-p keys for tree mode, and choose the right initial line
when no panes.


Revision tags: OPENBSD_6_2_BASE
# 1.17 30-Aug-2017 nicm

Pass flags into cmd_find_from_* to fix prefer-unattached, reported by
Thomas Sattler.


# 1.16 09-Aug-2017 nicm

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


# 1.15 09-Aug-2017 nicm

Add -F to choose-tree, choose-client, choose-buffer to specify the
format of each line, as well as adding a couple of formats needed for
the default display.


# 1.14 28-Jul-2017 nicm

Show pane title in window list for windows with only one pane.


# 1.13 12-Jul-2017 nicm

Line up keys in tree mode, and don't expand windows with one pane. From
Thomas Adam.


# 1.12 07-Jul-2017 nicm

Fix size of rightmost preview section.


# 1.11 04-Jul-2017 nicm

< and > keys to scroll preview list left and right in tree mode.


# 1.10 04-Jul-2017 nicm

Handle 0 size of preview box in caller.


# 1.9 03-Jul-2017 nicm

Change session and window preview so that the current window or pane is
always shown.


# 1.8 30-Jun-2017 nicm

Don't write over right border.


# 1.7 30-Jun-2017 nicm

Fix previous when we end up able to show no panes.


# 1.6 30-Jun-2017 nicm

Try to show a better preview of sessions and windows in tree mode.


# 1.5 09-Jun-2017 nicm

Extend filters (f key) to buffer and client mode and add -f flag to
specify to command.


# 1.4 09-Jun-2017 nicm

Add -O option to choose-* to set initial sort order.


# 1.3 07-Jun-2017 nicm

Add simple searching (C-s and n) to the various choose modes: by name
for client and tree, and by name and content for buffer.


# 1.2 06-Jun-2017 nicm

Do not pass a state into commands when fired on individual items in tree
mode, rely on the %% target substitution in the command for the chosen
pane and leave the default target as the current pane (where the mode
is). Otherwise, joinp and similar end up with -t and -s the
same. Reported by Jacob Niehus in GitHub issue 960.


# 1.1 30-May-2017 nicm

Rewrite of choose mode, both to simplify and tidy the code and to add
some modern features.

Now the common code is in mode-tree.c, which provides an API used by the
three modes now separated into window-{buffer,client,tree}.c. Buffer
mode shows buffers, client mode clients and tree mode a tree of
sessions, windows and panes.

Each mode has a common set of key bindings plus a few that are specific
to the mode. Other changes are:

- each mode has a preview pane: for buffers this is the buffer content
(very useful), for others it is a preview of the pane;

- items may be sorted in different ways ('O' key);

- multiple items may be tagged and an operation applied to all of them
(for example, to delete multiple buffers at once);

- in tree mode a command may be run on the selected item (session,
window, pane) or on tagged items (key ':');

- displayed items may be filtered in tree mode by using a format (this
is used to implement find-window) (key 'f');

- the custom format (-F) for the display is no longer available;

- shortcut keys change from 0-9, a-z, A-Z which was always a bit weird
with keys used for other uses to 0-9, M-a to M-z.

Now that the code is simpler, other improvements will come later.

Primary key bindings for each mode are documented under the commands in
the man page (choose-buffer, choose-client, choose-tree).

Parts written by Thomas Adam.


# 1.29 29-Mar-2018 nicm

Do not crash on empty window, reported by Jamie Macdonald in GitHub
issue 1299. Patch from Thomas Adam.


Revision tags: OPENBSD_6_3_BASE
# 1.28 28-Feb-2018 nicm

Add -Z flag to choose-tree, choose-client, choose-buffer to
automatically zoom the pane when the mode is entered and unzoom when it
exits, assuming the pane is not already zoomed. Add -Z to the default
key bindings.


# 1.27 03-Nov-2017 nicm

Support mouse on preview in tree mode.


# 1.26 02-Nov-2017 nicm

Make the mode draw function use the parent screen directly rather than
its own to avoid copying twice.


# 1.25 02-Nov-2017 nicm

Format for group list of "other sessions" is a bit weird, just list all
the sessions in the group.


# 1.24 02-Nov-2017 nicm

Tweak previous slightly so that current session is chosen if it is in
the group rather than first.


# 1.23 02-Nov-2017 nicm

Only show the first member of session groups in tree mode (-G flag
disables).


# 1.22 26-Oct-2017 nicm

Fix crash exiting command prompt (from Alex Maese in GitHub issue 1139)
and a man page tweak from jmc.


# 1.21 25-Oct-2017 nicm

Add P key to paste tagged in buffer mode, and trim some code that should
no longer be necessary.


# 1.20 22-Oct-2017 nicm

Use window_pane_index() when drawing pane numbers (so pane-base-index is
applied), from Thomas Adam. GitHub issue 1125.


# 1.19 11-Oct-2017 nicm

Box around label in preview.


# 1.18 11-Oct-2017 nicm

Add C-n and C-p keys for tree mode, and choose the right initial line
when no panes.


Revision tags: OPENBSD_6_2_BASE
# 1.17 30-Aug-2017 nicm

Pass flags into cmd_find_from_* to fix prefer-unattached, reported by
Thomas Sattler.


# 1.16 09-Aug-2017 nicm

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


# 1.15 09-Aug-2017 nicm

Add -F to choose-tree, choose-client, choose-buffer to specify the
format of each line, as well as adding a couple of formats needed for
the default display.


# 1.14 28-Jul-2017 nicm

Show pane title in window list for windows with only one pane.


# 1.13 12-Jul-2017 nicm

Line up keys in tree mode, and don't expand windows with one pane. From
Thomas Adam.


# 1.12 07-Jul-2017 nicm

Fix size of rightmost preview section.


# 1.11 04-Jul-2017 nicm

< and > keys to scroll preview list left and right in tree mode.


# 1.10 04-Jul-2017 nicm

Handle 0 size of preview box in caller.


# 1.9 03-Jul-2017 nicm

Change session and window preview so that the current window or pane is
always shown.


# 1.8 30-Jun-2017 nicm

Don't write over right border.


# 1.7 30-Jun-2017 nicm

Fix previous when we end up able to show no panes.


# 1.6 30-Jun-2017 nicm

Try to show a better preview of sessions and windows in tree mode.


# 1.5 09-Jun-2017 nicm

Extend filters (f key) to buffer and client mode and add -f flag to
specify to command.


# 1.4 09-Jun-2017 nicm

Add -O option to choose-* to set initial sort order.


# 1.3 07-Jun-2017 nicm

Add simple searching (C-s and n) to the various choose modes: by name
for client and tree, and by name and content for buffer.


# 1.2 06-Jun-2017 nicm

Do not pass a state into commands when fired on individual items in tree
mode, rely on the %% target substitution in the command for the chosen
pane and leave the default target as the current pane (where the mode
is). Otherwise, joinp and similar end up with -t and -s the
same. Reported by Jacob Niehus in GitHub issue 960.


# 1.1 30-May-2017 nicm

Rewrite of choose mode, both to simplify and tidy the code and to add
some modern features.

Now the common code is in mode-tree.c, which provides an API used by the
three modes now separated into window-{buffer,client,tree}.c. Buffer
mode shows buffers, client mode clients and tree mode a tree of
sessions, windows and panes.

Each mode has a common set of key bindings plus a few that are specific
to the mode. Other changes are:

- each mode has a preview pane: for buffers this is the buffer content
(very useful), for others it is a preview of the pane;

- items may be sorted in different ways ('O' key);

- multiple items may be tagged and an operation applied to all of them
(for example, to delete multiple buffers at once);

- in tree mode a command may be run on the selected item (session,
window, pane) or on tagged items (key ':');

- displayed items may be filtered in tree mode by using a format (this
is used to implement find-window) (key 'f');

- the custom format (-F) for the display is no longer available;

- shortcut keys change from 0-9, a-z, A-Z which was always a bit weird
with keys used for other uses to 0-9, M-a to M-z.

Now that the code is simpler, other improvements will come later.

Primary key bindings for each mode are documented under the commands in
the man page (choose-buffer, choose-client, choose-tree).

Parts written by Thomas Adam.


# 1.28 28-Feb-2018 nicm

Add -Z flag to choose-tree, choose-client, choose-buffer to
automatically zoom the pane when the mode is entered and unzoom when it
exits, assuming the pane is not already zoomed. Add -Z to the default
key bindings.


# 1.27 03-Nov-2017 nicm

Support mouse on preview in tree mode.


# 1.26 02-Nov-2017 nicm

Make the mode draw function use the parent screen directly rather than
its own to avoid copying twice.


# 1.25 02-Nov-2017 nicm

Format for group list of "other sessions" is a bit weird, just list all
the sessions in the group.


# 1.24 02-Nov-2017 nicm

Tweak previous slightly so that current session is chosen if it is in
the group rather than first.


# 1.23 02-Nov-2017 nicm

Only show the first member of session groups in tree mode (-G flag
disables).


# 1.22 26-Oct-2017 nicm

Fix crash exiting command prompt (from Alex Maese in GitHub issue 1139)
and a man page tweak from jmc.


# 1.21 25-Oct-2017 nicm

Add P key to paste tagged in buffer mode, and trim some code that should
no longer be necessary.


# 1.20 22-Oct-2017 nicm

Use window_pane_index() when drawing pane numbers (so pane-base-index is
applied), from Thomas Adam. GitHub issue 1125.


# 1.19 11-Oct-2017 nicm

Box around label in preview.


# 1.18 11-Oct-2017 nicm

Add C-n and C-p keys for tree mode, and choose the right initial line
when no panes.


Revision tags: OPENBSD_6_2_BASE
# 1.17 30-Aug-2017 nicm

Pass flags into cmd_find_from_* to fix prefer-unattached, reported by
Thomas Sattler.


# 1.16 09-Aug-2017 nicm

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


# 1.15 09-Aug-2017 nicm

Add -F to choose-tree, choose-client, choose-buffer to specify the
format of each line, as well as adding a couple of formats needed for
the default display.


# 1.14 28-Jul-2017 nicm

Show pane title in window list for windows with only one pane.


# 1.13 12-Jul-2017 nicm

Line up keys in tree mode, and don't expand windows with one pane. From
Thomas Adam.


# 1.12 07-Jul-2017 nicm

Fix size of rightmost preview section.


# 1.11 04-Jul-2017 nicm

< and > keys to scroll preview list left and right in tree mode.


# 1.10 04-Jul-2017 nicm

Handle 0 size of preview box in caller.


# 1.9 03-Jul-2017 nicm

Change session and window preview so that the current window or pane is
always shown.


# 1.8 30-Jun-2017 nicm

Don't write over right border.


# 1.7 30-Jun-2017 nicm

Fix previous when we end up able to show no panes.


# 1.6 30-Jun-2017 nicm

Try to show a better preview of sessions and windows in tree mode.


# 1.5 09-Jun-2017 nicm

Extend filters (f key) to buffer and client mode and add -f flag to
specify to command.


# 1.4 09-Jun-2017 nicm

Add -O option to choose-* to set initial sort order.


# 1.3 07-Jun-2017 nicm

Add simple searching (C-s and n) to the various choose modes: by name
for client and tree, and by name and content for buffer.


# 1.2 06-Jun-2017 nicm

Do not pass a state into commands when fired on individual items in tree
mode, rely on the %% target substitution in the command for the chosen
pane and leave the default target as the current pane (where the mode
is). Otherwise, joinp and similar end up with -t and -s the
same. Reported by Jacob Niehus in GitHub issue 960.


# 1.1 30-May-2017 nicm

Rewrite of choose mode, both to simplify and tidy the code and to add
some modern features.

Now the common code is in mode-tree.c, which provides an API used by the
three modes now separated into window-{buffer,client,tree}.c. Buffer
mode shows buffers, client mode clients and tree mode a tree of
sessions, windows and panes.

Each mode has a common set of key bindings plus a few that are specific
to the mode. Other changes are:

- each mode has a preview pane: for buffers this is the buffer content
(very useful), for others it is a preview of the pane;

- items may be sorted in different ways ('O' key);

- multiple items may be tagged and an operation applied to all of them
(for example, to delete multiple buffers at once);

- in tree mode a command may be run on the selected item (session,
window, pane) or on tagged items (key ':');

- displayed items may be filtered in tree mode by using a format (this
is used to implement find-window) (key 'f');

- the custom format (-F) for the display is no longer available;

- shortcut keys change from 0-9, a-z, A-Z which was always a bit weird
with keys used for other uses to 0-9, M-a to M-z.

Now that the code is simpler, other improvements will come later.

Primary key bindings for each mode are documented under the commands in
the man page (choose-buffer, choose-client, choose-tree).

Parts written by Thomas Adam.


# 1.27 03-Nov-2017 nicm

Support mouse on preview in tree mode.


# 1.26 02-Nov-2017 nicm

Make the mode draw function use the parent screen directly rather than
its own to avoid copying twice.


# 1.25 02-Nov-2017 nicm

Format for group list of "other sessions" is a bit weird, just list all
the sessions in the group.


# 1.24 02-Nov-2017 nicm

Tweak previous slightly so that current session is chosen if it is in
the group rather than first.


# 1.23 02-Nov-2017 nicm

Only show the first member of session groups in tree mode (-G flag
disables).


# 1.22 26-Oct-2017 nicm

Fix crash exiting command prompt (from Alex Maese in GitHub issue 1139)
and a man page tweak from jmc.


# 1.21 25-Oct-2017 nicm

Add P key to paste tagged in buffer mode, and trim some code that should
no longer be necessary.


# 1.20 22-Oct-2017 nicm

Use window_pane_index() when drawing pane numbers (so pane-base-index is
applied), from Thomas Adam. GitHub issue 1125.


# 1.19 11-Oct-2017 nicm

Box around label in preview.


# 1.18 11-Oct-2017 nicm

Add C-n and C-p keys for tree mode, and choose the right initial line
when no panes.


Revision tags: OPENBSD_6_2_BASE
# 1.17 30-Aug-2017 nicm

Pass flags into cmd_find_from_* to fix prefer-unattached, reported by
Thomas Sattler.


# 1.16 09-Aug-2017 nicm

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


# 1.15 09-Aug-2017 nicm

Add -F to choose-tree, choose-client, choose-buffer to specify the
format of each line, as well as adding a couple of formats needed for
the default display.


# 1.14 28-Jul-2017 nicm

Show pane title in window list for windows with only one pane.


# 1.13 12-Jul-2017 nicm

Line up keys in tree mode, and don't expand windows with one pane. From
Thomas Adam.


# 1.12 07-Jul-2017 nicm

Fix size of rightmost preview section.


# 1.11 04-Jul-2017 nicm

< and > keys to scroll preview list left and right in tree mode.


# 1.10 04-Jul-2017 nicm

Handle 0 size of preview box in caller.


# 1.9 03-Jul-2017 nicm

Change session and window preview so that the current window or pane is
always shown.


# 1.8 30-Jun-2017 nicm

Don't write over right border.


# 1.7 30-Jun-2017 nicm

Fix previous when we end up able to show no panes.


# 1.6 30-Jun-2017 nicm

Try to show a better preview of sessions and windows in tree mode.


# 1.5 09-Jun-2017 nicm

Extend filters (f key) to buffer and client mode and add -f flag to
specify to command.


# 1.4 09-Jun-2017 nicm

Add -O option to choose-* to set initial sort order.


# 1.3 07-Jun-2017 nicm

Add simple searching (C-s and n) to the various choose modes: by name
for client and tree, and by name and content for buffer.


# 1.2 06-Jun-2017 nicm

Do not pass a state into commands when fired on individual items in tree
mode, rely on the %% target substitution in the command for the chosen
pane and leave the default target as the current pane (where the mode
is). Otherwise, joinp and similar end up with -t and -s the
same. Reported by Jacob Niehus in GitHub issue 960.


# 1.1 30-May-2017 nicm

Rewrite of choose mode, both to simplify and tidy the code and to add
some modern features.

Now the common code is in mode-tree.c, which provides an API used by the
three modes now separated into window-{buffer,client,tree}.c. Buffer
mode shows buffers, client mode clients and tree mode a tree of
sessions, windows and panes.

Each mode has a common set of key bindings plus a few that are specific
to the mode. Other changes are:

- each mode has a preview pane: for buffers this is the buffer content
(very useful), for others it is a preview of the pane;

- items may be sorted in different ways ('O' key);

- multiple items may be tagged and an operation applied to all of them
(for example, to delete multiple buffers at once);

- in tree mode a command may be run on the selected item (session,
window, pane) or on tagged items (key ':');

- displayed items may be filtered in tree mode by using a format (this
is used to implement find-window) (key 'f');

- the custom format (-F) for the display is no longer available;

- shortcut keys change from 0-9, a-z, A-Z which was always a bit weird
with keys used for other uses to 0-9, M-a to M-z.

Now that the code is simpler, other improvements will come later.

Primary key bindings for each mode are documented under the commands in
the man page (choose-buffer, choose-client, choose-tree).

Parts written by Thomas Adam.